source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0O.m

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

initial load of FOIAVistA 6/30/08 version

File size: 8.6 KB
Line 
1OCXOZ0O ;SLC/RJS,CLA - Order Check Scan ;SEP 4,2007 at 23:12
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,221**;Dec 17,1997
3 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
4 ;
5 ; ***************************************************************
6 ; ** Warning: This routine is automatically generated by the **
7 ; ** Rule Compiler (^OCXOCMP) and ANY changes to this routine **
8 ; ** will be lost the next time the rule compiler executes. **
9 ; ***************************************************************
10 ;
11 Q
12 ;
13R19R1B ; Send Order Check, Notication messages and/or Execute code for Rule #19 'PATIENT DISCHARGE' Relation #1 'DISCHARGE'
14 ; Called from R19R1A+10^OCXOZ0N.
15 ;
16 Q:$G(OCXOERR)
17 ;
18 ; Local Extrinsic Functions
19 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
20 ; INT2DT( ----------> CONVERT DATE FROM OCX FORMAT TO READABLE FORMAT
21 ; NEWRULE( ---------> NEW RULE MESSAGE
22 ;
23 Q:$D(OCXRULE("R19R1B"))
24 ;
25 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
26 S OCXCMSG=""
27 S OCXNMSG="Discharged on "_$$INT2DT($$GETDATA(DFN,"56^",26),0)
28 ;
29 Q:$G(OCXOERR)
30 ;
31 ; Send Notification
32 ;
33 S (OCXDUZ,OCXDATA)="",OCXNUM=0
34 I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
35 .S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
36 .S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
37 I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
38 .I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
39 .S OCXNUM=+$P(OCXORD,U,2)
40 S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
41 S OCXRULE("R19R1B")=""
42 I $$NEWRULE(DFN,OCXNUM,19,1,35,OCXNMSG) D I 1
43 .D:($G(OCXTRACE)<5) EN^ORB3(35,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
44 Q
45 ;
46R22R1A ; Verify all Event/Elements of Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
47 ; Called from EL47+5^OCXOZ0G.
48 ;
49 Q:$G(OCXOERR)
50 ;
51 ; Local Extrinsic Functions
52 ; MCE47( -----------> Verify Event/Element: 'ORDER REQUIRES CO-SIGNATURE'
53 ;
54 Q:$G(^OCXS(860.2,22,"INACT"))
55 ;
56 I $$MCE47 D R22R1B
57 Q
58 ;
59R22R1B ; Send Order Check, Notication messages and/or Execute code for Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
60 ; Called from R22R1A+10.
61 ;
62 Q:$G(OCXOERR)
63 ;
64 ; Local Extrinsic Functions
65 ; NEWRULE( ---------> NEW RULE MESSAGE
66 ;
67 Q:$D(OCXRULE("R22R1B"))
68 ;
69 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
70 S OCXCMSG=""
71 S OCXNMSG="Order requires a co-signature"
72 ;
73 Q:$G(OCXOERR)
74 ;
75 ; Send Notification
76 ;
77 S (OCXDUZ,OCXDATA)="",OCXNUM=0
78 I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
79 .S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
80 .S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
81 I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
82 .I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
83 .S OCXNUM=+$P(OCXORD,U,2)
84 S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
85 S OCXRULE("R22R1B")=""
86 I $$NEWRULE(DFN,OCXNUM,22,1,37,OCXNMSG) D I 1
87 .D:($G(OCXTRACE)<5) EN^ORB3(37,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
88 Q
89 ;
90R24R1A ; Verify all Event/Elements of Rule #24 'ORDERER FLAGGED RESULTS AVAILABLE' Relation #1 'ORDER FLAGGED FOR RESULTS AND (LAB RESULT OR IMAGI...'
91 ; Called from EL5+5^OCXOZ0H, and EL49+5^OCXOZ0H, and EL55+5^OCXOZ0H, and EL101+5^OCXOZ0H.
92 ;
93 Q:$G(OCXOERR)
94 ;
95 ; Local Extrinsic Functions
96 ; MCE101( ----------> Verify Event/Element: 'HL7 FINAL IMAGING RESULT'
97 ; MCE49( -----------> Verify Event/Element: 'ORDER FLAGGED FOR RESULTS'
98 ; MCE5( ------------> Verify Event/Element: 'HL7 FINAL LAB RESULT'
99 ; MCE55( -----------> Verify Event/Element: 'CONSULT FINAL RESULTS'
100 ;
101 Q:$G(^OCXS(860.2,24,"INACT"))
102 ;
103 I $$MCE49 D
104 .I $$MCE5 D R24R1B^OCXOZ0P
105 .I $$MCE101 D R24R1B^OCXOZ0P
106 .I $$MCE55 D R24R1B^OCXOZ0P
107 Q
108 ;
109CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
110 ;
111 N CKSUM,PTR,ASC S CKSUM=0
112 S STR=$TR(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
113 F PTR=$L(STR):-1:1 S ASC=$A(STR,PTR)-42 I (ASC>0),(ASC<51) S CKSUM=CKSUM*2+ASC
114 Q +CKSUM
115 ;
116GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
117 ;
118 N OCXE,VAL,PC S VAL=""
119 F PC=1:1:$L(OCXL,U) S OCXE=$P(OCXL,U,PC) I OCXE S VAL=$G(^TMP("OCXCHK",$J,DFN,OCXE,OCXDFI)) Q:$L(VAL)
120 Q VAL
121 ;
122INT2DT(OCXDT,OCXF) ; This Local Extrinsic Function converts an OCX internal format
123 ; date into an Externl Format (Human Readable) date. 'OCXF=SHORT FORMAT OCXF=LONG FORMAT
124 ;
125 Q:'$L($G(OCXDT)) "" S OCXF=+$G(OCXF)
126 N OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXCYR
127 S (OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXAP)=""
128 S OCXSEC=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
129 S OCXMIN=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
130 S OCXHR=$E(OCXDT#24+100,2,3),OCXDT=OCXDT\24
131 S OCXCYR=($H\1461)*4+1841+(($H#1461)\365)
132 S OCXYR=(OCXDT\1461)*4+1841,OCXDT=OCXDT#1461
133 S OCXLPYR=(OCXDT\365),OCXDT=OCXDT-(OCXLPYR*365),OCXYR=OCXYR+OCXLPYR
134 S OCXCNT="031^059^090^120^151^181^212^243^273^304^334^365"
135 S:(OCXLPYR=3) OCXCNT="031^060^091^121^152^182^213^244^274^305^335^366"
136 F OCXMON=1:1:12 Q:(OCXDT<$P(OCXCNT,U,OCXMON))
137 S OCXDAY=OCXDT-$P(OCXCNT,U,OCXMON-1)+1
138 I OCXF S OCXMON=$P("January^February^March^April^May^June^July^August^September^October^November^December",U,OCXMON)
139 E S OCXMON=$E(OCXMON+100,2,3)
140 S OCXAP=$S('OCXHR:"Midnight",(OCXHR=12):"Noon",(OCXHR<12):"AM",1:"PM")
141 I OCXF S OCXHR=OCXHR#12 S:'OCXHR OCXHR=12
142 Q:'OCXF $E(OCXMON+100,2,3)_"/"_$E(OCXDAY+100,2,3)_$S((OCXCYR=OCXYR):" "_OCXHR_":"_OCXMIN,1:"/"_$E(OCXYR,3,4))
143 Q:(OCXHR+OCXMIN+OCXSEC) OCXMON_" "_OCXDAY_","_OCXYR_" at "_OCXHR_":"_OCXMIN_"."_OCXSEC_" "_OCXAP
144 Q OCXMON_" "_OCXDAY_","_OCXYR
145 ;
146MCE101() ; Verify Event/Element: HL7 FINAL IMAGING RESULT
147 ;
148 ;
149 N OCXRES
150 I $L(OCXDF(37)) S OCXRES(101,37)=OCXDF(37)
151 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),101)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),101))
152 Q 0
153 ;
154MCE47() ; Verify Event/Element: ORDER REQUIRES CO-SIGNATURE
155 ;
156 ; OCXDF(37) -> PATIENT IEN data field
157 ;
158 N OCXRES
159 S OCXDF(37)=$P($G(OCXORD),"^",1) I $L(OCXDF(37)) S OCXRES(47,37)=OCXDF(37)
160 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),47)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),47))
161 Q 0
162 ;
163MCE49() ; Verify Event/Element: ORDER FLAGGED FOR RESULTS
164 ;
165 ;
166 N OCXRES
167 I $L(OCXDF(37)) S OCXRES(49,37)=OCXDF(37)
168 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),49)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),49))
169 Q 0
170 ;
171MCE5() ; Verify Event/Element: HL7 FINAL LAB RESULT
172 ;
173 ;
174 N OCXRES
175 I $L(OCXDF(37)) S OCXRES(5,37)=OCXDF(37)
176 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),5)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),5))
177 Q 0
178 ;
179MCE55() ; Verify Event/Element: CONSULT FINAL RESULTS
180 ;
181 ;
182 N OCXRES
183 I $L(OCXDF(37)) S OCXRES(55,37)=OCXDF(37)
184 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),55)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),55))
185 Q 0
186 ;
187NEWRULE(OCXDFN,OCXORD,OCXRUL,OCXREL,OCXNOTF,OCXMESS) ; Has this rule already been triggered for this order number
188 ;
189 ;
190 Q:'$G(OCXDFN) 0 Q:'$G(OCXRUL) 0
191 Q:'$G(OCXREL) 0 Q:'$G(OCXNOTF) 0 Q:'$L($G(OCXMESS)) 0
192 S OCXORD=+$G(OCXORD),OCXDFN=+OCXDFN
193 ;
194 N OCXNDX,OCXDATA,OCXDFI,OCXELE,OCXGR,OCXTIME,OCXCKSUM,OCXTSP,OCXTSPL
195 ;
196 S OCXTIME=(+$H)
197 S OCXCKSUM=$$CKSUM(OCXMESS)
198 ;
199 S OCXTSP=($H*86400)+$P($H,",",2)
200 S OCXTSPL=($G(^OCXD(860.7,"AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM))+$G(OCXTSPI,300))
201 ;
202 Q:(OCXTSPL>OCXTSP) 0
203 ;
204 K OCXDATA
205 S OCXDATA(OCXDFN,0)=OCXDFN
206 S OCXDATA("B",OCXDFN,OCXDFN)=""
207 S OCXDATA("AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM)=OCXTSP
208 ;
209 S OCXGR="^OCXD(860.7"
210 D SETAP(OCXGR_")",0,.OCXDATA,OCXDFN)
211 ;
212 K OCXDATA
213 S OCXDATA(OCXRUL,0)=OCXRUL_U_(OCXTIME)_U_(+OCXORD)
214 S OCXDATA(OCXRUL,"M")=OCXMESS
215 S OCXDATA("B",OCXRUL,OCXRUL)=""
216 S OCXGR=OCXGR_","_OCXDFN_",1"
217 D SETAP(OCXGR_")","860.71P",.OCXDATA,OCXRUL)
218 ;
219 K OCXDATA
220 S OCXDATA(OCXREL,0)=OCXREL
221 S OCXDATA("B",OCXREL,OCXREL)=""
222 S OCXGR=OCXGR_","_OCXRUL_",1"
223 D SETAP(OCXGR_")","860.712",.OCXDATA,OCXREL)
224 ;
225 S OCXELE=0 F S OCXELE=$O(^OCXS(860.2,OCXRUL,"C","C",OCXELE)) Q:'OCXELE D
226 .;
227 .N OCXGR1
228 .S OCXGR1=OCXGR_","_OCXREL_",1"
229 .K OCXDATA
230 .S OCXDATA(OCXELE,0)=OCXELE
231 .S OCXDATA(OCXELE,"TIME")=OCXTIME
232 .S OCXDATA(OCXELE,"LOG")=$G(OCXOLOG)
233 .S OCXDATA("B",OCXELE,OCXELE)=""
234 .K ^OCXD(860.7,OCXDFN,1,OCXRUL,1,OCXREL,1,OCXELE)
235 .D SETAP(OCXGR1_")","860.7122P",.OCXDATA,OCXELE)
236 .;
237 .S OCXDFI=0 F S OCXDFI=$O(^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)) Q:'OCXDFI D
238 ..N OCXGR2
239 ..S OCXGR2=OCXGR1_","_OCXELE_",1"
240 ..K OCXDATA
241 ..S OCXDATA(OCXDFI,0)=OCXDFI
242 ..S OCXDATA(OCXDFI,"VAL")=^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)
243 ..S OCXDATA("B",OCXDFI,OCXDFI)=""
244 ..D SETAP(OCXGR2_")","860.71223P",.OCXDATA,OCXDFI)
245 ;
246 Q 1
247 ;
248SETAP(ROOT,DD,DATA,DA) ; Set Rule Event data
249 M @ROOT=DATA
250 I +$G(DD) S @ROOT@(0)="^"_($G(DD))_"^"_($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
251 I '$G(DD) S $P(@ROOT@(0),U,3,4)=($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
252 ;
253 Q
254 ;
255 ;
Note: See TracBrowser for help on using the repository browser.