OCXOZ0E ;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
;
CHK436 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK1+33^OCXOZ02.
;
Q:$G(OCXOERR)
;
; Local CHK436 Variables
; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
; OCXDF(146) --> Data Field: INPT/OUTPT (FREE TEXT)
; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
;
; Local Extrinsic Functions
; FILE(DFN,127, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: INPATIENT)
; FILE(DFN,128, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: OUTPATIENT)
; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
; PATLOC( ----------> PATIENT LOCATION
;
I (OCXDF(146)="I"),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)),OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,127,"9,96,147") Q:OCXOERR
I (OCXDF(146)="O"),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)),OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,128,"9,96,147") Q:OCXOERR
Q
;
CHK446 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK58+22^OCXOZ05.
;
Q:$G(OCXOERR)
;
; Local CHK446 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(57) ---> Data Field: MOST RECENT RENAL TEST ABNORMAL FLAG (BOOLEAN)
; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
; OCXDF(155) --> Data Field: RECENT CONTRAST MEDIA CREATININE FLAG (BOOLEAN)
;
; Local Extrinsic Functions
; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
; RECCREAT( --------> RECENT CREATININE LAB PROCEDURE
;
S OCXDF(57)=$P($$ABREN(OCXDF(37)),"^",1) I $L(OCXDF(57)),(OCXDF(57)) S OCXDF(58)=$P($$ABREN(OCXDF(37)),"^",2),OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1) D CHK451
S OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1) I $L(OCXDF(154)) S OCXDF(155)=$P($$RECCREAT(OCXDF(37),OCXDF(154)),"^",1) I $L(OCXDF(155)),'(OCXDF(155)) D CHK482^OCXOZ0F
Q
;
CHK451 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK446+16.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; FILE(DFN,129, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: ABNORMAL RENAL RESULTS)
;
S OCXOERR=$$FILE(DFN,129,"58,154") Q:OCXOERR
Q
;
CHK458 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK196+15^OCXOZ09.
;
Q:$G(OCXOERR)
;
; Local CHK458 Variables
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
;
; Local Extrinsic Functions
; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
; FILE(DFN,130, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CONTRAST MEDIA ORDER)
;
S OCXDF(58)=$P($$ABREN(OCXDF(37)),"^",2),OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1),OCXOERR=$$FILE(DFN,130,"58,154") Q:OCXOERR
Q
;
CHK463 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK1+34^OCXOZ02.
;
Q:$G(OCXOERR)
;
; Local CHK463 Variables
; OCXDF(12) ---> Data Field: LAB RESULT (FREE TEXT)
; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
; OCXDF(113) --> Data Field: LAB TEST ID (NUMERIC)
; OCXDF(150) --> Data Field: LAB RESULT < THRESHOLD (BOOLEAN)
; OCXDF(151) --> Data Field: LAB RESULT > THRESHOLD (BOOLEAN)
; OCXDF(152) --> Data Field: LAB SPECIMEN ID (NUMERIC)
;
; Local Extrinsic Functions
; LABTHRSB( --------> LAB THRESHOLD EXCEEDED BOOLEAN
; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
;
S OCXDF(151)=$P($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),">"),"^",1) I $L(OCXDF(151)),(OCXDF(151)),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)) I $L(OCXDF(37)) D CHK469^OCXOZ0F
S OCXDF(150)=$P($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),"<"),"^",1) I $L(OCXDF(150)),(OCXDF(150)),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)) I $L(OCXDF(37)) D CHK476^OCXOZ0F
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
;
;
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
;
LABTHRSB(OCXLAB,OCXSPEC,OCXRSLT,OCXOP) ; Compiler Function: LAB THRESHOLD EXCEEDED BOOLEAN
;
S OCXRSLT=$TR($G(OCXRSLT),"<>=","")
Q:'$G(OCXLAB)!'$G(OCXSPEC)!'$G(OCXRSLT)!'$L($G(OCXOP)) 0
;
N OCXX,OCXPENT,OCXERR,OCXLABSP,OCXPVAL,OCXEXCD
S OCXEXCD=0,OCXLABSP=OCXLAB_";"_OCXSPEC
D ENVAL^XPAR(.OCXX,"ORB LAB "_OCXOP_" THRESHOLD",OCXLABSP,.OCXERR)
Q:+$G(ORERR)'=0 OCXEXCD
Q:+$G(OCXX)=0 OCXEXCD
S OCXPENT="" F S OCXPENT=$O(OCXX(OCXPENT)) Q:'OCXPENT!OCXEXCD=1 D
.S OCXPVAL=OCXX(OCXPENT,OCXLABSP)
.I $L(OCXPVAL) D
..I $P(OCXPENT,";",2)="VA(200,",@((+OCXRSLT)_OCXOP_OCXPVAL) D
...S OCXEXCD=1
Q OCXEXCD
;
ORDITEM(OIEN) ; Compiler Function: GET ORDERABLE ITEM FROM ORDER NUMBER
Q:'$G(OIEN) ""
;
N OITXT,X S OITXT=$$OI^ORQOR2(OIEN) Q:'OITXT "No orderable item found."
S X=$G(^ORD(101.43,+OITXT,0)) Q:'$L(X) "No orderable item found."
Q $P(X,U,1)
;
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"
;
RECCREAT(ORDFN,ORDAYS) ;extrinsic function to return most recent
;SERUM CREATININE within <ORDAYS> in format:
; test id^result units flag ref range collection d/t
N BDT,CDT,ORY,ORX,ORZ,X,ORI,ORJ,CREARSLT,LABFILE,SPECFILE
Q:'$L($G(ORDFN)) "0^"
Q:'$L($G(ORDAYS)) "0^"
D NOW^%DTC
S BDT=$$FMADD^XLFDT(%,"-"_ORDAYS,"","","")
K %
Q:'$L($G(BDT)) "0^"
S LABFILE=$$TERMLKUP("SERUM CREATININE",.ORY)
Q:$G(LABFILE)'=60 "0^"
Q:+$D(ORY)<1 "0^"
S SPECFILE=$$TERMLKUP("SERUM SPECIMEN",.ORX)
Q:$G(SPECFILE)'=61 "0^"
Q:+$D(ORX)<1 "0^"
S ORI=0 F S ORI=$O(ORY(ORI)) Q:'ORI I +$G(CREARSLT)<1 D
.S ORJ=0 F S ORJ=$O(ORX(ORJ)) Q:'ORJ I +$G(CREARSLT)<1 D
..S ORZ=$$LOCL^ORQQLR1(ORDFN,ORI,ORJ)
..Q:'$L($G(ORZ))
..S CDT=$P(ORZ,U,7)
..I CDT'<BDT S CREARSLT=1
Q:+$G(CREARSLT)<1 "0^"
Q $P(ORZ,U)_U_$P(ORZ,U,3)_" "_$P(ORZ,U,4)_" "_$P(ORZ,U,5)_" ("_$P(ORZ,U,6)_") "_$$FMTE^XLFDT(CDT,"2P")_U_$P(ORZ,U,3)
;
TERMLKUP(OCXTERM,OCXLIST) ;
Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
;
OCXOZ0E ;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 ;
CHK436 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK1+33^OCXOZ02.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK436 Variables
+6 ; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
+7 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+8 ; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
+9 ; OCXDF(146) --> Data Field: INPT/OUTPT (FREE TEXT)
+10 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
+11 ;
+12 ; Local Extrinsic Functions
+13 ; FILE(DFN,127, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: INPATIENT)
+14 ; FILE(DFN,128, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: OUTPATIENT)
+15 ; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
+16 ; PATLOC( ----------> PATIENT LOCATION
+17 ;
+18 IF (OCXDF(146)="I")
IF $LENGTH(OCXDF(34))
SET OCXDF(96)=$$ORDITEM(OCXDF(34))
SET OCXDF(147)=$PIECE($$PATLOC(OCXDF(37)),"^",2)
SET OCXOERR=$$FILE(DFN,127,"9,96,147")
IF OCXOERR
QUIT
+19 IF (OCXDF(146)="O")
IF $LENGTH(OCXDF(34))
SET OCXDF(96)=$$ORDITEM(OCXDF(34))
SET OCXDF(147)=$PIECE($$PATLOC(OCXDF(37)),"^",2)
SET OCXOERR=$$FILE(DFN,128,"9,96,147")
IF OCXOERR
QUIT
+20 QUIT
+21 ;
CHK446 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK58+22^OCXOZ05.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK446 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(57) ---> Data Field: MOST RECENT RENAL TEST ABNORMAL FLAG (BOOLEAN)
+8 ; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
+9 ; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
+10 ; OCXDF(155) --> Data Field: RECENT CONTRAST MEDIA CREATININE FLAG (BOOLEAN)
+11 ;
+12 ; Local Extrinsic Functions
+13 ; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
+14 ; RECCREAT( --------> RECENT CREATININE LAB PROCEDURE
+15 ;
+16 SET OCXDF(57)=$PIECE($$ABREN(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(57))
IF (OCXDF(57))
SET OCXDF(58)=$PIECE($$ABREN(OCXDF(37)),"^",2)
SET OCXDF(154)=$PIECE($$CMCDAYS^ORKRA(OCXDF(37)),"^",1)
DO CHK451
+17 SET OCXDF(154)=$PIECE($$CMCDAYS^ORKRA(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(154))
SET OCXDF(155)=$PIECE($$RECCREAT(OCXDF(37),OCXDF(154)),"^",1)
IF $LENGTH(OCXDF(155))
IF '(OCXDF(155))
DO CHK482^OCXOZ0F
+18 QUIT
+19 ;
CHK451 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK446+16.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; FILE(DFN,129, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: ABNORMAL RENAL RESULTS)
+7 ;
+8 SET OCXOERR=$$FILE(DFN,129,"58,154")
IF OCXOERR
QUIT
+9 QUIT
+10 ;
CHK458 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK196+15^OCXOZ09.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK458 Variables
+6 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+7 ; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
+8 ; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
+9 ;
+10 ; Local Extrinsic Functions
+11 ; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
+12 ; FILE(DFN,130, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CONTRAST MEDIA ORDER)
+13 ;
+14 SET OCXDF(58)=$PIECE($$ABREN(OCXDF(37)),"^",2)
SET OCXDF(154)=$PIECE($$CMCDAYS^ORKRA(OCXDF(37)),"^",1)
SET OCXOERR=$$FILE(DFN,130,"58,154")
IF OCXOERR
QUIT
+15 QUIT
+16 ;
CHK463 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK1+34^OCXOZ02.
+2 ;
+3 IF $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK463 Variables
+6 ; OCXDF(12) ---> Data Field: LAB RESULT (FREE TEXT)
+7 ; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
+8 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+9 ; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
+10 ; OCXDF(113) --> Data Field: LAB TEST ID (NUMERIC)
+11 ; OCXDF(150) --> Data Field: LAB RESULT < THRESHOLD (BOOLEAN)
+12 ; OCXDF(151) --> Data Field: LAB RESULT > THRESHOLD (BOOLEAN)
+13 ; OCXDF(152) --> Data Field: LAB SPECIMEN ID (NUMERIC)
+14 ;
+15 ; Local Extrinsic Functions
+16 ; LABTHRSB( --------> LAB THRESHOLD EXCEEDED BOOLEAN
+17 ; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
+18 ;
+19 SET OCXDF(151)=$PIECE($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),">"),"^",1)
IF $LENGTH(OCXDF(151))
IF (OCXDF(151))
IF $LENGTH(OCXDF(34))
SET OCXDF(96)=$$ORDITEM(OCXDF(34))
IF $LENGTH(OCXDF(37))
DO CHK469^OCXOZ0F
+20 SET OCXDF(150)=$PIECE($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),"<"),"^",1)
IF $LENGTH(OCXDF(150))
IF (OCXDF(150))
IF $LENGTH(OCXDF(34))
SET OCXDF(96)=$$ORDITEM(OCXDF(34))
IF $LENGTH(OCXDF(37))
DO CHK476^OCXOZ0F
+21 QUIT
+22 ;
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 ;
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 ;
LABTHRSB(OCXLAB,OCXSPEC,OCXRSLT,OCXOP) ; Compiler Function: LAB THRESHOLD EXCEEDED BOOLEAN
+1 ;
+2 SET OCXRSLT=$TRANSLATE($GET(OCXRSLT),"<>=","")
+3 IF '$GET(OCXLAB)!'$GET(OCXSPEC)!'$GET(OCXRSLT)!'$LENGTH($GET(OCXOP))
QUIT 0
+4 ;
+5 NEW OCXX,OCXPENT,OCXERR,OCXLABSP,OCXPVAL,OCXEXCD
+6 SET OCXEXCD=0
SET OCXLABSP=OCXLAB_";"_OCXSPEC
+7 DO ENVAL^XPAR(.OCXX,"ORB LAB "_OCXOP_" THRESHOLD",OCXLABSP,.OCXERR)
+8 IF +$GET(ORERR)'=0
QUIT OCXEXCD
+9 IF +$GET(OCXX)=0
QUIT OCXEXCD
+10 SET OCXPENT=""
FOR
SET OCXPENT=$ORDER(OCXX(OCXPENT))
IF 'OCXPENT!OCXEXCD=1
QUIT
Begin DoDot:1
+11 SET OCXPVAL=OCXX(OCXPENT,OCXLABSP)
+12 IF $LENGTH(OCXPVAL)
Begin DoDot:2
+13 IF $PIECE(OCXPENT,";",2)="VA(200,"
IF @((+OCXRSLT)_OCXOP_OCXPVAL)
Begin DoDot:3
+14 SET OCXEXCD=1
End DoDot:3
End DoDot:2
End DoDot:1
+15 QUIT OCXEXCD
+16 ;
ORDITEM(OIEN) ; Compiler Function: GET ORDERABLE ITEM FROM ORDER NUMBER
+1 IF '$GET(OIEN)
QUIT ""
+2 ;
+3 NEW OITXT,X
SET OITXT=$$OI^ORQOR2(OIEN)
IF 'OITXT
QUIT "No orderable item found."
+4 SET X=$GET(^ORD(101.43,+OITXT,0))
IF '$LENGTH(X)
QUIT "No orderable item found."
+5 QUIT $PIECE(X,U,1)
+6 ;
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 ;
RECCREAT(ORDFN,ORDAYS) ;extrinsic function to return most recent
+1 ;SERUM CREATININE within <ORDAYS> in format:
+2 ; test id^result units flag ref range collection d/t
+3 NEW BDT,CDT,ORY,ORX,ORZ,X,ORI,ORJ,CREARSLT,LABFILE,SPECFILE
+4 IF '$LENGTH($GET(ORDFN))
QUIT "0^"
+5 IF '$LENGTH($GET(ORDAYS))
QUIT "0^"
+6 DO NOW^%DTC
+7 SET BDT=$$FMADD^XLFDT(%,"-"_ORDAYS,"","","")
+8 KILL %
+9 IF '$LENGTH($GET(BDT))
QUIT "0^"
+10 SET LABFILE=$$TERMLKUP("SERUM CREATININE",.ORY)
+11 IF $GET(LABFILE)'=60
QUIT "0^"
+12 IF +$DATA(ORY)<1
QUIT "0^"
+13 SET SPECFILE=$$TERMLKUP("SERUM SPECIMEN",.ORX)
+14 IF $GET(SPECFILE)'=61
QUIT "0^"
+15 IF +$DATA(ORX)<1
QUIT "0^"
+16 SET ORI=0
FOR
SET ORI=$ORDER(ORY(ORI))
IF 'ORI
QUIT
IF +$GET(CREARSLT)<1
Begin DoDot:1
+17 SET ORJ=0
FOR
SET ORJ=$ORDER(ORX(ORJ))
IF 'ORJ
QUIT
IF +$GET(CREARSLT)<1
Begin DoDot:2
+18 SET ORZ=$$LOCL^ORQQLR1(ORDFN,ORI,ORJ)
+19 IF '$LENGTH($GET(ORZ))
QUIT
+20 SET CDT=$PIECE(ORZ,U,7)
+21 IF CDT'<BDT
SET CREARSLT=1
End DoDot:2
End DoDot:1
+22 IF +$GET(CREARSLT)<1
QUIT "0^"
+23 QUIT $PIECE(ORZ,U)_U_$PIECE(ORZ,U,3)_" "_$PIECE(ORZ,U,4)_" "_$PIECE(ORZ,U,5)_" ("_$PIECE(ORZ,U,6)_") "_$$FMTE^XLFDT(CDT,"2P")_U_$PIECE(ORZ,U,3)
+24 ;
TERMLKUP(OCXTERM,OCXLIST) ;
+1 QUIT $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
+2 ;