source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ12.m@ 1154

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

initial load of FOIAVistA 6/30/08 version

File size: 7.5 KB
Line 
1OCXOZ12 ;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 ;
13R69R1B ; Send Order Check, Notication messages and/or Execute code for Rule #69 'LAB THRESHOLD' Relation #1 'IF HL7 LAB RESULTS AND (GREATER THAN THRESHOLD VAL...'
14 ; Called from R69R1A+13^OCXOZ11.
15 ;
16 Q:$G(OCXOERR)
17 ;
18 ; Local Extrinsic Functions
19 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
20 ; LABTHRSR( --------> LAB THRESHOLD EXCEEDED RESULTS
21 ; NEWRULE( ---------> NEW RULE MESSAGE
22 ;
23 Q:$D(OCXRULE("R69R1B"))
24 ;
25 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
26 S OCXCMSG=""
27 S OCXNMSG="["_$$GETDATA(DFN,"5^131^132",147)_"] Lab threshold exceeded - ["_$$GETDATA(DFN,"5^131^132",96)_"]"
28 ;
29 ;
30 ; Run Execute Code
31 ;
32 S OCXTMP=$$LABTHRSR(.OCXDUZ,$$GETDATA(DFN,"5^131^132",113),$$GETDATA(DFN,"5^131^132",152),$$GETDATA(DFN,"5^131^132",12),$$GETDATA(DFN,"5^131^132",37))
33 Q:$G(OCXOERR)
34 ;
35 ; Send Notification
36 ;
37 S (OCXDUZ,OCXDATA)="",OCXNUM=0
38 I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
39 .S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
40 .S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
41 I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
42 .I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
43 .S OCXNUM=+$P(OCXORD,U,2)
44 S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
45 S OCXRULE("R69R1B")=""
46 I $$NEWRULE(DFN,OCXNUM,69,1,68,OCXNMSG) D I 1
47 .D:($G(OCXTRACE)<5) EN^ORB3(68,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
48 Q
49 ;
50R70R1A ; Verify all Event/Elements of Rule #70 'NO ALLERGY ASSESSMENT' Relation #1 'NO ALLERGY ASSESSMENT AND (RADIOLOGY ORDER OR PHAR...'
51 ; Called from EL28+5^OCXOZ0I, and EL135+5^OCXOZ0I, and EL136+5^OCXOZ0I, and EL137+5^OCXOZ0I.
52 ;
53 Q:$G(OCXOERR)
54 ;
55 ; Local Extrinsic Functions
56 ; MCE135( ----------> Verify Event/Element: 'DIET ORDER'
57 ; MCE136( ----------> Verify Event/Element: 'NO ALLERGY ASSESSMENT'
58 ; MCE137( ----------> Verify Event/Element: 'PHARMACY ORDER'
59 ; MCE28( -----------> Verify Event/Element: 'RADIOLOGY ORDER'
60 ;
61 Q:$G(^OCXS(860.2,70,"INACT"))
62 ;
63 I $$MCE136 D
64 .I $$MCE28 D R70R1B
65 .I $$MCE137 D R70R1B
66 .I $$MCE135 D R70R1B
67 Q
68 ;
69R70R1B ; Send Order Check, Notication messages and/or Execute code for Rule #70 'NO ALLERGY ASSESSMENT' Relation #1 'NO ALLERGY ASSESSMENT AND (RADIOLOGY ORDER OR PHAR...'
70 ; Called from R70R1A+14.
71 ;
72 Q:$G(OCXOERR)
73 ;
74 ; Local Extrinsic Functions
75 ; NEWRULE( ---------> NEW RULE MESSAGE
76 ;
77 Q:$D(OCXRULE("R70R1B"))
78 ;
79 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
80 I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^32^^Patient has no allergy assessment." I 1
81 E S OCXCMSG="Patient has no allergy assessment."
82 S OCXNMSG=""
83 ;
84 ;
85 ; Run Execute Code
86 ;
87 Q:'$$NEWRULE(DFN,$J,39,1,999,"Patient has no allergy assessment.")
88 Q:$G(OCXOERR)
89 ;
90 ; Send Order Check Message
91 ;
92 S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
93 Q
94 ;
95CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
96 ;
97 N CKSUM,PTR,ASC S CKSUM=0
98 S STR=$TR(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
99 F PTR=$L(STR):-1:1 S ASC=$A(STR,PTR)-42 I (ASC>0),(ASC<51) S CKSUM=CKSUM*2+ASC
100 Q +CKSUM
101 ;
102GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
103 ;
104 N OCXE,VAL,PC S VAL=""
105 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)
106 Q VAL
107 ;
108LABTHRSR(OCXDUZ,OCXLAB,OCXSPEC,OCXRSLT,OCXPTDFN) ; Compiler Function: LAB THRESHOLD EXCEEDED RESULTS
109 ;
110 Q:'$G(OCXLAB)!'$G(OCXSPEC)!'$G(OCXRSLT) 0
111 ;
112 N OCXX,OCXPENT,OCXERR,OCXLABSP,OCXPVAL,OCXOP,OCXEXCD
113 S OCXEXCD=0,OCXLABSP=OCXLAB_";"_OCXSPEC
114 F OCXOP="<",">" D
115 .D ENVAL^XPAR(.OCXX,"ORB LAB "_OCXOP_" THRESHOLD",OCXLABSP,.OCXERR)
116 .Q:+$G(ORERR)'=0
117 .Q:+$G(OCXX)=0
118 .S OCXPENT="" F S OCXPENT=$O(OCXX(OCXPENT)) Q:'OCXPENT D
119 ..S OCXPVAL=OCXX(OCXPENT,OCXLABSP)
120 ..I $L(OCXPVAL) D
121 ...I $P(OCXPENT,";",2)="VA(200,",@(OCXRSLT_OCXOP_OCXPVAL) D
122 ....I +$$PPLINK^ORQPTQ1(+OCXPENT,OCXPTDFN) D
123 .....S OCXDUZ(+OCXPENT)="",OCXEXCD=1
124 Q OCXEXCD
125 ;
126MCE135() ; Verify Event/Element: DIET ORDER
127 ;
128 ; OCXDF(37) -> PATIENT IEN data field
129 ;
130 N OCXRES
131 S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(135,37)=OCXDF(37)
132 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),135)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),135))
133 Q 0
134 ;
135MCE136() ; Verify Event/Element: NO ALLERGY ASSESSMENT
136 ;
137 ; OCXDF(37) -> PATIENT IEN data field
138 ;
139 N OCXRES
140 S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(136,37)=OCXDF(37)
141 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),136)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),136))
142 Q 0
143 ;
144MCE137() ; Verify Event/Element: PHARMACY ORDER
145 ;
146 ; OCXDF(37) -> PATIENT IEN data field
147 ;
148 N OCXRES
149 S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(137,37)=OCXDF(37)
150 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),137)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),137))
151 Q 0
152 ;
153MCE28() ; Verify Event/Element: RADIOLOGY ORDER
154 ;
155 ; OCXDF(37) -> PATIENT IEN data field
156 ;
157 N OCXRES
158 S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(28,37)=OCXDF(37)
159 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),28)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),28))
160 Q 0
161 ;
162NEWRULE(OCXDFN,OCXORD,OCXRUL,OCXREL,OCXNOTF,OCXMESS) ; Has this rule already been triggered for this order number
163 ;
164 ;
165 Q:'$G(OCXDFN) 0 Q:'$G(OCXRUL) 0
166 Q:'$G(OCXREL) 0 Q:'$G(OCXNOTF) 0 Q:'$L($G(OCXMESS)) 0
167 S OCXORD=+$G(OCXORD),OCXDFN=+OCXDFN
168 ;
169 N OCXNDX,OCXDATA,OCXDFI,OCXELE,OCXGR,OCXTIME,OCXCKSUM,OCXTSP,OCXTSPL
170 ;
171 S OCXTIME=(+$H)
172 S OCXCKSUM=$$CKSUM(OCXMESS)
173 ;
174 S OCXTSP=($H*86400)+$P($H,",",2)
175 S OCXTSPL=($G(^OCXD(860.7,"AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM))+$G(OCXTSPI,300))
176 ;
177 Q:(OCXTSPL>OCXTSP) 0
178 ;
179 K OCXDATA
180 S OCXDATA(OCXDFN,0)=OCXDFN
181 S OCXDATA("B",OCXDFN,OCXDFN)=""
182 S OCXDATA("AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM)=OCXTSP
183 ;
184 S OCXGR="^OCXD(860.7"
185 D SETAP(OCXGR_")",0,.OCXDATA,OCXDFN)
186 ;
187 K OCXDATA
188 S OCXDATA(OCXRUL,0)=OCXRUL_U_(OCXTIME)_U_(+OCXORD)
189 S OCXDATA(OCXRUL,"M")=OCXMESS
190 S OCXDATA("B",OCXRUL,OCXRUL)=""
191 S OCXGR=OCXGR_","_OCXDFN_",1"
192 D SETAP(OCXGR_")","860.71P",.OCXDATA,OCXRUL)
193 ;
194 K OCXDATA
195 S OCXDATA(OCXREL,0)=OCXREL
196 S OCXDATA("B",OCXREL,OCXREL)=""
197 S OCXGR=OCXGR_","_OCXRUL_",1"
198 D SETAP(OCXGR_")","860.712",.OCXDATA,OCXREL)
199 ;
200 S OCXELE=0 F S OCXELE=$O(^OCXS(860.2,OCXRUL,"C","C",OCXELE)) Q:'OCXELE D
201 .;
202 .N OCXGR1
203 .S OCXGR1=OCXGR_","_OCXREL_",1"
204 .K OCXDATA
205 .S OCXDATA(OCXELE,0)=OCXELE
206 .S OCXDATA(OCXELE,"TIME")=OCXTIME
207 .S OCXDATA(OCXELE,"LOG")=$G(OCXOLOG)
208 .S OCXDATA("B",OCXELE,OCXELE)=""
209 .K ^OCXD(860.7,OCXDFN,1,OCXRUL,1,OCXREL,1,OCXELE)
210 .D SETAP(OCXGR1_")","860.7122P",.OCXDATA,OCXELE)
211 .;
212 .S OCXDFI=0 F S OCXDFI=$O(^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)) Q:'OCXDFI D
213 ..N OCXGR2
214 ..S OCXGR2=OCXGR1_","_OCXELE_",1"
215 ..K OCXDATA
216 ..S OCXDATA(OCXDFI,0)=OCXDFI
217 ..S OCXDATA(OCXDFI,"VAL")=^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)
218 ..S OCXDATA("B",OCXDFI,OCXDFI)=""
219 ..D SETAP(OCXGR2_")","860.71223P",.OCXDATA,OCXDFI)
220 ;
221 Q 1
222 ;
223SETAP(ROOT,DD,DATA,DA) ; Set Rule Event data
224 M @ROOT=DATA
225 I +$G(DD) S @ROOT@(0)="^"_($G(DD))_"^"_($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
226 I '$G(DD) S $P(@ROOT@(0),U,3,4)=($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
227 ;
228 Q
229 ;
230 ;
Note: See TracBrowser for help on using the repository browser.