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

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

initial load of WorldVistAEHR

File size: 7.9 KB
RevLine 
[613]1DGPFHLS ;ALB/RPM - PRF HL7 SEND DRIVERS ; 7/31/06 10:10am
2 ;;5.3;Registration;**425,650**;Aug 13, 1993;Build 3
3 ;
4SNDORU(DGPFIEN,DGPFHARR,DGFAC) ;Send ORU Message Types (ORU~R01)
5 ;This function builds and transmits a single ORU message to all sites
6 ;in the associated patient's TREATING FACILITY LIST (#391.91) file.
7 ;The optional input parameter DGFAC overrides selection of sites
8 ;from the TREATING FACILITY LIST file.
9 ;
10 ; Supported DBIA #2990: This supported DBIA is used to access the
11 ; Registration API to generate a list of
12 ; treating facilities for a given patient.
13 ; Input:
14 ; DGPFIEN - (required) IEN of assignment in PRF ASSIGNMENT (#26.13)
15 ; file to transmit
16 ; DGPFHARR - (optional) array of assignment history IENs from the
17 ; PRF ASSIGNMENT HISTORY (#26.14) file to
18 ; include in ORU.
19 ; format: DGPFHARR(assignment_date_time)=IEN
20 ; assignment_date_time in FM format
21 ; [default = $$GETLAST^DGPFAAH(DGPFIEN)]
22 ; DGFAC - (optional) array of message destination facilities
23 ; passed by reference
24 ; format: DGFAC(#)=station#
25 ;
26 ; Output:
27 ; Function value - 1 on success, 0 on failure
28 ;
29 N DGHLEID ;event protocol ID
30 N DGHL ;VistA HL7 environment array
31 N DGHLROOT ;message array location
32 N DGPFA ;assignment data array
33 N DGPFAH ;assignment history data array
34 N DGPFHIEN ;assignment history IEN
35 N DGRSLT ;function value
36 ;
37 S DGRSLT=0
38 S DGHLROOT=$NA(^TMP("PRFORU",$J))
39 K @DGHLROOT
40 ;
41 I +$G(DGPFIEN)>0,$D(^DGPF(26.13,DGPFIEN)) D
42 . ;
43 . ;retrieve assignment record
44 . Q:'$$GETASGN^DGPFAA(DGPFIEN,.DGPFA)
45 . ;
46 . ;set up default history IEN array
47 . I '$O(DGPFHARR(0)) D
48 . . N DGPFAH
49 . . S DGPFHIEN=$$GETLAST^DGPFAAH(DGPFIEN)
50 . . Q:'$$GETHIST^DGPFAAH(DGPFHIEN,.DGPFAH)
51 . . S DGPFHARR(+$G(DGPFAH("ASSIGNDT")))=DGPFHIEN
52 . Q:'$O(DGPFHARR(0))
53 . ;
54 . ;retrieve treating facilities when no destination is provided
55 . I $G(DGFAC(1))'>0 D TFL^VAFCTFU1(.DGFAC,+$G(DGPFA("DFN")))
56 . Q:$G(DGFAC(1))'>0
57 . ;
58 . ;initialize VistA HL7 environment
59 . S DGHLEID=$$INIT^DGPFHLUT("DGPF PRF ORU/R01 EVENT",.DGHL)
60 . Q:'DGHLEID
61 . ;
62 . ;build ORU segments array
63 . S DGPFHIEN=$$BLDORU^DGPFHLU(.DGPFA,.DGPFHARR,.DGHL,DGHLROOT)
64 . Q:'DGPFHIEN
65 . ;
66 . ;transmit and log messages
67 . Q:'$$XMIT^DGPFHLU6(DGPFHIEN,DGHLEID,.DGFAC,DGHLROOT,.DGHL)
68 . ;
69 . ;success
70 . S DGRSLT=1
71 ;
72 ;cleanup
73 K @DGHLROOT
74 Q DGRSLT
75 ;
76SNDACK(DGACKTYP,DGMIEN,DGHL,DGSEGERR,DGSTOERR) ;Send ACK Message Type (ACK~R01)
77 ;This procedure assumes the the VistA HL7 environment is providing the
78 ;environment variables and will produce a fatal error if they are
79 ;missing.
80 ;
81 ; Input:
82 ; DGACKTYP - (required) ACK message type ("AA","AE")
83 ; DGMIEN - (required) IEN of message entry in file #773
84 ; DGHL - (required) HL7 environment array
85 ; DGSEGERR - (optional) Errors found during parsing
86 ; DGSTOERR - (optional) Errors during data storage
87 ;
88 ; Output:
89 ; none
90 ;
91 N DGHLROOT
92 N DGHLERR
93 ;
94 Q:($G(DGACKTYP)']"")
95 Q:('+$G(DGMIEN))
96 ;
97 S DGHLROOT=$NA(^TMP("HLA",$J))
98 K @DGHLROOT
99 ;
100 ;build ACK segments array
101 I $$BLDACK^DGPFHLU4(DGACKTYP,DGHLROOT,.DGHL,.DGSEGERR,.DGSTOERR) D
102 . ;
103 . ;generate the message
104 . D GENACK^HLMA1(DGHL("EID"),DGMIEN,DGHL("EIDS"),"GM",1,.DGHLERR)
105 ;
106 ;cleanup
107 K @DGHLROOT
108 Q
109 ;
110SNDQRY(DGDFN,DGMODE,DGFAC) ;Send QRY Message Types (QRY~R02)
111 ;This function transmits a PRF Query (QRY~R02) HL7 message to a given
112 ;patient's treating facility.
113 ;
114 ; Input:
115 ; DGDFN - (required) pointer to patient in PATIENT (#2) file
116 ; DGMODE - (optional) type of HL7 connection to use ("1" - direct
117 ; connection, "2" - deferred connection [default],
118 ; "3" - direct connection/display mode)
119 ; DGFAC - (optional) station number of query destination.
120 ; [default - most recent unqueried treating facility]
121 ;
122 ; Output:
123 ; Function value - 1 on success, 0 on failure
124 ;
125 N DGEVNT
126 N DGHLROOT
127 N DGHLLNK
128 N DGHL
129 N DGICN
130 N DGLSQ
131 N DGMSG
132 N DGMSGID
133 N DGNXTF
134 N DGRSLT
135 N HLL
136 N DGHLEID
137 N DGHLRSLT
138 ;
139 ;the following HL* variables are created by DIRECT^HLMA
140 N HL,HLCS,HLDOM,HLECH,HLFS,HLINST,HLINSTN
141 N HLMTIEN,HLNEXT,HLNODE,HLPARAM,HLPROD,HLQ
142 N HLQUIT
143 ;
144 S DGMODE=+$G(DGMODE)
145 S DGFAC=$G(DGFAC)
146 S DGRSLT=0
147 S DGHLROOT=$NA(^TMP("HLS",$J))
148 K @DGHLROOT
149 ;
150 I +$G(DGDFN)>0,$D(^DPT(DGDFN,0)) D
151 . ;
152 . ;ICN must be national
153 . Q:'$$MPIOK^DGPFUT(DGDFN,.DGICN)
154 . ;
155 . ;find event, get last site queried and next treating facility
156 . S DGEVNT=$$FNDEVNT^DGPFHLL1(DGDFN)
157 . I 'DGEVNT,DGMODE'=3 D ;no event and not display? create it!
158 . . D STOEVNT^DGPFHLL1(DGDFN)
159 . . S DGEVNT=$$FNDEVNT^DGPFHLL1(DGDFN)
160 . S DGLSQ=$$GETLSQ^DGPFHLL(DGEVNT)
161 . S DGNXTF=$$GETNXTF^DGPFUT(DGDFN,DGLSQ)
162 . ;
163 . ;determine treating facility institution number to query
164 . S DGFAC=$S(DGFAC]"":$$IEN^XUAF4(DGFAC),DGNXTF:DGNXTF,DGLSQ&('DGNXTF):$$GETNXTF^DGPFUT(DGDFN),1:0)
165 . ;
166 . ;mark query event COMPLETE and return SUCCESS when no non-local
167 . ;treating facilities are found and no previous queries have been run.
168 . I DGFAC'>0,'DGLSQ D
169 . . D STOEVNT^DGPFHLL1(DGDFN,"C")
170 . . S DGRSLT=1
171 . Q:(DGFAC'>0)
172 . ;
173 . ;retrieve treating facility HL Logical Link and build HLL array
174 . S DGHLLNK=$$GETLINK^DGPFHLUT(DGFAC)
175 . Q:(DGHLLNK=0)
176 . S HLL("LINKS",1)="DGPF PRF ORF/R04 SUBSC"_U_DGHLLNK
177 . ;
178 . ;initialize VistA HL7 environment
179 . S DGHLEID=$$INIT^DGPFHLUT("DGPF PRF QRY/R02 EVENT",.DGHL)
180 . Q:'DGHLEID
181 . ;
182 . ;build QRY segments array
183 . Q:'$$BLDQRY^DGPFHLQ(DGDFN,DGICN,DGHLROOT,.DGHL)
184 . ;
185 . ;display busy message to interactive users when direct-connect
186 . I DGMODE=1!(DGMODE=3),$E($G(IOST),1,2)="C-" D
187 . . S DGMSG(1)="Attempting to connect to "_$P($$NS^XUAF4(DGFAC),U)
188 . . S DGMSG(2)="to search for Patient Record Flag Assignments."
189 . . S DGMSG(3)="This request may take sometime, please be patient ..."
190 . . D EN^DDIOL(.DGMSG)
191 . ;
192 . ;generate HL7 message
193 . I DGMODE=1!(DGMODE=3) D ;generate direct-connect HL7 message
194 . . D DIRECT^HLMA(DGHLEID,"GM",1,.DGHLRSLT,"","")
195 . . ;The DIRECT^HLMA API contains a bug that causes the message ID
196 . . ;returned to be based on the HL7 MESSAGE TEXT (#772) file IEN and
197 . . ;not the HL7 MESSAGE ADMINISTRATION (#773) file IEN. Therefore,
198 . . ;the following call to $$CONVMID is required to convert the
199 . . ;message ID to the value stored in file #773.
200 . . S DGMSGID=$$CONVMID^DGPFHLUT($P(DGHLRSLT,U))
201 . . I DGMODE=1,DGMSGID>0 D STOQXMIT^DGPFHLL(DGEVNT,DGMSGID,DGFAC)
202 . . I HLMTIEN,DGMODE'=3 D RCV^DGPFHLR
203 . . I DGMODE=3 D DISPLAY^DGPFHLUQ(HLMTIEN,DGHLRSLT)
204 . . ;success
205 . . I '+$P(DGHLRSLT,U,2) S DGRSLT=1
206 . ;
207 . E D ;generate deferred HL7 message
208 . . D GENERATE^HLMA(DGHLEID,"GM",1,.DGHLRSLT,"","")
209 . . I $P(DGHLRSLT,U)>0 D STOQXMIT^DGPFHLL(DGEVNT,$P(DGHLRSLT,U),DGFAC)
210 . . ;success
211 . . I '+$P(DGHLRSLT,U,2) S DGRSLT=1
212 ;
213 ;cleanup
214 K @DGHLROOT
215 Q DGRSLT
216 ;
217SNDORF(DGQRY,DGMIEN,DGHL,DGDFN,DGSEGERR,DGQRYERR) ;Send ORF Message Type (ORF~R04)
218 ;This procedure assumes the the VistA HL7 environment is providing the
219 ;environment variables and will produce a fatal error if they are
220 ;missing.
221 ;
222 ; Input:
223 ; DGQRY - (required) Array of QRY parsing results
224 ; DGMIEN - (required) IEN of message entry in file #773
225 ; DGHL - (required) HL7 environment array
226 ; DGDFN - (required) Pointer to patient in PATIENT (#2) file
227 ; DGSEGERR - (optional) Errors found during parsing
228 ; DGQRYERR - (optional) Errors found during query
229 ;
230 ; Output:
231 ; none
232 ;
233 N DGHLROOT
234 N DGHLERR
235 ;
236 Q:('$D(DGQRY))
237 Q:('+$G(DGMIEN))
238 ;
239 S DGHLROOT=$NA(^TMP("HLA",$J))
240 K @DGHLROOT
241 ;
242 ;build ORF segments array
243 I $$BLDORF^DGPFHLQ(DGHLROOT,.DGHL,DGDFN,.DGQRY,.DGSEGERR,.DGQRYERR) D
244 . ;
245 . ;generate the message
246 . D GENACK^HLMA1(DGHL("EID"),DGMIEN,DGHL("EIDS"),"GM",1,.DGHLERR)
247 ;
248 ;cleanup
249 K @DGHLROOT
250 Q
Note: See TracBrowser for help on using the repository browser.