OCXOZ10 ;SLC/RJS,CLA - Order Check Scan ;JAN 28,2014 at 03:37
;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,221,243**;Dec 17,1997;Build 242
;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
;
; ***************************************************************
; ** Warning: This routine is automatically generated by the **
; ** Rule Compiler (^OCXOCMP) and ANY changes to this routine **
; ** will be lost the next time the rule compiler executes. **
; ***************************************************************
;
Q
;
R62R1A ; Verify all Event/Elements of Rule #62 'FOOD/DRUG INTERACTION' Relation #1 'INPATIENT FOOD DRUG REACTION'
; Called from EL84+5^OCXOZ0H.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE84( -----------> Verify Event/Element: 'INPATIENT FOOD-DRUG REACTION'
;
Q:$G(^OCXS(860.2,62,"INACT"))
;
I $$MCE84 D R62R1B
Q
;
R62R1B ; Send Order Check, Notication messages and/or Execute code for Rule #62 'FOOD/DRUG INTERACTION' Relation #1 'INPATIENT FOOD DRUG REACTION'
; Called from R62R1A+10.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
; NEWRULE( ---------> NEW RULE MESSAGE
;
Q:$D(OCXRULE("R62R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
S OCXCMSG=""
S OCXNMSG="["_$$GETDATA(DFN,"84^",147)_"] "_$$GETDATA(DFN,"84^",82)_" ordered - adjust diet accordingly."
;
Q:$G(OCXOERR)
;
; Send Notification
;
S (OCXDUZ,OCXDATA)="",OCXNUM=0
I ($G(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY") D
.S OCXDATA=$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",2))_"|"_$G(^TMP("OCXSWAP",$J,"OCXODATA","ORC",3))
.S OCXDATA=$TR(OCXDATA,"^","@"),OCXNUM=+OCXDATA
I ($G(OCXOSRC)="CPRS ORDER PROTOCOL") D
.I $P($G(OCXORD),U,3) S OCXDUZ(+$P(OCXORD,U,3))=""
.S OCXNUM=+$P(OCXORD,U,2)
S:($G(OCXOSRC)="CPRS ORDER PRESCAN") OCXNUM=+$P(OCXPSD,"|",5)
S OCXRULE("R62R1B")=""
I $$NEWRULE(DFN,OCXNUM,62,1,55,OCXNMSG) D I 1
.D:($G(OCXTRACE)<5) EN^ORB3(55,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
Q
;
R63R1A ; Verify all Event/Elements of Rule #63 'GLUCOPHAGE - CONTRAST MEDIA' Relation #1 'IF PROC USES NON-BARIUM MEDIA AND PATIENT TAKING G...'
; Called from EL91+5^OCXOZ0H, and EL106+5^OCXOZ0H.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE106( ----------> Verify Event/Element: 'RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA'
; MCE91( -----------> Verify Event/Element: 'PATIENT WITH GLUCOPHAGE MED'
;
Q:$G(^OCXS(860.2,63,"INACT"))
;
I $$MCE106 D
.I $$MCE91 D R63R1B
Q
;
R63R1B ; Send Order Check, Notication messages and/or Execute code for Rule #63 'GLUCOPHAGE - CONTRAST MEDIA' Relation #1 'IF PROC USES NON-BARIUM MEDIA AND PATIENT TAKING G...'
; Called from R63R1A+12.
;
Q:$G(OCXOERR)
;
Q:$D(OCXRULE("R63R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^23^^Procedure uses intravenous contrast media and patient is taking metformin." I 1
E S OCXCMSG="Procedure uses intravenous contrast media and patient is taking metformin."
S OCXNMSG=""
;
Q:$G(OCXOERR)
;
; Send Order Check Message
;
S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
Q
;
R65R1A ; Verify all Event/Elements of Rule #65 'POLYPHARMACY' Relation #1 'POLYPHARMACY'
; Called from EL95+5^OCXOZ0H.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE95( -----------> Verify Event/Element: 'POLYPHARMACY'
;
Q:$G(^OCXS(860.2,65,"INACT"))
;
I $$MCE95 D R65R1B
Q
;
R65R1B ; Send Order Check, Notication messages and/or Execute code for Rule #65 'POLYPHARMACY' Relation #1 'POLYPHARMACY'
; Called from R65R1A+10.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
;
Q:$D(OCXRULE("R65R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^26^^Potential polypharmacy - patient currently receiving "_$$GETDATA(DFN,"95^",109)_" medications." I 1
E S OCXCMSG="Potential polypharmacy - patient currently receiving "_$$GETDATA(DFN,"95^",109)_" medications."
S OCXNMSG=""
;
Q:$G(OCXOERR)
;
; Send Order Check Message
;
S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
Q
;
R66R1A ; Verify all Event/Elements of Rule #66 'LAB RESULTS' Relation #1 'HL7 LAB RESULTS'
; Called from EL5+6^OCXOZ0G.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE5( ------------> Verify Event/Element: 'HL7 FINAL LAB RESULT'
;
Q:$G(^OCXS(860.2,66,"INACT"))
;
I $$MCE5 D R66R1B^OCXOZ11
Q
;
CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
;
N CKSUM,PTR,ASC S CKSUM=0
S STR=$TR(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
F PTR=$L(STR):-1:1 S ASC=$A(STR,PTR)-42 I (ASC>0),(ASC<51) S CKSUM=CKSUM*2+ASC
Q +CKSUM
;
GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
;
N OCXE,VAL,PC S VAL=""
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)
Q VAL
;
MCE106() ; Verify Event/Element: RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA
;
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(106,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),106)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),106))
Q 0
;
MCE5() ; Verify Event/Element: HL7 FINAL LAB RESULT
;
;
N OCXRES
I $L(OCXDF(37)) S OCXRES(5,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),5)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),5))
Q 0
;
MCE84() ; Verify Event/Element: INPATIENT FOOD-DRUG REACTION
;
;
N OCXRES
I $L(OCXDF(37)) S OCXRES(84,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),84)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),84))
Q 0
;
MCE91() ; Verify Event/Element: PATIENT WITH GLUCOPHAGE MED
;
; OCXDF(103) -> PATIENT CURRENTLY ON GLUCOPHAGE data field
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(91,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),91)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),91))
S OCXRES(91)=0,OCXDF(103)=$P($$TAKEMED^ORKPS(OCXDF(37),"^GLUCOPHAGE^METFORMIN^AVANDAMET^METAGLIP"),"^",1) I $L(OCXDF(103)) S OCXRES(91,103)=OCXDF(103) I (OCXDF(103))
E Q 0
S OCXRES(91)=11 M ^TMP("OCXCHK",$J,OCXDF(37),91)=OCXRES(91)
Q +OCXRES(91)
;
MCE95() ; Verify Event/Element: POLYPHARMACY
;
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(95,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),95)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),95))
Q 0
;
NEWRULE(OCXDFN,OCXORD,OCXRUL,OCXREL,OCXNOTF,OCXMESS) ; Has this rule already been triggered for this order number
;
;
Q:'$G(OCXDFN) 0 Q:'$G(OCXRUL) 0
Q:'$G(OCXREL) 0 Q:'$G(OCXNOTF) 0 Q:'$L($G(OCXMESS)) 0
S OCXORD=+$G(OCXORD),OCXDFN=+OCXDFN
;
N OCXNDX,OCXDATA,OCXDFI,OCXELE,OCXGR,OCXTIME,OCXCKSUM,OCXTSP,OCXTSPL
;
S OCXTIME=(+$H)
S OCXCKSUM=$$CKSUM(OCXMESS)
;
S OCXTSP=($H*86400)+$P($H,",",2)
S OCXTSPL=($G(^OCXD(860.7,"AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM))+$G(OCXTSPI,300))
;
Q:(OCXTSPL>OCXTSP) 0
;
K OCXDATA
S OCXDATA(OCXDFN,0)=OCXDFN
S OCXDATA("B",OCXDFN,OCXDFN)=""
S OCXDATA("AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM)=OCXTSP
;
S OCXGR="^OCXD(860.7"
D SETAP(OCXGR_")",0,.OCXDATA,OCXDFN)
;
K OCXDATA
S OCXDATA(OCXRUL,0)=OCXRUL_U_(OCXTIME)_U_(+OCXORD)
S OCXDATA(OCXRUL,"M")=OCXMESS
S OCXDATA("B",OCXRUL,OCXRUL)=""
S OCXGR=OCXGR_","_OCXDFN_",1"
D SETAP(OCXGR_")","860.71P",.OCXDATA,OCXRUL)
;
K OCXDATA
S OCXDATA(OCXREL,0)=OCXREL
S OCXDATA("B",OCXREL,OCXREL)=""
S OCXGR=OCXGR_","_OCXRUL_",1"
D SETAP(OCXGR_")","860.712",.OCXDATA,OCXREL)
;
S OCXELE=0 F S OCXELE=$O(^OCXS(860.2,OCXRUL,"C","C",OCXELE)) Q:'OCXELE D
.;
.N OCXGR1
.S OCXGR1=OCXGR_","_OCXREL_",1"
.K OCXDATA
.S OCXDATA(OCXELE,0)=OCXELE
.S OCXDATA(OCXELE,"TIME")=OCXTIME
.S OCXDATA(OCXELE,"LOG")=$G(OCXOLOG)
.S OCXDATA("B",OCXELE,OCXELE)=""
.K ^OCXD(860.7,OCXDFN,1,OCXRUL,1,OCXREL,1,OCXELE)
.D SETAP(OCXGR1_")","860.7122P",.OCXDATA,OCXELE)
.;
.S OCXDFI=0 F S OCXDFI=$O(^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)) Q:'OCXDFI D
..N OCXGR2
..S OCXGR2=OCXGR1_","_OCXELE_",1"
..K OCXDATA
..S OCXDATA(OCXDFI,0)=OCXDFI
..S OCXDATA(OCXDFI,"VAL")=^TMP("OCXCHK",$J,OCXDFN,OCXELE,OCXDFI)
..S OCXDATA("B",OCXDFI,OCXDFI)=""
..D SETAP(OCXGR2_")","860.71223P",.OCXDATA,OCXDFI)
;
Q 1
;
SETAP(ROOT,DD,DATA,DA) ; Set Rule Event data
M @ROOT=DATA
I +$G(DD) S @ROOT@(0)="^"_($G(DD))_"^"_($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
I '$G(DD) S $P(@ROOT@(0),U,3,4)=($P($G(@ROOT@(0)),U,3)+1)_"^"_$G(DA)
;
Q
;
;
OCXOZ10 ;SLC/RJS,CLA - Order Check Scan ;JAN 28,2014 at 03:37
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,221,243**;Dec 17,1997;Build 242
+2 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
+3 ;
+4 ; ***************************************************************
+5 ; ** Warning: This routine is automatically generated by the **
+6 ; ** Rule Compiler (^OCXOCMP) and ANY changes to this routine **
+7 ; ** will be lost the next time the rule compiler executes. **
+8 ; ***************************************************************
+9 ;
+10 QUIT
+11 ;
R62R1A ; Verify all Event/Elements of Rule #62 'FOOD/DRUG INTERACTION' Relation #1 'INPATIENT FOOD DRUG REACTION'
+1 ; Called from EL84+5^OCXOZ0H.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE84( -----------> Verify Event/Element: 'INPATIENT FOOD-DRUG REACTION'
+7 ;
+8 IF $GET(^OCXS(860.2,62,"INACT"))
QUIT
+9 ;
+10 IF $$MCE84
DO R62R1B
+11 QUIT
+12 ;
R62R1B ; Send Order Check, Notication messages and/or Execute code for Rule #62 'FOOD/DRUG INTERACTION' Relation #1 'INPATIENT FOOD DRUG REACTION'
+1 ; Called from R62R1A+10.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
+7 ; NEWRULE( ---------> NEW RULE MESSAGE
+8 ;
+9 IF $DATA(OCXRULE("R62R1B"))
QUIT
+10 ;
+11 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+12 SET OCXCMSG=""
+13 SET OCXNMSG="["_$$GETDATA(DFN,"84^",147)_"] "_$$GETDATA(DFN,"84^",82)_" ordered - adjust diet accordingly."
+14 ;
+15 IF $GET(OCXOERR)
QUIT
+16 ;
+17 ; Send Notification
+18 ;
+19 SET (OCXDUZ,OCXDATA)=""
SET OCXNUM=0
+20 IF ($GET(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY")
Begin DoDot:1
+21 SET OCXDATA=$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",2))_"|"_$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",3))
+22 SET OCXDATA=$TRANSLATE(OCXDATA,"^","@")
SET OCXNUM=+OCXDATA
End DoDot:1
+23 IF ($GET(OCXOSRC)="CPRS ORDER PROTOCOL")
Begin DoDot:1
+24 IF $PIECE($GET(OCXORD),U,3)
SET OCXDUZ(+$PIECE(OCXORD,U,3))=""
+25 SET OCXNUM=+$PIECE(OCXORD,U,2)
End DoDot:1
+26 IF ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXNUM=+$PIECE(OCXPSD,"|",5)
+27 SET OCXRULE("R62R1B")=""
+28 IF $$NEWRULE(DFN,OCXNUM,62,1,55,OCXNMSG)
Begin DoDot:1
+29 IF ($GET(OCXTRACE)<5)
DO EN^ORB3(55,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
End DoDot:1
IF 1
+30 QUIT
+31 ;
R63R1A ; Verify all Event/Elements of Rule #63 'GLUCOPHAGE - CONTRAST MEDIA' Relation #1 'IF PROC USES NON-BARIUM MEDIA AND PATIENT TAKING G...'
+1 ; Called from EL91+5^OCXOZ0H, and EL106+5^OCXOZ0H.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE106( ----------> Verify Event/Element: 'RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA'
+7 ; MCE91( -----------> Verify Event/Element: 'PATIENT WITH GLUCOPHAGE MED'
+8 ;
+9 IF $GET(^OCXS(860.2,63,"INACT"))
QUIT
+10 ;
+11 IF $$MCE106
Begin DoDot:1
+12 IF $$MCE91
DO R63R1B
End DoDot:1
+13 QUIT
+14 ;
R63R1B ; Send Order Check, Notication messages and/or Execute code for Rule #63 'GLUCOPHAGE - CONTRAST MEDIA' Relation #1 'IF PROC USES NON-BARIUM MEDIA AND PATIENT TAKING G...'
+1 ; Called from R63R1A+12.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 IF $DATA(OCXRULE("R63R1B"))
QUIT
+6 ;
+7 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+8 IF ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXCMSG=(+OCXPSD)_"^23^^Procedure uses intravenous contrast media and patient is taking metformin."
IF 1
+9 IF '$TEST
SET OCXCMSG="Procedure uses intravenous contrast media and patient is taking metformin."
+10 SET OCXNMSG=""
+11 ;
+12 IF $GET(OCXOERR)
QUIT
+13 ;
+14 ; Send Order Check Message
+15 ;
+16 SET OCXOCMSG($ORDER(OCXOCMSG(999999),-1)+1)=OCXCMSG
+17 QUIT
+18 ;
R65R1A ; Verify all Event/Elements of Rule #65 'POLYPHARMACY' Relation #1 'POLYPHARMACY'
+1 ; Called from EL95+5^OCXOZ0H.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE95( -----------> Verify Event/Element: 'POLYPHARMACY'
+7 ;
+8 IF $GET(^OCXS(860.2,65,"INACT"))
QUIT
+9 ;
+10 IF $$MCE95
DO R65R1B
+11 QUIT
+12 ;
R65R1B ; Send Order Check, Notication messages and/or Execute code for Rule #65 'POLYPHARMACY' Relation #1 'POLYPHARMACY'
+1 ; Called from R65R1A+10.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
+7 ;
+8 IF $DATA(OCXRULE("R65R1B"))
QUIT
+9 ;
+10 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+11 IF ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXCMSG=(+OCXPSD)_"^26^^Potential polypharmacy - patient currently receiving "_$$GETDATA(DFN,"95^",109)_" medications."
IF 1
+12 IF '$TEST
SET OCXCMSG="Potential polypharmacy - patient currently receiving "_$$GETDATA(DFN,"95^",109)_" medications."
+13 SET OCXNMSG=""
+14 ;
+15 IF $GET(OCXOERR)
QUIT
+16 ;
+17 ; Send Order Check Message
+18 ;
+19 SET OCXOCMSG($ORDER(OCXOCMSG(999999),-1)+1)=OCXCMSG
+20 QUIT
+21 ;
R66R1A ; Verify all Event/Elements of Rule #66 'LAB RESULTS' Relation #1 'HL7 LAB RESULTS'
+1 ; Called from EL5+6^OCXOZ0G.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE5( ------------> Verify Event/Element: 'HL7 FINAL LAB RESULT'
+7 ;
+8 IF $GET(^OCXS(860.2,66,"INACT"))
QUIT
+9 ;
+10 IF $$MCE5
DO R66R1B^OCXOZ11
+11 QUIT
+12 ;
CKSUM(STR) ; Compiler Function: GENERATE STRING CHECKSUM
+1 ;
+2 NEW CKSUM,PTR,ASC
SET CKSUM=0
+3 SET STR=$TRANSLATE(STR,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+4 FOR PTR=$LENGTH(STR):-1:1
SET ASC=$ASCII(STR,PTR)-42
IF (ASC>0)
IF (ASC<51)
SET CKSUM=CKSUM*2+ASC
+5 QUIT +CKSUM
+6 ;
GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
+1 ;
+2 NEW OCXE,VAL,PC
SET VAL=""
+3 FOR PC=1:1:$LENGTH(OCXL,U)
SET OCXE=$PIECE(OCXL,U,PC)
IF OCXE
SET VAL=$GET(^TMP("OCXCHK",$JOB,DFN,OCXE,OCXDFI))
IF $LENGTH(VAL)
QUIT
+4 QUIT VAL
+5 ;
MCE106() ; Verify Event/Element: RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA
+1 ;
+2 ; OCXDF(37) -> PATIENT IEN data field
+3 ;
+4 NEW OCXRES
+5 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(106,37)=OCXDF(37)
+6 IF '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),106))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),106))
+7 QUIT 0
+8 ;
MCE5() ; Verify Event/Element: HL7 FINAL LAB RESULT
+1 ;
+2 ;
+3 NEW OCXRES
+4 IF $LENGTH(OCXDF(37))
SET OCXRES(5,37)=OCXDF(37)
+5 IF '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),5))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),5))
+6 QUIT 0
+7 ;
MCE84() ; Verify Event/Element: INPATIENT FOOD-DRUG REACTION
+1 ;
+2 ;
+3 NEW OCXRES
+4 IF $LENGTH(OCXDF(37))
SET OCXRES(84,37)=OCXDF(37)
+5 IF '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),84))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),84))
+6 QUIT 0
+7 ;
MCE91() ; Verify Event/Element: PATIENT WITH GLUCOPHAGE MED
+1 ;
+2 ; OCXDF(103) -> PATIENT CURRENTLY ON GLUCOPHAGE data field
+3 ; OCXDF(37) -> PATIENT IEN data field
+4 ;
+5 NEW OCXRES
+6 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(91,37)=OCXDF(37)
+7 IF '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),91))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),91))
+8 SET OCXRES(91)=0
SET OCXDF(103)=$PIECE($$TAKEMED^ORKPS(OCXDF(37),"^GLUCOPHAGE^METFORMIN^AVANDAMET^METAGLIP"),"^",1)
IF $LENGTH(OCXDF(103))
SET OCXRES(91,103)=OCXDF(103)
IF (OCXDF(103))
+9 IF '$TEST
QUIT 0
+10 SET OCXRES(91)=11
MERGE ^TMP("OCXCHK",$JOB,OCXDF(37),91)=OCXRES(91)
+11 QUIT +OCXRES(91)
+12 ;
MCE95() ; Verify Event/Element: POLYPHARMACY
+1 ;
+2 ; OCXDF(37) -> PATIENT IEN data field
+3 ;
+4 NEW OCXRES
+5 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(95,37)=OCXDF(37)
+6 IF '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),95))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),95))
+7 QUIT 0
+8 ;
NEWRULE(OCXDFN,OCXORD,OCXRUL,OCXREL,OCXNOTF,OCXMESS) ; Has this rule already been triggered for this order number
+1 ;
+2 ;
+3 IF '$GET(OCXDFN)
QUIT 0
IF '$GET(OCXRUL)
QUIT 0
+4 IF '$GET(OCXREL)
QUIT 0
IF '$GET(OCXNOTF)
QUIT 0
IF '$LENGTH($GET(OCXMESS))
QUIT 0
+5 SET OCXORD=+$GET(OCXORD)
SET OCXDFN=+OCXDFN
+6 ;
+7 NEW OCXNDX,OCXDATA,OCXDFI,OCXELE,OCXGR,OCXTIME,OCXCKSUM,OCXTSP,OCXTSPL
+8 ;
+9 SET OCXTIME=(+$HOROLOG)
+10 SET OCXCKSUM=$$CKSUM(OCXMESS)
+11 ;
+12 SET OCXTSP=($HOROLOG*86400)+$PIECE($HOROLOG,",",2)
+13 SET OCXTSPL=($GET(^OCXD(860.7,"AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM))+$GET(OCXTSPI,300))
+14 ;
+15 IF (OCXTSPL>OCXTSP)
QUIT 0
+16 ;
+17 KILL OCXDATA
+18 SET OCXDATA(OCXDFN,0)=OCXDFN
+19 SET OCXDATA("B",OCXDFN,OCXDFN)=""
+20 SET OCXDATA("AT",OCXTIME,OCXDFN,OCXRUL,+OCXORD,OCXCKSUM)=OCXTSP
+21 ;
+22 SET OCXGR="^OCXD(860.7"
+23 DO SETAP(OCXGR_")",0,.OCXDATA,OCXDFN)
+24 ;
+25 KILL OCXDATA
+26 SET OCXDATA(OCXRUL,0)=OCXRUL_U_(OCXTIME)_U_(+OCXORD)
+27 SET OCXDATA(OCXRUL,"M")=OCXMESS
+28 SET OCXDATA("B",OCXRUL,OCXRUL)=""
+29 SET OCXGR=OCXGR_","_OCXDFN_",1"
+30 DO SETAP(OCXGR_")","860.71P",.OCXDATA,OCXRUL)
+31 ;
+32 KILL OCXDATA
+33 SET OCXDATA(OCXREL,0)=OCXREL
+34 SET OCXDATA("B",OCXREL,OCXREL)=""
+35 SET OCXGR=OCXGR_","_OCXRUL_",1"
+36 DO SETAP(OCXGR_")","860.712",.OCXDATA,OCXREL)
+37 ;
+38 SET OCXELE=0
FOR
SET OCXELE=$ORDER(^OCXS(860.2,OCXRUL,"C","C",OCXELE))
IF 'OCXELE
QUIT
Begin DoDot:1
+39 ;
+40 NEW OCXGR1
+41 SET OCXGR1=OCXGR_","_OCXREL_",1"
+42 KILL OCXDATA
+43 SET OCXDATA(OCXELE,0)=OCXELE
+44 SET OCXDATA(OCXELE,"TIME")=OCXTIME
+45 SET OCXDATA(OCXELE,"LOG")=$GET(OCXOLOG)
+46 SET OCXDATA("B",OCXELE,OCXELE)=""
+47 KILL ^OCXD(860.7,OCXDFN,1,OCXRUL,1,OCXREL,1,OCXELE)
+48 DO SETAP(OCXGR1_")","860.7122P",.OCXDATA,OCXELE)
+49 ;
+50 SET OCXDFI=0
FOR
SET OCXDFI=$ORDER(^TMP("OCXCHK",$JOB,OCXDFN,OCXELE,OCXDFI))
IF 'OCXDFI
QUIT
Begin DoDot:2
+51 NEW OCXGR2
+52 SET OCXGR2=OCXGR1_","_OCXELE_",1"
+53 KILL OCXDATA
+54 SET OCXDATA(OCXDFI,0)=OCXDFI
+55 SET OCXDATA(OCXDFI,"VAL")=^TMP("OCXCHK",$JOB,OCXDFN,OCXELE,OCXDFI)
+56 SET OCXDATA("B",OCXDFI,OCXDFI)=""
+57 DO SETAP(OCXGR2_")","860.71223P",.OCXDATA,OCXDFI)
End DoDot:2
End DoDot:1
+58 ;
+59 QUIT 1
+60 ;
SETAP(ROOT,DD,DATA,DA) ; Set Rule Event data
+1 MERGE @ROOT=DATA
+2 IF +$GET(DD)
SET @ROOT@(0)="^"_($GET(DD))_"^"_($PIECE($GET(@ROOT@(0)),U,3)+1)_"^"_$GET(DA)
+3 IF '$GET(DD)
SET $PIECE(@ROOT@(0),U,3,4)=($PIECE($GET(@ROOT@(0)),U,3)+1)_"^"_$GET(DA)
+4 ;
+5 QUIT
+6 ;
+7 ;