OCXOZ02 ;SLC/RJS,CLA - Order Check Scan ;OCT 30,2024 at 12:49
;;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
;
CHK1 ; Look through the current environment for valid Event/Elements for this patient.
; Called from UPDATE+10^OCXOZ01.
;
Q:$G(OCXOERR)
;
; Local CHK1 Variables
; OCXDF(1) ----> Data Field: CONTROL CODE (FREE TEXT)
; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
; OCXDF(5) ----> Data Field: ORDER PRIORITY (OBR) (FREE TEXT)
; OCXDF(6) ----> Data Field: ABNORMAL FLAG (FREE TEXT)
; OCXDF(12) ---> Data Field: LAB RESULT (FREE TEXT)
; OCXDF(15) ---> Data Field: RESULT STATUS (OBX) (FREE TEXT)
; OCXDF(21) ---> Data Field: ORDER PRIORITY (ORC) (FREE TEXT)
; OCXDF(23) ---> Data Field: REQUEST STATUS (OBR) (FREE TEXT)
; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(113) --> Data Field: LAB TEST ID (NUMERIC)
; OCXDF(146) --> Data Field: INPT/OUTPT (FREE TEXT)
; OCXDF(152) --> Data Field: LAB SPECIMEN ID (NUMERIC)
; OCXDF(160) --> Data Field: CONTROL REASON (FREE TEXT)
; OCXDF(161) --> Data Field: ORDER TYPE (FREE TEXT)
;
; Local Extrinsic Functions
; FILE(DFN,16, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: HL7 OERR ORDER)
; LIST( ------------> IN LIST OPERATOR
; PATLOC( ----------> PATIENT LOCATION
;
I $L(OCXDF(23)) D CHK2
I $L(OCXDF(1)) D CHK12^OCXOZ03
I $L(OCXDF(2)),(OCXDF(2)="OR") S OCXOERR=$$FILE(DFN,16,"") Q:OCXOERR
I $L(OCXDF(6)) D CHK34^OCXOZ04
I $L(OCXDF(15)),$$LIST(OCXDF(15),"F,C") D CHK47^OCXOZ05
I $L(OCXDF(34)) D CHK113^OCXOZ06
I $L(OCXDF(5)),(OCXDF(5)="S") D CHK150^OCXOZ07
I $L(OCXDF(21)),(OCXDF(21)="S") D CHK156^OCXOZ07
I $L(OCXDF(37)) S OCXDF(146)=$P($$PATLOC(OCXDF(37)),"^",1) I $L(OCXDF(146)),$L(OCXDF(34)) S OCXDF(161)=$P($$ISCLORIP^ORB3F1(OCXDF(34),OCXDF(146)),"^",1) D CHK407^OCXOZ0D
I $L(OCXDF(12)),$L(OCXDF(152)),$L(OCXDF(113)) D CHK433^OCXOZ0E
I $L(OCXDF(160)) D CHK473^OCXOZ0F
Q
;
CHK2 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK1+27.
;
Q:$G(OCXOERR)
;
; Local CHK2 Variables
; OCXDF(1) ----> Data Field: CONTROL CODE (FREE TEXT)
; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
; OCXDF(23) ---> Data Field: REQUEST STATUS (OBR) (FREE TEXT)
;
; Local Extrinsic Functions
; LIST( ------------> IN LIST OPERATOR
;
I $$LIST(OCXDF(23),"F,C"),$L(OCXDF(1)),$$LIST(OCXDF(1),"RE"),$L(OCXDF(2)) D CHK6
I (OCXDF(23)="F"),$L(OCXDF(1)),$$LIST(OCXDF(1),"RE"),$L(OCXDF(2)) D CHK121^OCXOZ07
Q
;
CHK6 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK2+13.
;
Q:$G(OCXOERR)
;
; Local CHK6 Variables
; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
; OCXDF(55) ---> Data Field: SITE FLAGGED RESULT (BOOLEAN)
; 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
; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
; PATLOC( ----------> PATIENT LOCATION
;
I ($E(OCXDF(2),1,2)="LR"),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)) I $L(OCXDF(37)) S OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2) D CHK11
I (OCXDF(2)="RA"),$L(OCXDF(37)) S OCXDF(146)=$P($$PATLOC(OCXDF(37)),"^",1) I $L(OCXDF(146)),$L(OCXDF(34)) S OCXDF(55)=$$SITERES^ORB3F1(OCXDF(34),OCXDF(146)) D CHK301^OCXOZ0B
I (OCXDF(2)="GMRC"),$L(OCXDF(37)) S OCXDF(146)=$P($$PATLOC(OCXDF(37)),"^",1) I $L(OCXDF(146)),$L(OCXDF(34)) S OCXDF(55)=$$SITERES^ORB3F1(OCXDF(34),OCXDF(146)) D CHK335^OCXOZ0B
Q
;
CHK11 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK6+18.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; FILE(DFN,5, ------> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: HL7 FINAL LAB RESULT)
;
S OCXOERR=$$FILE(DFN,5,"12,37,96,113,147,152") Q:OCXOERR
Q
;
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)
;
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"
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HOCXOZ02 5967 printed Nov 22, 2024@17:35:48 Page 2
OCXOZ02 ;SLC/RJS,CLA - Order Check Scan ;OCT 30,2024 at 12:49
+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 ;
CHK1 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from UPDATE+10^OCXOZ01.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK1 Variables
+6 ; OCXDF(1) ----> Data Field: CONTROL CODE (FREE TEXT)
+7 ; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
+8 ; OCXDF(5) ----> Data Field: ORDER PRIORITY (OBR) (FREE TEXT)
+9 ; OCXDF(6) ----> Data Field: ABNORMAL FLAG (FREE TEXT)
+10 ; OCXDF(12) ---> Data Field: LAB RESULT (FREE TEXT)
+11 ; OCXDF(15) ---> Data Field: RESULT STATUS (OBX) (FREE TEXT)
+12 ; OCXDF(21) ---> Data Field: ORDER PRIORITY (ORC) (FREE TEXT)
+13 ; OCXDF(23) ---> Data Field: REQUEST STATUS (OBR) (FREE TEXT)
+14 ; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
+15 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+16 ; OCXDF(113) --> Data Field: LAB TEST ID (NUMERIC)
+17 ; OCXDF(146) --> Data Field: INPT/OUTPT (FREE TEXT)
+18 ; OCXDF(152) --> Data Field: LAB SPECIMEN ID (NUMERIC)
+19 ; OCXDF(160) --> Data Field: CONTROL REASON (FREE TEXT)
+20 ; OCXDF(161) --> Data Field: ORDER TYPE (FREE TEXT)
+21 ;
+22 ; Local Extrinsic Functions
+23 ; FILE(DFN,16, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: HL7 OERR ORDER)
+24 ; LIST( ------------> IN LIST OPERATOR
+25 ; PATLOC( ----------> PATIENT LOCATION
+26 ;
+27 IF $LENGTH(OCXDF(23))
DO CHK2
+28 IF $LENGTH(OCXDF(1))
DO CHK12^OCXOZ03
+29 IF $LENGTH(OCXDF(2))
IF (OCXDF(2)="OR")
SET OCXOERR=$$FILE(DFN,16,"")
if OCXOERR
QUIT
+30 IF $LENGTH(OCXDF(6))
DO CHK34^OCXOZ04
+31 IF $LENGTH(OCXDF(15))
IF $$LIST(OCXDF(15),"F,C")
DO CHK47^OCXOZ05
+32 IF $LENGTH(OCXDF(34))
DO CHK113^OCXOZ06
+33 IF $LENGTH(OCXDF(5))
IF (OCXDF(5)="S")
DO CHK150^OCXOZ07
+34 IF $LENGTH(OCXDF(21))
IF (OCXDF(21)="S")
DO CHK156^OCXOZ07
+35 IF $LENGTH(OCXDF(37))
SET OCXDF(146)=$PIECE($$PATLOC(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(146))
IF $LENGTH(OCXDF(34))
SET OCXDF(161)=$PIECE($$ISCLORIP^ORB3F1(OCXDF(34),OCXDF(146)),"^",1)
DO CHK407^OCXOZ0D
+36 IF $LENGTH(OCXDF(12))
IF $LENGTH(OCXDF(152))
IF $LENGTH(OCXDF(113))
DO CHK433^OCXOZ0E
+37 IF $LENGTH(OCXDF(160))
DO CHK473^OCXOZ0F
+38 QUIT
+39 ;
CHK2 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK1+27.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK2 Variables
+6 ; OCXDF(1) ----> Data Field: CONTROL CODE (FREE TEXT)
+7 ; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
+8 ; OCXDF(23) ---> Data Field: REQUEST STATUS (OBR) (FREE TEXT)
+9 ;
+10 ; Local Extrinsic Functions
+11 ; LIST( ------------> IN LIST OPERATOR
+12 ;
+13 IF $$LIST(OCXDF(23),"F,C")
IF $LENGTH(OCXDF(1))
IF $$LIST(OCXDF(1),"RE")
IF $LENGTH(OCXDF(2))
DO CHK6
+14 IF (OCXDF(23)="F")
IF $LENGTH(OCXDF(1))
IF $$LIST(OCXDF(1),"RE")
IF $LENGTH(OCXDF(2))
DO CHK121^OCXOZ07
+15 QUIT
+16 ;
CHK6 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK2+13.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local CHK6 Variables
+6 ; OCXDF(2) ----> Data Field: FILLER (FREE TEXT)
+7 ; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
+8 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
+9 ; OCXDF(55) ---> Data Field: SITE FLAGGED RESULT (BOOLEAN)
+10 ; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
+11 ; OCXDF(146) --> Data Field: INPT/OUTPT (FREE TEXT)
+12 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
+13 ;
+14 ; Local Extrinsic Functions
+15 ; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
+16 ; PATLOC( ----------> PATIENT LOCATION
+17 ;
+18 IF ($EXTRACT(OCXDF(2),1,2)="LR")
IF $LENGTH(OCXDF(34))
SET OCXDF(96)=$$ORDITEM(OCXDF(34))
IF $LENGTH(OCXDF(37))
SET OCXDF(147)=$PIECE($$PATLOC(OCXDF(37)),"^",2)
DO CHK11
+19 IF (OCXDF(2)="RA")
IF $LENGTH(OCXDF(37))
SET OCXDF(146)=$PIECE($$PATLOC(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(146))
IF $LENGTH(OCXDF(34))
SET OCXDF(55)=$$SITERES^ORB3F1(OCXDF(34),OCXDF(146))
DO CHK301^OCXOZ0B
+20 IF (OCXDF(2)="GMRC")
IF $LENGTH(OCXDF(37))
SET OCXDF(146)=$PIECE($$PATLOC(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(146))
IF $LENGTH(OCXDF(34))
SET OCXDF(55)=$$SITERES^ORB3F1(OCXDF(34),OCXDF(146))
DO CHK335^OCXOZ0B
+21 QUIT
+22 ;
CHK11 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK6+18.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; FILE(DFN,5, ------> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: HL7 FINAL LAB RESULT)
+7 ;
+8 SET OCXOERR=$$FILE(DFN,5,"12,37,96,113,147,152")
if OCXOERR
QUIT
+9 QUIT
+10 ;
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 ;
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 ;