source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0L.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

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