Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: OCXOZ0A

OCXOZ0A.m

Go to the documentation of this file.
  1. OCXOZ0A ;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
  1. ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
  1. ;
  1. ; ***************************************************************
  1. ; ** Warning: This routine is automatically generated by the **
  1. ; ** Rule Compiler (^OCXOCMP) and ANY changes to this routine **
  1. ; ** will be lost the next time the rule compiler executes. **
  1. ; ***************************************************************
  1. ;
  1. Q
  1. ;
  1. CHK226 ; Look through the current environment for valid Event/Elements for this patient.
  1. ; Called from CHK162+20^OCXOZ07.
  1. ;
  1. Q:$G(OCXOERR)
  1. ;
  1. ; Local CHK226 Variables
  1. ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
  1. ; OCXDF(43) ---> Data Field: OI NATIONAL ID (FREE TEXT)
  1. ; OCXDF(74) ---> Data Field: VA DRUG CLASS (FREE TEXT)
  1. ;
  1. ; Local Extrinsic Functions
  1. ;
  1. S OCXDF(74)=$P($$ENVAC^PSJORUT2(OCXDF(43)),"^",2) I $L(OCXDF(74)),(OCXDF(74)="AMINOGLYCOSIDES") S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) D CHK231
  1. Q
  1. ;
  1. CHK231 ; Look through the current environment for valid Event/Elements for this patient.
  1. ; Called from CHK226+12.
  1. ;
  1. Q:$G(OCXOERR)
  1. ;
  1. ; Local CHK231 Variables
  1. ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
  1. ; OCXDF(64) ---> Data Field: FORMATTED RENAL LAB RESULTS (FREE TEXT)
  1. ; OCXDF(76) ---> Data Field: CREATININE CLEARANCE (ESTIM) VALUE (NUMERIC)
  1. ;
  1. ; Local Extrinsic Functions
  1. ; CRCL( ------------> CREATININE CLEARANCE (ESTIMATED/CALCULATED)
  1. ; FILE(DFN,71, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: AMINOGLYCOSIDE ORDER SESSION)
  1. ; FLAB( ------------> FORMATTED LAB RESULTS
  1. ;
  1. S OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN"),OCXDF(76)=$P($$CRCL(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,71,"64,76") Q:OCXOERR
  1. Q
  1. ;
  1. CHK235 ; Look through the current environment for valid Event/Elements for this patient.
  1. ; Called from CHK198+10^OCXOZ09.
  1. ;
  1. Q:$G(OCXOERR)
  1. ;
  1. ; Local CHK235 Variables
  1. ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
  1. ; OCXDF(67) ---> Data Field: CONTRAST MEDIA CODE (FREE TEXT)
  1. ; OCXDF(73) ---> Data Field: ORDERABLE ITEM IEN (NUMERIC)
  1. ; OCXDF(78) ---> Data Field: PATIENT TOO BIG FOR SCANNER FLAG (BOOLEAN)
  1. ;
  1. ; Local Extrinsic Functions
  1. ; CLIST( -----------> STRING CONTAINS ONE OF A LIST OF VALUES
  1. ; CTMRI( -----------> CT MRI PHYSICAL LIMITS
  1. ; FILE(DFN,106, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA)
  1. ;
  1. S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXDF(78)=$P($$CTMRI(OCXDF(37),OCXDF(73)),"^",1) I $L(OCXDF(78)),(OCXDF(78)) D CHK240
  1. S OCXDF(67)=$$CM^ORQQRA(OCXDF(73)) I $L(OCXDF(67)),$$CLIST(OCXDF(67),"M,I,N") S OCXOERR=$$FILE(DFN,106,"") Q:OCXOERR
  1. Q
  1. ;
  1. CHK240 ; Look through the current environment for valid Event/Elements for this patient.
  1. ; Called from CHK235+16.
  1. ;
  1. Q:$G(OCXOERR)
  1. ;
  1. ; Local CHK240 Variables
  1. ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
  1. ; OCXDF(73) ---> Data Field: ORDERABLE ITEM IEN (NUMERIC)
  1. ; OCXDF(79) ---> Data Field: PATIENT TOO BIG FOR SCANNER TEXT (FREE TEXT)
  1. ; OCXDF(80) ---> Data Field: PATIENT TOO BIG FOR SCANNER DEVICE (FREE TEXT)
  1. ;
  1. ; Local Extrinsic Functions
  1. ; CTMRI( -----------> CT MRI PHYSICAL LIMITS
  1. ; FILE(DFN,72, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: PATIENT OVER CT OR MRI DEVICE LIMITATIONS)
  1. ;
  1. S OCXDF(79)=$P($$CTMRI(OCXDF(37),OCXDF(73)),"^",2),OCXDF(80)=$P($$CTMRI(OCXDF(37),OCXDF(73)),"^",3),OCXOERR=$$FILE(DFN,72,"79,80") Q:OCXOERR
  1. Q
  1. ;
  1. CHK246 ; Look through the current environment for valid Event/Elements for this patient.
  1. ; Called from CHK181+19^OCXOZ08.
  1. ;
  1. Q:$G(OCXOERR)
  1. ;
  1. ; Local CHK246 Variables
  1. ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
  1. ; OCXDF(64) ---> Data Field: FORMATTED RENAL LAB RESULTS (FREE TEXT)
  1. ;
  1. ; Local Extrinsic Functions
  1. ; FILE(DFN,73, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CREATININE CLEARANCE ESTIMATE)
  1. ; FLAB( ------------> FORMATTED LAB RESULTS
  1. ;
  1. S OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN"),OCXOERR=$$FILE(DFN,73,"64,76") Q:OCXOERR
  1. Q
  1. ;
  1. CLIST(DATA,LIST) ; DOES THE DATA FIELD CONTAIN AN ELEMENT IN THE LIST
  1. ;
  1. N PC F PC=1:1:$L(LIST,","),0 I PC,$L($P(LIST,",",PC)),(DATA[$P(LIST,",",PC)) Q
  1. Q ''PC
  1. ;
  1. CRCL(DFN) ; Compiler Function: CREATININE CLEARANCE (ESTIMATED/CALCULATED)
  1. ;
  1. N HT,AGE,SEX,SCR,SCRD,CRCL,LRWKLD,RSLT,ORW,ORH,PSCR
  1. N HTGT60,ABW,IBW,BWRATIO,BWDIFF,LOWBW,ADJBW
  1. S RSLT="0^<Unavailable>"
  1. S PSCR="^^^^^^0"
  1. D VITAL^ORQQVI("WEIGHT","WT",DFN,.ORW,0,"",$$NOW^XLFDT)
  1. Q:'$D(ORW) RSLT
  1. S ABW=$P(ORW(1),U,3) Q:+$G(ABW)<1 RSLT
  1. S ABW=ABW/2.2 ;ABW (actual body weight) in kg
  1. D VITAL^ORQQVI("HEIGHT","HT",DFN,.ORH,0,"",$$NOW^XLFDT)
  1. Q:'$D(ORH) RSLT
  1. S HT=$P(ORH(1),U,3) Q:+$G(HT)<1 RSLT
  1. S AGE=$$AGE^ORQPTQ4(DFN) Q:'AGE RSLT
  1. S SEX=$P($$SEX^ORQPTQ4(DFN),U,1) Q:'$L(SEX) RSLT
  1. S OCXTL="" Q:'$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE") RSLT
  1. S OCXTLS="" Q:'$$TERMLKUP^ORB31(.OCXTLS,"SERUM SPECIMEN") RSLT
  1. S SCR="",OCXT=0 F S OCXT=$O(OCXTL(OCXT)) Q:'OCXT D
  1. .S OCXTS=0 F S OCXTS=$O(OCXTLS(OCXTS)) Q:'OCXTS D
  1. ..S SCR=$$LOCL^ORQQLR1(DFN,$P(OCXTL(OCXT),U),$P(OCXTLS(OCXTS),U))
  1. ..I $P(SCR,U,7)>$P(PSCR,U,7) S PSCR=SCR
  1. S SCR=PSCR,SCRV=$P(SCR,U,3) Q:+$G(SCRV)<.01 RSLT
  1. S SCRD=$P(SCR,U,7) Q:'$L(SCRD) RSLT
  1. ;
  1. S HTGT60=$S(HT>60:(HT-60)*2.3,1:0) ;if ht > 60 inches
  1. I HTGT60>0 D
  1. .S IBW=$S(SEX="M":50+HTGT60,1:45.5+HTGT60) ;Ideal Body Weight
  1. .S BWRATIO=(ABW/IBW) ;body weight ratio
  1. .S BWDIFF=$S(ABW>IBW:ABW-IBW,1:0)
  1. .S LOWBW=$S(IBW<ABW:IBW,1:ABW)
  1. .I BWRATIO>1.3,(BWDIFF>0) S ADJBW=((0.3*BWDIFF)+IBW)
  1. .E S ADJBW=LOWBW
  1. I +$G(ADJBW)<1 D
  1. .S ADJBW=ABW
  1. S CRCL=(((140-AGE)*ADJBW)/(SCRV*72))
  1. ;
  1. S:SEX="M" RSLT=SCRD_U_$J(CRCL,1,1)
  1. S:SEX="F" RSLT=SCRD_U_$J((CRCL*.85),1,1)
  1. Q RSLT
  1. ;
  1. CTMRI(DFN,OCXOI) ; Compiler Function: CT MRI PHYSICAL LIMITS
  1. ;
  1. N OCXDEV,OCXWTP,OCXHTP,OCXWTL,OCXHTL
  1. S OCXDEV=$$TYPE^ORKRA(OCXOI)
  1. Q:'((OCXDEV="MRI")!(OCXDEV="CT")) 0_U
  1. S OCXWTP=$P($$WT^ORQPTQ4(DFN),U,2),OCXHTP=$P($$HT^ORQPTQ4(DFN),U,2)
  1. I (OCXDEV="CT") S OCXWTL=$$GET^XPAR("ALL","ORK CT LIMIT WT",1,"Q"),OCXHTL=$$GET^XPAR("ALL","ORK CT LIMIT HT",1,"Q")
  1. I (OCXDEV="CT"),(OCXWTL),(OCXWTP>OCXWTL) Q 1_U_"too heavy"_U_"CT scanner"
  1. I (OCXDEV="CT"),(OCXHTL),(OCXHTP>OCXHTL) Q 1_U_"too tall"_U_"CT scanner"
  1. I (OCXDEV="MRI") S OCXWTL=$$GET^XPAR("ALL","ORK MRI LIMIT WT",1,"Q"),OCXHTL=$$GET^XPAR("ALL","ORK MRI LIMIT HT",1,"Q")
  1. I (OCXDEV="MRI"),(OCXWTL),(OCXWTP>OCXWTL) Q 1_U_"too heavy"_U_"MRI scanner"
  1. I (OCXDEV="MRI"),(OCXHTL),(OCXHTP>OCXHTL) Q 1_U_"too tall"_U_"MRI scanner"
  1. Q 0_U
  1. ;
  1. FILE(DFN,OCXELE,OCXDFL) ; This Local Extrinsic Function logs a validated event/element.
  1. ;
  1. N OCXTIMN,OCXTIML,OCXTIMT1,OCXTIMT2,OCXDATA,OCXPC,OCXPC,OCXVAL,OCXSUB,OCXDFI
  1. S DFN=+$G(DFN),OCXELE=+$G(OCXELE)
  1. ;
  1. Q:'DFN 1 Q:'OCXELE 1 K OCXDATA
  1. ;
  1. S OCXDATA(DFN,OCXELE)=1
  1. F OCXPC=1:1:$L(OCXDFL,",") S OCXDFI=$P(OCXDFL,",",OCXPC) I OCXDFI D
  1. .S OCXVAL=$G(OCXDF(+OCXDFI)),OCXDATA(DFN,OCXELE,+OCXDFI)=OCXVAL
  1. ;
  1. M ^TMP("OCXCHK",$J,DFN)=OCXDATA(DFN)
  1. ;
  1. Q 0
  1. ;
  1. FLAB(DFN,OCXLIST,OCXSPEC) ; Compiler Function: FORMATTED LAB RESULTS
  1. ;
  1. Q:'$G(DFN) "<Patient Not Specified>"
  1. Q:'$L($G(OCXLIST)) "<Lab Tests Not Specified>"
  1. N OCXLAB,OCXOUT,OCXPC,OCXSL,SPEC S OCXOUT="",SPEC=""
  1. I $L($G(OCXSPEC)) S OCXSL=$$TERMLKUP(OCXSPEC,.OCXSL)
  1. F OCXPC=1:1:$L(OCXLIST,U) S OCXLAB=$P(OCXLIST,U,OCXPC) I $L(OCXLAB) D
  1. .N OCXX,OCXY,X,Y,DIC,TEST,SPEC,OCXTL,OCXA,OCXR
  1. .S OCXTL="" Q:'$$TERMLKUP(OCXLAB,.OCXTL)
  1. .S OCXX="",TEST=0 F S TEST=$O(OCXTL(TEST)) Q:'TEST D
  1. ..I $L($G(OCXSL)) D
  1. ...S SPEC=0 F S SPEC=$O(OCXSL(SPEC)) Q:'SPEC D
  1. ....S OCXX=$$LOCL^ORQQLR1(DFN,TEST,SPEC) I $L(OCXX) D
  1. .....S OCXA($P(OCXX,U,7))=OCXX
  1. ..I '$L($G(OCXSL)) S OCXX=$$LOCL^ORQQLR1(DFN,TEST,"")
  1. ..Q:'$L(OCXX)
  1. .I $D(OCXA) S OCXR="",OCXR=$O(OCXA(OCXR),-1),OCXX=OCXA(OCXR)
  1. .I $L(OCXX) D
  1. ..S OCXY=$P(OCXX,U,2)_": "_$P(OCXX,U,3)_" "_$P(OCXX,U,4)
  1. ..S OCXY=OCXY_" "_$S($L($P(OCXX,U,5)):"["_$P(OCXX,U,5)_"]",1:"")
  1. ..I $L($P(OCXX,U,7)) S OCXY=OCXY_" "_$$FMTE^XLFDT($P(OCXX,U,7),"2P")
  1. .S:$L(OCXOUT) OCXOUT=OCXOUT_" " S OCXOUT=OCXOUT_$G(OCXY)
  1. Q:'$L(OCXOUT) "<Results Not Found>" Q OCXOUT
  1. ;
  1. TERMLKUP(OCXTERM,OCXLIST) ;
  1. Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
  1. ;