PSIVOCDS ;BIR/MV - PROCESS DOSING ORDER CHECKS FOR IV ;6 Jun 07 / 3:37 PM
;;5.0;INPATIENT MEDICATIONS ;**181,252,257,256,347,358**;16 DEC 97;Build 10
;
; Reference to ^PS(51.1 is supported by DBIA #2177
; Reference to ^PSDRUG( is supported by DBIA #2192.
; Reference to ^PSSDSAPI is supported by DBIA #5425.
; Reference to ^PSSFDBRT is supported by DBIA #5496.
; Reference to $$CONV^PSSDSAPK is supported by DBIA #5497.
;
IN(PSJBASE) ;
;PSJBASE - Base(Literal value for TMP global)- Required
;PSIVDDSV(AD/SOL,CNT)=P1..P9
; P1=Drug IEN; P2=Dspl name(add/sol or CPRS OI; P3=Numeric dose & unit; P4=Bottle #
; P5=""; P6=""; P7=""; P8=Strength/Vol; P9=Unit
;
;These two flags below are set when stuff freq, duration to 1 & Duration rate = dose rate
;They are used by the output routine to generate the appropriate output messages.
;PSJFDB(PSJCNT,"INF_ERROR")="" & PSJFDB(PSJCNT,"FRQ_ERROR")=""
;
NEW ON,PSJCNT,PSJCNTX,PSJONEFG,PSJRT,PSIVAS,PSIVAS0,PSIVDDSV,PSPDRG,PSJALLGY,X,PSJP8,PSJP8NUM,PSJP8UNT,PSJP8TME,PSJOIX
K PSJOCDS,PSJFDB,PSIVDDSV,PSPDRG,PSJALLGY
S PSJCNT=0
;PSJRT - FDB Route
S PSJRT=$P($$MRT^PSSDSAPI(+P("MR")),U,2)
;Set Flag to indicate CPRS OI had no active AD/SOL.
S PSJOIX="" F S PSJOIX=$O(PSJIV("OI_ERROR",PSJOIX)) Q:PSJOIX="" D
. S PSJCNT=PSJCNT+1
. S PSJFDB(PSJCNT,"RX_NUM")="I;;PROSPECTIVE;"_PSJCNT
. S PSJFDB(PSJCNT,"DRUG_NM")=PSJOIX
. S PSJFDB(PSJCNT,"OI")=$P(PSJIV("OI_ERROR",PSJOIX),U,2)
. S PSJFDB(PSJCNT,"OI_ERROR",PSJOIX)=$P(PSJIV("OI_ERROR",PSJOIX),U)_U_"I;;PROSPECTIVE;"_PSJCNT
D SETDD^PSIVOC(1)
I ($G(PSIVDDSV("TOT_VOL"))=""),($G(PSJIV("TOT_VOL"))]"") S PSIVDDSV("TOT_VOL")=PSJIV("TOT_VOL")
F PSIVAS="AD","SOL" F PSJCNTX=0:0 S PSJCNTX=$O(PSIVDDSV(PSIVAS,PSJCNTX)) Q:'PSJCNTX D
. S PSIVAS0=$G(PSIVDDSV(PSIVAS,PSJCNTX))
.;PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" now FDB handles both units for this drug.
.;I PSIVAS="SOL" S X=$$LITER($P(PSIVAS0,U,8)) I X]"" D
.;. S $P(PSIVAS0,U,8)=$P(X,U)
.;. S $P(PSIVAS0,U,9)=$P(X,U,2)
. S PSJCNT=PSJCNT+1
. D COMMON
. I P("DTYP")=1 S PSJOCDS("CONTEXT")="IP-IV-I" D IVPB
. I P("DTYP")>1 S PSJOCDS("CONTEXT")="IP-IV-C" D IV
Q
IV ;Setup input data for Continuous IV (admixture, hyperal)
NEW PSJXRT,PSJP8ERR
S PSJP8=$$P8^PSJMISC2(P(8))
D BASIC
S PSJP8NUM=+$P(PSJP8,U)
S PSJP8UNT=$P(PSJP8,U,2)
S PSJP8TME=$P(PSJP8,U,3)
;All premix are using the "Continuous Infusion" Route logic. This is so Potassium gets both single
;and max dosing checks. Cisplatin premix won't work since FDB can't process as "Continuous Infusion"
I PSIVAS="SOL" D PREMIX Q
S PSJXRT=$$RTESCRN($P($$MRT^PSSDSAPI(+P("MR")),U,1))
I $$ISONEAD(),$$ISALLBAG(),('$$CLASS(PSJFDB(PSJCNT,"DRUG_IEN"))),(PSJXRT'=0),$$FDBRT(PSJFDB(PSJCNT,"DRUG_IEN"),PSJXRT) D ONEAD(PSJXRT) Q
I PSJP8="" D FREEDOSE Q
D CONTIV
Q
IVPB ;Setup input data for Schedule IV
NEW X,PSJP9,PSJP15,PSJX
S PSJOCDS(PSJCNT,"DRUG_AMT")=$P(PSIVAS0,U,8)
S PSJOCDS(PSJCNT,"DRUG_UNIT")=$P(PSIVAS0,U,9)
I '+$G(PSJIV("DUR")) D
. S X=$$DURATION()
. S PSJOCDS(PSJCNT,"DRATE")=$S(+X:X_"M",1:"")
I +$G(PSJIV("DUR"))<1440,(+$G(PSJIV("DUR"))>0) S PSJOCDS(PSJCNT,"DRATE")=PSJIV("DUR")
S PSJOCDS(PSJCNT,"MR_IEN")=+P("MR")
S PSJOCDS(PSJCNT,"DO")=""
S PSJOCDS(PSJCNT,"SCHEDULE")=P(9)
;
S PSJFDB(PSJCNT,"DOSE_AMT")=$S('+$P(PSIVAS0,U,8):"",1:$P(PSIVAS0,U,8))
S PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
S PSJFDB(PSJCNT,"DOSE_UNIT")=$P(PSIVAS0,U,9)
;
S PSJONEFG=0
;PSJ*5*347 - P(9) contains " PRN"
S PSJP9=P(9)
I (P(9)[" PRN"),'$D(^PS(51.1,"APPSJ",P(9))) S PSJP9=$P(P(9)," PRN",1)
I $$ONE^PSJORPOE(PSJP9)!$$ONCALL^PSJMISC(PSJP9) S PSJONEFG=1 D SINGLE Q
;I $$ONE^PSJORPOE(P(9))!$$ONCALL^PSJMISC(P(9)) S PSJONEFG=1 D SINGLE Q
I +$G(PSJIV("DOSE_CNT")) S PSJFDB(PSJCNT,"FREQ")=$G(PSJIV("DOSE_CNT")) Q
I +$G(PSJOCDS(PSJCNT,"DRATE")) D UND24HRS^PSJOCDS(+PSJOCDS(PSJCNT,"DRATE"),$G(P(11)),$G(P(15)),$G(P(2)),$G(P(3)),$G(P(9))) Q
I 'PSJONEFG D
. S X="",PSJP9=P(9),PSJX=0
. S:P(9)]"" PSJX=+$O(^PS(51.1,"AC","PSJ",P(9),0))
. S PSJP15=P(15)
. I (P(9)["PRN"),'PSJX S PSJP15=""
. ;I (P(9)["PRN"),'$O(^PS(51.1,"AC","PSJ",P(9),0)) S PSJP15=""
. ;I P(15)="D",(P(11)]"") S $P(PSJP9,"@",2)=P(11)
. I 'PSJX&(P(15)="D")&(P(11)]"") S $P(PSJP9,"@",2)=P(11)
. ;Check for DOW schedule
. I PSJP15="",PSJX S PSJP15=$P($G(^PS(51.1,PSJX,0)),U,5)
. I P(9)]"" S X=$P($$FRQ^PSSDSAPI(PSJP9,PSJP15,"I",,PSJFDB(PSJCNT,"DRUG_IEN")),U)
. I X="" S X=1 S PSJFDB(PSJCNT,"FRQ_ERROR")=""
. S PSJFDB(PSJCNT,"FREQ")=X
. S PSJFDB(PSJCNT,"DURATION")=1
. S PSJFDB(PSJCNT,"DURATION_RT")="DAY"
Q
SINGLE ;Set fields needed for Single Dose type
; Can't get FDB to return correct data for Continuous Infusion /w Single dose so all Continuous will be sent in as Maintenance.
I PSJFDB(PSJCNT,"ROUTE")=("CONTINUOUS INFUSION") Q
S PSJFDB(PSJCNT,"DOSE_TYPE")="SINGLE DOSE"
S PSJFDB(PSJCNT,"FREQ")=1
S PSJFDB(PSJCNT,"DURATION")=1
S PSJFDB(PSJCNT,"DURATION_RT")=PSJFDB(PSJCNT,"DOSE_RATE")
Q
COMMON ;Set common data for all IV types
S PSJFDB(PSJCNT,"RX_NUM")="I;"_$G(PSJPON)_";PROSPECTIVE;"_PSJCNT
S PSJFDB(PSJCNT,"DRUG_IEN")=$P(PSIVAS0,U)
S PSJFDB(PSJCNT,"DRUG_NM")=$P(PSIVAS0,U,2)_" "_$P(PSIVAS0,U,3)
S PSJFDB(PSJCNT,"DOSE_UNIT")=$P(PSIVAS0,U,9)
S PSJFDB(PSJCNT,"ROUTE")=PSJRT
S PSJFDB(PSJCNT,"DOSE_TYPE")="MAINTENANCE"
S PSJFDB(PSJCNT,"SPECIFIC")=1
;This is set when CPRS sends Duration without entering a solution.
I $D(PSJIV("FRQ_ERROR")) S PSJFDB(PSJCNT,"FRQ_ERROR")="",PSJFDB(PSJCNT,"FREQ")=1
Q
BASIC ;Set basic data for non schedule IVs
S PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
S PSJFDB(PSJCNT,"FREQ")=""
S PSJFDB(PSJCNT,"DURATION")=1
S PSJFDB(PSJCNT,"DURATION_RT")="DAY"
; SDA is set to the additive strength or volume of the solution.
S PSJFDB(PSJCNT,"DOSE_AMT")=$P(PSIVAS0,U,8)
Q
FREEDOSE ;Set data for free text dose
;"GENERAL" info only needed to pass in Dose Route and Dose Type.
;"Exception" node sets here to get the specified error back for free text dosing.
S PSJFDB(PSJCNT,"FREQ")=1
S PSJFDB(PSJCNT,"DURATION")=1
S PSJFDB(PSJCNT,"DURATION_RT")=PSJFDB(PSJCNT,"DOSE_RATE")
S PSJFDB(PSJCNT,"INF_ERROR")=""
I $G(PSJP8ERR)=2!($G(PSJP8ERR)=4) S PSJFDB(PSJCNT,"WT_ERROR")=""
I $G(PSJP8ERR)=3!($G(PSJP8ERR)=4) S PSJFDB(PSJCNT,"HT_ERROR")=""
Q
ONEAD(PSJRT) ;Setup data for 'Continuous Infusion' IV type
NEW PSJCLASS,PSJX
I $G(PSJRT)=0!($G(PSJRT)="") Q
;Check to make sure the infusion rate is in form of "ml/hr" before applying the calculation
S PSJFDB(PSJCNT,"FREQ")=1
S PSJFDB(PSJCNT,"DURATION")=1
S PSJFDB(PSJCNT,"ROUTE")=PSJRT
I PSJP8="" D FREEDOSE Q
S PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
S PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
I PSJP8UNT="MILLILITERS",(PSJP8TME="HOUR") D
. S PSJFDB(PSJCNT,"DOSE_AMT")=$$SDACI()
. S PSJFDB(PSJCNT,"DOSE_UNIT")=$P(PSIVAS0,U,9)
I PSJP8UNT'="MILLILITERS" D
. S PSJFDB(PSJCNT,"FREQ")=1
. S PSJFDB(PSJCNT,"DOSE_AMT")=PSJP8NUM
. S PSJFDB(PSJCNT,"DOSE_UNIT")=PSJP8UNT
. S PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
. S PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
Q
CONTIV ;Set data needed for continuous IV with multiple drugs
NEW PSJFREQ,PSJDIFF
S PSJDIFF=+$$DURATION()
; Order has duration <24 hrs
I PSJDIFF D UND24HRS
; Order has duration >= 24 hrs
I 'PSJDIFF S PSJFDB(PSJCNT,"FREQ")=$$IVFREQ
;
S PSJFDB(PSJCNT,"DURATION")=1
S PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
S PSJFDB(PSJCNT,"DURATION_RT")="DAY"
Q
ISONEAD() ;Return 1 if there's only one additive
NEW X,PSJX
I $D(PSIVDDSV("AD")),$D(PSIVDDSV("SOL")) Q 0
I $O(PSIVDDSV("SOL",0)) Q 0
S PSJX=0
F X=0:0 S X=$O(PSIVDDSV("AD",X)) Q:'X S PSJX=PSJX+1 Q:PSJX>1
I PSJX>1 Q 0
Q 1
ISALLBAG() ;Return 1 if not additive not in all bags
;***this call assuming only 1 additive entered in the order
;The bottle field can be either See comments, all bags, null or a numeric value (ex 1,3...)
NEW X,PSIVAS0
S X=$O(PSIVDDSV("AD",0))
S PSIVAS0=$G(PSIVDDSV("AD",X))
I +$P(PSIVAS0,U,4) Q 0
Q 1
ISNOADD() ;Return 1 if there's no additives
NEW X,PSJX
I $O(PSIVDDSV("AD",0)) Q 0
I $D(PSIVDDSV("SOL")) Q 1
Q 0
PREMIX ;The route is always set to "Continuous Infusion" & the FREQUENCY must set to 1
NEW X
S PSJFDB(PSJCNT,"ROUTE")=$$RTESCRN(PSJRT)
I PSJFDB(PSJCNT,"ROUTE")=0 S PSJFDB(PSJCNT,"ROUTE")=PSJRT
I PSJP8="" D FREEDOSE Q
S PSJFDB(PSJCNT,"FREQ")=1
S PSJFDB(PSJCNT,"DOSE_AMT")=PSJP8NUM
S PSJFDB(PSJCNT,"DOSE_UNIT")=PSJP8UNT
S PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
S PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
;PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" now FDB handles both units for this drug.
;S PSJFDB(PSJCNT,"ROUTE")="CONTINUOUS INFUSION"
;I PSJP8UNT="MILLILITERS" S X=$$LITER(PSJP8NUM) I X]"" D
;. S PSJFDB(PSJCNT,"DOSE_AMT")=$P(X,U)
;. S PSJFDB(PSJCNT,"DOSE_UNIT")=$P(X,U,2)
Q
SDACI() ;Return Single Dose Amount for ad for 'CONTINUOUS INFUSION' FDB Route (Not classed at "VT" or "TN")
;Single Dose Amount(PSJSDA):
; For Additive - PSJSDA=(Strength/Tot vol)*Infusion Rate
; If can't calculate then return null
NEW PSJSDA,X
S PSJSDA=""
I $D(PSIVDDSV("AD")) D
. S X=+$G(PSIVDDSV("TOT_VOL")) Q:'X
. S PSJSDA=($P(PSIVAS0,U,8)/X)*PSJP8NUM
I '+PSJSDA S PSJSDA=$P(PSIVAS0,U,8),PSJFDB(PSJCNT,"INF_ERROR")=""
Q PSJSDA
CLASS(PSJDD) ;Check if the Drug contains "VT" & "TN" classes
;Return 1 if "VT" or "TN"
;Return 0 if not
Q:'+$G(PSJDD) 0
NEW PSJCLASS
S PSJCLASS=$P($G(^PSDRUG(+PSJDD,0)),U,2)
;I (PSJCLASS["TN")!(PSJCLASS["VT") Q 1
I PSJCLASS["VT" Q 1
Q 0
IVFREQ() ;Return the frequency for an continuous IV
; Hours needed to run a bag is defined as: Total Volume / Infusion rate
; # of bags needed for a day is defined as: 24 / Hours need to run a bag
; PSJFREQ is either in Q#H or N for # of admin per day
NEW PSJFREQ,PSJBOT,PSJX,X,PSJTOTBG,PSJTOTBT,PSJTOTV,PSJBAGX
S (PSJFREQ,PSJTOTBG,PSJTOTBT)=0
S PSJTOTV=+$G(PSIVDDSV("TOT_VOL"))
;CONV^PSSDSAPK converts # of hours to run a bag to either Q#H or n for number of admin per day
I +PSJTOTV,PSJP8NUM D
. I +PSJTOTV#PSJP8NUM D
.. S PSJFDB(PSJCNT,"DOSE_AMT")=$$ADJSDA(+PSJTOTV,PSJP8NUM,+PSJFDB(PSJCNT,"DOSE_AMT"),1)
. S PSJBAGX=PSJTOTV/PSJP8NUM
. I PSJBAGX<1 S PSJFREQ="Q1H"
. S:PSJBAGX'<1 PSJFREQ=$$CONV^PSSDSAPK(PSJTOTV/PSJP8NUM)
. S PSJTOTBG=24/(+PSJTOTV/PSJP8NUM)
I PSIVAS="AD" D BOTTLE(PSJTOTBG,$P(PSIVAS0,U,4)) D
. I PSJTOTBG<1,'(+PSJTOTV#PSJP8NUM) S PSJFDB(PSJCNT,"DOSE_AMT")=$$ADJSDA(+PSJTOTV,PSJP8NUM,+PSJFDB(PSJCNT,"DOSE_AMT"),0)
I PSJFREQ=""!(PSJFREQ=0) S PSJFREQ=1 S PSJFDB(PSJCNT,"FRQ_ERROR")=""
Q PSJFREQ
ADJSDA(PSJTOTV,PSJINFRT,PSJSDA,PSJNOTE) ;Adjust SDA
NEW PSJBAGX,X,PSJNOTEV
I '+$G(PSJTOTV) Q ""
I '+$G(PSJINFRT) Q ""
I '+$G(PSJSDA) Q ""
S (PSJBAGX,X)=+PSJTOTV/PSJINFRT
;** Removed for MOCHA 2.0 When it takes < 1 hour to run a bag. May need to bring back for MOCHA 2.1 (Daily dose check).
;I PSJBAGX<1 S PSJSDA=PSJSDA/PSJBAGX
I PSJBAGX<1 D
. S PSJFDB(PSJCNT,"FREQ")=1
. S PSJFDB(PSJCNT,"DURATION")=1
. S PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
. S PSJFDB(PSJCNT,"DURATION_RT")="DAY"
I PSJBAGX'<1 D
. S X=$J(PSJBAGX,"",0)
. S PSJSDA=PSJSDA/(+PSJTOTV)*PSJINFRT*($S(X<24:X,1:24))
. S PSJNOTEV=($S(X<24:X,1:24)*PSJINFRT)_" ML over "_$S(X<24:X,1:24)_" hours)."
. I $G(PSJNOTE) D
.. S PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the nearest whole number of hours ("_PSJNOTEV
. I '$G(PSJNOTE) D
.. S PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the duration of the order or 24 hours; whichever is less ("_PSJNOTEV
Q PSJSDA
UND24HRS ;Calculate freq for order <24 hrs
NEW PSJTOTV,PSJBAG,PSJMNBAG,PSJTOTBG,PSJFREQ,PSJHRS,X
S (PSJFREQ,PSJBAG,PSJMNBAG)=0
S PSJTOTV=+$G(PSIVDDSV("TOT_VOL"))
I +PSJTOTV,PSJP8NUM D
. S PSJHRS=PSJTOTV/PSJP8NUM
. S PSJMNBAG=PSJHRS*60
. S PSJTOTBG=24/PSJHRS
I '+PSJMNBAG D Q
. S PSJFDB(PSJCNT,"FREQ")=1
. S PSJFDB(PSJCNT,"FRQ_ERROR")=""
S:+PSJMNBAG PSJBAG=PSJDIFF/PSJMNBAG
; If the order is for < 24 hrs & Freq < 1 then adjust the SDA & Freq set to 1
I PSJBAG<1 D Q
. S X=$J((PSJDIFF/60),"",0)
. S PSJNOTEV=($S(X<24:X,1:24)*PSJP8NUM)_" ML over "_$S(X<24:X,1:24)_" hours)."
. S PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the duration of the order or 24 hours; whichever is less ("_PSJNOTEV
. S PSJFDB(PSJCNT,"FREQ")=1
. S PSJFDB(PSJCNT,"DOSE_AMT")=PSJBAG*(PSJFDB(PSJCNT,"DOSE_AMT"))
;
S PSJFREQ=$J(PSJBAG,"",0)
I PSIVAS="AD" D BOTTLE(PSJFREQ,$P(PSIVAS0,U,4))
S PSJFDB(PSJCNT,"FREQ")=PSJFREQ
Q
;
BOTTLE(PSJTOTBG,PSJBOT) ;Set freq to either specified bottle or # needed for the duration/24hrs of the order
NEW PSJTOTBT,X,PSJX
Q:'+$G(PSJTOTBG)
I $$UP^XLFSTR($G(PSJBOT))="ALL BAGS" S:PSJTOTBG<1 PSJFREQ=1 Q
I $$UP^XLFSTR($G(PSJBOT))="SEE COMMENTS" S:PSJTOTBG<1 PSJFREQ=1 Q
;
;PSJ*5*252 - ADJSDA already adjusted the SDA so recal SDA is not needed
I PSJTOTBG<1 S PSJFREQ=1 Q
Q:$G(PSJBOT)=""
S PSJTOTBT=0
F X=1:1:$L(PSJBOT,",") S PSJX=$P(PSJBOT,",",X) S:+PSJX PSJTOTBT=PSJTOTBT+1
S PSJFREQ=$S(PSJTOTBT>PSJTOTBG:PSJTOTBG,1:PSJTOTBT)
I PSJTOTV#PSJP8NUM,(PSJTOTBT>PSJTOTBG) D
. S PSJFREQ=$$CONV^PSSDSAPK(PSJTOTV/PSJP8NUM)
I PSJFREQ=0 S PSJFREQ=1 S PSJFDB(PSJCNT,"FRQ_ERROR")=""
Q
DURATION() ;
;If PSJIV("DUR") is passed in from CPRS then return the minutes if <1440 otherwise return ""
;If not call from CPRS then calculate from start, stop date
NEW PSJX,X,PSJP8X
S PSJX=""
I +$G(PSJIV("DUR")) D Q X
.S PSJX=+$G(PSJIV("DUR"))
.S X=$S(PSJX<1440:PSJX,1:"")
I +$G(PSJIV("TOT_VOL")) D Q X
. S PSJP8X=$S(+$G(PSJP8NUM):PSJP8NUM,+P(8):+P(8),1:0)
. S:PSJP8X PSJX=(+PSJIV("TOT_VOL")/PSJP8X)*60
. S X=$S(PSJX<1440:PSJX,1:"")
S X=$$DURATION^PSJOCDS($G(P(2)),$G(P(3)))
Q X
FDBRT(PSJDD,PSJRT) ;Check if the ordered route can be admin by FDB for this drug
;PSJDD = Drug IEN
;PSJRT = FDB continuous dose route (ordered MR -> Standard RT ->FDB cont. Rt)
;Return 1 if the route can admin by FDB; 0 if this route is not specify for this drug
NEW PSJFDBRT
I '+$G(PSJDD)!$G(PSJRT)="" Q 0
D GROUTE^PSSFDBRT(PSJDD,.PSJFDBRT)
I +$G(PSJFDBRT(0))=-1 Q 1
I $D(PSJFDBRT(PSJRT)) Q 1
Q 0
RTESCRN(PSJRT) ; Screen routes for none "VT or "TN"
;Return 0 or FDB continuous dose route if the standard route(mapped to the ordered MR) is one of the six below.
;PSJRT - standard route
I $G(PSJRT)="" Q 0
I PSJRT="EPIDURAL" Q "CONTINUOUS EPIDURAL"
I PSJRT="INTRA-ARTERIAL" Q "CONT INTRAARTER INF"
I PSJRT="INFILTRATION" Q "CONTINUOUS INFILTRAT"
I PSJRT="INTRACAUDAL" Q "CONT CAUDAL INFUSION"
I PSJRT="INTRAOSSEOUS" Q "CONT INTRAOSSEOUS"
I PSJRT="INTRATHECAL" Q "CONT INTRATHECAL INF"
I PSJRT="INTRAVENOUS" Q "CONTINUOUS INFUSION"
I PSJRT="NEBULIZATION" Q "CONT NEBULIZATION"
I PSJRT="SUBCUTANEOUS" Q "CONT SUBCUTAN INFUSI"
Q 0
LITER(PSJVOLP8) ; Convert the unit from ML to L for premix contains potassium
; PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" for this drug now that FDB handles both units.
; FDB only accept Liter for this type for drug
; PSJVOLP8 - Either = volume or the infusion rate
NEW PSJVAGEN,PSJSDA,PSJUNIT
Q:$G(PSJVOLP8)=""
S PSJVAGEN=$$VAGEN^PSJMISC($P(PSIVAS0,U))
I PSJVAGEN["POTASSIUM" D
. S PSJSDA=+(PSJVOLP8/1000)
. S PSJUNIT="L"
I '+$G(PSJSDA)!($G(PSJUNIT)="") Q ""
Q PSJSDA_U_PSJUNIT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSIVOCDS 15599 printed Dec 13, 2024@02:04:27 Page 2
PSIVOCDS ;BIR/MV - PROCESS DOSING ORDER CHECKS FOR IV ;6 Jun 07 / 3:37 PM
+1 ;;5.0;INPATIENT MEDICATIONS ;**181,252,257,256,347,358**;16 DEC 97;Build 10
+2 ;
+3 ; Reference to ^PS(51.1 is supported by DBIA #2177
+4 ; Reference to ^PSDRUG( is supported by DBIA #2192.
+5 ; Reference to ^PSSDSAPI is supported by DBIA #5425.
+6 ; Reference to ^PSSFDBRT is supported by DBIA #5496.
+7 ; Reference to $$CONV^PSSDSAPK is supported by DBIA #5497.
+8 ;
IN(PSJBASE) ;
+1 ;PSJBASE - Base(Literal value for TMP global)- Required
+2 ;PSIVDDSV(AD/SOL,CNT)=P1..P9
+3 ; P1=Drug IEN; P2=Dspl name(add/sol or CPRS OI; P3=Numeric dose & unit; P4=Bottle #
+4 ; P5=""; P6=""; P7=""; P8=Strength/Vol; P9=Unit
+5 ;
+6 ;These two flags below are set when stuff freq, duration to 1 & Duration rate = dose rate
+7 ;They are used by the output routine to generate the appropriate output messages.
+8 ;PSJFDB(PSJCNT,"INF_ERROR")="" & PSJFDB(PSJCNT,"FRQ_ERROR")=""
+9 ;
+10 NEW ON,PSJCNT,PSJCNTX,PSJONEFG,PSJRT,PSIVAS,PSIVAS0,PSIVDDSV,PSPDRG,PSJALLGY,X,PSJP8,PSJP8NUM,PSJP8UNT,PSJP8TME,PSJOIX
+11 KILL PSJOCDS,PSJFDB,PSIVDDSV,PSPDRG,PSJALLGY
+12 SET PSJCNT=0
+13 ;PSJRT - FDB Route
+14 SET PSJRT=$PIECE($$MRT^PSSDSAPI(+P("MR")),U,2)
+15 ;Set Flag to indicate CPRS OI had no active AD/SOL.
+16 SET PSJOIX=""
FOR
SET PSJOIX=$ORDER(PSJIV("OI_ERROR",PSJOIX))
if PSJOIX=""
QUIT
Begin DoDot:1
+17 SET PSJCNT=PSJCNT+1
+18 SET PSJFDB(PSJCNT,"RX_NUM")="I;;PROSPECTIVE;"_PSJCNT
+19 SET PSJFDB(PSJCNT,"DRUG_NM")=PSJOIX
+20 SET PSJFDB(PSJCNT,"OI")=$PIECE(PSJIV("OI_ERROR",PSJOIX),U,2)
+21 SET PSJFDB(PSJCNT,"OI_ERROR",PSJOIX)=$PIECE(PSJIV("OI_ERROR",PSJOIX),U)_U_"I;;PROSPECTIVE;"_PSJCNT
End DoDot:1
+22 DO SETDD^PSIVOC(1)
+23 IF ($GET(PSIVDDSV("TOT_VOL"))="")
IF ($GET(PSJIV("TOT_VOL"))]"")
SET PSIVDDSV("TOT_VOL")=PSJIV("TOT_VOL")
+24 FOR PSIVAS="AD","SOL"
FOR PSJCNTX=0:0
SET PSJCNTX=$ORDER(PSIVDDSV(PSIVAS,PSJCNTX))
if 'PSJCNTX
QUIT
Begin DoDot:1
+25 SET PSIVAS0=$GET(PSIVDDSV(PSIVAS,PSJCNTX))
+26 ;PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" now FDB handles both units for this drug.
+27 ;I PSIVAS="SOL" S X=$$LITER($P(PSIVAS0,U,8)) I X]"" D
+28 ;. S $P(PSIVAS0,U,8)=$P(X,U)
+29 ;. S $P(PSIVAS0,U,9)=$P(X,U,2)
+30 SET PSJCNT=PSJCNT+1
+31 DO COMMON
+32 IF P("DTYP")=1
SET PSJOCDS("CONTEXT")="IP-IV-I"
DO IVPB
+33 IF P("DTYP")>1
SET PSJOCDS("CONTEXT")="IP-IV-C"
DO IV
End DoDot:1
+34 QUIT
IV ;Setup input data for Continuous IV (admixture, hyperal)
+1 NEW PSJXRT,PSJP8ERR
+2 SET PSJP8=$$P8^PSJMISC2(P(8))
+3 DO BASIC
+4 SET PSJP8NUM=+$PIECE(PSJP8,U)
+5 SET PSJP8UNT=$PIECE(PSJP8,U,2)
+6 SET PSJP8TME=$PIECE(PSJP8,U,3)
+7 ;All premix are using the "Continuous Infusion" Route logic. This is so Potassium gets both single
+8 ;and max dosing checks. Cisplatin premix won't work since FDB can't process as "Continuous Infusion"
+9 IF PSIVAS="SOL"
DO PREMIX
QUIT
+10 SET PSJXRT=$$RTESCRN($PIECE($$MRT^PSSDSAPI(+P("MR")),U,1))
+11 IF $$ISONEAD()
IF $$ISALLBAG()
IF ('$$CLASS(PSJFDB(PSJCNT,"DRUG_IEN")))
IF (PSJXRT'=0)
IF $$FDBRT(PSJFDB(PSJCNT,"DRUG_IEN"),PSJXRT)
DO ONEAD(PSJXRT)
QUIT
+12 IF PSJP8=""
DO FREEDOSE
QUIT
+13 DO CONTIV
+14 QUIT
IVPB ;Setup input data for Schedule IV
+1 NEW X,PSJP9,PSJP15,PSJX
+2 SET PSJOCDS(PSJCNT,"DRUG_AMT")=$PIECE(PSIVAS0,U,8)
+3 SET PSJOCDS(PSJCNT,"DRUG_UNIT")=$PIECE(PSIVAS0,U,9)
+4 IF '+$GET(PSJIV("DUR"))
Begin DoDot:1
+5 SET X=$$DURATION()
+6 SET PSJOCDS(PSJCNT,"DRATE")=$SELECT(+X:X_"M",1:"")
End DoDot:1
+7 IF +$GET(PSJIV("DUR"))<1440
IF (+$GET(PSJIV("DUR"))>0)
SET PSJOCDS(PSJCNT,"DRATE")=PSJIV("DUR")
+8 SET PSJOCDS(PSJCNT,"MR_IEN")=+P("MR")
+9 SET PSJOCDS(PSJCNT,"DO")=""
+10 SET PSJOCDS(PSJCNT,"SCHEDULE")=P(9)
+11 ;
+12 SET PSJFDB(PSJCNT,"DOSE_AMT")=$SELECT('+$PIECE(PSIVAS0,U,8):"",1:$PIECE(PSIVAS0,U,8))
+13 SET PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
+14 SET PSJFDB(PSJCNT,"DOSE_UNIT")=$PIECE(PSIVAS0,U,9)
+15 ;
+16 SET PSJONEFG=0
+17 ;PSJ*5*347 - P(9) contains " PRN"
+18 SET PSJP9=P(9)
+19 IF (P(9)[" PRN")
IF '$DATA(^PS(51.1,"APPSJ",P(9)))
SET PSJP9=$PIECE(P(9)," PRN",1)
+20 IF $$ONE^PSJORPOE(PSJP9)!$$ONCALL^PSJMISC(PSJP9)
SET PSJONEFG=1
DO SINGLE
QUIT
+21 ;I $$ONE^PSJORPOE(P(9))!$$ONCALL^PSJMISC(P(9)) S PSJONEFG=1 D SINGLE Q
+22 IF +$GET(PSJIV("DOSE_CNT"))
SET PSJFDB(PSJCNT,"FREQ")=$GET(PSJIV("DOSE_CNT"))
QUIT
+23 IF +$GET(PSJOCDS(PSJCNT,"DRATE"))
DO UND24HRS^PSJOCDS(+PSJOCDS(PSJCNT,"DRATE"),$GET(P(11)),$GET(P(15)),$GET(P(2)),$GET(P(3)),$GET(P(9)))
QUIT
+24 IF 'PSJONEFG
Begin DoDot:1
+25 SET X=""
SET PSJP9=P(9)
SET PSJX=0
+26 if P(9)]""
SET PSJX=+$ORDER(^PS(51.1,"AC","PSJ",P(9),0))
+27 SET PSJP15=P(15)
+28 IF (P(9)["PRN")
IF 'PSJX
SET PSJP15=""
+29 ;I (P(9)["PRN"),'$O(^PS(51.1,"AC","PSJ",P(9),0)) S PSJP15=""
+30 ;I P(15)="D",(P(11)]"") S $P(PSJP9,"@",2)=P(11)
+31 IF 'PSJX&(P(15)="D")&(P(11)]"")
SET $PIECE(PSJP9,"@",2)=P(11)
+32 ;Check for DOW schedule
+33 IF PSJP15=""
IF PSJX
SET PSJP15=$PIECE($GET(^PS(51.1,PSJX,0)),U,5)
+34 IF P(9)]""
SET X=$PIECE($$FRQ^PSSDSAPI(PSJP9,PSJP15,"I",,PSJFDB(PSJCNT,"DRUG_IEN")),U)
+35 IF X=""
SET X=1
SET PSJFDB(PSJCNT,"FRQ_ERROR")=""
+36 SET PSJFDB(PSJCNT,"FREQ")=X
+37 SET PSJFDB(PSJCNT,"DURATION")=1
+38 SET PSJFDB(PSJCNT,"DURATION_RT")="DAY"
End DoDot:1
+39 QUIT
SINGLE ;Set fields needed for Single Dose type
+1 ; Can't get FDB to return correct data for Continuous Infusion /w Single dose so all Continuous will be sent in as Maintenance.
+2 IF PSJFDB(PSJCNT,"ROUTE")=("CONTINUOUS INFUSION")
QUIT
+3 SET PSJFDB(PSJCNT,"DOSE_TYPE")="SINGLE DOSE"
+4 SET PSJFDB(PSJCNT,"FREQ")=1
+5 SET PSJFDB(PSJCNT,"DURATION")=1
+6 SET PSJFDB(PSJCNT,"DURATION_RT")=PSJFDB(PSJCNT,"DOSE_RATE")
+7 QUIT
COMMON ;Set common data for all IV types
+1 SET PSJFDB(PSJCNT,"RX_NUM")="I;"_$GET(PSJPON)_";PROSPECTIVE;"_PSJCNT
+2 SET PSJFDB(PSJCNT,"DRUG_IEN")=$PIECE(PSIVAS0,U)
+3 SET PSJFDB(PSJCNT,"DRUG_NM")=$PIECE(PSIVAS0,U,2)_" "_$PIECE(PSIVAS0,U,3)
+4 SET PSJFDB(PSJCNT,"DOSE_UNIT")=$PIECE(PSIVAS0,U,9)
+5 SET PSJFDB(PSJCNT,"ROUTE")=PSJRT
+6 SET PSJFDB(PSJCNT,"DOSE_TYPE")="MAINTENANCE"
+7 SET PSJFDB(PSJCNT,"SPECIFIC")=1
+8 ;This is set when CPRS sends Duration without entering a solution.
+9 IF $DATA(PSJIV("FRQ_ERROR"))
SET PSJFDB(PSJCNT,"FRQ_ERROR")=""
SET PSJFDB(PSJCNT,"FREQ")=1
+10 QUIT
BASIC ;Set basic data for non schedule IVs
+1 SET PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
+2 SET PSJFDB(PSJCNT,"FREQ")=""
+3 SET PSJFDB(PSJCNT,"DURATION")=1
+4 SET PSJFDB(PSJCNT,"DURATION_RT")="DAY"
+5 ; SDA is set to the additive strength or volume of the solution.
+6 SET PSJFDB(PSJCNT,"DOSE_AMT")=$PIECE(PSIVAS0,U,8)
+7 QUIT
FREEDOSE ;Set data for free text dose
+1 ;"GENERAL" info only needed to pass in Dose Route and Dose Type.
+2 ;"Exception" node sets here to get the specified error back for free text dosing.
+3 SET PSJFDB(PSJCNT,"FREQ")=1
+4 SET PSJFDB(PSJCNT,"DURATION")=1
+5 SET PSJFDB(PSJCNT,"DURATION_RT")=PSJFDB(PSJCNT,"DOSE_RATE")
+6 SET PSJFDB(PSJCNT,"INF_ERROR")=""
+7 IF $GET(PSJP8ERR)=2!($GET(PSJP8ERR)=4)
SET PSJFDB(PSJCNT,"WT_ERROR")=""
+8 IF $GET(PSJP8ERR)=3!($GET(PSJP8ERR)=4)
SET PSJFDB(PSJCNT,"HT_ERROR")=""
+9 QUIT
ONEAD(PSJRT) ;Setup data for 'Continuous Infusion' IV type
+1 NEW PSJCLASS,PSJX
+2 IF $GET(PSJRT)=0!($GET(PSJRT)="")
QUIT
+3 ;Check to make sure the infusion rate is in form of "ml/hr" before applying the calculation
+4 SET PSJFDB(PSJCNT,"FREQ")=1
+5 SET PSJFDB(PSJCNT,"DURATION")=1
+6 SET PSJFDB(PSJCNT,"ROUTE")=PSJRT
+7 IF PSJP8=""
DO FREEDOSE
QUIT
+8 SET PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
+9 SET PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
+10 IF PSJP8UNT="MILLILITERS"
IF (PSJP8TME="HOUR")
Begin DoDot:1
+11 SET PSJFDB(PSJCNT,"DOSE_AMT")=$$SDACI()
+12 SET PSJFDB(PSJCNT,"DOSE_UNIT")=$PIECE(PSIVAS0,U,9)
End DoDot:1
+13 IF PSJP8UNT'="MILLILITERS"
Begin DoDot:1
+14 SET PSJFDB(PSJCNT,"FREQ")=1
+15 SET PSJFDB(PSJCNT,"DOSE_AMT")=PSJP8NUM
+16 SET PSJFDB(PSJCNT,"DOSE_UNIT")=PSJP8UNT
+17 SET PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
+18 SET PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
End DoDot:1
+19 QUIT
CONTIV ;Set data needed for continuous IV with multiple drugs
+1 NEW PSJFREQ,PSJDIFF
+2 SET PSJDIFF=+$$DURATION()
+3 ; Order has duration <24 hrs
+4 IF PSJDIFF
DO UND24HRS
+5 ; Order has duration >= 24 hrs
+6 IF 'PSJDIFF
SET PSJFDB(PSJCNT,"FREQ")=$$IVFREQ
+7 ;
+8 SET PSJFDB(PSJCNT,"DURATION")=1
+9 SET PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
+10 SET PSJFDB(PSJCNT,"DURATION_RT")="DAY"
+11 QUIT
ISONEAD() ;Return 1 if there's only one additive
+1 NEW X,PSJX
+2 IF $DATA(PSIVDDSV("AD"))
IF $DATA(PSIVDDSV("SOL"))
QUIT 0
+3 IF $ORDER(PSIVDDSV("SOL",0))
QUIT 0
+4 SET PSJX=0
+5 FOR X=0:0
SET X=$ORDER(PSIVDDSV("AD",X))
if 'X
QUIT
SET PSJX=PSJX+1
if PSJX>1
QUIT
+6 IF PSJX>1
QUIT 0
+7 QUIT 1
ISALLBAG() ;Return 1 if not additive not in all bags
+1 ;***this call assuming only 1 additive entered in the order
+2 ;The bottle field can be either See comments, all bags, null or a numeric value (ex 1,3...)
+3 NEW X,PSIVAS0
+4 SET X=$ORDER(PSIVDDSV("AD",0))
+5 SET PSIVAS0=$GET(PSIVDDSV("AD",X))
+6 IF +$PIECE(PSIVAS0,U,4)
QUIT 0
+7 QUIT 1
ISNOADD() ;Return 1 if there's no additives
+1 NEW X,PSJX
+2 IF $ORDER(PSIVDDSV("AD",0))
QUIT 0
+3 IF $DATA(PSIVDDSV("SOL"))
QUIT 1
+4 QUIT 0
PREMIX ;The route is always set to "Continuous Infusion" & the FREQUENCY must set to 1
+1 NEW X
+2 SET PSJFDB(PSJCNT,"ROUTE")=$$RTESCRN(PSJRT)
+3 IF PSJFDB(PSJCNT,"ROUTE")=0
SET PSJFDB(PSJCNT,"ROUTE")=PSJRT
+4 IF PSJP8=""
DO FREEDOSE
QUIT
+5 SET PSJFDB(PSJCNT,"FREQ")=1
+6 SET PSJFDB(PSJCNT,"DOSE_AMT")=PSJP8NUM
+7 SET PSJFDB(PSJCNT,"DOSE_UNIT")=PSJP8UNT
+8 SET PSJFDB(PSJCNT,"DOSE_RATE")=PSJP8TME
+9 SET PSJFDB(PSJCNT,"DURATION_RT")=PSJP8TME
+10 ;PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" now FDB handles both units for this drug.
+11 ;S PSJFDB(PSJCNT,"ROUTE")="CONTINUOUS INFUSION"
+12 ;I PSJP8UNT="MILLILITERS" S X=$$LITER(PSJP8NUM) I X]"" D
+13 ;. S PSJFDB(PSJCNT,"DOSE_AMT")=$P(X,U)
+14 ;. S PSJFDB(PSJCNT,"DOSE_UNIT")=$P(X,U,2)
+15 QUIT
SDACI() ;Return Single Dose Amount for ad for 'CONTINUOUS INFUSION' FDB Route (Not classed at "VT" or "TN")
+1 ;Single Dose Amount(PSJSDA):
+2 ; For Additive - PSJSDA=(Strength/Tot vol)*Infusion Rate
+3 ; If can't calculate then return null
+4 NEW PSJSDA,X
+5 SET PSJSDA=""
+6 IF $DATA(PSIVDDSV("AD"))
Begin DoDot:1
+7 SET X=+$GET(PSIVDDSV("TOT_VOL"))
if 'X
QUIT
+8 SET PSJSDA=($PIECE(PSIVAS0,U,8)/X)*PSJP8NUM
End DoDot:1
+9 IF '+PSJSDA
SET PSJSDA=$PIECE(PSIVAS0,U,8)
SET PSJFDB(PSJCNT,"INF_ERROR")=""
+10 QUIT PSJSDA
CLASS(PSJDD) ;Check if the Drug contains "VT" & "TN" classes
+1 ;Return 1 if "VT" or "TN"
+2 ;Return 0 if not
+3 if '+$GET(PSJDD)
QUIT 0
+4 NEW PSJCLASS
+5 SET PSJCLASS=$PIECE($GET(^PSDRUG(+PSJDD,0)),U,2)
+6 ;I (PSJCLASS["TN")!(PSJCLASS["VT") Q 1
+7 IF PSJCLASS["VT"
QUIT 1
+8 QUIT 0
IVFREQ() ;Return the frequency for an continuous IV
+1 ; Hours needed to run a bag is defined as: Total Volume / Infusion rate
+2 ; # of bags needed for a day is defined as: 24 / Hours need to run a bag
+3 ; PSJFREQ is either in Q#H or N for # of admin per day
+4 NEW PSJFREQ,PSJBOT,PSJX,X,PSJTOTBG,PSJTOTBT,PSJTOTV,PSJBAGX
+5 SET (PSJFREQ,PSJTOTBG,PSJTOTBT)=0
+6 SET PSJTOTV=+$GET(PSIVDDSV("TOT_VOL"))
+7 ;CONV^PSSDSAPK converts # of hours to run a bag to either Q#H or n for number of admin per day
+8 IF +PSJTOTV
IF PSJP8NUM
Begin DoDot:1
+9 IF +PSJTOTV#PSJP8NUM
Begin DoDot:2
+10 SET PSJFDB(PSJCNT,"DOSE_AMT")=$$ADJSDA(+PSJTOTV,PSJP8NUM,+PSJFDB(PSJCNT,"DOSE_AMT"),1)
End DoDot:2
+11 SET PSJBAGX=PSJTOTV/PSJP8NUM
+12 IF PSJBAGX<1
SET PSJFREQ="Q1H"
+13 if PSJBAGX'<1
SET PSJFREQ=$$CONV^PSSDSAPK(PSJTOTV/PSJP8NUM)
+14 SET PSJTOTBG=24/(+PSJTOTV/PSJP8NUM)
End DoDot:1
+15 IF PSIVAS="AD"
DO BOTTLE(PSJTOTBG,$PIECE(PSIVAS0,U,4))
Begin DoDot:1
+16 IF PSJTOTBG<1
IF '(+PSJTOTV#PSJP8NUM)
SET PSJFDB(PSJCNT,"DOSE_AMT")=$$ADJSDA(+PSJTOTV,PSJP8NUM,+PSJFDB(PSJCNT,"DOSE_AMT"),0)
End DoDot:1
+17 IF PSJFREQ=""!(PSJFREQ=0)
SET PSJFREQ=1
SET PSJFDB(PSJCNT,"FRQ_ERROR")=""
+18 QUIT PSJFREQ
ADJSDA(PSJTOTV,PSJINFRT,PSJSDA,PSJNOTE) ;Adjust SDA
+1 NEW PSJBAGX,X,PSJNOTEV
+2 IF '+$GET(PSJTOTV)
QUIT ""
+3 IF '+$GET(PSJINFRT)
QUIT ""
+4 IF '+$GET(PSJSDA)
QUIT ""
+5 SET (PSJBAGX,X)=+PSJTOTV/PSJINFRT
+6 ;** Removed for MOCHA 2.0 When it takes < 1 hour to run a bag. May need to bring back for MOCHA 2.1 (Daily dose check).
+7 ;I PSJBAGX<1 S PSJSDA=PSJSDA/PSJBAGX
+8 IF PSJBAGX<1
Begin DoDot:1
+9 SET PSJFDB(PSJCNT,"FREQ")=1
+10 SET PSJFDB(PSJCNT,"DURATION")=1
+11 SET PSJFDB(PSJCNT,"DOSE_RATE")="DAY"
+12 SET PSJFDB(PSJCNT,"DURATION_RT")="DAY"
End DoDot:1
+13 IF PSJBAGX'<1
Begin DoDot:1
+14 SET X=$JUSTIFY(PSJBAGX,"",0)
+15 SET PSJSDA=PSJSDA/(+PSJTOTV)*PSJINFRT*($SELECT(X<24:X,1:24))
+16 SET PSJNOTEV=($SELECT(X<24:X,1:24)*PSJINFRT)_" ML over "_$SELECT(X<24:X,1:24)_" hours)."
+17 IF $GET(PSJNOTE)
Begin DoDot:2
+18 SET PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the nearest whole number of hours ("_PSJNOTEV
End DoDot:2
+19 IF '$GET(PSJNOTE)
Begin DoDot:2
+20 SET PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the duration of the order or 24 hours; whichever is less ("_PSJNOTEV
End DoDot:2
End DoDot:1
+21 QUIT PSJSDA
UND24HRS ;Calculate freq for order <24 hrs
+1 NEW PSJTOTV,PSJBAG,PSJMNBAG,PSJTOTBG,PSJFREQ,PSJHRS,X
+2 SET (PSJFREQ,PSJBAG,PSJMNBAG)=0
+3 SET PSJTOTV=+$GET(PSIVDDSV("TOT_VOL"))
+4 IF +PSJTOTV
IF PSJP8NUM
Begin DoDot:1
+5 SET PSJHRS=PSJTOTV/PSJP8NUM
+6 SET PSJMNBAG=PSJHRS*60
+7 SET PSJTOTBG=24/PSJHRS
End DoDot:1
+8 IF '+PSJMNBAG
Begin DoDot:1
+9 SET PSJFDB(PSJCNT,"FREQ")=1
+10 SET PSJFDB(PSJCNT,"FRQ_ERROR")=""
End DoDot:1
QUIT
+11 if +PSJMNBAG
SET PSJBAG=PSJDIFF/PSJMNBAG
+12 ; If the order is for < 24 hrs & Freq < 1 then adjust the SDA & Freq set to 1
+13 IF PSJBAG<1
Begin DoDot:1
+14 SET X=$JUSTIFY((PSJDIFF/60),"",0)
+15 SET PSJNOTEV=($SELECT(X<24:X,1:24)*PSJP8NUM)_" ML over "_$SELECT(X<24:X,1:24)_" hours)."
+16 SET PSJFDB(PSJCNT,"ADJ_MSG")="PLEASE NOTE: The single dose of the IV Additive has been adjusted to reflect the amount of drug infused over the duration of the order or 24 hours; whichever is less ("_PSJNOTEV
+17 SET PSJFDB(PSJCNT,"FREQ")=1
+18 SET PSJFDB(PSJCNT,"DOSE_AMT")=PSJBAG*(PSJFDB(PSJCNT,"DOSE_AMT"))
End DoDot:1
QUIT
+19 ;
+20 SET PSJFREQ=$JUSTIFY(PSJBAG,"",0)
+21 IF PSIVAS="AD"
DO BOTTLE(PSJFREQ,$PIECE(PSIVAS0,U,4))
+22 SET PSJFDB(PSJCNT,"FREQ")=PSJFREQ
+23 QUIT
+24 ;
BOTTLE(PSJTOTBG,PSJBOT) ;Set freq to either specified bottle or # needed for the duration/24hrs of the order
+1 NEW PSJTOTBT,X,PSJX
+2 if '+$GET(PSJTOTBG)
QUIT
+3 IF $$UP^XLFSTR($GET(PSJBOT))="ALL BAGS"
if PSJTOTBG<1
SET PSJFREQ=1
QUIT
+4 IF $$UP^XLFSTR($GET(PSJBOT))="SEE COMMENTS"
if PSJTOTBG<1
SET PSJFREQ=1
QUIT
+5 ;
+6 ;PSJ*5*252 - ADJSDA already adjusted the SDA so recal SDA is not needed
+7 IF PSJTOTBG<1
SET PSJFREQ=1
QUIT
+8 if $GET(PSJBOT)=""
QUIT
+9 SET PSJTOTBT=0
+10 FOR X=1:1:$LENGTH(PSJBOT,",")
SET PSJX=$PIECE(PSJBOT,",",X)
if +PSJX
SET PSJTOTBT=PSJTOTBT+1
+11 SET PSJFREQ=$SELECT(PSJTOTBT>PSJTOTBG:PSJTOTBG,1:PSJTOTBT)
+12 IF PSJTOTV#PSJP8NUM
IF (PSJTOTBT>PSJTOTBG)
Begin DoDot:1
+13 SET PSJFREQ=$$CONV^PSSDSAPK(PSJTOTV/PSJP8NUM)
End DoDot:1
+14 IF PSJFREQ=0
SET PSJFREQ=1
SET PSJFDB(PSJCNT,"FRQ_ERROR")=""
+15 QUIT
DURATION() ;
+1 ;If PSJIV("DUR") is passed in from CPRS then return the minutes if <1440 otherwise return ""
+2 ;If not call from CPRS then calculate from start, stop date
+3 NEW PSJX,X,PSJP8X
+4 SET PSJX=""
+5 IF +$GET(PSJIV("DUR"))
Begin DoDot:1
+6 SET PSJX=+$GET(PSJIV("DUR"))
+7 SET X=$SELECT(PSJX<1440:PSJX,1:"")
End DoDot:1
QUIT X
+8 IF +$GET(PSJIV("TOT_VOL"))
Begin DoDot:1
+9 SET PSJP8X=$SELECT(+$GET(PSJP8NUM):PSJP8NUM,+P(8):+P(8),1:0)
+10 if PSJP8X
SET PSJX=(+PSJIV("TOT_VOL")/PSJP8X)*60
+11 SET X=$SELECT(PSJX<1440:PSJX,1:"")
End DoDot:1
QUIT X
+12 SET X=$$DURATION^PSJOCDS($GET(P(2)),$GET(P(3)))
+13 QUIT X
FDBRT(PSJDD,PSJRT) ;Check if the ordered route can be admin by FDB for this drug
+1 ;PSJDD = Drug IEN
+2 ;PSJRT = FDB continuous dose route (ordered MR -> Standard RT ->FDB cont. Rt)
+3 ;Return 1 if the route can admin by FDB; 0 if this route is not specify for this drug
+4 NEW PSJFDBRT
+5 IF '+$GET(PSJDD)!$GET(PSJRT)=""
QUIT 0
+6 DO GROUTE^PSSFDBRT(PSJDD,.PSJFDBRT)
+7 IF +$GET(PSJFDBRT(0))=-1
QUIT 1
+8 IF $DATA(PSJFDBRT(PSJRT))
QUIT 1
+9 QUIT 0
RTESCRN(PSJRT) ; Screen routes for none "VT or "TN"
+1 ;Return 0 or FDB continuous dose route if the standard route(mapped to the ordered MR) is one of the six below.
+2 ;PSJRT - standard route
+3 IF $GET(PSJRT)=""
QUIT 0
+4 IF PSJRT="EPIDURAL"
QUIT "CONTINUOUS EPIDURAL"
+5 IF PSJRT="INTRA-ARTERIAL"
QUIT "CONT INTRAARTER INF"
+6 IF PSJRT="INFILTRATION"
QUIT "CONTINUOUS INFILTRAT"
+7 IF PSJRT="INTRACAUDAL"
QUIT "CONT CAUDAL INFUSION"
+8 IF PSJRT="INTRAOSSEOUS"
QUIT "CONT INTRAOSSEOUS"
+9 IF PSJRT="INTRATHECAL"
QUIT "CONT INTRATHECAL INF"
+10 IF PSJRT="INTRAVENOUS"
QUIT "CONTINUOUS INFUSION"
+11 IF PSJRT="NEBULIZATION"
QUIT "CONT NEBULIZATION"
+12 IF PSJRT="SUBCUTANEOUS"
QUIT "CONT SUBCUTAN INFUSI"
+13 QUIT 0
LITER(PSJVOLP8) ; Convert the unit from ML to L for premix contains potassium
+1 ; PSJ*5*252 (6/29/11) - No longer need to convert "ML" to "L" for this drug now that FDB handles both units.
+2 ; FDB only accept Liter for this type for drug
+3 ; PSJVOLP8 - Either = volume or the infusion rate
+4 NEW PSJVAGEN,PSJSDA,PSJUNIT
+5 if $GET(PSJVOLP8)=""
QUIT
+6 SET PSJVAGEN=$$VAGEN^PSJMISC($PIECE(PSIVAS0,U))
+7 IF PSJVAGEN["POTASSIUM"
Begin DoDot:1
+8 SET PSJSDA=+(PSJVOLP8/1000)
+9 SET PSJUNIT="L"
End DoDot:1
+10 IF '+$GET(PSJSDA)!($GET(PSJUNIT)="")
QUIT ""
+11 QUIT PSJSDA_U_PSJUNIT