source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0U.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

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