OCXOZ0F ;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
;
CHK469 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK463+19^OCXOZ0E.
;
Q:$G(OCXOERR)
;
; Local CHK469 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
;
; Local Extrinsic Functions
; FILE(DFN,131, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: GREATER THAN LAB THRESHOLD)
; PATLOC( ----------> PATIENT LOCATION
;
S OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,131,"12,37,96,113,147,152") Q:OCXOERR
Q
;
CHK476 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK463+20^OCXOZ0E.
;
Q:$G(OCXOERR)
;
; Local CHK476 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
;
; Local Extrinsic Functions
; FILE(DFN,132, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: LESS THAN LAB THRESHOLD)
; PATLOC( ----------> PATIENT LOCATION
;
S OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,132,"12,37,96,113,147,152") Q:OCXOERR
Q
;
CHK482 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK446+17^OCXOZ0E.
;
Q:$G(OCXOERR)
;
; Local CHK482 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
;
; Local Extrinsic Functions
; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
; FILE(DFN,133, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: NO CREAT RESULTS W/IN X DAYS)
;
S OCXDF(58)=$P($$ABREN(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,133,"58,154") Q:OCXOERR
Q
;
CHK489 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK196+16^OCXOZ09.
;
Q:$G(OCXOERR)
;
; Local CHK489 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(156) --> Data Field: ALLERGY ASSESSMENT (BOOLEAN)
; OCXDF(159) --> Data Field: ALLERGIES UNASSESSIBLE (BOOLEAN)
;
; Local Extrinsic Functions
; ALRGY( -----------> ALLERGY ASSESSMENT
; ALUNASS( ---------> ALLERGIES UNASSESSIBLE
; FILE(DFN,136, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: NO ALLERGY ASSESSMENT)
; FILE(DFN,140, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: ALLERGIES UNASSESSIBLE)
;
S OCXDF(156)=$$ALRGY(OCXDF(37)) I $L(OCXDF(156)),'(OCXDF(156)) S OCXOERR=$$FILE(DFN,136,"") Q:OCXOERR
S OCXDF(159)=$$ALUNASS(OCXDF(37)) I $L(OCXDF(159)),'(OCXDF(159)) S OCXOERR=$$FILE(DFN,140,"") Q:OCXOERR
Q
;
CHK497 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK360+15^OCXOZ0C.
;
Q:$G(OCXOERR)
;
; Local CHK497 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(74) ---> Data Field: VA DRUG CLASS (FREE TEXT)
; OCXDF(158) --> Data Field: DUPLICATE OPIOID MEDICATIONS TEXT (FREE TEXT)
;
; Local Extrinsic Functions
; LIST( ------------> IN LIST OPERATOR
; OPIOID( ----------> OPIOID MEDICATIONS
;
I $$LIST(OCXDF(74),"OPIOID ANALGESICS,OPIOID ANTAGONIST ANALGESICS") S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXDF(158)=$P($$OPIOID(OCXDF(37)),"^",2) D CHK501
Q
;
CHK501 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK497+14.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; FILE(DFN,139, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: OPIOID MED ORDER)
;
S OCXOERR=$$FILE(DFN,139,"158") Q:OCXOERR
Q
;
CHK508 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK355+14^OCXOZ0C.
;
Q:$G(OCXOERR)
;
; Local CHK508 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(130) --> Data Field: CLOZAPINE LAB RESULTS (FREE TEXT)
; OCXDF(131) --> Data Field: PHARMACY LOCAL ID (FREE TEXT)
;
; Local Extrinsic Functions
; FILE(DFN,141, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CLOZAPINE ANC >= 1.5 & < 2.0)
;
S OCXDF(130)=$P($$CLOZLABS^ORKLR(OCXDF(37),"",OCXDF(131)),"^",4),OCXOERR=$$FILE(DFN,141,"130") Q:OCXOERR
Q
;
ABREN(DFN) ; Compiler Function: DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
;
N OCXFLAG,OCXVAL,OCXLIST,OCXTEST,UNAV,OCXTLIST,OCXTERM,OCXSLIST,OCXSPEC
S (OCXLIST,OCXTLIST)="",UNAV="0^<Unavailable>"
S OCXSLIST="" Q:'$$TERMLKUP("SERUM SPECIMEN",.OCXSLIST) UNAV
F OCXTERM="SERUM CREATININE","SERUM UREA NITROGEN" D Q:($L(OCXLIST)>130)
.Q:'$$TERMLKUP(OCXTERM,.OCXTLIST)
.S OCXTEST=0 F S OCXTEST=$O(OCXTLIST(OCXTEST)) Q:'OCXTEST D Q:($L(OCXLIST)>130)
..S OCXSPEC=0 F S OCXSPEC=$O(OCXSLIST(OCXSPEC)) Q:'OCXSPEC D Q:($L(OCXLIST)>130)
...S OCXVAL=$$LOCL^ORQQLR1(DFN,OCXTEST,OCXSPEC),OCXFLAG=$P(OCXVAL,U,5)
...I $L(OCXVAL),((OCXFLAG["H")!(OCXFLAG["L")) D
....N OCXY S OCXY=""
....S OCXY=$P(OCXVAL,U,2)_": "_$P(OCXVAL,U,3)_" "_$P(OCXVAL,U,4)
....S OCXY=OCXY_" "_$S($L(OCXFLAG):"["_OCXFLAG_"]",1:"")
....S OCXY=OCXY_" "_$$FMTE^XLFDT($P(OCXVAL,U,7),"2P")
....S:$L(OCXLIST) OCXLIST=OCXLIST_" " S OCXLIST=OCXLIST_OCXY
Q:'$L(OCXLIST) UNAV Q 1_U_OCXLIST
;
;
ALRGY(ORPT) ; determine if pt has an allergy assessment
; rtn 0 if no allergy assessment, 1 if allergy assessment or NKA
N ORALRGY
D EN1^GMRAOR1(ORPT,"ORALRGY")
Q:$G(ORALRGY)="" 0
Q 1
;
ALUNASS(ORPT) ; determine if pt was unable to be assessed
; rtn 0 if unable to assessment, 1 otherwise
N ORALASS
S ORALASS=$$UNASS^GMRAOR1(ORPT)
Q:ORALASS=0 0
Q 1
;
FILE(DFN,OCXELE,OCXDFL) ; This Local Extrinsic Function logs a validated event/element.
;
N OCXTIMN,OCXTIML,OCXTIMT1,OCXTIMT2,OCXDATA,OCXPC,OCXPC,OCXVAL,OCXSUB,OCXDFI
S DFN=+$G(DFN),OCXELE=+$G(OCXELE)
;
Q:'DFN 1 Q:'OCXELE 1 K OCXDATA
;
S OCXDATA(DFN,OCXELE)=1
F OCXPC=1:1:$L(OCXDFL,",") S OCXDFI=$P(OCXDFL,",",OCXPC) I OCXDFI D
.S OCXVAL=$G(OCXDF(+OCXDFI)),OCXDATA(DFN,OCXELE,+OCXDFI)=OCXVAL
;
M ^TMP("OCXCHK",$J,DFN)=OCXDATA(DFN)
;
Q 0
;
LIST(DATA,LIST) ; IS THE DATA FIELD IN THE LIST
;
S:'($E(LIST,1)=",") LIST=","_LIST S:'($E(LIST,$L(LIST))=",") LIST=LIST_"," S DATA=","_DATA_","
Q (LIST[DATA)
;
OPIOID(ORPT) ;determine if pat is receiving opioid med
; rtn 1^opioid drug 1, opioid drug 2, opioid drug3, ...
N ORDG,ORTN,ORNUM,ORDI,ORDCLAS,ORDERS,ORTEXT,DUP,DUPI,DUPJ,DUPLEN
S ORDG=0,ORTN=0,DUPI=0,DUPLEN=20
K ^TMP("ORR",$J)
S ORDG=$O(^ORD(100.98,"B","RX",ORDG))
D EN^ORQ1(ORPT_";DPT(",ORDG,2,"","","",0,0)
N J,HOR,SEQ,X S J=1,HOR=0,SEQ=0
S HOR=$O(^TMP("ORR",$J,HOR)) Q:+HOR<1 ORTN
F S SEQ=$O(^TMP("ORR",$J,HOR,SEQ)) Q:+SEQ<1 D
.S X=^TMP("ORR",$J,HOR,SEQ)
.S ORNUM=+$P(X,";")
.Q:ORNUM=+$G(ORIFN) ;quit if dup med order # = current order #
.S ORDI=$$VALUE^ORCSAVE2(ORNUM,"DRUG")
.I +$G(ORDI)>0 D
..S ORDCLAS=$P(^PSDRUG(ORDI,0),U,2) ;va drug class
..I ($G(ORDCLAS)="CN101")!($G(ORDCLAS)="CN102") D ;opioid classes
...S ORTEXT=$$FULLTEXT^ORQOR1(ORNUM)
...S ORTEXT=$P(ORTEXT,U)_" ["_$P(ORTEXT,U,2)_"]"
...S DUPI=DUPI+1,DUP(DUPI)=" ["_DUPI_"] "_ORTEXT
...S ORTN=1
I DUPI>0 D
.S DUPLEN=$P(215/DUPI,".")
.F DUPJ=1:1:DUPI D
..I DUPJ=1 S ORDERS=$E(DUP(DUPJ),1,DUPLEN)
..E S ORDERS=ORDERS_", "_$E(DUP(DUPJ),1,DUPLEN)
K ^TMP("ORR",$J)
Q ORTN_U_$G(ORDERS)
;
PATLOC(DFN) ; Compiler Function: PATIENT LOCATION
;
N OCXP1,OCXP2
S OCXP1=$G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",2))
S OCXP2=$P($G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",3)),"^",1)
I OCXP2 D
.S OCXP2=$P($G(^SC(+OCXP2,0)),"^",1,2)
.I $L($P(OCXP2,"^",2)) S OCXP2=$P(OCXP2,"^",2)
.E S OCXP2=$P(OCXP2,"^",1)
.S:'$L(OCXP2) OCXP2="NO LOC"
I $L(OCXP1),$L(OCXP2) Q OCXP1_"^"_OCXP2
;
S OCXP2=$G(^DPT(+$G(DFN),.1))
I $L(OCXP2) Q "I^"_OCXP2
Q "O^OUTPT"
;
TERMLKUP(OCXTERM,OCXLIST) ;
Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
;
OCXOZ0F ;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 ;
CHK469 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK463+19^OCXOZ0E.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK469 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
+8 ;
+9 ; Local Extrinsic Functions
+10 ; FILE(DFN,131, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: GREATER THAN LAB THRESHOLD)
+11 ; PATLOC( ----------> PATIENT LOCATION
+12 ;
+13 SET OCXDF(147)=$PIECE($$PATLOC(OCXDF(37)),"^",2)
SET OCXOERR=$$FILE(DFN,131,"12,37,96,113,147,152")
IF OCXOERR
QUIT
+14 QUIT
+15 ;
CHK476 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK463+20^OCXOZ0E.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK476 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
+8 ;
+9 ; Local Extrinsic Functions
+10 ; FILE(DFN,132, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: LESS THAN LAB THRESHOLD)
+11 ; PATLOC( ----------> PATIENT LOCATION
+12 ;
+13 SET OCXDF(147)=$PIECE($$PATLOC(OCXDF(37)),"^",2)
SET OCXOERR=$$FILE(DFN,132,"12,37,96,113,147,152")
IF OCXOERR
QUIT
+14 QUIT
+15 ;
CHK482 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK446+17^OCXOZ0E.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK482 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
+8 ;
+9 ; Local Extrinsic Functions
+10 ; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
+11 ; FILE(DFN,133, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: NO CREAT RESULTS W/IN X DAYS)
+12 ;
+13 SET OCXDF(58)=$PIECE($$ABREN(OCXDF(37)),"^",2)
SET OCXOERR=$$FILE(DFN,133,"58,154")
IF OCXOERR
QUIT
+14 QUIT
+15 ;
CHK489 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK196+16^OCXOZ09.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK489 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(156) --> Data Field: ALLERGY ASSESSMENT (BOOLEAN)
+8 ; OCXDF(159) --> Data Field: ALLERGIES UNASSESSIBLE (BOOLEAN)
+9 ;
+10 ; Local Extrinsic Functions
+11 ; ALRGY( -----------> ALLERGY ASSESSMENT
+12 ; ALUNASS( ---------> ALLERGIES UNASSESSIBLE
+13 ; FILE(DFN,136, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: NO ALLERGY ASSESSMENT)
+14 ; FILE(DFN,140, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: ALLERGIES UNASSESSIBLE)
+15 ;
+16 SET OCXDF(156)=$$ALRGY(OCXDF(37))
IF $LENGTH(OCXDF(156))
IF '(OCXDF(156))
SET OCXOERR=$$FILE(DFN,136,"")
IF OCXOERR
QUIT
+17 SET OCXDF(159)=$$ALUNASS(OCXDF(37))
IF $LENGTH(OCXDF(159))
IF '(OCXDF(159))
SET OCXOERR=$$FILE(DFN,140,"")
IF OCXOERR
QUIT
+18 QUIT
+19 ;
CHK497 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK360+15^OCXOZ0C.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK497 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(74) ---> Data Field: VA DRUG CLASS (FREE TEXT)
+8 ; OCXDF(158) --> Data Field: DUPLICATE OPIOID MEDICATIONS TEXT (FREE TEXT)
+9 ;
+10 ; Local Extrinsic Functions
+11 ; LIST( ------------> IN LIST OPERATOR
+12 ; OPIOID( ----------> OPIOID MEDICATIONS
+13 ;
+14 IF $$LIST(OCXDF(74),"OPIOID ANALGESICS,OPIOID ANTAGONIST ANALGESICS")
SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXDF(158)=$PIECE($$OPIOID(OCXDF(37)),"^",2)
DO CHK501
+15 QUIT
+16 ;
CHK501 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK497+14.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; FILE(DFN,139, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: OPIOID MED ORDER)
+7 ;
+8 SET OCXOERR=$$FILE(DFN,139,"158")
IF OCXOERR
QUIT
+9 QUIT
+10 ;
CHK508 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK355+14^OCXOZ0C.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK508 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(130) --> Data Field: CLOZAPINE LAB RESULTS (FREE TEXT)
+8 ; OCXDF(131) --> Data Field: PHARMACY LOCAL ID (FREE TEXT)
+9 ;
+10 ; Local Extrinsic Functions
+11 ; FILE(DFN,141, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CLOZAPINE ANC >= 1.5 & < 2.0)
+12 ;
+13 SET OCXDF(130)=$PIECE($$CLOZLABS^ORKLR(OCXDF(37),"",OCXDF(131)),"^",4)
SET OCXOERR=$$FILE(DFN,141,"130")
IF OCXOERR
QUIT
+14 QUIT
+15 ;
ABREN(DFN) ; Compiler Function: DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
+1 ;
+2 NEW OCXFLAG,OCXVAL,OCXLIST,OCXTEST,UNAV,OCXTLIST,OCXTERM,OCXSLIST,OCXSPEC
+3 SET (OCXLIST,OCXTLIST)=""
SET UNAV="0^<Unavailable>"
+4 SET OCXSLIST=""
IF '$$TERMLKUP("SERUM SPECIMEN",.OCXSLIST)
QUIT UNAV
+5 FOR OCXTERM="SERUM CREATININE","SERUM UREA NITROGEN"
Begin DoDot:1
+6 IF '$$TERMLKUP(OCXTERM,.OCXTLIST)
QUIT
+7 SET OCXTEST=0
FOR
SET OCXTEST=$ORDER(OCXTLIST(OCXTEST))
IF 'OCXTEST
QUIT
Begin DoDot:2
+8 SET OCXSPEC=0
FOR
SET OCXSPEC=$ORDER(OCXSLIST(OCXSPEC))
IF 'OCXSPEC
QUIT
Begin DoDot:3
+9 SET OCXVAL=$$LOCL^ORQQLR1(DFN,OCXTEST,OCXSPEC)
SET OCXFLAG=$PIECE(OCXVAL,U,5)
+10 IF $LENGTH(OCXVAL)
IF ((OCXFLAG["H")!(OCXFLAG["L"))
Begin DoDot:4
+11 NEW OCXY
SET OCXY=""
+12 SET OCXY=$PIECE(OCXVAL,U,2)_": "_$PIECE(OCXVAL,U,3)_" "_$PIECE(OCXVAL,U,4)
+13 SET OCXY=OCXY_" "_$SELECT($LENGTH(OCXFLAG):"["_OCXFLAG_"]",1:"")
+14 SET OCXY=OCXY_" "_$$FMTE^XLFDT($PIECE(OCXVAL,U,7),"2P")
+15 IF $LENGTH(OCXLIST)
SET OCXLIST=OCXLIST_" "
SET OCXLIST=OCXLIST_OCXY
End DoDot:4
End DoDot:3
IF ($LENGTH(OCXLIST)>130)
QUIT
End DoDot:2
IF ($LENGTH(OCXLIST)>130)
QUIT
End DoDot:1
IF ($LENGTH(OCXLIST)>130)
QUIT
+16 IF '$LENGTH(OCXLIST)
QUIT UNAV
QUIT 1_U_OCXLIST
+17 ;
+18 ;
ALRGY(ORPT) ; determine if pt has an allergy assessment
+1 ; rtn 0 if no allergy assessment, 1 if allergy assessment or NKA
+2 NEW ORALRGY
+3 DO EN1^GMRAOR1(ORPT,"ORALRGY")
+4 IF $GET(ORALRGY)=""
QUIT 0
+5 QUIT 1
+6 ;
ALUNASS(ORPT) ; determine if pt was unable to be assessed
+1 ; rtn 0 if unable to assessment, 1 otherwise
+2 NEW ORALASS
+3 SET ORALASS=$$UNASS^GMRAOR1(ORPT)
+4 IF ORALASS=0
QUIT 0
+5 QUIT 1
+6 ;
FILE(DFN,OCXELE,OCXDFL) ; This Local Extrinsic Function logs a validated event/element.
+1 ;
+2 NEW OCXTIMN,OCXTIML,OCXTIMT1,OCXTIMT2,OCXDATA,OCXPC,OCXPC,OCXVAL,OCXSUB,OCXDFI
+3 SET DFN=+$GET(DFN)
SET OCXELE=+$GET(OCXELE)
+4 ;
+5 IF 'DFN
QUIT 1
IF 'OCXELE
QUIT 1
KILL OCXDATA
+6 ;
+7 SET OCXDATA(DFN,OCXELE)=1
+8 FOR OCXPC=1:1:$LENGTH(OCXDFL,",")
SET OCXDFI=$PIECE(OCXDFL,",",OCXPC)
IF OCXDFI
Begin DoDot:1
+9 SET OCXVAL=$GET(OCXDF(+OCXDFI))
SET OCXDATA(DFN,OCXELE,+OCXDFI)=OCXVAL
End DoDot:1
+10 ;
+11 MERGE ^TMP("OCXCHK",$JOB,DFN)=OCXDATA(DFN)
+12 ;
+13 QUIT 0
+14 ;
LIST(DATA,LIST) ; IS THE DATA FIELD IN THE LIST
+1 ;
+2 IF '($EXTRACT(LIST,1)=",")
SET LIST=","_LIST
IF '($EXTRACT(LIST,$LENGTH(LIST))=",")
SET LIST=LIST_","
SET DATA=","_DATA_","
+3 QUIT (LIST[DATA)
+4 ;
OPIOID(ORPT) ;determine if pat is receiving opioid med
+1 ; rtn 1^opioid drug 1, opioid drug 2, opioid drug3, ...
+2 NEW ORDG,ORTN,ORNUM,ORDI,ORDCLAS,ORDERS,ORTEXT,DUP,DUPI,DUPJ,DUPLEN
+3 SET ORDG=0
SET ORTN=0
SET DUPI=0
SET DUPLEN=20
+4 KILL ^TMP("ORR",$JOB)
+5 SET ORDG=$ORDER(^ORD(100.98,"B","RX",ORDG))
+6 DO EN^ORQ1(ORPT_";DPT(",ORDG,2,"","","",0,0)
+7 NEW J,HOR,SEQ,X
SET J=1
SET HOR=0
SET SEQ=0
+8 SET HOR=$ORDER(^TMP("ORR",$JOB,HOR))
IF +HOR<1
QUIT ORTN
+9 FOR
SET SEQ=$ORDER(^TMP("ORR",$JOB,HOR,SEQ))
IF +SEQ<1
QUIT
Begin DoDot:1
+10 SET X=^TMP("ORR",$JOB,HOR,SEQ)
+11 SET ORNUM=+$PIECE(X,";")
+12 ;quit if dup med order # = current order #
IF ORNUM=+$GET(ORIFN)
QUIT
+13 SET ORDI=$$VALUE^ORCSAVE2(ORNUM,"DRUG")
+14 IF +$GET(ORDI)>0
Begin DoDot:2
+15 ;va drug class
SET ORDCLAS=$PIECE(^PSDRUG(ORDI,0),U,2)
+16 ;opioid classes
IF ($GET(ORDCLAS)="CN101")!($GET(ORDCLAS)="CN102")
Begin DoDot:3
+17 SET ORTEXT=$$FULLTEXT^ORQOR1(ORNUM)
+18 SET ORTEXT=$PIECE(ORTEXT,U)_" ["_$PIECE(ORTEXT,U,2)_"]"
+19 SET DUPI=DUPI+1
SET DUP(DUPI)=" ["_DUPI_"] "_ORTEXT
+20 SET ORTN=1
End DoDot:3
End DoDot:2
End DoDot:1
+21 IF DUPI>0
Begin DoDot:1
+22 SET DUPLEN=$PIECE(215/DUPI,".")
+23 FOR DUPJ=1:1:DUPI
Begin DoDot:2
+24 IF DUPJ=1
SET ORDERS=$EXTRACT(DUP(DUPJ),1,DUPLEN)
+25 IF '$TEST
SET ORDERS=ORDERS_", "_$EXTRACT(DUP(DUPJ),1,DUPLEN)
End DoDot:2
End DoDot:1
+26 KILL ^TMP("ORR",$JOB)
+27 QUIT ORTN_U_$GET(ORDERS)
+28 ;
PATLOC(DFN) ; Compiler Function: PATIENT LOCATION
+1 ;
+2 NEW OCXP1,OCXP2
+3 SET OCXP1=$GET(^TMP("OCXSWAP",$JOB,"OCXODATA","PV1",2))
+4 SET OCXP2=$PIECE($GET(^TMP("OCXSWAP",$JOB,"OCXODATA","PV1",3)),"^",1)
+5 IF OCXP2
Begin DoDot:1
+6 SET OCXP2=$PIECE($GET(^SC(+OCXP2,0)),"^",1,2)
+7 IF $LENGTH($PIECE(OCXP2,"^",2))
SET OCXP2=$PIECE(OCXP2,"^",2)
+8 IF '$TEST
SET OCXP2=$PIECE(OCXP2,"^",1)
+9 IF '$LENGTH(OCXP2)
SET OCXP2="NO LOC"
End DoDot:1
+10 IF $LENGTH(OCXP1)
IF $LENGTH(OCXP2)
QUIT OCXP1_"^"_OCXP2
+11 ;
+12 SET OCXP2=$GET(^DPT(+$GET(DFN),.1))
+13 IF $LENGTH(OCXP2)
QUIT "I^"_OCXP2
+14 QUIT "O^OUTPT"
+15 ;
TERMLKUP(OCXTERM,OCXLIST) ;
+1 QUIT $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
+2 ;