source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0R.m@ 1800

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

revised back to 6/30/08 version

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