source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0T.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: 8.4 KB
Line 
1OCXOZ0T ;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 ;
13R48R2B ; Send Order Check, Notication messages and/or Execute code for Rule #48 'SITE FLAGGED ORDER' Relation #2 'NEW SITE FLAGGED ORDER AND OUTPATIENT'
14 ; Called from R48R2A+12^OCXOZ0S.
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("R48R2B"))
24 ;
25 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
26 S OCXCMSG=""
27 S OCXNMSG="["_$$GETDATA(DFN,"58^128",147)_"] Order placed: "_$$GETDATA(DFN,"58^128",96)_" "_$$INT2DT($$GETDATA(DFN,"58^128",9),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("R48R2B")=""
42 I $$NEWRULE(DFN,OCXNUM,48,2,61,OCXNMSG) D I 1
43 .D:($G(OCXTRACE)<5) EN^ORB3(61,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
44 Q
45 ;
46R49R1A ; Verify all Event/Elements of Rule #49 'SITE FLAGGED RESULT' Relation #1 'INPATIENT AND (SITE FLAGGED LAB RESULT OR SITE FLA...'
47 ; Called from EL127+6^OCXOZ0H, and EL59+5^OCXOZ0H, and EL102+5^OCXOZ0H, and EL109+5^OCXOZ0H.
48 ;
49 Q:$G(OCXOERR)
50 ;
51 ; Local Extrinsic Functions
52 ; MCE102( ----------> Verify Event/Element: 'SITE FLAGGED FINAL IMAGING RESULT'
53 ; MCE109( ----------> Verify Event/Element: 'SITE FLAGGED FINAL CONSULT RESULT'
54 ; MCE127( ----------> Verify Event/Element: 'INPATIENT'
55 ; MCE59( -----------> Verify Event/Element: 'SITE FLAGGED FINAL LAB RESULT'
56 ;
57 Q:$G(^OCXS(860.2,49,"INACT"))
58 ;
59 I $$MCE127 D
60 .I $$MCE59 D R49R1B
61 .I $$MCE102 D R49R1B
62 .I $$MCE109 D R49R1B
63 Q
64 ;
65R49R1B ; Send Order Check, Notication messages and/or Execute code for Rule #49 'SITE FLAGGED RESULT' Relation #1 'INPATIENT AND (SITE FLAGGED LAB RESULT OR SITE FLA...'
66 ; Called from R49R1A+14.
67 ;
68 Q:$G(OCXOERR)
69 ;
70 ; Local Extrinsic Functions
71 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
72 ; INT2DT( ----------> CONVERT DATE FROM OCX FORMAT TO READABLE FORMAT
73 ; NEWRULE( ---------> NEW RULE MESSAGE
74 ;
75 Q:$D(OCXRULE("R49R1B"))
76 ;
77 N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
78 S OCXCMSG=""
79 S OCXNMSG="["_$$GETDATA(DFN,"59^102^109^127",147)_"] Result available: "_$$GETDATA(DFN,"59^102^109^127",96)_" "_$$INT2DT($$GETDATA(DFN,"59^102^109^127",9),0)_" "
80 ;
81 Q:$G(OCXOERR)
82 ;
83 ; Send Notification
84 ;
85 S (OCXDUZ,OCXDATA)="",OCXNUM=0
86 I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
87 .S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
88 .S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
89 I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
90 .I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
91 .S OCXNUM=+$P(OCXORD,U,2)
92 S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
93 S OCXRULE("R49R1B")=""
94 I $$NEWRULE(DFN,OCXNUM,49,1,32,OCXNMSG) D I 1
95 .D:($G(OCXTRACE)<5) EN^ORB3(32,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
96 Q
97 ;
98CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
99 ;
100 N CKSUM,PTR,ASC S CKSUM=0
101 S STR=$TR(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
102 F PTR=$L(STR):-1:1 S ASC=$A(STR,PTR)-42 I (ASC>0),(ASC<51) S CKSUM=CKSUM*2+ASC
103 Q +CKSUM
104 ;
105GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
106 ;
107 N OCXE,VAL,PC S VAL=""
108 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)
109 Q VAL
110 ;
111INT2DT(OCXDT,OCXF) ; This Local Extrinsic Function converts an OCX internal format
112 ; date into an Externl Format (Human Readable) date. 'OCXF=SHORT FORMAT OCXF=LONG FORMAT
113 ;
114 Q:'$L($G(OCXDT)) "" S OCXF=+$G(OCXF)
115 N OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXCYR
116 S (OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXAP)=""
117 S OCXSEC=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
118 S OCXMIN=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
119 S OCXHR=$E(OCXDT#24+100,2,3),OCXDT=OCXDT\24
120 S OCXCYR=($H\1461)*4+1841+(($H#1461)\365)
121 S OCXYR=(OCXDT\1461)*4+1841,OCXDT=OCXDT#1461
122 S OCXLPYR=(OCXDT\365),OCXDT=OCXDT-(OCXLPYR*365),OCXYR=OCXYR+OCXLPYR
123 S OCXCNT="031^059^090^120^151^181^212^243^273^304^334^365"
124 S:(OCXLPYR=3) OCXCNT="031^060^091^121^152^182^213^244^274^305^335^366"
125 F OCXMON=1:1:12 Q:(OCXDT<$P(OCXCNT,U,OCXMON))
126 S OCXDAY=OCXDT-$P(OCXCNT,U,OCXMON-1)+1
127 I OCXF S OCXMON=$P("January^February^March^April^May^June^July^August^September^October^November^December",U,OCXMON)
128 E S OCXMON=$E(OCXMON+100,2,3)
129 S OCXAP=$S('OCXHR:"Midnight",(OCXHR=12):"Noon",(OCXHR<12):"AM",1:"PM")
130 I OCXF S OCXHR=OCXHR#12 S:'OCXHR OCXHR=12
131 Q:'OCXF $E(OCXMON+100,2,3)_"/"_$E(OCXDAY+100,2,3)_$S((OCXCYR=OCXYR):" "_OCXHR_":"_OCXMIN,1:"/"_$E(OCXYR,3,4))
132 Q:(OCXHR+OCXMIN+OCXSEC) OCXMON_" "_OCXDAY_","_OCXYR_" at "_OCXHR_":"_OCXMIN_"."_OCXSEC_" "_OCXAP
133 Q OCXMON_" "_OCXDAY_","_OCXYR
134 ;
135MCE102() ; Verify Event/Element: SITE FLAGGED FINAL IMAGING RESULT
136 ;
137 ;
138 N OCXRES
139 I $L(OCXDF(37)) S OCXRES(102,37)=OCXDF(37)
140 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),102)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),102))
141 Q 0
142 ;
143MCE109() ; Verify Event/Element: SITE FLAGGED FINAL CONSULT RESULT
144 ;
145 ;
146 N OCXRES
147 I $L(OCXDF(37)) S OCXRES(109,37)=OCXDF(37)
148 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),109)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),109))
149 Q 0
150 ;
151MCE127() ; Verify Event/Element: INPATIENT
152 ;
153 ;
154 N OCXRES
155 I $L(OCXDF(37)) S OCXRES(127,37)=OCXDF(37)
156 Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),127)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),127))
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.