Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ONCSNACR

ONCSNACR.m

Go to the documentation of this file.
  1. ONCSNACR ;HINES OIFO/SG - NACCR TOOLS ; 3/9/07 10:40am
  1. ;;2.2;ONCOLOGY;**1,13**;Jul 31, 2013;Build 7
  1. ;
  1. ; ONC8DST ------------- DESCRIPTOR OF THE DESTINATION BUFFER
  1. ; (a parameter of BEGIN, END, FLUSH, and
  1. ; WRITE). See also the ^ONCSAPIR.
  1. ;
  1. ; ONC8DST( Closed root of the destination buffer
  1. ; "BUF") Output buffer
  1. ; "LBA") Available space in the output buffer
  1. ; "PTR") Pointer in the destination buffer
  1. ; "PTRC") Continuation pointer (optional)
  1. ;
  1. Q
  1. ;
  1. ;***** STARTS THE NAACCR RECORD OUTPUT
  1. ;
  1. ; [.ONC8DST] Reference to a descriptor of the destination buffer
  1. ;
  1. BEGIN(ONC8DST) ;
  1. Q:$G(ONC8DST)=""
  1. K ONC8DST("BUF"),ONC8DST("LBA")
  1. S:'$D(ONC8DST("PTR")) ONC8DST("PTR")=+$O(@ONC8DST@(""),-1)
  1. ;--- Open tag for the NAACCR record
  1. D PUT^ONCSAPIR(.ONC8DST,"NAACCR-RECORD",,1)
  1. D FLUSH(.ONC8DST)
  1. Q
  1. ;
  1. ;***** RETURNS CRC32 VALUE FOR THE NAACCR RECORD
  1. ;
  1. ; [.ONC8DST] Reference to a descriptor of the destination buffer
  1. ;
  1. ; Return values:
  1. ; 0 NAACCR record data has not been found
  1. ; ... CRC32 value
  1. ;
  1. CRC32(ONC8DST) ;
  1. N BUF,CRC,FLT,FLTL,PI
  1. S FLTL=$L(ONC8DST)-1,FLT=$E(ONC8DST,1,FLTL)
  1. ;--- Search for beginning of the record data
  1. S PI=ONC8DST
  1. F S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT Q:$E(@PI,1,14)="<NAACCR-RECORD"
  1. Q:$E(PI,1,FLTL)'=FLT 0
  1. ;--- Calculate the checksum
  1. S CRC=4294967295
  1. F S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT S BUF=@PI Q:BUF="</NAACCR-RECORD>" D
  1. . S CRC=$$CRC32^XLFCRC(BUF,CRC)
  1. ;--- Success
  1. Q CRC
  1. ;
  1. ;***** FINISHES THE NAACCR RECORD OUTPUT
  1. ;
  1. ; [.ONC8DST] Reference to a descriptor of the destination buffer
  1. ;
  1. END(ONC8DST) ;
  1. I $G(ONC8DST)="" W ! Q
  1. ;--- Close tag for the NAACCR record
  1. D FLUSH(.ONC8DST),APPEND^ONCSAPIR(.ONC8DST,"</NAACCR-RECORD>",1)
  1. K ONC8DST("BUF"),ONC8DST("LBA")
  1. Q
  1. ;
  1. ;***** FLUSHES THE OUTPUT BUFFER
  1. ;
  1. ; [.ONC8DST] Reference to a descriptor of the destination buffer
  1. ;
  1. FLUSH(ONC8DST) ;
  1. Q:$G(ONC8DST)=""
  1. D:$G(ONC8DST("BUF"))'="" APPEND^ONCSAPIR(.ONC8DST,ONC8DST("BUF"),1)
  1. S ONC8DST("BUF")="",ONC8DST("LBA")=250
  1. Q
  1. ;
  1. ;***** OUTPUTS THE PIECE OF THE NAACCR RECORD
  1. ;
  1. ; [.ONC8DST] Reference to a descriptor of the destination buffer
  1. ;
  1. ; VAL A piece of the NAACCR record
  1. ;
  1. WRITE(ONC8DST,VAL) ;
  1. I $G(ONC8DST)="" W VAL Q
  1. N ENCTXT,LT
  1. ; S ENCTXT=$$SYMENC^MXMLUTL(VAL),LT=$L(ENCTXT) ;remove call to fix CHKERR length problem
  1. S ENCTXT=VAL,LT=$L(ENCTXT)
  1. F Q:LT'>0 D
  1. . I LT>ONC8DST("LBA") D
  1. . . S ONC8DST("BUF")=ONC8DST("BUF")_$E(ENCTXT,1,ONC8DST("LBA"))
  1. . . S $E(ENCTXT,1,ONC8DST("LBA"))=""
  1. . . S LT=LT-ONC8DST("LBA"),ONC8DST("LBA")=0
  1. . E D
  1. . . S ONC8DST("BUF")=ONC8DST("BUF")_ENCTXT
  1. . . S ONC8DST("LBA")=ONC8DST("LBA")-LT,LT=0
  1. . D:ONC8DST("LBA")'>0 FLUSH(.ONC8DST)
  1. Q