source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0J.m@ 1639

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

revised back to 6/30/08 version

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