source: FOIAVistA/trunk/r/ENROLLMENT_APPLICATION_SYSTEM-EAS/EASEGT2.m@ 1713

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

initial load of FOIAVistA 6/30/08 version

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