source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/VAFHLZEL.m@ 1578

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

initial load of WorldVistAEHR

File size: 5.2 KB
Line 
1VAFHLZEL ;ALB/ESD,KCL,SCK,JRP - Creation of ZEL segment ; 11/23/99
2 ;;5.3;Registration;**122,160,195,243,342**;Aug 13, 1993
3 ;
4 ;
5EN(DFN,VAFSTR,VAFNUM) ; This function call has been left for backwards
6 ; compatability and is superceeded by EN1^VAFHLZEL. This function
7 ; call is designed to build the HL7 ZEL segment. This segment contains
8 ; VA-specific patient eligibility data. Because a patient can have
9 ; more than eligibility, the ZEL segment for the patient's primary
10 ; eligibility will be the output of the function call and all other
11 ; eligibilities will be returned in the array VAFZEL. Because this
12 ; call was not designed to accomodate a segment length greater than
13 ; 245, sequence numbers 1 to 24 are the only fields supported.
14 ;
15 ;Input: DFN - Pointer to PATIENT file (#2)
16 ; VAFSTR - String of fields requested separated by commas
17 ; VAFNUM - Eligibility number to determine type of data
18 ; returned
19 ; 1 = primary eligibility only
20 ; 2 = all eligibilities
21 ; VAFMSTDT - Date to use when getting MST status (optional)
22 ; Assumes existance of the HL7 enconding characters
23 ; (HLFS,HLENC,HLQ)
24 ;
25 ;Output: The ZEL segment for the patient's primary eligibility
26 ;
27 ; VAFZEL(1..N) - If all eligibilities are chosen, an array of
28 ; string(s) forming the ZEL segments for the patient's
29 ; other entitled eligibilities.
30 ;
31 ;Notes: All fields will be returned with the primary eligibility
32 ; : Eligibility Code, Long ID, and Short ID will be the only
33 ; fields returned for other eligibilities
34 ; : VAFZEL is initialized (KILLed) on entry
35 ;
36 N VAFPRIM,X,MAXSEQ
37 ;Build segment using newer call
38 D EN1($G(DFN),$G(VAFSTR),$G(VAFNUM),.VAFZEL)
39 ;Make output backward compatible
40 S MAXSEQ=25
41 S VAFPRIM=$P(VAFZEL(1),HLFS,1,MAXSEQ+1)
42 K VAFZEL(1)
43 S X=1
44 F S X=+$O(VAFZEL(X)) Q:'X D
45 .S VAFZEL(X-1)=$P(VAFZEL(X),HLFS,1,MAXSEQ+1)
46 .K VAFZEL(X)
47 Q VAFPRIM
48 ;
49EN1(DFN,VAFSTR,VAFNUM,VAFZEL) ; This procedure call is designed to build the
50 ; HL7 ZEL segment. This segment contains VA-specific patient
51 ; eligibility data. Because a patient can have more than eligibility,
52 ; the ZEL segment(s) will be returned in the array VAFZEL. This call
53 ; superceeds $$EN^VAFHLZEL because it accomodates a segment length
54 ; greater than 245.
55 ;
56 ;Input: DFN - Pointer to PATIENT file (#2)
57 ; VAFSTR - String of fields requested separated by commas
58 ; VAFNUM - Eligibility number to determine type of data
59 ; returned
60 ; 1 = primary eligibility only (default)
61 ; 2 = all eligibilities
62 ; .VAFZEL - Array to return segment(s) in
63 ; VAFMSTDT - Date to use when getting MST status (optional)
64 ; Existance of HL7 enconding characters (HLFS,HLENC,HLQ) assumed
65 ;
66 ;Output: VAFZEL(X) = ZEL segment (first 245 characters)
67 ; VAFZEL(X,Y) = Remaining portion of ZEL segment in 245 chunks
68 ;
69 ;Notes: VAFZEL(1) will be the primary eligibility
70 ; : VAFZEL(2..n) will be other eligibilities
71 ; : All fields will be returned with the primary eligibility
72 ; : Eligibility Code, Long ID, and Short ID will be the only
73 ; fields returned for other eligibilities
74 ; : Fields will not be split across nodes in VAFZEL()
75 ; : VAFZEL is initialized (KILLed) on entry
76 ;
77 N VAFPELIG,VAFNODE,VAFPRIM,VAFHLZEL,VAFSETID,VAFELPTR,VAFMAXL,X
78 K VAFZEL
79 S VAFMAXL=245
80 I '$G(DFN)!($G(VAFSTR)="") S VAFZEL(1)="ZEL"_HLFS Q
81 S VAFNUM=$S('$D(VAFNUM):1,VAFNUM'<2:2,1:1)
82 S VAFSTR=","_VAFSTR_","
83 ;Build ZEL segment for primary eligibility
84 S VAFPELIG=$G(^DPT(DFN,.36))
85 S VAFNODE=$G(^DPT(DFN,"E",+VAFPELIG,0))
86 S VAFSETID=1 D GETDATA^VAFHLZE1,MAKESEG
87 ;Only build for primary elig.
88 Q:VAFNUM=1
89 ;Build ZEL segments for other eligibilities
90 S VAFELPTR=0
91 F S VAFELPTR=$O(^DPT(DFN,"E",VAFELPTR)) Q:'VAFELPTR I VAFELPTR'=+VAFPELIG D
92 .S VAFNODE=$G(^DPT(DFN,"E",VAFELPTR,0))
93 .S VAFSETID=VAFSETID+1 D GETDATA^VAFHLZE1,MAKESEG
94 ;Done
95 Q
96 ;
97MAKESEG ;Make segment using obtained data
98 ;Input: Existance of the following variables is assumed
99 ; VAFSETID = Number denoting Xth repetition of the ZEL segment
100 ; VAFMAXL = Maximum length of each node (defaults to 245)
101 ; VAFHLZEL(SeqNum) = Value
102 ; HL7 encoding characters (HLFS, HLENC, HLQ)
103 ;
104 ;Output: VAFZEL(VAFSETID) = ZEL segment (first VAFMAXL characters)
105 ; VAFZEL(VAFSETID,x) = Remaining portion of ZEL segment in
106 ; VAFMAXL character chunks (if needed)
107 ; beginning with a field seperator
108 ;
109 ;Notes: VAFZEL(VAFSETID) is initialized (KILLed) on input
110 ; : Fields will not be split across nodes in VAFZEL()
111 ;
112 N SEQ,SPILL,SPILLON,SPOT,LASTSEQ,VAFY
113 K VAFZEL(VAFSETID)
114 S VAFZEL(VAFSETID)="ZEL"
115 S VAFMAXL=+$G(VAFMAXL) S:'VAFMAXL VAFMAXL=245
116 S VAFY=$NA(VAFZEL(VAFSETID))
117 S (SPILL,SPILLON)=0
118 S LASTSEQ=+$O(VAFHLZEL(""),-1)
119 F SEQ=1:1:LASTSEQ D
120 .;Make sure maximum length won't be exceeded
121 .I ($L(@VAFY)+$L($G(VAFHLZEL(SEQ)))+1)>VAFMAXL D
122 ..;Max length exceeded - start putting data on next node
123 ..S SPILL=SPILL+1
124 ..S SPILLON=SEQ-1
125 ..S VAFY=$NA(VAFZEL(VAFSETID,SPILL))
126 .;Add to string
127 .S SPOT=(SEQ+1)-SPILLON
128 .S $P(@VAFY,HLFS,SPOT)=$G(VAFHLZEL(SEQ))
129 ;Done
130 Q
Note: See TracBrowser for help on using the repository browser.