OCXOZ02 ;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
;
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)
;
; 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^OCXOZ07
I $L(OCXDF(5)),(OCXDF(5)="S") D CHK151^OCXOZ07
I $L(OCXDF(21)),(OCXDF(21)="S") D CHK157^OCXOZ07
I $L(OCXDF(37)) S OCXDF(146)=$P($$PATLOC(OCXDF(37)),"^",1) I $L(OCXDF(146)) D CHK436^OCXOZ0E
I $L(OCXDF(12)),$L(OCXDF(152)),$L(OCXDF(113)) D CHK463^OCXOZ0E
Q
;
CHK2 ; Look through the current environment for valid Event/Elements for this patient.
; Called from CHK1+25.
;
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 CHK302^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 CHK336^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"
;
OCXOZ02 ;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 ;
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 ;
+20 ; Local Extrinsic Functions
+21 ; FILE(DFN,16, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: HL7 OERR ORDER)
+22 ; LIST( ------------> IN LIST OPERATOR
+23 ; PATLOC( ----------> PATIENT LOCATION
+24 ;
+25 IF $LENGTH(OCXDF(23))
DO CHK2
+26 IF $LENGTH(OCXDF(1))
DO CHK12^OCXOZ03
+27 IF $LENGTH(OCXDF(2))
IF (OCXDF(2)="OR")
SET OCXOERR=$$FILE(DFN,16,"")
IF OCXOERR
QUIT
+28 IF $LENGTH(OCXDF(6))
DO CHK34^OCXOZ04
+29 IF $LENGTH(OCXDF(15))
IF $$LIST(OCXDF(15),"F,C")
DO CHK47^OCXOZ05
+30 IF $LENGTH(OCXDF(34))
DO CHK113^OCXOZ07
+31 IF $LENGTH(OCXDF(5))
IF (OCXDF(5)="S")
DO CHK151^OCXOZ07
+32 IF $LENGTH(OCXDF(21))
IF (OCXDF(21)="S")
DO CHK157^OCXOZ07
+33 IF $LENGTH(OCXDF(37))
SET OCXDF(146)=$PIECE($$PATLOC(OCXDF(37)),"^",1)
IF $LENGTH(OCXDF(146))
DO CHK436^OCXOZ0E
+34 IF $LENGTH(OCXDF(12))
IF $LENGTH(OCXDF(152))
IF $LENGTH(OCXDF(113))
DO CHK463^OCXOZ0E
+35 QUIT
+36 ;
CHK2 ; Look through the current environment for valid Event/Elements for this patient.
+1 ; Called from CHK1+25.
+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 CHK302^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 CHK336^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 ;