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

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

initial load of FOIAVistA 6/30/08 version

File size: 6.6 KB
Line 
1DGENQRY ;ALB/CJM - API for ENROLLMENT QUERIES; 11/17/00 12:07pm ; 12/6/00 5:32pm
2 ;;5.3;REGISTRATION;**147,222,232,314**;Aug 13,1993
3 ;
4QRY(DFN) ;
5 ;Description: Used to implment the automatic querying of HEC for
6 ;enrollment/eligibility data.
7 ;
8 ;Input:
9 ; DGQRY - this array should contain values for all the subscripts
10 ; defined for the DGQRY array. (pass by reference)
11 ;
12 ;Output:
13 ; Function Value - If successful, returns the ien of the newly created
14 ; record, otherwise returns 0.
15 ;
16 N STATUS
17 Q:'$G(DFN) 0
18 Q:'$$VET^DGENPTA(DFN) 0
19 Q:$$PENDING^DGENQRY(DFN) 0
20 S STATUS=$$STATUS^DGENA(DFN)
21 ; Purple Heart added status 21
22 Q:((STATUS=1)!(STATUS=2)!(STATUS=9)!(STATUS=15)!(STATUS=16)!(STATUS=17)!(STATUS=18)!(STATUS=21)) 0
23 Q $$SEND^DGENQRY1(DFN)
24 ;
25LOCK(DFN) ;
26 ;Description: Locks a record in the ENROLLMENT QUERY file.
27 ;Input:
28 ; DFN - ien of record in PATIENT file.
29 ;Output:
30 ; Function Value - 1 if successful, 0 otherwise.
31 ;
32 I $G(DFN) L +^DGEN(27.12,DFN):3
33 Q $T
34 ;
35UNLOCK(DFN) ;
36 ;Description: Releases a lock set by $$LOCK.
37 ;Input:
38 ; DFN - ien of record in the PATIENT file.
39 ;Output: None
40 ;
41 I $G(DFN) L -^DGEN(27.12,DFN)
42 Q
43 ;
44PENDING(DFN) ;
45 ;Description: Used to determine if, for a given patient, there is
46 ;an enrollment query pending (STATUS=TRANSMITTED).
47 ;
48 N DGQRY,PENDING
49 S PENDING=0
50 I $$GET^DGENQRY($$FINDLAST($G(DFN)),.DGQRY) I 'DGQRY("STATUS") S PENDING=1
51 Q PENDING
52 ;
53FINDMSG(MSGID) ;
54 ;Description: Used to find a record in the ENROLLMENT QUERY LOG file,
55 ;give the unique message id assigned to the query by the HL7 package.
56 ;
57 ;Input:
58 ; MSGID - the unique id assigned to the query by the HL7 package and stored in the ENROLLMENT QUERY LOG as the MESSAGE ID field.
59 ;
60 ;Output:
61 ; Function Value - If successful, returns the ien of the record in the file, otherwise returns 0 on failure.
62 Q:($G(MSGID)="") 0
63 Q $O(^DGEN(27.12,"C",MSGID,0))
64 ;
65FINDLAST(DFN) ;
66 ;
67 ;Description: Finds the last query sent for a patient.
68 ;Input:
69 ; DFN - ien of record in the PATIENT file, identifies the patient to
70 ; find the query for.
71 ;Output:
72 ; Function Value - If successful, returns the ien of the record in the
73 ; file, otherwise returns 0 on failure.
74 ;
75 Q:'$G(DFN) 0
76 N TIME
77 S TIME=$O(^DGEN(27.12,"ADT",DFN,9999999.999999),-1)
78 Q:'TIME 0
79 Q $O(^DGEN(27.12,"ADT",DFN,TIME,0))
80 ;
81GET(IEN,DGQRY) ;
82 ;Description: Used to obtain a record in the ENROLLMENT QUERY LOG file
83 ;The values are returned in the PLOG() array.
84 ;
85 ;Input:
86 ; IEN -of a record in the ENROLLMENT QUERY LOG file.
87 ;
88 ;Output:
89 ; Function Value - 1 on success, 0 on failure.
90 ; DGQRY() array, pass by reference. Subscripts are
91 ; "DFN" - PATIENT field
92 ; "SENT" - DT/TM SENT field
93 ; "STATUS" - STATUS field
94 ; "MSGID" - MESSAGE ID field
95 ; "RESPONSE" - DT/TM RESPONSE
96 ; "RESPONSE ID" - MSG ID OF RESPONSE
97 ; "NOTIFY" - NOTIFY field
98 ; "FIRST" - FIRST DT/TM field
99 ;
100 ;
101 N NODE,SUCCESS
102 K DGQRY
103 S SUCCESS=1
104 I '$G(IEN) S SUCCESS=0
105 S NODE=$S(SUCCESS:$G(^DGEN(27.12,IEN,0)),1:"")
106 S DGQRY("DFN")=$P(NODE,"^")
107 S DGQRY("SENT")=$P(NODE,"^",2)
108 S DGQRY("STATUS")=$P(NODE,"^",3)
109 S DGQRY("MSGID")=$P(NODE,"^",5)
110 S DGQRY("RESPONSE")=$P(NODE,"^",6)
111 S DGQRY("RESPONSEID")=$P(NODE,"^",7)
112 S DGQRY("NOTIFY")=$P(NODE,"^",8)
113 S DGQRY("FIRST")=$P(NODE,"^",9)
114 S DGQRY("ERROR")=$P($G(^DGEN(27.12,IEN,10)),"^")
115 Q SUCCESS
116 ;
117LOG(DGQRY) ;
118 ;Description: Creates a record in the ENROLLMENT QUERY LOG file from the
119 ;values contained in the DGQRY() array. Note: this function does not
120 ;lock the ENROLLMENT QUERY LOG file for the patient. It should be
121 ;locked before calling this function.
122 ;
123 ;Input:
124 ; DGQRY - this array should contain values for all the subscripts
125 ; defined for the DGQRY array. (pass by reference)
126 ;
127 ;Output:
128 ; Function Value - If successful, returns the ien of the newly created
129 ; record, otherwise returns 0.
130 ;
131 N DATA
132 S DATA(.01)=DGQRY("DFN")
133 S DATA(.02)=DGQRY("SENT")
134 S DATA(.03)=DGQRY("STATUS")
135 S DATA(.05)=DGQRY("MSGID")
136 S DATA(.06)=DGQRY("RESPONSE")
137 S DATA(.07)=DGQRY("RESPONSEID")
138 S DATA(.08)=DGQRY("NOTIFY")
139 S DATA(.09)=DGQRY("FIRST")
140 Q $$ADD^DGENDBS(27.12,,.DATA)
141 ;
142DELETE(IEN) ;
143 ;Description: Deletes the record in the ENROLLMENT QUERY LOG file whose ien=IEN.
144 ;
145 ;Input:
146 ; IEN - the internal entry number of the record.
147 ;
148 ;Output:
149 ; Function Value - 1 on success, 0 on failure.
150 ;
151 Q:'$G(IEN) 0
152 N DIK,DA
153 S DIK="^DGEN(27.12,"
154 S DA=IEN
155 D ^DIK
156 Q 1
157 ;
158SETADT1(IEN,DFN) ;
159 ;set logic for the ADT x-ref of the ENROLLMENT QUERY LOG
160 ;
161 Q:'DFN
162 N SENT
163 S SENT=$P($G(^DGEN(27.12,IEN,0)),"^",2)
164 Q:'SENT
165 S ^DGEN(27.12,"ADT",DFN,SENT,IEN)=""
166 Q
167KILLADT1(IEN,DFN) ;
168 ;kill logic for the ADT x-ref of the ENROLLMENT QUERY LOG
169 ;
170 Q:'DFN
171 N SENT
172 S SENT=$P($G(^DGEN(27.12,IEN,0)),"^",2)
173 Q:'SENT
174 K ^DGEN(27.12,"ADT",DFN,SENT,IEN)
175 Q
176SETADT2(IEN,SENT) ;
177 ;set logic for the ADT x-ref of the ENROLLMENT QUERY LOG
178 ;
179 Q:'SENT
180 N DFN
181 S DFN=$P($G(^DGEN(27.12,IEN,0)),"^")
182 Q:'DFN
183 S ^DGEN(27.12,"ADT",DFN,SENT,IEN)=""
184 Q
185 ;
186KILLADT2(IEN,SENT) ;
187 ;kill logic for the ADT x-ref of the ENROLLMENT QUERY LOG
188 ;
189 Q:'SENT
190 N DFN
191 S DFN=$P($G(^DGEN(27.12,IEN,0)),"^")
192 Q:'DFN
193 K ^DGEN(27.12,"ADT",DFN,SENT,IEN)
194 Q
195 ;
196SETADS1(IEN,STATUS) ;
197 ;set logic for the ADS x-ref of the ENROLLMENT QUERY LOG
198 ;
199 Q:STATUS
200 N SENT
201 S SENT=$P($P($G(^DGEN(27.12,IEN,0)),"^",2),".")
202 Q:'SENT
203 S ^DGEN(27.12,"ADS",SENT,IEN)=""
204 Q
205KILLADS1(IEN,STATUS) ;
206 ;kill logic for the ADS x-ref of the ENROLLMENT QUERY LOG
207 ;
208 Q:STATUS
209 N SENT
210 S SENT=$P($P($G(^DGEN(27.12,IEN,0)),"^",2),".")
211 Q:'SENT
212 K ^DGEN(27.12,"ADS",SENT,IEN)
213 Q
214SETADS2(IEN,SENT) ;
215 ;set logic for the ADS x-ref of the ENROLLMENT QUERY LOG
216 ;
217 S SENT=$P(SENT,".")
218 Q:'SENT
219 N STATUS
220 S STATUS=$P($G(^DGEN(27.12,IEN,0)),"^",3)
221 Q:STATUS
222 S ^DGEN(27.12,"ADS",SENT,IEN)=""
223 Q
224 ;
225KILLADS2(IEN,SENT) ;
226 ;kill logic for the ADS x-ref of the ENROLLMENT QUERY LOG
227 ;
228 S SENT=$P(SENT,".")
229 Q:'SENT
230 N STATUS
231 S STATUS=$P($G(^DGEN(27.12,IEN,0)),"^",3)
232 Q:STATUS
233 K ^DGEN(27.12,"ADS",SENT,IEN)
234 Q
235 ;
236ON(DGON) ;
237 ;check to see if the ENROLLMENT QUERY ACTIVE? switch is on or off
238 ;returns 0 if not set to transmit queries to HEC
239 ;returns 1 if set to transmit queries to HEC
240 ;
241 N DGON,DA
242 S DGON=0
243 S DA=$O(^IVM(301.9,0))
244 I DA,$P($G(^IVM(301.9,DA,15)),"^") S DGON=1
245 Q DGON
246 ;
247TURNON ;put 1 in the new ENROLLMENT QUERY ACTIVE? field (#15) of the
248 ;IVM SITE PARAMETER file (#301.9)
249 ;
250 N DA,DATA
251 S DA=$O(^IVM(301.9,0))
252 S DATA(15)=1
253 I $$UPD^DGENDBS(301.9,DA,.DATA) ;else the update failed
254 Q
255 ;
256TURNOFF ;put 0 in the new ENROLLMENT QUERY ACTIVE? field (#15) of the
257 ;IVM SITE PARAMETER file (#301.9)
258 ;
259 N DA,DATA
260 S DA=$O(^IVM(301.9,0))
261 S DATA(15)=0
262 I $$UPD^DGENDBS(301.9,DA,.DATA) ;else the update failed
263 Q
Note: See TracBrowser for help on using the repository browser.