OCXOZ0W ;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
;
R61R1A ; Verify all Event/Elements of Rule #61 'CREATININE CLEARANCE ESTIMATION' Relation #1 'IF CREAT CLEAR AND ( CREATININE CLEARANCE DATE OR ...'
; Called from EL73+5^OCXOZ0H, and EL96+5^OCXOZ0H, and EL97+5^OCXOZ0H.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; MCE73( -----------> Verify Event/Element: 'CREATININE CLEARANCE ESTIMATE'
; MCE96( -----------> Verify Event/Element: 'CREATININE CLEARANCE DATE/TIME'
; MCE97( -----------> Verify Event/Element: 'RENAL RESULTS'
;
Q:$G(^OCXS(860.2,61,"INACT"))
;
I $$MCE73 D
.I $$MCE96 D R61R1B
.I $$MCE97 D R61R1B
Q
;
R61R1B ; Send Order Check, Notication messages and/or Execute code for Rule #61 'CREATININE CLEARANCE ESTIMATION' Relation #1 'IF CREAT CLEAR AND ( CREATININE CLEARANCE DATE OR ...'
; Called from R61R1A+13.
;
Q:$G(OCXOERR)
;
; Local Extrinsic Functions
; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
;
Q:$D(OCXRULE("R61R1B"))
;
N OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
I ($G(OCXOSRC)="CPRS ORDER PRESCAN") S OCXCMSG=(+OCXPSD)_"^1^^Est. CrCl: "_$$GETDATA(DFN,"73^96^97",76)_" ("_$$GETDATA(DFN,"73^96^97",64)_") [Est. CrCl based on modified Cockcroft-Gault equation using Adjusted Body Weight (if ht > 60 in.)]" I 1
E S OCXCMSG="Est. CrCl: "_$$GETDATA(DFN,"73^96^97",76)_" ("_$$GETDATA(DFN,"73^96^97",64)_") [Est. CrCl based on modified Cockcroft-Gault equation using Adjusted Body Weight (if ht > 60 in.)]"
S OCXNMSG=""
;
Q:$G(OCXOERR)
;
; Send Order Check Message
;
S OCXOCMSG($O(OCXOCMSG(999999),-1)+1)=OCXCMSG
Q
;
CRCL(DFN) ; Compiler Function: CREATININE CLEARANCE (ESTIMATED/CALCULATED)
;
N HT,AGE,SEX,SCR,SCRD,CRCL,LRWKLD,RSLT,ORW,ORH,PSCR
N HTGT60,ABW,IBW,BWRATIO,BWDIFF,LOWBW,ADJBW
S RSLT="0^<Unavailable>"
S PSCR="^^^^^^0"
D VITAL^ORQQVI("WEIGHT","WT",DFN,.ORW,0,"",$$NOW^XLFDT)
Q:'$D(ORW) RSLT
S ABW=$P(ORW(1),U,3) Q:+$G(ABW)<1 RSLT
S ABW=ABW/2.2 ;ABW (actual body weight) in kg
D VITAL^ORQQVI("HEIGHT","HT",DFN,.ORH,0,"",$$NOW^XLFDT)
Q:'$D(ORH) RSLT
S HT=$P(ORH(1),U,3) Q:+$G(HT)<1 RSLT
S AGE=$$AGE^ORQPTQ4(DFN) Q:'AGE RSLT
S SEX=$P($$SEX^ORQPTQ4(DFN),U,1) Q:'$L(SEX) RSLT
S OCXTL="" Q:'$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE") RSLT
S OCXTLS="" Q:'$$TERMLKUP^ORB31(.OCXTLS,"SERUM SPECIMEN") RSLT
S SCR="",OCXT=0 F S OCXT=$O(OCXTL(OCXT)) Q:'OCXT D
.S OCXTS=0 F S OCXTS=$O(OCXTLS(OCXTS)) Q:'OCXTS D
..S SCR=$$LOCL^ORQQLR1(DFN,$P(OCXTL(OCXT),U),$P(OCXTLS(OCXTS),U))
..I $P(SCR,U,7)>$P(PSCR,U,7) S PSCR=SCR
S SCR=PSCR,SCRV=$P(SCR,U,3) Q:+$G(SCRV)<.01 RSLT
S SCRD=$P(SCR,U,7) Q:'$L(SCRD) RSLT
;
S HTGT60=$S(HT>60:(HT-60)*2.3,1:0) ;if ht > 60 inches
I HTGT60>0 D
.S IBW=$S(SEX="M":50+HTGT60,1:45.5+HTGT60) ;Ideal Body Weight
.S BWRATIO=(ABW/IBW) ;body weight ratio
.S BWDIFF=$S(ABW>IBW:ABW-IBW,1:0)
.S LOWBW=$S(IBW<ABW:IBW,1:ABW)
.I BWRATIO>1.3,(BWDIFF>0) S ADJBW=((0.3*BWDIFF)+IBW)
.E S ADJBW=LOWBW
I +$G(ADJBW)<1 D
.S ADJBW=ABW
S CRCL=(((140-AGE)*ADJBW)/(SCRV*72))
;
S:SEX="M" RSLT=SCRD_U_$J(CRCL,1,1)
S:SEX="F" RSLT=SCRD_U_$J((CRCL*.85),1,1)
Q RSLT
;
DT2INT(OCXDT) ; This Local Extrinsic Function converts a date into an integer
; By taking the Years, Months, Days, Hours and Minutes converting
; Them into Seconds and then adding them all together into one big integer
;
Q:'$L($G(OCXDT)) ""
N OCXDIFF,OCXVAL S (OCXDIFF,OCXVAL)=0
;
I $L(OCXDT),'OCXDT,(OCXDT[" at ") D ; EXTERNAL EXPERT SYSTEM FORMAT 1 TO EXTERNAL FORMAT
.N OCXHR,OCXMIN,OCXTIME
.S OCXTIME=$P($P(OCXDT," at ",2),".",1),OCXHR=$P(OCXTIME,":",1),OCXMIN=$P(OCXTIME,":",2)
.S:(OCXDT["Midnight") OCXHR=00
.S:(OCXDT["PM") OCXHR=OCXHR+12
.S OCXDT=$P(OCXDT," at ")_"@"_$E(OCXHR+100,2,3)_$E(OCXMIN+100,2,3)
;
I $L(OCXDT),(OCXDT?1.2N1"/"1.2N.1" ".2N.1":".2N) D ; EXTERNAL EXPERT SYSTEM FORMAT 2 TO EXTERNAL FORMAT
.N OCXMON
.S OCXMON=$P("January^February^March^April^May^June^July^August^September^October^November^December",U,$P(OCXDT,"/",1))
.I $L($P(OCXDT," ",2)) S OCXDT=OCXMON_" "_$P($P(OCXDT," ",1),"/",2)_"@"_$TR($P(OCXDT," ",2),":","")
.E S OCXDT=OCXMON_" "_$P($P(OCXDT," ",1),"/",2)
;
I $L(OCXDT),(OCXDT?1.2N1"/"1.2N1"/"1.2N.1" ".2N.1":".2N) D ; EXTERNAL EXPERT SYSTEM FORMAT 3 TO EXTERNAL FORMAT
.N OCXMON
.S OCXMON=$P("January^February^March^April^May^June^July^August^September^October^November^December",U,$P(OCXDT,"/",1))
.I $L($P(OCXDT," ",2)) S OCXDT=OCXMON_" "_$P($P(OCXDT," ",1),"/",2)_","_$P($P(OCXDT," ",1),"/",3)_"@"_$TR($P(OCXDT," ",2),":","")
.E S OCXDT=OCXMON_" "_$P($P(OCXDT," ",1),"/",2)_", "_$P($P(OCXDT," ",1),"/",3)
;
I $L(OCXDT),'OCXDT D ; EXTERNAL FORMAT TO INTERNAL FILEMAN FORMAT
.I (OCXDT["@0000") S OCXDT=$P(OCXDT,"@",1),OCXDIFF=1
.N %DT,X,Y S X=OCXDT,%DT="" S:(OCXDT["@")!(OCXDT="N") %DT="T" D ^%DT S OCXDT=+Y
;
I ($L(OCXDT\1)>7) S OCXDT=$$HL7TFM^XLFDT(OCXDT) ; HL7 FORMAT TO INTERNAL FILEMAN FORMAT
;
I ($L(OCXDT\1)=7) S OCXDT=$$FMTH^XLFDT(+OCXDT) ; INTERNAL FILEMAN FORMAT TO $H FORMAT
;
I (OCXDT?5N1","1.5N) S OCXVAL=(OCXDT*86400)+$P(OCXDT,",",2) ; $H FORMAT TO EXPERT SYSTEM INTERNAL FORMAT
;
Q OCXVAL
;
FLAB(DFN,OCXLIST,OCXSPEC) ; Compiler Function: FORMATTED LAB RESULTS
;
Q:'$G(DFN) "<Patient Not Specified>"
Q:'$L($G(OCXLIST)) "<Lab Tests Not Specified>"
N OCXLAB,OCXOUT,OCXPC,OCXSL,SPEC S OCXOUT="",SPEC=""
I $L($G(OCXSPEC)) S OCXSL=$$TERMLKUP(OCXSPEC,.OCXSL)
F OCXPC=1:1:$L(OCXLIST,U) S OCXLAB=$P(OCXLIST,U,OCXPC) I $L(OCXLAB) D
.N OCXX,OCXY,X,Y,DIC,TEST,SPEC,OCXTL,OCXA,OCXR
.S OCXTL="" Q:'$$TERMLKUP(OCXLAB,.OCXTL)
.S OCXX="",TEST=0 F S TEST=$O(OCXTL(TEST)) Q:'TEST D
..I $L($G(OCXSL)) D
...S SPEC=0 F S SPEC=$O(OCXSL(SPEC)) Q:'SPEC D
....S OCXX=$$LOCL^ORQQLR1(DFN,TEST,SPEC) I $L(OCXX) D
.....S OCXA($P(OCXX,U,7))=OCXX
..I '$L($G(OCXSL)) S OCXX=$$LOCL^ORQQLR1(DFN,TEST,"")
..Q:'$L(OCXX)
.I $D(OCXA) S OCXR="",OCXR=$O(OCXA(OCXR),-1),OCXX=OCXA(OCXR)
.I $L(OCXX) D
..S OCXY=$P(OCXX,U,2)_": "_$P(OCXX,U,3)_" "_$P(OCXX,U,4)
..S OCXY=OCXY_" "_$S($L($P(OCXX,U,5)):"["_$P(OCXX,U,5)_"]",1:"")
..I $L($P(OCXX,U,7)) S OCXY=OCXY_" "_$$FMTE^XLFDT($P(OCXX,U,7),"2P")
.S:$L(OCXOUT) OCXOUT=OCXOUT_" " S OCXOUT=OCXOUT_$G(OCXY)
Q:'$L(OCXOUT) "<Results Not Found>" Q OCXOUT
;
GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
;
N OCXE,VAL,PC S VAL=""
F PC=1:1:$L(OCXL,U) S OCXE=$P(OCXL,U,PC) I OCXE S VAL=$G(^TMP("OCXCHK",$J,DFN,OCXE,OCXDFI)) Q:$L(VAL)
Q VAL
;
MCE73() ; Verify Event/Element: CREATININE CLEARANCE ESTIMATE
;
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(73,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),73)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),73))
Q 0
;
MCE96() ; Verify Event/Element: CREATININE CLEARANCE DATE/TIME
;
; OCXDF(76) -> CREATININE CLEARANCE (ESTIM) VALUE data field
; OCXDF(64) -> FORMATTED RENAL LAB RESULTS data field
; OCXDF(77) -> CREATININE CLEARANCE (ESTIM) DATE data field
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(96,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),96)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),96))
S OCXRES(96)=0,OCXDF(77)=$$DT2INT($P($$CRCL(OCXDF(37)),"^",1)) I $L(OCXDF(77)) S OCXRES(96,77)=OCXDF(77) I (OCXDF(77)>$$DT2INT(0))
E Q 0
S OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN"),OCXDF(76)=$P($$CRCL(OCXDF(37)),"^",2),OCXRES(96)=11 M ^TMP("OCXCHK",$J,OCXDF(37),96)=OCXRES(96)
Q +OCXRES(96)
;
MCE97() ; Verify Event/Element: RENAL RESULTS
;
; OCXDF(76) -> CREATININE CLEARANCE (ESTIM) VALUE data field
; OCXDF(64) -> FORMATTED RENAL LAB RESULTS data field
; OCXDF(37) -> PATIENT IEN data field
;
N OCXRES
S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXRES(97,37)=OCXDF(37)
Q:'(OCXDF(37)) 0 I $D(^TMP("OCXCHK",$J,OCXDF(37),97)) Q $G(^TMP("OCXCHK",$J,OCXDF(37),97))
S OCXRES(97)=0,OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN") I '(OCXDF(64)="<Results Not Found>")
E Q 0
S OCXDF(76)=$P($$CRCL(OCXDF(37)),"^",2),OCXRES(97)=11 M ^TMP("OCXCHK",$J,OCXDF(37),97)=OCXRES(97)
Q +OCXRES(97)
;
TERMLKUP(OCXTERM,OCXLIST) ;
Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HOCXOZ0W 8930 printed Nov 22, 2024@17:36:16 Page 2
OCXOZ0W ;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 ;
R61R1A ; Verify all Event/Elements of Rule #61 'CREATININE CLEARANCE ESTIMATION' Relation #1 'IF CREAT CLEAR AND ( CREATININE CLEARANCE DATE OR ...'
+1 ; Called from EL73+5^OCXOZ0H, and EL96+5^OCXOZ0H, and EL97+5^OCXOZ0H.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; MCE73( -----------> Verify Event/Element: 'CREATININE CLEARANCE ESTIMATE'
+7 ; MCE96( -----------> Verify Event/Element: 'CREATININE CLEARANCE DATE/TIME'
+8 ; MCE97( -----------> Verify Event/Element: 'RENAL RESULTS'
+9 ;
+10 if $GET(^OCXS(860.2,61,"INACT"))
QUIT
+11 ;
+12 IF $$MCE73
Begin DoDot:1
+13 IF $$MCE96
DO R61R1B
+14 IF $$MCE97
DO R61R1B
End DoDot:1
+15 QUIT
+16 ;
R61R1B ; Send Order Check, Notication messages and/or Execute code for Rule #61 'CREATININE CLEARANCE ESTIMATION' Relation #1 'IF CREAT CLEAR AND ( CREATININE CLEARANCE DATE OR ...'
+1 ; Called from R61R1A+13.
+2 ;
+3 if $GET(OCXOERR)
QUIT
+4 ;
+5 ; Local Extrinsic Functions
+6 ; GETDATA( ---------> GET DATA FROM THE ACTIVE DATA FILE
+7 ;
+8 if $DATA(OCXRULE("R61R1B"))
QUIT
+9 ;
+10 NEW OCXNMSG,OCXCMSG,OCXPORD,OCXFORD,OCXDATA,OCXNUM,OCXDUZ,OCXQUIT,OCXLOGS,OCXLOGD
+11 IF ($GET(OCXOSRC)="CPRS ORDER PRESCAN")
SET OCXCMSG=(+OCXPSD)_"^1^^Est. CrCl: "_$$GETDATA(DFN,"73^96^97",76)_" ("_$$GETDATA(DFN,"73^96^97",64)_") [Est. CrCl based on modified Cockcroft-Gault equation using Adjusted Body Weight (if ht > 60 in.)]"
IF 1
+12 IF '$TEST
SET OCXCMSG="Est. CrCl: "_$$GETDATA(DFN,"73^96^97",76)_" ("_$$GETDATA(DFN,"73^96^97",64)_") [Est. CrCl based on modified Cockcroft-Gault equation using Adjusted Body Weight (if ht > 60 in.)]"
+13 SET OCXNMSG=""
+14 ;
+15 if $GET(OCXOERR)
QUIT
+16 ;
+17 ; Send Order Check Message
+18 ;
+19 SET OCXOCMSG($ORDER(OCXOCMSG(999999),-1)+1)=OCXCMSG
+20 QUIT
+21 ;
CRCL(DFN) ; Compiler Function: CREATININE CLEARANCE (ESTIMATED/CALCULATED)
+1 ;
+2 NEW HT,AGE,SEX,SCR,SCRD,CRCL,LRWKLD,RSLT,ORW,ORH,PSCR
+3 NEW HTGT60,ABW,IBW,BWRATIO,BWDIFF,LOWBW,ADJBW
+4 SET RSLT="0^<Unavailable>"
+5 SET PSCR="^^^^^^0"
+6 DO VITAL^ORQQVI("WEIGHT","WT",DFN,.ORW,0,"",$$NOW^XLFDT)
+7 if '$DATA(ORW)
QUIT RSLT
+8 SET ABW=$PIECE(ORW(1),U,3)
if +$GET(ABW)<1
QUIT RSLT
+9 ;ABW (actual body weight) in kg
SET ABW=ABW/2.2
+10 DO VITAL^ORQQVI("HEIGHT","HT",DFN,.ORH,0,"",$$NOW^XLFDT)
+11 if '$DATA(ORH)
QUIT RSLT
+12 SET HT=$PIECE(ORH(1),U,3)
if +$GET(HT)<1
QUIT RSLT
+13 SET AGE=$$AGE^ORQPTQ4(DFN)
if 'AGE
QUIT RSLT
+14 SET SEX=$PIECE($$SEX^ORQPTQ4(DFN),U,1)
if '$LENGTH(SEX)
QUIT RSLT
+15 SET OCXTL=""
if '$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE")
QUIT RSLT
+16 SET OCXTLS=""
if '$$TERMLKUP^ORB31(.OCXTLS,"SERUM SPECIMEN")
QUIT RSLT
+17 SET SCR=""
SET OCXT=0
FOR
SET OCXT=$ORDER(OCXTL(OCXT))
if 'OCXT
QUIT
Begin DoDot:1
+18 SET OCXTS=0
FOR
SET OCXTS=$ORDER(OCXTLS(OCXTS))
if 'OCXTS
QUIT
Begin DoDot:2
+19 SET SCR=$$LOCL^ORQQLR1(DFN,$PIECE(OCXTL(OCXT),U),$PIECE(OCXTLS(OCXTS),U))
+20 IF $PIECE(SCR,U,7)>$PIECE(PSCR,U,7)
SET PSCR=SCR
End DoDot:2
End DoDot:1
+21 SET SCR=PSCR
SET SCRV=$PIECE(SCR,U,3)
if +$GET(SCRV)<.01
QUIT RSLT
+22 SET SCRD=$PIECE(SCR,U,7)
if '$LENGTH(SCRD)
QUIT RSLT
+23 ;
+24 ;if ht > 60 inches
SET HTGT60=$SELECT(HT>60:(HT-60)*2.3,1:0)
+25 IF HTGT60>0
Begin DoDot:1
+26 ;Ideal Body Weight
SET IBW=$SELECT(SEX="M":50+HTGT60,1:45.5+HTGT60)
+27 ;body weight ratio
SET BWRATIO=(ABW/IBW)
+28 SET BWDIFF=$SELECT(ABW>IBW:ABW-IBW,1:0)
+29 SET LOWBW=$SELECT(IBW<ABW:IBW,1:ABW)
+30 IF BWRATIO>1.3
IF (BWDIFF>0)
SET ADJBW=((0.3*BWDIFF)+IBW)
+31 IF '$TEST
SET ADJBW=LOWBW
End DoDot:1
+32 IF +$GET(ADJBW)<1
Begin DoDot:1
+33 SET ADJBW=ABW
End DoDot:1
+34 SET CRCL=(((140-AGE)*ADJBW)/(SCRV*72))
+35 ;
+36 if SEX="M"
SET RSLT=SCRD_U_$JUSTIFY(CRCL,1,1)
+37 if SEX="F"
SET RSLT=SCRD_U_$JUSTIFY((CRCL*.85),1,1)
+38 QUIT RSLT
+39 ;
DT2INT(OCXDT) ; This Local Extrinsic Function converts a date into an integer
+1 ; By taking the Years, Months, Days, Hours and Minutes converting
+2 ; Them into Seconds and then adding them all together into one big integer
+3 ;
+4 if '$LENGTH($GET(OCXDT))
QUIT ""
+5 NEW OCXDIFF,OCXVAL
SET (OCXDIFF,OCXVAL)=0
+6 ;
+7 ; EXTERNAL EXPERT SYSTEM FORMAT 1 TO EXTERNAL FORMAT
IF $LENGTH(OCXDT)
IF 'OCXDT
IF (OCXDT[" at ")
Begin DoDot:1
+8 NEW OCXHR,OCXMIN,OCXTIME
+9 SET OCXTIME=$PIECE($PIECE(OCXDT," at ",2),".",1)
SET OCXHR=$PIECE(OCXTIME,":",1)
SET OCXMIN=$PIECE(OCXTIME,":",2)
+10 if (OCXDT["Midnight")
SET OCXHR=00
+11 if (OCXDT["PM")
SET OCXHR=OCXHR+12
+12 SET OCXDT=$PIECE(OCXDT," at ")_"@"_$EXTRACT(OCXHR+100,2,3)_$EXTRACT(OCXMIN+100,2,3)
End DoDot:1
+13 ;
+14 ; EXTERNAL EXPERT SYSTEM FORMAT 2 TO EXTERNAL FORMAT
IF $LENGTH(OCXDT)
IF (OCXDT?1.2N1"/"1.2N.1" ".2N.1":".2N)
Begin DoDot:1
+15 NEW OCXMON
+16 SET OCXMON=$PIECE("January^February^March^April^May^June^July^August^September^October^November^December",U,$PIECE(OCXDT,"/",1))
+17 IF $LENGTH($PIECE(OCXDT," ",2))
SET OCXDT=OCXMON_" "_$PIECE($PIECE(OCXDT," ",1),"/",2)_"@"_$TRANSLATE($PIECE(OCXDT," ",2),":","")
+18 IF '$TEST
SET OCXDT=OCXMON_" "_$PIECE($PIECE(OCXDT," ",1),"/",2)
End DoDot:1
+19 ;
+20 ; EXTERNAL EXPERT SYSTEM FORMAT 3 TO EXTERNAL FORMAT
IF $LENGTH(OCXDT)
IF (OCXDT?1.2N1"/"1.2N1"/"1.2N.1" ".2N.1":".2N)
Begin DoDot:1
+21 NEW OCXMON
+22 SET OCXMON=$PIECE("January^February^March^April^May^June^July^August^September^October^November^December",U,$PIECE(OCXDT,"/",1))
+23 IF $LENGTH($PIECE(OCXDT," ",2))
SET OCXDT=OCXMON_" "_$PIECE($PIECE(OCXDT," ",1),"/",2)_","_$PIECE($PIECE(OCXDT," ",1),"/",3)_"@"_$TRANSLATE($PIECE(OCXDT," ",2),":","")
+24 IF '$TEST
SET OCXDT=OCXMON_" "_$PIECE($PIECE(OCXDT," ",1),"/",2)_", "_$PIECE($PIECE(OCXDT," ",1),"/",3)
End DoDot:1
+25 ;
+26 ; EXTERNAL FORMAT TO INTERNAL FILEMAN FORMAT
IF $LENGTH(OCXDT)
IF 'OCXDT
Begin DoDot:1
+27 IF (OCXDT["@0000")
SET OCXDT=$PIECE(OCXDT,"@",1)
SET OCXDIFF=1
+28 NEW %DT,X,Y
SET X=OCXDT
SET %DT=""
if (OCXDT["@")!(OCXDT="N")
SET %DT="T"
DO ^%DT
SET OCXDT=+Y
End DoDot:1
+29 ;
+30 ; HL7 FORMAT TO INTERNAL FILEMAN FORMAT
IF ($LENGTH(OCXDT\1)>7)
SET OCXDT=$$HL7TFM^XLFDT(OCXDT)
+31 ;
+32 ; INTERNAL FILEMAN FORMAT TO $H FORMAT
IF ($LENGTH(OCXDT\1)=7)
SET OCXDT=$$FMTH^XLFDT(+OCXDT)
+33 ;
+34 ; $H FORMAT TO EXPERT SYSTEM INTERNAL FORMAT
IF (OCXDT?5N1","1.5N)
SET OCXVAL=(OCXDT*86400)+$PIECE(OCXDT,",",2)
+35 ;
+36 QUIT OCXVAL
+37 ;
FLAB(DFN,OCXLIST,OCXSPEC) ; Compiler Function: FORMATTED LAB RESULTS
+1 ;
+2 if '$GET(DFN)
QUIT "<Patient Not Specified>"
+3 if '$LENGTH($GET(OCXLIST))
QUIT "<Lab Tests Not Specified>"
+4 NEW OCXLAB,OCXOUT,OCXPC,OCXSL,SPEC
SET OCXOUT=""
SET SPEC=""
+5 IF $LENGTH($GET(OCXSPEC))
SET OCXSL=$$TERMLKUP(OCXSPEC,.OCXSL)
+6 FOR OCXPC=1:1:$LENGTH(OCXLIST,U)
SET OCXLAB=$PIECE(OCXLIST,U,OCXPC)
IF $LENGTH(OCXLAB)
Begin DoDot:1
+7 NEW OCXX,OCXY,X,Y,DIC,TEST,SPEC,OCXTL,OCXA,OCXR
+8 SET OCXTL=""
if '$$TERMLKUP(OCXLAB,.OCXTL)
QUIT
+9 SET OCXX=""
SET TEST=0
FOR
SET TEST=$ORDER(OCXTL(TEST))
if 'TEST
QUIT
Begin DoDot:2
+10 IF $LENGTH($GET(OCXSL))
Begin DoDot:3
+11 SET SPEC=0
FOR
SET SPEC=$ORDER(OCXSL(SPEC))
if 'SPEC
QUIT
Begin DoDot:4
+12 SET OCXX=$$LOCL^ORQQLR1(DFN,TEST,SPEC)
IF $LENGTH(OCXX)
Begin DoDot:5
+13 SET OCXA($PIECE(OCXX,U,7))=OCXX
End DoDot:5
End DoDot:4
End DoDot:3
+14 IF '$LENGTH($GET(OCXSL))
SET OCXX=$$LOCL^ORQQLR1(DFN,TEST,"")
+15 if '$LENGTH(OCXX)
QUIT
End DoDot:2
+16 IF $DATA(OCXA)
SET OCXR=""
SET OCXR=$ORDER(OCXA(OCXR),-1)
SET OCXX=OCXA(OCXR)
+17 IF $LENGTH(OCXX)
Begin DoDot:2
+18 SET OCXY=$PIECE(OCXX,U,2)_": "_$PIECE(OCXX,U,3)_" "_$PIECE(OCXX,U,4)
+19 SET OCXY=OCXY_" "_$SELECT($LENGTH($PIECE(OCXX,U,5)):"["_$PIECE(OCXX,U,5)_"]",1:"")
+20 IF $LENGTH($PIECE(OCXX,U,7))
SET OCXY=OCXY_" "_$$FMTE^XLFDT($PIECE(OCXX,U,7),"2P")
End DoDot:2
+21 if $LENGTH(OCXOUT)
SET OCXOUT=OCXOUT_" "
SET OCXOUT=OCXOUT_$GET(OCXY)
End DoDot:1
+22 if '$LENGTH(OCXOUT)
QUIT "<Results Not Found>"
QUIT OCXOUT
+23 ;
GETDATA(DFN,OCXL,OCXDFI) ; This Local Extrinsic Function returns runtime data
+1 ;
+2 NEW OCXE,VAL,PC
SET VAL=""
+3 FOR PC=1:1:$LENGTH(OCXL,U)
SET OCXE=$PIECE(OCXL,U,PC)
IF OCXE
SET VAL=$GET(^TMP("OCXCHK",$JOB,DFN,OCXE,OCXDFI))
if $LENGTH(VAL)
QUIT
+4 QUIT VAL
+5 ;
MCE73() ; Verify Event/Element: CREATININE CLEARANCE ESTIMATE
+1 ;
+2 ; OCXDF(37) -> PATIENT IEN data field
+3 ;
+4 NEW OCXRES
+5 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(73,37)=OCXDF(37)
+6 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),73))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),73))
+7 QUIT 0
+8 ;
MCE96() ; Verify Event/Element: CREATININE CLEARANCE DATE/TIME
+1 ;
+2 ; OCXDF(76) -> CREATININE CLEARANCE (ESTIM) VALUE data field
+3 ; OCXDF(64) -> FORMATTED RENAL LAB RESULTS data field
+4 ; OCXDF(77) -> CREATININE CLEARANCE (ESTIM) DATE data field
+5 ; OCXDF(37) -> PATIENT IEN data field
+6 ;
+7 NEW OCXRES
+8 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(96,37)=OCXDF(37)
+9 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),96))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),96))
+10 SET OCXRES(96)=0
SET OCXDF(77)=$$DT2INT($PIECE($$CRCL(OCXDF(37)),"^",1))
IF $LENGTH(OCXDF(77))
SET OCXRES(96,77)=OCXDF(77)
IF (OCXDF(77)>$$DT2INT(0))
+11 IF '$TEST
QUIT 0
+12 SET OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN")
SET OCXDF(76)=$PIECE($$CRCL(OCXDF(37)),"^",2)
SET OCXRES(96)=11
MERGE ^TMP("OCXCHK",$JOB,OCXDF(37),96)=OCXRES(96)
+13 QUIT +OCXRES(96)
+14 ;
MCE97() ; Verify Event/Element: RENAL RESULTS
+1 ;
+2 ; OCXDF(76) -> CREATININE CLEARANCE (ESTIM) VALUE data field
+3 ; OCXDF(64) -> FORMATTED RENAL LAB RESULTS data field
+4 ; OCXDF(37) -> PATIENT IEN data field
+5 ;
+6 NEW OCXRES
+7 SET OCXDF(37)=$GET(DFN)
IF $LENGTH(OCXDF(37))
SET OCXRES(97,37)=OCXDF(37)
+8 if '(OCXDF(37))
QUIT 0
IF $DATA(^TMP("OCXCHK",$JOB,OCXDF(37),97))
QUIT $GET(^TMP("OCXCHK",$JOB,OCXDF(37),97))
+9 SET OCXRES(97)=0
SET OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN")
IF '(OCXDF(64)="<Results Not Found>")
+10 IF '$TEST
QUIT 0
+11 SET OCXDF(76)=$PIECE($$CRCL(OCXDF(37)),"^",2)
SET OCXRES(97)=11
MERGE ^TMP("OCXCHK",$JOB,OCXDF(37),97)=OCXRES(97)
+12 QUIT +OCXRES(97)
+13 ;
TERMLKUP(OCXTERM,OCXLIST) ;
+1 QUIT $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
+2 ;