[623] | 1 | OCXOZ10 ;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 | ;
|
---|
| 13 | R66R1B ; Send Order Check, Notication messages and/or Execute code for Rule #66 'LAB RESULTS' Relation #1 'HL7 LAB RESULTS'
|
---|
| 14 | ; Called from R66R1A+10^OCXOZ0Z.
|
---|
| 15 | ;
|
---|
| 16 | Q:$G(OCXOERR)
|
---|
| 17 | ;
|
---|
| 18 | ; Local Extrinsic Functions
|
---|
| 19 | ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
|
---|
| 20 | ; NEWRULE( ---------> NEW RULE MESSAGE
|
---|
| 21 | ;
|
---|
| 22 | Q:$D(OCXRULE("R66R1B"))
|
---|
| 23 | ;
|
---|
| 24 | N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
|
---|
| 25 | S OCXCMSG=""
|
---|
| 26 | S OCXNMSG="Labs resulted - ["_$$GETDATA(DFN,"5^",96)_"]"
|
---|
| 27 | ;
|
---|
| 28 | Q:$G(OCXOERR)
|
---|
| 29 | ;
|
---|
| 30 | ; Send Notification
|
---|
| 31 | ;
|
---|
| 32 | S (OCXDUZ,OCXDATA)="",OCXNUM=0
|
---|
| 33 | I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
|
---|
| 34 | .S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
|
---|
| 35 | .S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
|
---|
| 36 | I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
|
---|
| 37 | .I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
|
---|
| 38 | .S OCXNUM=+$P(OCXORD,U,2)
|
---|
| 39 | S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
|
---|
| 40 | S OCXRULE("R66R1B")=""
|
---|
| 41 | I $$NEWRULE(DFN,OCXNUM,66,1,3,OCXNMSG) D I 1
|
---|
| 42 | .D:($G(OCXTRACE)<5) EN^ORB3(3,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
|
---|
| 43 | Q
|
---|
| 44 | ;
|
---|
| 45 | R67R1A ; Verify all Event/Elements of Rule #67 'GLUCOPHAGE - LAB RESULTS' Relation #1 'GLUCOPHAGE ORDER AND GLUCOPHAGE CREATININE > 1.5'
|
---|
| 46 | ; Called from EL86+5^OCXOZ0I, and EL111+5^OCXOZ0I.
|
---|
| 47 | ;
|
---|
| 48 | Q:$G(OCXOERR)
|
---|
| 49 | ;
|
---|
| 50 | ; Local Extrinsic Functions
|
---|
| 51 | ; MCE111( ----------> Verify Event/Element: 'GLUCOPHAGE CREATININE > 1.5'
|
---|
| 52 | ; MCE86( -----------> Verify Event/Element: 'GLUCOPHAGE ORDER'
|
---|
| 53 | ;
|
---|
| 54 | Q:$G(^OCXS(860.2,67,"INACT"))
|
---|
| 55 | ;
|
---|
| 56 | I $$MCE86 D
|
---|
| 57 | .I $$MCE111 D R67R1B
|
---|
| 58 | Q
|
---|
| 59 | ;
|
---|
| 60 | R67R1B ; Send Order Check, Notication messages and/or Execute code for Rule #67 'GLUCOPHAGE - LAB RESULTS' Relation #1 'GLUCOPHAGE ORDER AND GLUCOPHAGE CREATININE > 1.5'
|
---|
| 61 | ; Called from R67R1A+12.
|
---|
| 62 | ;
|
---|
| 63 | Q:$G(OCXOERR)
|
---|
| 64 | ;
|
---|
| 65 | ; Local Extrinsic Functions
|
---|
| 66 | ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
|
---|
| 67 | ;
|
---|
| 68 | Q:$D(OCXRULE("R67R1B"))
|
---|
| 69 | ;
|
---|
| 70 | N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
|
---|
| 71 | I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^28^^Metformin - Creatinine results: "_$$GETDATA(DFN,"86^111",125) I 1
|
---|
| 72 | E S OCXCMSG="Metformin - Creatinine results: "_$$GETDATA(DFN,"86^111",125)
|
---|
| 73 | S OCXNMSG=""
|
---|
| 74 | ;
|
---|
| 75 | Q:$G(OCXOERR)
|
---|
| 76 | ;
|
---|
| 77 | ; Send Order Check Message
|
---|
| 78 | ;
|
---|
| 79 | S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
|
---|
| 80 | Q
|
---|
| 81 | ;
|
---|
| 82 | R67R2A ; Verify all Event/Elements of Rule #67 'GLUCOPHAGE - LAB RESULTS' Relation #2 'GLUCOPHAGE ORDER AND NO GLUCOPHAGE CREATININE'
|
---|
| 83 | ; Called from EL86+6^OCXOZ0I, and EL112+5^OCXOZ0I.
|
---|
| 84 | ;
|
---|
| 85 | Q:$G(OCXOERR)
|
---|
| 86 | ;
|
---|
| 87 | ; Local Extrinsic Functions
|
---|
| 88 | ; MCE112( ----------> Verify Event/Element: 'NO GLUCOPHAGE CREATININE'
|
---|
| 89 | ; MCE86( -----------> Verify Event/Element: 'GLUCOPHAGE ORDER'
|
---|
| 90 | ;
|
---|
| 91 | Q:$G(^OCXS(860.2,67,"INACT"))
|
---|
| 92 | ;
|
---|
| 93 | I $$MCE86 D
|
---|
| 94 | .I $$MCE112 D R67R2B
|
---|
| 95 | Q
|
---|
| 96 | ;
|
---|
| 97 | R67R2B ; Send Order Check, Notication messages and/or Execute code for Rule #67 'GLUCOPHAGE - LAB RESULTS' Relation #2 'GLUCOPHAGE ORDER AND NO GLUCOPHAGE CREATININE'
|
---|
| 98 | ; Called from R67R2A+12.
|
---|
| 99 | ;
|
---|
| 100 | Q:$G(OCXOERR)
|
---|
| 101 | ;
|
---|
| 102 | ; Local Extrinsic Functions
|
---|
| 103 | ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
|
---|
| 104 | ;
|
---|
| 105 | Q:$D(OCXRULE("R67R2B"))
|
---|
| 106 | ;
|
---|
| 107 | N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
|
---|
| 108 | I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^28^^Metformin - no serum creatinine within past "_$$GETDATA(DFN,"86^112",127)_" days." I 1
|
---|
| 109 | E S OCXCMSG="Metformin - no serum creatinine within past "_$$GETDATA(DFN,"86^112",127)_" days."
|
---|
| 110 | S OCXNMSG=""
|
---|
| 111 | ;
|
---|
| 112 | Q:$G(OCXOERR)
|
---|
| 113 | ;
|
---|
| 114 | ; Send Order Check Message
|
---|
| 115 | ;
|
---|
| 116 | S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
|
---|
| 117 | Q
|
---|
| 118 | ;
|
---|
| 119 | CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
|
---|
| 120 | ;
|
---|
| 121 | N CKSUM,PTR,ASC S CKSUM=0
|
---|
| 122 | S STR=$TR(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
---|
| 123 | F PTR=$L(STR):-1:1 S ASC=$A(STR,PTR)-42 I (ASC>0),(ASC<51) S CKSUM=CKSUM*2+ASC
|
---|
| 124 | Q +CKSUM
|
---|
| 125 | ;
|
---|
| 126 | GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
|
---|
| 127 | ;
|
---|
| 128 | N OCXE,VAL,PC S VAL=""
|
---|
| 129 | 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)
|
---|
| 130 | Q VAL
|
---|
| 131 | ;
|
---|
| 132 | MCE111() ; Verify Event/Element: GLUCOPHAGE CREATININE > 1.5
|
---|
| 133 | ;
|
---|
| 134 | ; OCXDF(127) -> RECENT GLUCOPHAGE CREATININE DAYS data field
|
---|
| 135 | ; OCXDF(125) -> RECENT GLUCOPHAGE CREATININE TEXT data field
|
---|
| 136 | ; OCXDF(126) -> RECENT GLUCOPHAGE CREATININE RESULT data field
|
---|
| 137 | ; OCXDF(37) -> PATIENT IEN data field
|
---|
| 138 | ;
|
---|
| 139 | N OCXRES
|
---|
| 140 | S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(111,37)=OCXDF(37)
|
---|
| 141 | Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),111)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),111))
|
---|
| 142 | S OCXRES(111)=0,OCXDF(126)=$P($$GLCREAT^ORKPS(OCXDF(37)),"^",3) I $L(OCXDF(126)) S OCXRES(111,126)=OCXDF(126) I (OCXDF(126)>1.5)
|
---|
| 143 | E Q 0
|
---|
| 144 | S OCXDF(125)=$P($$GLCREAT^ORKPS(OCXDF(37)),"^",2),OCXDF(127)=$P($$GCDAYS^ORKPS(OCXDF(37)),"^",1),OCXRES(111)=11 M ^TMP("OCXCHK",$J,OCXDF(37),111)=OCXRES(111)
|
---|
| 145 | Q +OCXRES(111)
|
---|
| 146 | ;
|
---|
| 147 | MCE112() ; Verify Event/Element: NO GLUCOPHAGE CREATININE
|
---|
| 148 | ;
|
---|
| 149 | ; OCXDF(127) -> RECENT GLUCOPHAGE CREATININE DAYS data field
|
---|
| 150 | ; OCXDF(125) -> RECENT GLUCOPHAGE CREATININE TEXT data field
|
---|
| 151 | ; OCXDF(124) -> RECENT GLUCOPHAGE CREATININE FLAG data field
|
---|
| 152 | ; OCXDF(37) -> PATIENT IEN data field
|
---|
| 153 | ;
|
---|
| 154 | N OCXRES
|
---|
| 155 | S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(112,37)=OCXDF(37)
|
---|
| 156 | Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),112)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),112))
|
---|
| 157 | S OCXRES(112)=0,OCXDF(124)=$P($$GLCREAT^ORKPS(OCXDF(37)),"^",1) I $L(OCXDF(124)) S OCXRES(112,124)=OCXDF(124) I '(OCXDF(124))
|
---|
| 158 | E Q 0
|
---|
| 159 | S OCXDF(125)=$P($$GLCREAT^ORKPS(OCXDF(37)),"^",2),OCXDF(127)=$P($$GCDAYS^ORKPS(OCXDF(37)),"^",1),OCXRES(112)=11 M ^TMP("OCXCHK",$J,OCXDF(37),112)=OCXRES(112)
|
---|
| 160 | Q +OCXRES(112)
|
---|
| 161 | ;
|
---|
| 162 | MCE86() ; Verify Event/Element: GLUCOPHAGE ORDER
|
---|
| 163 | ;
|
---|
| 164 | ; OCXDF(37) -> PATIENT IEN data field
|
---|
| 165 | ;
|
---|
| 166 | N OCXRES
|
---|
| 167 | S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(86,37)=OCXDF(37)
|
---|
| 168 | Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),86)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),86))
|
---|
| 169 | Q 0
|
---|
| 170 | ;
|
---|
| 171 | NEWRULE(OCXDFN,OCXORD,OCXRUL,OCXREL,OCXNOTF,OCXMESS) ; Has this rule already been triggered for this order number
|
---|
| 172 | ;
|
---|
| 173 | ;
|
---|
| 174 | Q:'$G(OCXDFN) 0 Q:'$G(OCXRUL) 0
|
---|
| 175 | Q:'$G(OCXREL) 0 Q:'$G(OCXNOTF) 0 Q:'$L($G(OCXMESS)) 0
|
---|
| 176 | S OCXORD=+$G(OCXORD),OCXDFN=+OCXDFN
|
---|
| 177 | ;
|
---|
| 178 | N OCXNDX,OCXDATA,OCXDFI,OCXELE,OCXGR,OCXTIME,OCXCKSUM,OCXTSP,OCXTSPL
|
---|
| 179 | ;
|
---|
| 180 | S OCXTIME=(+$H)
|
---|
| 181 | S OCXCKSUM=$$CKSUM(OCXMESS)
|
---|
| 182 | ;
|
---|
| 183 | S OCXTSP=($H*86400)+$P($H,",",2)
|
---|
| 184 | S OCXTSPL=($G(^OCXD(860.7,"AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM))+$G(OCXTSPI,300))
|
---|
| 185 | ;
|
---|
| 186 | Q:(OCXTSPL>OCXTSP) 0
|
---|
| 187 | ;
|
---|
| 188 | K OCXDATA
|
---|
| 189 | S OCXDATA(OCXDFN,0)=OCXDFN
|
---|
| 190 | S OCXDATA("B",OCXDFN,OCXDFN)=""
|
---|
| 191 | S OCXDATA("AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM)=OCXTSP
|
---|
| 192 | ;
|
---|
| 193 | S OCXGR="^OCXD(860.7"
|
---|
| 194 | D SETAP(OCXGR_")",0,.OCXDATA,OCXDFN)
|
---|
| 195 | ;
|
---|
| 196 | K OCXDATA
|
---|
| 197 | S OCXDATA(OCXRUL,0)=OCXRUL_U_(OCXTIME)_U_(+OCXORD)
|
---|
| 198 | S OCXDATA(OCXRUL,"M")=OCXMESS
|
---|
| 199 | S OCXDATA("B",OCXRUL,OCXRUL)=""
|
---|
| 200 | S OCXGR=OCXGR_","_OCXDFN_",1"
|
---|
| 201 | D SETAP(OCXGR_")","860.71P",.OCXDATA,OCXRUL)
|
---|
| 202 | ;
|
---|
| 203 | K OCXDATA
|
---|
| 204 | S OCXDATA(OCXREL,0)=OCXREL
|
---|
| 205 | S OCXDATA("B",OCXREL,OCXREL)=""
|
---|
| 206 | S OCXGR=OCXGR_","_OCXRUL_",1"
|
---|
| 207 | D SETAP(OCXGR_")","860.712",.OCXDATA,OCXREL)
|
---|
| 208 | ;
|
---|
| 209 | S OCXELE=0 F S OCXELE=$O(^OCXS(860.2,OCXRUL,"C","C",OCXELE)) Q:'OCXELE D
|
---|
| 210 | .;
|
---|
| 211 | .N OCXGR1
|
---|
| 212 | .S OCXGR1=OCXGR_","_OCXREL_",1"
|
---|
| 213 | .K OCXDATA
|
---|
| 214 | .S OCXDATA(OCXELE,0)=OCXELE
|
---|
| 215 | .S OCXDATA(OCXELE,"TIME")=OCXTIME
|
---|
| 216 | .S OCXDATA(OCXELE,"LOG")=$G(OCXOLOG)
|
---|
| 217 | .S OCXDATA("B",OCXELE,OCXELE)=""
|
---|
| 218 | .K ^OCXD(860.7,OCXDFN,1,OCXRUL,1,OCXREL,1,OCXELE)
|
---|
| 219 | .D SETAP(OCXGR1_")","860.7122P",.OCXDATA,OCXELE)
|
---|
| 220 | .;
|
---|
| 221 | .S OCXDFI=0 F S OCXDFI=$O(^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)) Q:'OCXDFI D
|
---|
| 222 | ..N OCXGR2
|
---|
| 223 | ..S OCXGR2=OCXGR1_","_OCXELE_",1"
|
---|
| 224 | ..K OCXDATA
|
---|
| 225 | ..S OCXDATA(OCXDFI,0)=OCXDFI
|
---|
| 226 | ..S OCXDATA(OCXDFI,"VAL")=^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)
|
---|
| 227 | ..S OCXDATA("B",OCXDFI,OCXDFI)=""
|
---|
| 228 | ..D SETAP(OCXGR2_")","860.71223P",.OCXDATA,OCXDFI)
|
---|
| 229 | ;
|
---|
| 230 | Q 1
|
---|
| 231 | ;
|
---|
| 232 | SETAP(ROOT,DD,DATA,DA) ; Set Rule Event data
|
---|
| 233 | M @ROOT=DATA
|
---|
| 234 | I +$G(DD) S @ROOT@(0)="^"_($G(DD))_"^"_($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
|
---|
| 235 | I '$G(DD) S $P(@ROOT@(0),U,3,4)=($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
|
---|
| 236 | ;
|
---|
| 237 | Q
|
---|
| 238 | ;
|
---|
| 239 | ;
|
---|