OCXOZ0N ;SLC/RJS,CLA - Order Check Scan ;JUL 1,2021 at 11:27
;;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
;
R19R1B ; Send Order Check, Notication messages and/or Execute code for Rule #19 'PATIENT DISCHARGE' Relation #1 'DISCHARGE'
; Called from R19R1A+10^OCXOZ0M.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
; INT2DT( ----------> CONVERT DATE FROM OCX FORMAT TO READABLE FORMAT
; NEWRULE( ---------> NEW RULE MESSAGE
;
Q:$D(OCXRULE("R19R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
S OCXCMSG=""
S OCXNMSG="Discharged on "_$$INT2DT($$GETDATA(DFN,"56^",26),0)
;
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("R19R1B")=""
I $$NEWRULE(DFN,OCXNUM,19,1,35,OCXNMSG) D I 1
.D:($G(OCXTRACE)<5) EN^ORB3(35,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
Q
;
R22R1A ; Verify all Event/Elements of Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
; Called from EL47+5^OCXOZ0G.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE47( -----------> Verify Event/Element: 'ORDER REQUIRES CO-SIGNATURE'
;
Q:$G(^OCXS(860.2,22,"INACT"))
;
I $$MCE47 D R22R1B
Q
;
R22R1B ; Send Order Check, Notication messages and/or Execute code for Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
; Called from R22R1A+10.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; NEWRULE( ---------> NEW RULE MESSAGE
;
Q:$D(OCXRULE("R22R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
S OCXCMSG=""
S OCXNMSG="Order requires a co-signature"
;
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("R22R1B")=""
I $$NEWRULE(DFN,OCXNUM,22,1,37,OCXNMSG) D I 1
.D:($G(OCXTRACE)<5) EN^ORB3(37,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
Q
;
R24R1A ; Verify all Event/Elements of Rule #24 'ORDERER FLAGGED RESULTS AVAILABLE' Relation #1 'ORDER FLAGGED FOR RESULTS AND (LAB RESULT OR IMAGI...'
; Called from EL5+5^OCXOZ0G, and EL49+5^OCXOZ0G, and EL55+5^OCXOZ0G, and EL101+5^OCXOZ0G.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE101( ----------> Verify Event/Element: 'HL7 FINAL IMAGING RESULT'
; MCE49( -----------> Verify Event/Element: 'ORDER FLAGGED FOR RESULTS'
; MCE5( ------------> Verify Event/Element: 'HL7 FINAL LAB RESULT'
; MCE55( -----------> Verify Event/Element: 'CONSULT FINAL RESULTS'
;
Q:$G(^OCXS(860.2,24,"INACT"))
;
I $$MCE49 D
.I $$MCE5 D R24R1B^OCXOZ0O
.I $$MCE101 D R24R1B^OCXOZ0O
.I $$MCE55 D R24R1B^OCXOZ0O
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
;
INT2DT(OCXDT,OCXF) ; This Local Extrinsic Function converts an OCX internal format
; date into an Externl Format (Human Readable) date. 'OCXF=SHORT FORMAT OCXF=LONG FORMAT
;
Q:'$L($G(OCXDT)) "" S OCXF=+$G(OCXF)
N OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXCYR
S (OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXAP)=""
S OCXSEC=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
S OCXMIN=$E(OCXDT#60+100,2,3),OCXDT=OCXDT\60
S OCXHR=$E(OCXDT#24+100,2,3),OCXDT=OCXDT\24
S OCXCYR=($H\1461)*4+1841+(($H#1461)\365)
S OCXYR=(OCXDT\1461)*4+1841,OCXDT=OCXDT#1461
S OCXLPYR=(OCXDT\365),OCXDT=OCXDT-(OCXLPYR*365),OCXYR=OCXYR+OCXLPYR
S OCXCNT="031^059^090^120^151^181^212^243^273^304^334^365"
S:(OCXLPYR=3) OCXCNT="031^060^091^121^152^182^213^244^274^305^335^366"
F OCXMON=1:1:12 Q:(OCXDT<$P(OCXCNT,U,OCXMON))
S OCXDAY=OCXDT-$P(OCXCNT,U,OCXMON-1)+1
I OCXF S OCXMON=$P("January^February^March^April^May^June^July^August^September^October^November^December",U,OCXMON)
E S OCXMON=$E(OCXMON+100,2,3)
S OCXAP=$S('OCXHR:"Midnight",(OCXHR=12):"Noon",(OCXHR<12):"AM",1:"PM")
I OCXF S OCXHR=OCXHR#12 S:'OCXHR OCXHR=12
Q:'OCXF $E(OCXMON+100,2,3)_"/"_$E(OCXDAY+100,2,3)_$S((OCXCYR=OCXYR):" "_OCXHR_":"_OCXMIN,1:"/"_$E(OCXYR,3,4))
Q:(OCXHR+OCXMIN+OCXSEC) OCXMON_" "_OCXDAY_","_OCXYR_" at "_OCXHR_":"_OCXMIN_"."_OCXSEC_" "_OCXAP
Q OCXMON_" "_OCXDAY_","_OCXYR
;
MCE101() ; Verify Event/Element: HL7 FINAL IMAGING RESULT
;
;
N OCXRES
I $L(OCXDF(37)) S OCXRES(101,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),101)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),101))
Q 0
;
MCE47() ; Verify Event/Element: ORDER REQUIRES CO-SIGNATURE
;
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$P($G(OCXORD),"^",1) I $L(OCXDF(37)) S OCXRES(47,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),47)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),47))
Q 0
;
MCE49() ; Verify Event/Element: ORDER FLAGGED FOR RESULTS
;
;
N OCXRES
I $L(OCXDF(37)) S OCXRES(49,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),49)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),49))
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
;
MCE55() ; Verify Event/Element: CONSULT FINAL RESULTS
;
;
N OCXRES
I $L(OCXDF(37)) S OCXRES(55,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),55)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),55))
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
;
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HOCXOZ0N 9062 printed Oct 16, 2024@18:26:45 Page 2
OCXOZ0N ;SLC/RJS,CLA - Order Check Scan ;JUL 1,2021 at 11:27
+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 ;
R19R1B ; Send Order Check, Notication messages and/or Execute code for Rule #19 'PATIENT DISCHARGE' Relation #1 'DISCHARGE'
+1 ; Called from R19R1A+10^OCXOZ0M.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
+7 ; INT2DT( ----------> CONVERT DATE FROM OCX FORMAT TO READABLE FORMAT
+8 ; NEWRULE( ---------> NEW RULE MESSAGE
+9 ;
+10 if $DATA(OCXRULE("R19R1B"))
QUIT
+11 ;
+12 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+13 SET OCXCMSG=""
+14 SET OCXNMSG="Discharged on "_$$INT2DT($$GETDATA(DFN,"56^",26),0)
+15 ;
+16 if $GET(OCXOERR)
QUIT
+17 ;
+18 ; Send Notification
+19 ;
+20 SET (OCXDUZ,OCXDATA)=""
SET OCXNUM=0
+21 IF ($GET(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY")
Begin DoDot:1
+22 SET OCXDATA=$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",2))_"|"_$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",3))
+23 SET OCXDATA=$TRANSLATE(OCXDATA,"^","@")
SET OCXNUM=+OCXDATA
End DoDot:1
+24 IF ($GET(OCXOSRC)="CPRS ORDER PROTOCOL")
Begin DoDot:1
+25 IF $PIECE($GET(OCXORD),U,3)
SET OCXDUZ(+$PIECE(OCXORD,U,3))=""
+26 SET OCXNUM=+$PIECE(OCXORD,U,2)
End DoDot:1
+27 if ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXNUM=+$PIECE(OCXPSD,"|",5)
+28 SET OCXRULE("R19R1B")=""
+29 IF $$NEWRULE(DFN,OCXNUM,19,1,35,OCXNMSG)
Begin DoDot:1
+30 if ($GET(OCXTRACE)<5)
DO EN^ORB3(35,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
End DoDot:1
IF 1
+31 QUIT
+32 ;
R22R1A ; Verify all Event/Elements of Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
+1 ; Called from EL47+5^OCXOZ0G.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE47( -----------> Verify Event/Element: 'ORDER REQUIRES CO-SIGNATURE'
+7 ;
+8 if $GET(^OCXS(860.2,22,"INACT"))
QUIT
+9 ;
+10 IF $$MCE47
DO R22R1B
+11 QUIT
+12 ;
R22R1B ; Send Order Check, Notication messages and/or Execute code for Rule #22 'ORDER REQUIRES CO-SIGNATURE' Relation #1 'COSIG'
+1 ; Called from R22R1A+10.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; NEWRULE( ---------> NEW RULE MESSAGE
+7 ;
+8 if $DATA(OCXRULE("R22R1B"))
QUIT
+9 ;
+10 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+11 SET OCXCMSG=""
+12 SET OCXNMSG="Order requires a co-signature"
+13 ;
+14 if $GET(OCXOERR)
QUIT
+15 ;
+16 ; Send Notification
+17 ;
+18 SET (OCXDUZ,OCXDATA)=""
SET OCXNUM=0
+19 IF ($GET(OCXOSRC)="GENERIC HL7 MESSAGE ARRAY")
Begin DoDot:1
+20 SET OCXDATA=$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",2))_"|"_$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","ORC",3))
+21 SET OCXDATA=$TRANSLATE(OCXDATA,"^","@")
SET OCXNUM=+OCXDATA
End DoDot:1
+22 IF ($GET(OCXOSRC)="CPRS ORDER PROTOCOL")
Begin DoDot:1
+23 IF $PIECE($GET(OCXORD),U,3)
SET OCXDUZ(+$PIECE(OCXORD,U,3))=""
+24 SET OCXNUM=+$PIECE(OCXORD,U,2)
End DoDot:1
+25 if ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXNUM=+$PIECE(OCXPSD,"|",5)
+26 SET OCXRULE("R22R1B")=""
+27 IF $$NEWRULE(DFN,OCXNUM,22,1,37,OCXNMSG)
Begin DoDot:1
+28 if ($GET(OCXTRACE)<5)
DO EN^ORB3(37,DFN,OCXNUM,.OCXDUZ,OCXNMSG,.OCXDATA)
End DoDot:1
IF 1
+29 QUIT
+30 ;
R24R1A ; Verify all Event/Elements of Rule #24 'ORDERER FLAGGED RESULTS AVAILABLE' Relation #1 'ORDER FLAGGED FOR RESULTS AND (LAB RESULT OR IMAGI...'
+1 ; Called from EL5+5^OCXOZ0G, and EL49+5^OCXOZ0G, and EL55+5^OCXOZ0G, and EL101+5^OCXOZ0G.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE101( ----------> Verify Event/Element: 'HL7 FINAL IMAGING RESULT'
+7 ; MCE49( -----------> Verify Event/Element: 'ORDER FLAGGED FOR RESULTS'
+8 ; MCE5( ------------> Verify Event/Element: 'HL7 FINAL LAB RESULT'
+9 ; MCE55( -----------> Verify Event/Element: 'CONSULT FINAL RESULTS'
+10 ;
+11 if $GET(^OCXS(860.2,24,"INACT"))
QUIT
+12 ;
+13 IF $$MCE49
Begin DoDot:1
+14 IF $$MCE5
DO R24R1B^OCXOZ0O
+15 IF $$MCE101
DO R24R1B^OCXOZ0O
+16 IF $$MCE55
DO R24R1B^OCXOZ0O
End DoDot:1
+17 QUIT
+18 ;
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 ;
INT2DT(OCXDT,OCXF) ; This Local Extrinsic Function converts an OCX internal format
+1 ; date into an Externl Format (Human Readable) date. 'OCXF=SHORT FORMAT OCXF=LONG FORMAT
+2 ;
+3 if '$LENGTH($GET(OCXDT))
QUIT ""
SET OCXF=+$GET(OCXF)
+4 NEW OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXCYR
+5 SET (OCXYR,OCXLPYR,OCXMON,OCXDAY,OCXHR,OCXMIN,OCXSEC,OCXAP)=""
+6 SET OCXSEC=$EXTRACT(OCXDT#60+100,2,3)
SET OCXDT=OCXDT\60
+7 SET OCXMIN=$EXTRACT(OCXDT#60+100,2,3)
SET OCXDT=OCXDT\60
+8 SET OCXHR=$EXTRACT(OCXDT#24+100,2,3)
SET OCXDT=OCXDT\24
+9 SET OCXCYR=($HOROLOG\1461)*4+1841+(($HOROLOG#1461)\365)
+10 SET OCXYR=(OCXDT\1461)*4+1841
SET OCXDT=OCXDT#1461
+11 SET OCXLPYR=(OCXDT\365)
SET OCXDT=OCXDT-(OCXLPYR*365)
SET OCXYR=OCXYR+OCXLPYR
+12 SET OCXCNT="031^059^090^120^151^181^212^243^273^304^334^365"
+13 if (OCXLPYR=3)
SET OCXCNT="031^060^091^121^152^182^213^244^274^305^335^366"
+14 FOR OCXMON=1:1:12
if (OCXDT<$PIECE(OCXCNT,U,OCXMON))
QUIT
+15 SET OCXDAY=OCXDT-$PIECE(OCXCNT,U,OCXMON-1)+1
+16 IF OCXF
SET OCXMON=$PIECE("January^February^March^April^May^June^July^August^September^October^November^December",U,OCXMON)
+17 IF '$TEST
SET OCXMON=$EXTRACT(OCXMON+100,2,3)
+18 SET OCXAP=$SELECT('OCXHR:"Midnight",(OCXHR=12):"Noon",(OCXHR<12):"AM",1:"PM")
+19 IF OCXF
SET OCXHR=OCXHR#12
if 'OCXHR
SET OCXHR=12
+20 if 'OCXF
QUIT $EXTRACT(OCXMON+100,2,3)_"/"_$EXTRACT(OCXDAY+100,2,3)_$SELECT((OCXCYR=OCXYR):" "_OCXHR_":"_OCXMIN,1:"/"_$EXTRACT(OCXYR,3,4))
+21 if (OCXHR+OCXMIN+OCXSEC)
QUIT OCXMON_" "_OCXDAY_","_OCXYR_" at "_OCXHR_":"_OCXMIN_"."_OCXSEC_" "_OCXAP
+22 QUIT OCXMON_" "_OCXDAY_","_OCXYR
+23 ;
MCE101() ; Verify Event/Element: HL7 FINAL IMAGING RESULT
+1 ;
+2 ;
+3 NEW OCXRES
+4 IF $LENGTH(OCXDF(37))
SET OCXRES(101,37)=OCXDF(37)
+5 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),101))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),101))
+6 QUIT 0
+7 ;
MCE47() ; Verify Event/Element: ORDER REQUIRES CO-SIGNATURE
+1 ;
+2 ; OCXDF(37) -> PATIENT IEN data field
+3 ;
+4 NEW OCXRES
+5 SET OCXDF(37)=$PIECE($GET(OCXORD),"^",1)
IF $LENGTH(OCXDF(37))
SET OCXRES(47,37)=OCXDF(37)
+6 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),47))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),47))
+7 QUIT 0
+8 ;
MCE49() ; Verify Event/Element: ORDER FLAGGED FOR RESULTS
+1 ;
+2 ;
+3 NEW OCXRES
+4 IF $LENGTH(OCXDF(37))
SET OCXRES(49,37)=OCXDF(37)
+5 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),49))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),49))
+6 QUIT 0
+7 ;
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 ;
MCE55() ; Verify Event/Element: CONSULT FINAL RESULTS
+1 ;
+2 ;
+3 NEW OCXRES
+4 IF $LENGTH(OCXDF(37))
SET OCXRES(55,37)=OCXDF(37)
+5 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),55))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),55))
+6 QUIT 0
+7 ;
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 ;