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

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

initial load of FOIAVistA 6/30/08 version

File size: 8.6 KB
Line 
1DGENEGT2 ;ALB/KCL - PROCESS INCOMING MFN TYPE HL7 MSGS; 04-MAY-1999 ; 3/7/01 9:14am
2 ;;5.3;Registration;**232,417,363**;Aug 13, 1993
3 ;
4 ;
5MFN ; Description: This entry point is the handler for incoming MFN type
6 ; HL7 messages. This entry point is called from the PROCESSING ROUTINE
7 ; field of the HL7 MESSAGE (multiple) field of the #771 file entry.
8 ;
9 ; Input:
10 ; The following HL7 variables are set when the DHCP Application
11 ; processing routine is invoked:
12 ; HLDA - the internal entry number for the entry created in
13 ; file #772.
14 ; HLDAN - the name of the receiving application from the HL7 DHCP
15 ; APPLICATION #771 file
16 ; HLDAP - ien of the receiving application from the HL7 DHCP
17 ; APPLICATION #771 file
18 ; HLDT - date/time message was received in internal fileman format
19 ; HLDT1 - date/time message was received in HL7 format
20 ; HLECH - HL7 Encoding Characters from the 'EC' node of file #771
21 ; HLFS - HL7 Field Separator from the 'FS' node of file #771
22 ; HLMID - HL7 message control ID of the message received
23 ; HLMTN - 3-7 character message type of the message received
24 ; HLNDAP - Non-DHCP Application Pointer from file #770
25 ; HLNDAP0 - Zero node from file #770 corresponding to HLNDAP
26 ; HLQ - Double quotes ("") for use in building HL7 segments
27 ; HLVER - HL7 version number of the HL7 protocol that was used to
28 ; build the message received
29 ;
30 ; other HL7 variables used:
31 ; HLEVN - number of HL7 events included in the HL7 message
32 ; HLSDT - a flag that indicates that the data to be sent is
33 ; stored in the ^TMP("HLS") global array.
34 ; HLTRANS - existence of this variable indicates that the incoming
35 ; HL7 message is being processed by the HLSERV routine and
36 ; VA MailMan is the lowere level protocol being used.
37 ;
38 ;
39 N EVENT,MSGID,SEG
40 N CNT,HL,IVMRTN,SEGCNT
41 ;
42 ; SET UP WORK GLOBAL WITH INCOMING MESSAGE
43 S IVMRTN="DGENEGT2"
44 K ^TMP($J,IVMRTN)
45 F SEGCNT=1:1 X HLNEXT Q:HLQUIT'>0 D
46 .S CNT=0
47 .S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE
48 .F S CNT=$O(HLNODE(CNT)) Q:'CNT D
49 ..S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
50 S HLDA=HLMTIEN
51 ;
52 ; INITIALIZE HL7 VARIABLES
53 S HLEID="VAMC "_$P($$SITE^VASITE,"^",3)_" MFN-ZEG SERVER"
54 S HLEID=$O(^ORD(101,"B",HLEID,0))
55 D INIT^HLFNC2(HLEID,.HL)
56 S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
57 ;
58 D NXTSEG^DGENUPL(HLDA,0,.SEG)
59 Q:(SEG("TYPE")'="MSH")
60 S EVENT=$P(SEG(9),$E(HLECH),2)
61 ;
62 I EVENT="ZEG" D
63 .S MSGID=SEG(10)
64 .D EGT(HLDA,MSGID)
65 ;
66 K ^TMP($J,IVMRTN)
67 Q
68 ;
69 ;
70EGT(MSGIEN,MSGID) ;
71 ; Description: This procedure is used to process an MFN~ZEG message.
72 ; It uploads the enrollment group threshold (EGT) data. An HL7
73 ; Master File Acknowledgement (MFK) will be returned.
74 ;
75 ; Input:
76 ; MSGIEN - the internal entry number of the HL7 message in the
77 ; HL7 MESSAGE TEXT (#772) file
78 ; MSGID - the message control id from the MSH segment
79 ;
80 ; Output: None
81 ;
82 N CURLINE,ERRCOUNT,SEG
83 ;
84 ; initialize HL7 variables
85 S HLSDT="IVMQ" ; subscript in ^TMP( global for MFK message
86 K ^TMP("HLA",$J)
87 ;
88 ; init variables
89 S ERRCOUNT=0 ; used to indicate error
90 S CURLINE=1
91 ;
92 ; process master file notification msg
93 D MFNZEG(MSGIEN,MSGID,.CURLINE,.ERRCOUNT)
94 ;
95 ; transmit master file application acknowledgment (MFK)
96 S HLEVN=$S(+$G(ERRCOUNT):+$G(ERRCOUNT),1:1)
97 S HLARYTYP="GM",HLFORMAT=1
98 D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESLTA)
99 ;
100 Q
101 ;
102 ;
103MFNZEG(MSGIEN,MSGID,CURLINE,ERRCOUNT) ;
104 ; Description: This procedure is used to process a MFN~ZEG msg.
105 ;
106 ; Input:
107 ; MSGIEN - the internal entry number of the HL7 message in the
108 ; HL7 MESSAGE TEXT (#772) file
109 ; MSGID - message control id of HL7 msg in the MSH segment
110 ; CURLINE - the subscript of the MSH segment of the current message
111 ; (pass by reference)
112 ;
113 ; Output:
114 ; CURLINE - upon leaving the procedure this parameter should be set to
115 ; the end of the current message. (pass by reference)
116 ; ERRCOUNT - set if error encountered (pass by reference)
117 ;
118 N DGEGT,DGMFI,DGMFE,ERRMSG,OLDEGT
119 ;
120 ; drops out of DO block on error
121 D
122 .; parse the message
123 .Q:'$$PARSE(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGEGT,.DGMFI,.DGMFE)
124 .;
125 .; get the current EGT record if it exists
126 .I $$GET^DGENEGT($$FINDCUR^DGENEGT(),.OLDEGT)
127 .;
128 .; add assumed values to the EGT record containing the update
129 .S DGEGT("ENTDATE")=$$NOW^XLFDT ; set to currnet date/time
130 .S DGEGT("SOURCE")=1 ; set source of EGT to 'HEC'
131 .;
132 .; perform field validation checks on the EGT record
133 .I '$$VALID^DGENEGT(.DGEGT,.ERRMSG) D Q
134 ..D ADDERROR(MSGID,ERRMSG,.ERRCOUNT,.DGMFI,.DGMFE)
135 .;
136 .; store enrollment group threshold (EGT) record
137 .D UPLDEGT^DGENEGT3(.DGEGT)
138 .;
139 .; if no error encountered, create an 'AA' MFK
140 .D ACCEPT(MSGID,.DGMFI,.DGMFE)
141 .;
142 .; send local EGT notification msg
143 .D NOTIFY^DGENEGT1(.DGEGT,.OLDEGT)
144 ;
145 Q
146 ;
147 ;
148PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGEGT,DGMFI,DGMFE) ;
149 ; Description: This function is used to parse the HL7 segments of the message.
150 ;
151 ; Input:
152 ; MSGIEN - the internal entry number of the HL7 message in the
153 ; HL7 MESSAGE TEXT (#772) file
154 ; MSGID - message control id of HL7 msg in the MSH segment
155 ; CURLINE - the subscript of the MSH segment of the current message
156 ; (pass by reference)
157 ;
158 ; Output:
159 ; Function Value: Returns 1 on success, 0 on failure
160 ; DGEGT - array containing the EGT record (pass by reference)
161 ; DGMFI - array containing fields of MFI segment needed for
162 ; MFK (pass by reference)
163 ; DGMFE - array containing fields of MFE segment needed for
164 ; MFK (pass by reference)
165 ; ERRCOUNT - set if error encountered (pass by reference)
166 ;
167 N ERROR,SEG
168 S ERROR=0
169 ;
170 K DGEGT,DGMFI,DGMFE
171 S (DGMFI,DGMFE)=""
172 ;
173 F SEG="MFI","MFE","ZEG" D Q:ERROR
174 .D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
175 .I SEG("TYPE")=SEG D
176 ..D @SEG^DGENEGT3
177 .E D
178 ..D ADDERROR(MSGID,SEG_" SEGMENT MISSING",.ERRCOUNT,.DGMFI,.DGMFE)
179 ..S ERROR=1
180 ;
181 Q $S(ERROR:0,1:1)
182 ;
183 ;
184ADDERROR(MSGID,ERRMSG,ERRCOUNT,DGMFI,DGMFE) ;
185 ; Description - This procedure writes an MFK - Application Error (AE)
186 ; to the global that is used in the transmission of the 'MFK' msg.
187 ;
188 ; Inputs:
189 ; MSGID - message control id of HL7 msg in the MSH segment
190 ; ERRMSG - the error msg text
191 ; ERRCOUNT - count of errors written (pass by reference)
192 ; DGMFI - array containing fields of MFI segment received, needed
193 ; for MFK (pass by reference)
194 ; DGMFE - array containing fields of MFI segment received, needed
195 ; for MFK (pass by reference)
196 ;
197 ; Outputs:
198 ; ^TMP("HLS",$J,I) - global array containing all segments of
199 ; the HL7 message that the receiving application wishes to send
200 ; as response. The HLSDT variable is a flag that indicates that
201 ; the data to be sent is stored in in the ^TMP("HLS") global
202 ; array. The variable (I) is sequential number.
203 ;
204 S ERRCOUNT=+$G(ERRCOUNT)
205 ;
206 ; MSA segment
207 S ^TMP("HLA",$J,(ERRCOUNT*2)+1)="MSA"_HLFS_"AE"_HLFS_MSGID_HLFS_ERRMSG
208 ;
209 ; MFI segment
210 S ^TMP("HLA",$J,(ERRCOUNT*2)+2)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
211 ;
212 ; MFA segment
213 S ^TMP("HLA",$J,(ERRCOUNT*2)+3)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"U"_HLFS_$G(DGMFE("PRIMKEY"))
214 S ERRCOUNT=ERRCOUNT+1
215 Q
216 ;
217 ;
218ACCEPT(MSGID,DGMFI,DGMFE) ;
219 ; Description - This procedure writes an MFK - Application Accept (AA)
220 ; to the global that is used in the transmission of the 'MFK' msg.
221 ;
222 ; Inputs:
223 ; MSGID - message control id of HL7 msg in the MSH segment
224 ; DGMFI - array containing fields of MFI segment received, needed
225 ; for MFK (pass by reference)
226 ; DGMFE - array containing fields of MFI segment received, needed
227 ; for MFK (pass by reference)
228 ;
229 ; Outputs:
230 ; ^TMP("HLS",$J,HLSDT,I) - global array containing all segments of
231 ; the HL7 message that the receiving application wishes to send
232 ; as response. The HLSDT variable is a flag that indicates that
233 ; the data to be sent is stored in in the ^TMP("HLS") global
234 ; array. The variable (I) is sequential number.
235 ;
236 N DGCOUNT
237 S DGCOUNT=1 ; sequential number used as array subscript
238 ;
239 ; MSA segment
240 S DGCOUNT=DGCOUNT+1
241 S ^TMP("HLA",$J,DGCOUNT)="MSA"_HLFS_"AA"_HLFS_MSGID
242 ;
243 ; MFI segment
244 S DGCOUNT=DGCOUNT+1
245 S ^TMP("HLA",$J,DGCOUNT)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
246 ;
247 ; MFA segment
248 S DGCOUNT=DGCOUNT+1
249 S ^TMP("HLA",$J,DGCOUNT)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"S"_HLFS_$G(DGMFE("PRIMKEY"))
250 Q
Note: See TracBrowser for help on using the repository browser.