source: qrda/C0Q/branches/recon/C0QTEST.m@ 1442

Last change on this file since 1442 was 1442, checked in by George Lilly, 12 years ago

for comparisons

File size: 18.0 KB
Line 
1C0PTEST ; ERX/GPL - eRx Refill utilities ; 3/19/10 11:53am
2 ;;0.1;C0P;nopatch;noreleasedate;Build 26
3 ;Copyright 2009,2010 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22TESTMEDS ; PRINT OUT MEDICATIONS FOR INPATIENTS WITH MEDS BUT NO INPATIENT
23 ; MEDS
24 S ZI=""
25 D BUILD^C0QPRML
26 S GNEW=$NA(C0QLIST("NoMedOrders"))
27 S GOLD=$NA(C0QLIST("HasMed"))
28 K G
29 D UNITY^C0QSET("G",GNEW,GOLD)
30 F S ZI=$O(G(1,ZI)) Q:ZI="" D ; FOR EACH PATIENT IN BOTH LISTS
31 . K GG
32 . D COVER^ORWPS(.GG,ZI) ; GET MED LIST
33 . W !,"PATIENT: ",ZI,!
34 . ZWR GG
35 Q
36 ;
37TESTREQ(ZDUZ,ZDFN) ; TEST REFILL REQUEST
38 I '$D(ZDFN) S ZDFN=""
39 D REFREQ("ZG",ZDUZ,ZDFN)
40 W !
41 ZWR C0PRXML
42 Q
43 ;
44REFREQ(GRTN,IDUZ,IDFN) ; MAKE A WEB SERVICE CALL TO GENERATE A REFIL REQUEST
45 ;
46 N GPL,C0PFARY,GVOR
47 D ENCREQ("GPL",IDUZ,IDFN)
48 S GVOR("XMLIN")=GPL
49 S GVOR("ORIG-FILL-DATE")=""
50 S GVOR("CREATE-MED-YN")="0"
51 ;D EN^C0PMAIN("GG","GURL",IDUZ,IDFN,"GENREFILL","GVOR")
52 D INITXPF^C0PWS2("C0PFARY")
53 D SOAP^C0PWS2("GRTN","GENREFILL",IDUZ,IDFN,"GVOR")
54 ;D SOAP^C0CSOAP("GRTN","GENREFILL",,,"GG","C0PFARY") ;
55 Q
56 ;
57GG1 ; IDENTIFY ORPHAN NODES IN ^PS(55,DFN,"NVA",
58 S ZI="" S BAD="" S ZN=0
59 F S ZI=$O(^PS(55,ZI)) Q:ZI="" D ;
60 . S ZJ=""
61 . F S ZJ=$O(^PS(55,ZI,"NVA",ZJ)) Q:ZJ="" D ; FOR EACH NVA DRUG
62 . . I $D(^PS(55,ZI,"NVA",ZJ,1,7,0)) D ; IF THE CODES NODE EXISTS
63 . . . I '$D(^PS(55,ZI,"NVA",ZJ,1,0)) D ; I NO ZERO NODE
64 . . . . S BAD(ZI,ZJ)=""
65 . . . . S ZN=ZN+1
66 K ^G
67 M ^G("BAD")=BAD
68 ZWR BAD
69 W !,"BAD COUNT: ",ZN
70 Q
71 ;
72GG2 ; DISPLAY THE BAD NODES
73 S ZI=""
74 F S ZI=$O(^G("BAD",ZI)) Q:ZI="" D ;
75 . S ZJ=""
76 . F S ZJ=$O(^G("BAD",ZI,ZJ)) Q:ZJ="" D ;
77 . . W !,^PS(55,ZI,"NVA",ZJ,1,7,0)
78 . . I $D(^PS(55,ZI,"NVA",ZJ,1,0)) W !,"ERROR, DRUG EXISTS!"
79 Q
80 ;
81GGKILL ; KILL THE BAD NODES
82 S ZI=""
83 F S ZI=$O(^G("BAD",ZI)) Q:ZI="" D ;
84 . S ZJ=""
85 . F S ZJ=$O(^G("BAD",ZI,ZJ)) Q:ZJ="" D ;
86 . . W !,^PS(55,ZI,"NVA",ZJ,1,7,0)
87 . . I $D(^PS(55,ZI,"NVA",ZJ,1,0)) D Q ;
88 . . . W !," ERROR, DRUG EXISTS!"
89 . . . W !," NODE NOT KILLED, PLEASE REVIEW"
90 . . K ^PS(55,ZI,"NVA",ZJ,1,7,0)
91 . . W !," BAD NODE KILLED"
92 Q
93 ;
94GTEST ; TESTING RENEWAL PROCESSING
95 K G
96 D SOAP^C0PWS2("G","REFILLS",135,961)
97 S ZI=""
98 F S ZI=$O(G(ZI)) Q:ZI="" D ;
99 . S ZG=G(ZI,"RenewalRequestGuid")
100 . I ZG="" W !,"ERROR NULL GUID"
101 . S ZT=$O(^TMP("C0E","INDEX",ZG,""))
102 . I ZT'="" D ; HAVE A TOKEN
103 . . S ZM1=G(ZI,"DrugInfo")
104 . . S ZM2=^TMP("C0E","TOKEN",ZT,"renewalToken")
105 . . S ZM3=^TMP("C0E","TOKEN",ZT,"medication")
106 . . W !,!,"GUID:",ZG,!," TOKEN: ",ZT
107 . . W !,"DRUG1: ",ZM1,!," DRUG2: ",ZM2,!," DRUG3: ",ZM3
108 . . ;ZWR ^TMP("C0E","TOKEN",ZT,*)
109 Q
110 ;
111GTEST2 ; SECOND TEST - FINDING INCONSISTANCIES IN RENEWAL ALERTS
112 S ZI=""
113 S ZN=0
114 S ZTMP=$NA(^TMP("C0E","TOKEN"))
115 F S ZI=$O(@ZTMP@(ZI)) Q:ZI="" D ; FOR EACH TOKEN
116 . I @ZTMP@(ZI,"C0PRenewalName")["request for" D ; MED WHERE NAME SHOULD BE
117 . . W !,!,"TOKEN:",ZI
118 . . W !,"GUID:",@ZTMP@(ZI,"C0PGuid")
119 . . W !,@ZTMP@(ZI,"C0PRenewalName")
120 . . W !,@ZTMP@(ZI,"medication")
121 . . W !,@ZTMP@(ZI,"renewalToken")
122 . . S ISTR=@ZTMP@(ZI,"renewalToken")
123 . . S IDUZ=@ZTMP@(ZI,"IDUZ")
124 . . S ZALRT=$P(ISTR,";",3) ; RENEWAL TOKEN
125 . . S ^G2(IDUZ,ZALRT,ISTR)=""
126 . . S ZN=ZN+1
127 W !,!,"NUMBER OF TOKENS:",ZN
128 Q
129 ;
130GTEST3 ; USE ^G2 TO TRY AND FIND THE ALERTS
131 ;
132 S ZDUZ=""
133 F S ZDUZ=$O(^G2(ZDUZ)) Q:ZDUZ="" D ;
134 . S ZALRT=""
135 . F S ZALRT=$O(^G2(ZDUZ,ZALRT)) Q:ZALRT="" D ;
136 . . W !,!,ZALRT
137 . . W !,$G(^XTV(8992,ZDUZ,"XQA",ZALRT,0))
138 . . S NXTALRT=$O(^XTV(8992,ZDUZ,"XQA",ZALRT)) ; NEXT ALERT
139 . . W !,"NEXT:",NXTALRT
140 . . I NXTALRT'="" W !,$G(^XTV(8992,ZDUZ,"XQA",NXTALRT,0))
141 Q
142 ;
143GINDEX ; INDEX THE ^TMP("C0E","TOKEN") ARRAY BY GUID
144 S ZI=""
145 S ZN=0
146 F S ZI=$O(^TMP("C0E","TOKEN",ZI)) Q:ZI="" D ;
147 . S ZG=^TMP("C0E","TOKEN",ZI,"C0PGuid")
148 . S ^TMP("C0E","INDEX",ZG,ZI)=""
149 . S ZN=ZN+1
150 W !,"NUMBER OF TOKENS: ",ZN
151 Q
152 ;
153ENCREQ(ZRTN,ZDUZ,ZDFN) ; ENCODE AN NCSCRIPT RENEWAL REQUEST
154 ;
155 D GENTEST("GPL","GURL",ZDUZ,ZDFN,1)
156 ;S ZI=""
157 ;S GPL(1)="RxInput="_GPL(1)
158 S ZI=0 ;
159 ;F S ZI=$O(GPL(ZI)) Q:ZI="" D ; MAKE IT XML SAFE
160 ;. S GPL(ZI)=$$SYMENC^MXMLUTL(GPL(ZI))
161 ;. W !,GPL(ZI)
162 S ZI=0
163 S G=""
164 K GPL(0) ; GET RID OF LINE COUNT
165 F S ZI=$O(GPL(ZI)) Q:ZI="" D ;
166 . S G=G_GPL(ZI)
167 S @ZRTN=$$ENCODE^RGUTUU(G)
168 ;S @ZRTN=G
169 Q
170 ;
171CERTTEST ; GENERATE XML FILES FOR NEWCROP CERTIFICATION
172 ;
173 N ZII
174 S ZDFN=18 ; TEST PATIENT TO USE
175 F ZII=154,155,156,157 D ; IENS OF SUBSCRIBER PROFILES
176 . D CERTONE(ZII,ZDFN)
177 Q
178 ;
179CERTONE(ZI,ZDFN) ; GENERATE ONE XML FILE
180 N ZN
181 D EN^C0PMAIN("C0PG1","G2",ZI,ZDFN) ; GET THE NCSCRIPT
182 S ZN=$P($P(^VA(200,ZI,0),U,1),",",2) ; GIVEN NAME OF USER
183 ; ON OUR SYSTEM THESE ARE ERX,DOCTOR ERX,MID-LEVEL ERX,NURSE AND ERX,MANAGER
184 S ZN=ZN_".xml" ; APPEND .xml extension
185 K C0PG1(0)
186 S ZDIR=^TMP("C0CCCR","ODIR")
187 W !,$$OUTPUT^C0CXPATH("C0PG1(1)",ZN,ZDIR)
188 Q
189 ;
190GENTEST(RTNXML,RTNURL,ZDUZ,ZDFN,ZFILE) ; GENERATE A TEST
191 ; CLICK-THROUGH HTLM FILE FOR
192 ; GENERATING REFILL REQUESTS , XML IS RETURNED IN RTN,PASSED BY NAME
193 ; IF ZFILE IS 1, THE FILE IS WRITTEN TO HOST FILE
194 D EN^C0PMAIN("C0PG1","G2",ZDUZ,ZDFN) ; GET THE NCSCRIPT
195 ;D GETMEDS("G6",ZDFN) ;GET MEDICATIONS
196 ;D QUERY^C0CXPATH("G6","//NewPrescription[1]","G7") ;JUST THE FIRST ONE
197 ;D INSERT^C0CXPATH("C0PG1","G7","//NCScript")
198 K C0PG1(0)
199 M @RTNXML=C0PG1 ;
200 S ZDIR=^TMP("C0CCCR","ODIR")
201 I $G(ZFILE)=1 W $$OUTPUT^C0CXPATH("C0PG1(1)","REFILL-"_ZDFN_".xml",ZDIR)
202 Q
203 ;
204GETMEDS(OUTARY,ZDFN) ; GET THE PATIENT'S MEDS AND PUT INTO XML
205 ;
206 N ZG,ZG2,ZB,ZN
207 S DEBUG=0
208 D GETTEMP^C0PWS2("ZG","OUTMEDS") ;GET THE MEDICATIONS TEMPLATE
209 D SOAP^C0PWS2("ZG2","GETMEDS",$$PRIMARY^C0PMAIN(),ZDFN) ; GET MEDS
210 I '$D(ZG2) Q ; SHOULDN'T HAPPEN
211 I ZG2(1,"Status")'="OK" D Q ; BAD RETURN FROM WEB SERVER
212 . W $G(ZG2(1,"Message")),!
213 N ZI S ZI=""
214 S ZN=$NA(^TMP("C0PREFIL",$J))
215 K @ZN
216 F S ZI=$O(ZG2(ZI)) Q:ZI="" D ; FOR EACH MED
217 . N ZV
218 . S ZV=$NA(@ZN@("DATA",ZI))
219 . S ZX=$NA(@ZN@("XML",ZI))
220 . S @ZV@("dispenseNumber")=$G(ZG2(ZI,"Dispense"))
221 . S @ZV@("dosage")="Take "_$G(ZG2(ZI,"DosageNumberDescription"))_" "_$G(ZG2(ZI,"Route"))_" "_$G(ZG2(ZI,"DosageFrequencyDescription"))
222 . S @ZV@("drugIdentifier")=ZG2(ZI,"DrugID")
223 . S @ZV@("drugIdentifierType")="FDB"
224 . S @ZV@("pharmacistMessage")="No childproof caps please"
225 . S @ZV@("pharmacyIdentifier")=1231212
226 . S @ZV@("refillCount")=ZG2(ZI,"Refills")
227 . S @ZV@("substitution")="SubstitutionAllowed"
228 . D MAP^C0CXPATH("ZG",ZV,ZX)
229 . D QUEUE^C0CXPATH("ZB",ZX,2,$O(@ZX@(""),-1))
230 D BUILD^C0CXPATH("ZB",OUTARY)
231 K @ZN ;CLEAN UP
232 Q
233 ;
234 ;B
235 ;
236 ;D GET^C0PCUR(.ZG2,ZDFN) ; GET THE MEDS FOR THIS PATIENT
237 ;D EXTRACT^C0CALERT("ZG",ZDFN,"ZG2","ALGYCBK^C0PALGY3(ALTVMAP,A1)")
238 S ZN=$O(ZR(""),-1) ;NUMBER OF LINES IN OUTPUT
239 D QUEUE^C0CXPATH("ZB","ZG2",2,ZN-1)
240 D BUILD^C0CXPATH("ZB",OUTARY)
241 Q
242 ;
243RGUIDS(ZARY,ZDUZ) ; RETURNS AN ARRAY OF ALL REFILL REQUEST GUIDS FOR
244 ; DUZ ZDUZ. ZARY IS PASSED BY NAME
245 ; FORMAT IS @ZARY@("GUID")=IEN
246 ; THIS ROUTINE IS REUSED FOR THE STATUS ROUTINE - INCOMPLETE ORDERS
247 N ZI,ZJ,ZK,ZL,ZM,ZN
248 S ZI=0
249 ;F S ZI=$O(^XTV(8992.1,"R",ZDUZ,ZI)) Q:ZI="" D ; ALL ALERT FOR DUZ
250 F S ZI=$O(^XTV(8992,ZDUZ,"XQA",ZI)) Q:ZI="" D ; USE XQA MULTIPLE
251 . S ZL=^XTV(8992,ZDUZ,"XQA",ZI,0) ;
252 . S ZM=$P(ZL,U,2) ; RECORD ID
253 . S ZN=$O(^XTV(8992.1,"B",ZM,"")) ;IEN OF ALERT TRACKING RECORD
254 . S ZK=$$GET1^DIQ(8992.1,ZN_",",.03)
255 . I ZK'["OR,1130" Q ; NOT OUR PACKAGE - ALL ERX ALERTS START WITH 1130
256 . ; 11305 IS FOR REFILLS
257 . ; 11306 IS FOR INCOMPLETE ORDERS
258 . S ZJ=""
259 . S ZJ=$$GET1^DIQ(8992.1,ZN_",",2)
260 . I ZJ="" Q
261 . ; FOR RENEWALS (11305) NEED TO PULL THE GUID OUT - IT IS THE FIRST PIECE
262 . ; OTHERWISE USE THE ENTIRE STRING. FOR INCOMPLETE ORDERS THIS WILL
263 . ; INCLUDE THE MED AND PRESCRIPTION DATE
264 . I ZK["OR,11305" S ZJ=$P(ZJ,"^",1) ; FIRST PIECE IS THE GUILD GUID^DOB^SEX
265 . S @ZARY@(ZJ)=ZN
266 Q
267 ;
268EN ; BATCH ENTRY POINT FOR REFILL (RENEWAL) STATUS AND FAILEDFAX CHECKING
269 D REFILL
270 K ZRSLT
271 ;D STATUS ; ALSO RUN CHECK FOR INCOMPLETE ORDERS
272 D FAILFAX ; ALSO RUN CHECK FOR FAILED FAXES
273 Q
274 ;
275REFILL ; PULL REFILL REQUESTS AND POST ALERTS
276 ;
277 N ZDUZ ; USER NUMBER UNDER WHICH WE BUILD THE WEB SERVICE CALL
278 N ZDFN ; PATIENT NUMBER USED TO BUILD THE WEB SERVICE CALL
279 S ZDUZ=$$PRIMARY^C0PMAIN() ; PRIMARY ERX USER FOR BATCH CALLS
280 ;S ZDUZ=DUZ ; SHOULD CHANGE THIS FOR PRODUCTION TO A "BATCH" USER
281 S ZDFN="" ; NO PATIENT NEEDED FOR THESE CALLS
282 ; S ZDFN=18 ; SHOULD NOT NEED THIS BE MAKE THE CALL - FIX IN EN^C0PMAIN
283 N ZRSLT
284 D SOAP^C0PWS2("ZRSLT","REFILLS",ZDUZ,ZDFN) ; WS CALL TO RETURN REFILS
285 ;S XXX=YYY ;
286 I $G(ZRSLT(1,"Status"))'="OK" Q ; NO ROWS WERE RETURNED
287 I $G(ZRSLT(1,"RowCount"))=0 Q ; NO ROWS WERE RETURNED
288 D NOTIPURG^XQALBUTL(11305) ; DELETE ALL CURRENT REFILL ALERTS
289 S C0PNPIF=$$GET1^DIQ(C0PAF,C0PACCT_",",8,"I") ; LEGACY FLAG TO USE NPI FOR SID
290 N ZI S ZI=0
291 N ZAPACK S ZAPACK="OR" ; ALERT PACKAGE CODE
292 N ZADFN S ZADFN=0 ; DFN TO ASSOCIATE ALERT WITH - WE DON'T KNOW THIS
293 N ZACODE S ZACODE=11305 ; IEN TO OE/RR NOTIFICATIONS file for eRx Refills
294 F S ZI=$O(ZRSLT(ZI)) Q:+ZI=0 D ; FOR EACH RETURNED REFILL REQUEST
295 . N ZSID S ZSID=ZRSLT(ZI,"ExternalDoctorId") ; NPI FOR SUBSCRIBER
296 . I C0PNPIF'=1 S ZDUZ=$O(^VA(200,"AC0PSID",ZSID,"")) ; GUID SID
297 . E S ZDUZ=$O(^VA(200,"C0PNPI",ZSID,"")) ; DUZ FOR SUBSCRIBER
298 . S ZRSLT("DUZ",ZDUZ,ZI)=""
299 N ZJ S ZJ=""
300 F S ZJ=$O(ZRSLT("DUZ",ZJ)) Q:ZJ="" D ; FOR EACH PROVIDER
301 . N ZGUIDS
302 . D RGUIDS("ZGUIDS",ZJ) ; GET ARRAY OF CURRENT ACTIVE GUIDS
303 . S ZI=""
304 . F S ZI=$O(ZRSLT("DUZ",ZJ,ZI)) Q:ZI="" D ; FOR EACH REQUEST
305 . . N ZRRG S ZRRG=ZRSLT(ZI,"RenewalRequestGuid") ;renewal request number
306 . . I $D(ZGUIDS(ZRRG)) D Q ; THIS REQUEST IS A DUPLICATE, SKIP IT
307 . . . W ZRRG_" IS A DUP",!
308 . . N ZDATE S ZDATE=$P(ZRSLT(ZI,"ReceivedTimestamp")," ",1) ;DATE RECEIVED
309 . . I $G(^TMP("C0P","TestNoMatch"))=1 D ;
310 . . . S ZRSLT(ZI,"PatientMiddleName")="XXX" ;TESTING NO MATCH REMOVE ME
311 . . ;I DUZ=135 S ZRSLT(ZI,"PatientMiddleName")="Uta" ;TESTING NO MATCH REMOVE
312 . . N ZPAT S ZPAT=$G(ZRSLT(ZI,"PatientLastName"))_","_$G(ZRSLT(ZI,"PatientFirstName")) ; PATIENT NAME LAST,FIRST
313 . . I $G(ZRSLT(ZI,"PatientMiddleName"))'="" S ZPAT=ZPAT_" "_$G(ZRSLT(ZI,"PatientMiddleName"))
314 . . S ZDOB=$G(ZRSLT(ZI,"PatientDOB")) ;patient date of birth
315 . . S ZSEX=$G(ZRSLT(ZI,"PatientGender")) ;patient gender
316 . . S ZADFN=$$PATMAT(ZPAT,ZDOB,ZSEX) ; TRY AND MATCH THE PATIENT
317 . . ;W "DFN="_ZADFN," ",ZI,!
318 . . N ZXQAID S ZXQAID=ZAPACK_","_ZADFN_","_ZACODE ; FORMAT FOR P1 OF XQAID
319 . . N ZMED S ZMED=ZRSLT(ZI,"DrugInfo")
320 . . ;S XQA(ZDUZ)="" ; WHO TO SEND THE ALERT TO
321 . . I '$D(^TMP("C0P","AlertVerify")) S XQA(ZJ)="" ; WHO TO SEND THE ALERT TO
322 . . E D ; AlertVerify sends alerts only to testers, not recipients
323 . . . ; use this when installing eRx to verify ewd installation
324 . . . N ZZZ S ZZZ=""
325 . . . F S ZZZ=$O(^TMP("C0P","AlertVerify",ZZZ)) Q:ZZZ="" D ; WHICH DUZ
326 . . . . S XQA(ZZZ)="" ; MARK THIS USER TO RECIEVE ALERTS
327 . . ;S XQA(135)="" ; ALWAYS SEND TO GPL
328 . . ;S XQA(148)="" ; ALWAYS SEND TO RICH
329 . . N ZP6 ; STRING THAT CPRS WILL RETURN FOR MATCHING
330 . . I ZADFN=0 D ; NO MATCH
331 . . . S XQAMSG="no match: ): [eRx] "_ZPAT_" Renewal request for "_ZMED
332 . . . S ZP6=ZPAT_" Renewal request for "_ZMED
333 . . E D ;
334 . . . S XQAMSG=ZPAT_": ): [eRx] Renewal request for "_ZMED
335 . . . S ZP6="Renewal request for "_ZMED
336 . . ;S XQAMSG=$E(XQAMSG,1,70) ; TRUNCATE TO 70 CHARS
337 . . S XQAID=ZXQAID ; PACKAGE IDENTIFIER
338 . . ;S XQADATA=ZRRG ; THE GUID OF THE REQUEST. NEEDED TO PROCESS THE ALERT
339 . . S XQADATA=ZRRG_"^"_ZDOB_"^"_ZSEX ; SAVE DOB AND SEX WITH GUID
340 . . W "SENDING",XQAID_" "_XQADATA,!
341 . . D SETUP^XQALERT ; MAKE THE CALL TO SET THE ALERT
342 K ZRSLT
343 ;D STATUS ; ALSO RUN CHECK FOR INCOMPLETE ORDERS
344 ;D FAILFAX ; ALSO RUN CHECK FOR FAILED FAXES
345 Q
346 ;
347PATMAT(ZNAME,INDOB,INSEX) ;EXTRINSIC TO TRY AND MATCH THE PATIENT
348 ; RETURNS ZERO IF NO EXACT MATCH IS FOUND
349 N ZP
350 S ZP=$O(^DPT("B",ZNAME,""))
351 I ZP="" Q 0 ; EXACT MATCH NOT FOUND ON NAME
352 ; CHECK DATE OF BIRTH
353 ;W "CHECKING DATE OF BIRTH",!
354 N DOB
355 S DOB=$$GET1^DIQ(2,ZP_",",.03,"I") ; PATIENT'S DATE OF BIRTH IN VISTA
356 N ZD ;INCOMING DATE OF BIRTH IS IN YYYYMMDD FORMAT
357 S ZD=($E(INDOB,1,4)-1700)_$E(INDOB,5,8) ; DATE OF BIRTH CONVERTED TO FM FORMAT
358 ;W ZD_" "_DOB,!
359 I +ZD'=+DOB Q 0 ; DATE OF BIRTH DOES NOT MATCH
360 ;
361 ; CHECK GENDER
362 ;W "CHECKING GENDER",!
363 N GENDER
364 S GENDER=$$GET1^DIQ(2,ZP_",",.02,"I") ; PATIENT'S GENDER IN VISTA
365 ;W GENDER_INSEX,!
366 I GENDER'=INSEX Q 0 ;GENDER DOESN'T MATCH
367 Q ZP
368 ;
369STATUS ; BATCH CALL TO RETRIEVE ERX ACCOUNT STATUS
370 ; RETURNS UNFINISHED ORDERS FOR ALL PROVIDERS
371 ; AND SENDS STATUS ALERTS
372 N VOR
373 S VOR("STATUS-SECTION-TYPE")="AllDoctorReview"
374 S VOR("SORT-ORDER")="A"
375 S VOR("INCLUDE-SCHEMA")="N"
376 S ZDUZ=$$PRIMARY^C0PMAIN() ; PRIMARY ERX USER FOR BATCH CALLS
377 K ZRSLT
378 ; D SOAP^C0PWS1("ZRSLT","STATUS",ZDUZ,"","VOR")
379 D SOAP^C0PWS2("ZRSLT","STATUS",ZDUZ,"","VOR")
380 I '$D(ZRSLT) Q ; SHOULDN'T HAPPEN
381 I $G(ZRSLT(1,"DrugInfo"))="" Q ; NO ROWS
382 S C0PNPIF=$$GET1^DIQ(C0PAF,C0PACCT_",",8,"I") ; LEGACY FLAG TO USE NPI FOR SID
383 N ZI S ZI=0
384 N ZAPACK S ZAPACK="OR" ; ALERT PACKAGE CODE
385 N ZADFN S ZADFN=0 ; DFN TO ASSOCIATE ALERT WITH - WE DON'T KNOW THIS
386 N ZACODE S ZACODE=11306 ; IEN TO OE/RR NOTIFICATIONS file for eRx incomplete
387 ; orders
388 F S ZI=$O(ZRSLT(ZI)) Q:+ZI=0 D ; FOR EACH RETURNED REFILL REQUEST
389 . N ZSID S ZSID=$G(ZRSLT(ZI,"ExternalDoctorId")) ; NPI FOR SUBSCRIBER
390 . I ZSID="" Q ; NO EXTERNAL ID FOR THIS STATUS
391 . I C0PNPIF'=1 S ZDUZ=$O(^VA(200,"AC0PSID",ZSID,"")) ; GUID SID
392 . E S ZDUZ=$O(^VA(200,"C0PNPI",ZSID,"")) ; DUZ FOR SUBSCRIBER
393 . S ZRSLT("DUZ",ZDUZ,ZI)=""
394 N ZJ S ZJ=""
395 D RMSTATUS ; REMOVE ALL STATUS ALERTS
396 F S ZJ=$O(ZRSLT("DUZ",ZJ)) Q:ZJ="" D ; FOR EACH PROVIDER
397 . N ZGUIDS
398 . D RGUIDS("ZGUIDS",ZJ) ; GET ARRAY OF CURRENT ACTIVE ALERTS
399 . S ZI=""
400 . F S ZI=$O(ZRSLT("DUZ",ZJ,ZI)) Q:ZI="" D ; FOR EACH REQUEST
401 . . N ZRRG S ZRRG=$G(ZRSLT(ZI,"DrugInfo")) ; first piece of XQDATA
402 . . S $P(ZRRG,"^",2)=$G(ZRSLT(ZI,"PrescriptionDate")) ; second piece
403 . . I $D(ZGUIDS(ZRRG)) D Q ; THIS REQUEST IS A DUPLICATE, SKIP IT
404 . . . ;W ZRRG_" IS A DUP",!
405 . . I ZRRG="^" D Q ; THIS IS AN ERROR
406 . . . B
407 . . N ZDATE S ZDATE=$P($G(ZRSLT(ZI,"PrescriptionDate"))," ",1) ;
408 . . N ZPAT S ZPAT=$G(ZRSLT(ZI,"ExternalPatientId")) ; format PATIENTDFN
409 . . I ZPAT="" Q ;THIS IS AN ERROR
410 . . S ZADFN=$P(ZPAT,"PATIENT",2) ; EXTRACT THE DFN
411 . . S ZPAT=$$GET1^DIQ(2,ZADFN_",",.01) ;PATIENT'S NAME
412 . . ;W "DFN="_ZADFN," ",ZI,!
413 . . N ZXQAID S ZXQAID=ZAPACK_","_ZADFN_","_ZACODE ; FORMAT FOR P1 OF XQAID
414 . . N ZMED S ZMED=ZRSLT(ZI,"DrugInfo")
415 . . ;S XQA(ZDUZ)="" ; WHO TO SEND THE ALERT TO
416 . . S XQA(ZJ)="" ; WHO TO SEND THE ALERT TO
417 . . ;S XQA(135)="" ; ALWAYS SEND TO GPL
418 . . ;S XQA(148)="" ; ALWAYS SEND TO RICH
419 . . N ZP6 ; STRING THAT CPRS WILL RETURN FOR MATCHING
420 . . I ZADFN=0 D ; NO MATCH
421 . . . S XQAMSG="no match: ): [eRx] "_ZPAT_" Incomplete Order for "_ZMED
422 . . . S ZP6=ZPAT_" Incomplete Order for "_ZMED
423 . . E D ;
424 . . . S XQAMSG=ZPAT_": ): [eRx] Incomplete Order for "_ZMED
425 . . . S ZP6="Incomplete Order for "_ZMED
426 . . ;S XQAMSG=$E(XQAMSG,1,70) ; TRUNCATE TO 70 CHARS
427 . . S XQAID=ZXQAID ; PACKAGE IDENTIFIER
428 . . S XQADATA=ZRRG ; THE GUID OF THE REQUEST. NEEDED TO PROCESS THE ALERT
429 . . D SETUP^XQALERT ; MAKE THE CALL TO SET THE ALERT
430 Q
431 ;
432RMSTATUS ; DELETES ALL STATUS ALERTS FOR ALL USERS (THEY WILL BE
433 ; RESTORED NEXT TIME STATUS^C0PREFIL IS RUN - IN ERX BATCH
434 D NOTIPURG^XQALBUTL(11306) ;
435 W !,"ALL ERX STATUS ALERTS HAVE BEEN DELETED"
436 Q
437 ;
438FAILFAX ; BATCH CALL TO RETRIEVE ERX FAILED FAX STATUS
439 ; RETURNS A COUNT OF FAILED FAXES AND AN ARRAY OF PATIENTS
440 N VOR,ZRSLT
441 S VOR("STATUS-SECTION-TYPE")="FailedFax"
442 ;S VOR("ACCOUNT-PARTNERNAME")="demo"
443 S VOR("SORT-ORDER")="A"
444 S VOR("INCLUDE-SCHEMA")="N"
445 S ZDUZ=$$PRIMARY^C0PMAIN() ; PRIMARY ERX USER FOR BATCH CALLS
446 D SOAP^C0PWS1("ZRSLT","STATUS",ZDUZ,"","VOR")
447 N ZCOUNT
448 S ZCOUNT=$O(ZRSLT(""),-1) ; HOW MANY FAILED FAXES
449 I +ZCOUNT=0 Q ; NO FAILED FAXES
450 ;I $G(ZRSLT(1,"RowCount"))=0 Q ; NO FAILED FAXES
451 ;I $G(ZRSLT(1,"RowCount"))="" Q ; SHOULD NOT HAPPEN
452 N XQA,XQAMSG,XQAID,XQAKILL
453 S XQAID="C0P" ; GOING TO FIRST KILL ALL FAILED FAX ALERTS
454 D DELETEA^XQALERT ; KILL ALL FAILED FAX ALERTS
455 S XQA("G.ERX HELP DESK")=""
456 ;S XQA(135)=""
457 S XQAID="C0P"
458 S XQAMSG="eRx: "_ZCOUNT_" Failed Faxes on ePrescribing"
459 D SETUP^XQALERT ; CREATE NEW FAILED FAX ALERTS TO THE MAILGROUP
460 Q
461 ;
462RUN ; USED TO PROCESS AN ALERT. THIS ROUTINE IS LISTED IN
463 ; 0E/RR CPRS NOTIFICATIONS AS THE ROUTINE TO RUN TO PROCESS
464 ; A C0P ERX ALERT
465 W "MADE IT TO RUN C0PREFIL",!
466 W XQADATA
467 B
468 Q
469 ;
470GETALRT(ZARY,ZID) ; LOOKS UP AN ALERT BY USING THE "RECORDID" FROM CPRS,
471 ; PASSED BY VALUE IN ZID. RESULTS ARE RETURNED IN ZARY, PASSED BY NAME
472 ;N ZIEN
473 ;S ZIEN=$O(^XTV(8992.1,"B",ZID,"")) ;IEN IN THE ALERT TRACKING FILE
474 ;I ZIEN="" W "ERROR RETRIEVING ALERT",! Q ;
475 D GETN^C0CRNF(ZARY,8992.1,ZID,"B") ; GET ALL THE ALERT FIELDS
476 ; THE FORMAT IS @ZARY@("DATA FOR PROCESSING")="FILE^FIELD^VALUE"
477 ; ALL POPULATED FIELDS (BUT NOT SUBFILES) ARE RETURNED
478 Q
479 ;
480UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
481 K ZERR
482 D CLEAN^DILF
483 D UPDATE^DIE("","C0PFDA","","ZERR")
484 I $D(ZERR) D ;
485 . W "ERROR",!
486 . ZWR ZERR
487 . B
488 K C0PFDA
489 Q
490 ;
491FIND ; FIND ALL CURRENT ALERTS
492 N ZI S ZI="" ; DUZ
493 F S ZI=$O(^XTV(8992,"AXQAN","OR,0,11305",ZI)) Q:ZI="" D ;
494 . N ZJ S ZJ="" ; TIME STAMP
495 . F S ZJ=$O(^XTV(8992,"AXQAN","OR,0,11305",ZI,ZJ)) Q:ZJ="" D ;
496 . . N ZZ,ZT
497 . . S ZZ=$G(^XTV(8992,ZI,"XQA",ZJ,0))
498 . . S ZT=$P(ZZ,U,2)
499 . . Q:ZT=""
500 . . S ZG=$O(^XTV(8992.1,"B",ZT,""))
501 . . Q:ZG=""
502 . . S ZGUID=$G(^XTV(8992.1,ZG,2))
503 . . Q:ZGUID=""
504 . . S ZGUID=$P(ZGUID,U,1)
505 . . W !,ZI," ",ZJ," ",ZT," ",ZG," ",ZGUID
506 . . ;ZWR ^XTV(8992.1,ZG,*)
507 . . S G(ZJ,ZT,ZGUID)=""
508 Q
509 ;
Note: See TracBrowser for help on using the repository browser.