source: FOIAVistA/trunk/r/ONCOLOGY-ONC/ONCSNACR.m@ 1674

Last change on this file since 1674 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.7 KB
Line 
1ONCSNACR ;Hines OIFO/SG - NACCR TOOLS ; 3/9/07 10:40am
2 ;;2.11;ONCOLOGY;**47**;Mar 07, 1995;Build 19
3 ;
4 ; ONC8DST ------------- DESCRIPTOR OF THE DESTINATION BUFFER
5 ; (a parameter of BEGIN, END, FLUSH, and
6 ; WRITE). See also the ^ONCSAPIR.
7 ;
8 ; ONC8DST( Closed root of the destination buffer
9 ; "BUF") Output buffer
10 ; "LBA") Available space in the output buffer
11 ; "PTR") Pointer in the destination buffer
12 ; "PTRC") Continuation pointer (optional)
13 ;
14 Q
15 ;
16 ;***** STARTS THE NAACCR RECORD OUTPUT
17 ;
18 ; [.ONC8DST] Reference to a descriptor of the destination buffer
19 ;
20BEGIN(ONC8DST) ;
21 Q:$G(ONC8DST)=""
22 K ONC8DST("BUF"),ONC8DST("LBA")
23 S:'$D(ONC8DST("PTR")) ONC8DST("PTR")=+$O(@ONC8DST@(""),-1)
24 ;--- Open tag for the NAACCR record
25 D PUT^ONCSAPIR(.ONC8DST,"NAACCR-RECORD",,1)
26 D FLUSH(.ONC8DST)
27 Q
28 ;
29 ;***** RETURNS CRC32 VALUE FOR THE NAACCR RECORD
30 ;
31 ; [.ONC8DST] Reference to a descriptor of the destination buffer
32 ;
33 ; Return values:
34 ; 0 NAACCR record data has not been found
35 ; ... CRC32 value
36 ;
37CRC32(ONC8DST) ;
38 N BUF,CRC,FLT,FLTL,PI
39 S FLTL=$L(ONC8DST)-1,FLT=$E(ONC8DST,1,FLTL)
40 ;--- Search for beginning of the record data
41 S PI=ONC8DST
42 F S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT Q:$E(@PI,1,14)="<NAACCR-RECORD"
43 Q:$E(PI,1,FLTL)'=FLT 0
44 ;--- Calculate the checksum
45 S CRC=4294967295
46 F S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT S BUF=@PI Q:BUF="</NAACCR-RECORD>" D
47 . S CRC=$$CRC32^XLFCRC(BUF,CRC)
48 ;--- Success
49 Q CRC
50 ;
51 ;***** FINISHES THE NAACCR RECORD OUTPUT
52 ;
53 ; [.ONC8DST] Reference to a descriptor of the destination buffer
54 ;
55END(ONC8DST) ;
56 I $G(ONC8DST)="" W ! Q
57 ;--- Close tag for the NAACCR record
58 D FLUSH(.ONC8DST),APPEND^ONCSAPIR(.ONC8DST,"</NAACCR-RECORD>",1)
59 K ONC8DST("BUF"),ONC8DST("LBA")
60 Q
61 ;
62 ;***** FLUSHES THE OUTPUT BUFFER
63 ;
64 ; [.ONC8DST] Reference to a descriptor of the destination buffer
65 ;
66FLUSH(ONC8DST) ;
67 Q:$G(ONC8DST)=""
68 D:$G(ONC8DST("BUF"))'="" APPEND^ONCSAPIR(.ONC8DST,ONC8DST("BUF"),1)
69 S ONC8DST("BUF")="",ONC8DST("LBA")=250
70 Q
71 ;
72 ;***** OUTPUTS THE PIECE OF THE NAACCR RECORD
73 ;
74 ; [.ONC8DST] Reference to a descriptor of the destination buffer
75 ;
76 ; VAL A piece of the NAACCR record
77 ;
78WRITE(ONC8DST,VAL) ;
79 I $G(ONC8DST)="" W VAL Q
80 N ENCTXT,LT
81 S ENCTXT=$$SYMENC^MXMLUTL(VAL),LT=$L(ENCTXT)
82 F Q:LT'>0 D
83 . I LT>ONC8DST("LBA") D
84 . . S ONC8DST("BUF")=ONC8DST("BUF")_$E(ENCTXT,1,ONC8DST("LBA"))
85 . . S $E(ENCTXT,1,ONC8DST("LBA"))=""
86 . . S LT=LT-ONC8DST("LBA"),ONC8DST("LBA")=0
87 . E D
88 . . S ONC8DST("BUF")=ONC8DST("BUF")_ENCTXT
89 . . S ONC8DST("LBA")=ONC8DST("LBA")-LT,LT=0
90 . D:ONC8DST("LBA")'>0 FLUSH(.ONC8DST)
91 Q
Note: See TracBrowser for help on using the repository browser.