PSSDSUTA ;BIR/RTR-Dosing Utility Routine ;11/24/14
;;1.0;PHARMACY DATA MANAGEMENT;**178,224**;9/30/97;Build 3
;
FCY() ;Validate Frequency, leading and trailing spaces already stripped off, and uppercase conversion done
N PSSFCYF,PSSFCYL,PSSFCY1,PSSFCY2,PSSFCYA,PSSFCYB
S PSSFCYF=$P(PSSDBEB2,"^",8)
I $D(PSSDBCAZ(PSSDBEB1,"FRQ_ERROR"))!(PSSFCYF="")!(PSSFCYF[".") Q 1
I PSSFCYF?.N Q 0
I PSSFCYF="QD"!(PSSFCYF="BID")!(PSSFCYF="TID")!(PSSFCYF="QID")!(PSSFCYF="QAM")!(PSSFCYF="QSHIFT")!(PSSFCYF="QOD")!(PSSFCYF="QHS")!(PSSFCYF="QPM") Q 0
S PSSFCYL=$L(PSSFCYF) I PSSFCYL'=3,PSSFCYL'=4 Q 1
S PSSFCY1=$E(PSSFCYF),PSSFCY2=$E(PSSFCYF,PSSFCYL)
I PSSFCY1'="Q",PSSFCY1'="X" Q 1
I PSSFCY1="Q","DWLH"'[PSSFCY2 Q 1
I PSSFCY1="X","DWL"'[PSSFCY2 Q 1
S PSSFCYA=$E(PSSFCYF,2) I PSSFCYA'?1N Q 1
I PSSFCYL=3 Q 0
S PSSFCYB=$E(PSSFCYF,3) I PSSFCYB'?1N Q 1
Q 0
;
MAXD(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDBCAR) ; -- in 2.1 Perform Max Daily Dose check when Frequency is Out of Range - called from PSSHRQ24
;PSSDADO - Order Number
;PSSDADB - Base
;PSSDADNM - Drug Name
;PSSDADI - Drug IEN
;PSSDBCAR - array documented in PSSDSEXC
;
;Return: If message is built, show custom max daily dose message flag is set to 1
; $P(PSSDBCAR(PSSDADO),"^",28)=1
; If unable to complete max daily dose check, set frequency flag to 0
; $P(PSSDBCAR(PSSDADO),"^",4)=0
;
N PSSCMDDF,PSSDADD,PSSDADZ,PSSDADU,PSSDADH,PSSDADC1,PSSDADE,PSSDADF,PSSDADFF,PSSFDBU
; -- check for missing variables, exit if not defined
I $G(PSSDADO)']""!($G(PSSDADB)']"")!($G(PSSDADNM)']"")!($G(PSSDADI)'>0) Q
I $G(PSSDADO)]"",'$D(PSSDBCAR(PSSDADO)) Q
; -- initialize custom max daily dose check flag
S PSSCMDDF=0
; -- set PSSDADZ=Input Parameters
S PSSDADZ=$G(^TMP($J,PSSDADB,"IN","DOSE",PSSDADO))
; -- set PSSDADD=Dose Amount, PSSDADU=FDB Dose Unit, PSSDADF=Frequency
S PSSDADD=$P(PSSDADZ,"^",5),PSSDADU=$P(PSSDADZ,"^",6),PSSDADF=$P(PSSDADZ,"^",8)
; -- check key variables, exit if not defined
I PSSDADD=""!(PSSDADU="")!(PSSDADF="") G MAXDQ
; -- get dose form unit flag
S PSSDADFF=$P(PSSDADZ,"^",14)
; -- Calculated Daily Dose or Dose Form Amount
; -- if numeric PSSDADH=frequency*dose amount, otherwise call function to determine
S PSSDADH=$S(PSSDADF?.N:PSSDADF*PSSDADD,1:$$CALCDDA(PSSDADF,PSSDADD))
; -- exit if not defined
I 'PSSDADH G MAXDQ
; -- set PSSDADE=FDB Max Daily Dose or Dose Form Unit
S PSSDADE=$G(^TMP($J,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX",$S(PSSDADFF:"DOSEFORMUNIT",1:"DOSEUNIT"),PSSDADI))
; -- set PSSDADC1=FDB Max Daily Dose or Dose Form Amount
S PSSDADC1=$G(^TMP($J,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX",$S(PSSDADFF:"DOSEFORM",1:"DOSE"),PSSDADI))
; -- exit if not defined
I PSSDADE=""!(PSSDADC1="") G MAXDQ
;
; -- FDB not sending FDB Max Daily Dose or Dose Form Unit in Standard format try and derive
S PSSFDBU=$$GETUNIT(PSSDADE,PSSDADU)
; -- exit if not defined
I PSSFDBU="" G MAXDQ
;
; -- if FDB Dose Unit is different than FDB Max Daily Dose or Dose Form Unit see if FDB Max Daily Dose or Dose Form Amount can be converted, exit if not defined
I PSSDADU'=PSSFDBU S PSSDADC1=$$CONVMDDA(PSSDADU,PSSFDBU,PSSDADC1) I PSSDADC1="" G MAXDQ
;
; -- if FDB Max Daily Dose or Dose Form Unit Value contains "PER KILOGRAM"
; weight is required to derive the maximum daily dose, exit if not defined
I $$UP^XLFSTR(PSSDADE)["PER KILOGRAM" D G MAXDQ:PSSDADC1=""
. ; -- check weight
. I $G(^TMP($J,PSSDADB,"IN","DOSE","WT"))>0 D
. . ; -- Calculate FDB Max Daily Dose or Dose Form as PSSDADC1=PSSDADC1*patient weight (in kg)
. . S PSSDADC1=PSSDADC1*$G(^TMP($J,PSSDADB,"IN","DOSE","WT"))
. ELSE D
. . ; -- if unable to calculate set FDB Max Daily Dose or Dose Form Unit=""
. . S PSSDADC1=""
. . ; -- update max daily dose error message if weight missing
. . D ERRMSG(PSSDADO,PSSDADB,"Weight")
;
; -- if FDB Max Daily Dose or Dose Form Unit Value contains "PER METER SQUARED"
; BSA is required to derive the maximum daily dose, exit if not defined
I $$UP^XLFSTR(PSSDADE)["PER METER SQUARED" D G MAXDQ:PSSDADC1=""
. ; -- check BSA
. I $G(^TMP($J,PSSDADB,"IN","DOSE","BSA"))>0 D
. . ; -- Calculate FDB Max Daily Dose or Dose Form as PSSDADC1=PSSDADC1*patient BSA (in m2)
. . S PSSDADC1=PSSDADC1*$G(^TMP($J,PSSDADB,"IN","DOSE","BSA"))
. ELSE D
. . ; -- if unable to calculate set FDB Max Daily Dose or Dose Form Unit=""
. . S PSSDADC1=""
. . ; -- update max daily dose error message if BSA missing
. . D ERRMSG(PSSDADO,PSSDADB,"Body surface area")
;
; -- build customized max daily dose message, kill FDB message, set message flag
D MAXDMSG(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDADH,PSSDADU,PSSDADC1,PSSDADFF,.PSSDBCAR)
; -- set custom max daily dose check flag completed=1
S PSSCMDDF=1
MAXDQ ; -- set frequency flag=0 if unable to complete max daily dose check
I '$G(PSSCMDDF) S $P(PSSDBCAR(PSSDADO),"^",4)=0
Q
;
CALCDDA(PSSDADF,PSSDADD) ; -- in 2.1 calculate daily dose amount by converting FDB frequency patterns into numeric daily dose amount
;PSSDADF - Frequency Pattern
;PSSDADD - Dose Amount
;
;Return: Calculated Daily Dose Amount or 0
;
N PSSDADL,PSSDADN,PSSDADTM,PSSDADS
; -- check for missing variables, exit if not defined
I $G(PSSDADF)']""!($G(PSSDADD)'>0) Q 0
; -- every day, in morning, at bed time, in evening
I PSSDADF="QD"!(PSSDADF="QAM")!(PSSDADF="QHS")!(PSSDADF="QPM") Q PSSDADD
; -- every other day
I PSSDADF="QOD" Q .5*PSSDADD
; -- twice a day
I PSSDADF="BID" Q $$CALCDDAT("D",2,PSSDADD)
; -- three times per day
I PSSDADF="TID" Q $$CALCDDAT("D",3,PSSDADD)
; -- four times per day
I PSSDADF="QID" Q $$CALCDDAT("D",4,PSSDADD)
; -- set PSSDADL=Frequency Length, exit if not equal to 3 or 4
S PSSDADL=$L(PSSDADF) I PSSDADL'=3,PSSDADL'=4 Q 0
; -- set PSSDADS=Action associated with frequency Q=every, X=times
S PSSDADS=$E(PSSDADF)
; -- check action associated with frequency, exit if not "Q" or "X"
I PSSDADS'="Q",PSSDADS'="X" Q 0
; -- set PSSDADN=Frequency Number
S PSSDADN=$E(PSSDADF,2,$L(PSSDADF)-1)
; -- check if PSSDADN is numeric, exit if it is not
I PSSDADN'?.N Q 0
; -- set PSSDADTM=period of time associated with frequency H=hour, D=day, W=week, L=month
S PSSDADTM=$E(PSSDADF,PSSDADL)
; -- calculate times per day, week, month
I PSSDADS="X" Q $$CALCDDAT(PSSDADTM,PSSDADN,PSSDADD)
; -- check for period of time, exit if not defined
I PSSDADTM'="H",PSSDADTM'="D",PSSDADTM'="W",PSSDADTM'="L" Q 0
; -- calculate 24 hours/Frequency Number*Dose Amount
I PSSDADTM="H" Q 24/PSSDADN*PSSDADD
; -- calculate 1 day/Frequency Number*Dose Amount
I PSSDADTM="D" Q 1/PSSDADN*PSSDADD ;PSSDADD/PSSDADN
; -- calculate 1/(7 days*Frequency Number)*Dose Amount
I PSSDADTM="W" Q 1/(7*PSSDADN)*PSSDADD
; -- calculate 1/(30 days*Frequency Number)*Dose Amount
Q 1/(30*PSSDADN)*PSSDADD
;
CALCDDAT(PSSDADTM,PSSDADN,PSSDADD) ; -- in 2.1 calculate daily dose amount based on time per day, week or month
;PSSDADTM - Period of Time [D=day, W=week, L=month]
;PSSDADN - Frequency Number
;PSSDADD - Dose Amount
;
;Return: Calculated Daily Dose Amount or 0
;
; -- check for missing variables, exit if not defined
I $G(PSSDADTM)']""!($G(PSSDADN)'>0)!($G(PSSDADD)'>0) Q 0
; -- check for period of time, exit if not defined
I PSSDADTM'="D",PSSDADTM'="W",PSSDADTM'="L" Q 0
; -- times per day calculate Frequency Number*Dose Amount
I PSSDADTM="D" Q PSSDADN*PSSDADD
; -- times per week calculate (Frequency Number/7)*Dose Amount
I PSSDADTM="W" Q (PSSDADN/7)*PSSDADD
; -- times per month calculate (Frequency Number/30)*Dose Amount
Q (PSSDADN/30)*PSSDADD
;
GETUNIT(PSSDADE,PSSDADU) ; -- in 2.1 FDB not sending Dose Unit in Standard format try and derive
;PSSDADE - FDB Max Daily Dose or Dose Form Unit String
; [Ex. "milliliter per day"]
;PSSDADU - FDB Dose Unit
;
;Return: First Databank Dose Unit or ""
;
; -- check for missing variables, exit if not defined
I $G(PSSDADE)']""!($G(PSSDADU)']"") Q ""
; -- parse PSSDADE string to get text for Dose Unit before first space
N PSSDADL,PSSDUIEN,PSSFDBU
I PSSDADE[" " D I PSSDADE="" Q ""
. F PSSDADL=1:1:$L(PSSDADE) Q:$E(PSSDADE,PSSDADL)'=" "
. I $L(PSSDADE)=PSSDADL S PSSDADE="" Q
. S PSSDADE=$E(PSSDADE,PSSDADL,$L(PSSDADE))
. S PSSDADE=$P(PSSDADE," ")
; -- convert text to upper case
S PSSDADE=$$UP^XLFSTR(PSSDADE)
; -- if text matches FDB Dose Unit, return FDB Dose Unit and exit
I PSSDADE=PSSDADU Q PSSDADU
; -- check Dose Unit file (#51.24) for a matching First Databank Dose Unit
; -- if text matches First Databank Dose Unit, return First Databank Dose Unit and exit
S PSSDUIEN=$O(^PS(51.24,"C",PSSDADE,0)) I PSSDUIEN Q PSSDADE
; -- if text matches Name, return First Databank Dose Unit and exit
S PSSDUIEN=$O(^PS(51.24,"UPCASE",PSSDADE,0)) I PSSDUIEN D Q PSSFDBU
. S PSSFDBU=$P($G(^PS(51.24,PSSDUIEN,0)),"^",2)
; -- if text matches a Synonym, return First Databank Dose Unit and exit
S PSSDUIEN=$O(^PS(51.24,"D",PSSDADE,0)) I PSSDUIEN D Q PSSFDBU
. S PSSFDBU=$P($G(^PS(51.24,PSSDUIEN,0)),"^",2)
Q ""
;
CONVMDDA(PSSDADU,PSSFDBU,PSSDADC1) ; -- in 2.1 Convert FDB Max Daily Dose or Dose Form Amount using Dose Unit Conversion file (#51.25)
;PSSDADU - FDB Dose Unit
;PSSFDBU - FDB Max Daily Dose or Dose Form Unit
;PSSDADC1- FDB Max Daily Dose or Dose Form Amount
;
;Return: Converted FDB Max Daily Dose or Dose Form Amount or ""
;
N PSSCMDDA,PSSDADM,PSSDUCI,PSSDUC2I
; -- check for missing variables, exit if not defined
I $G(PSSDADU)']""!($G(PSSFDBU)']"")!($G(PSSDADC1)'>0) Q ""
; -- If FDB Dose Unit is the same as the FDB Max Daily Dose or Dose Form Unit
; return the FDB Max Daily Dose or Dose Form Amount
I PSSDADU=PSSFDBU Q PSSDADC1
; -- set PSSDUCI=Dose Unit Conversion file (#51.25) IEN, exit if not defined
S PSSDUCI=$O(^PS(51.25,"B",PSSFDBU,0)) I 'PSSDUCI Q ""
; -- set PSSDUC2I=Dose Unit 2 sub-file (#51.251) IEN, exit if not defined
S PSSDUC2I=$O(^PS(51.25,PSSDUCI,1,"B",PSSDADU,0)) I 'PSSDUC2I Q ""
; -- set PSSDADM=Conversion Factor field (#1) in Dose Unit 2 sub-file (#51.251), exit if not defined
S PSSDADM=$P($G(^PS(51.25,PSSDUCI,1,PSSDUC2I,0)),"^",2) I 'PSSDADM Q ""
; -- set PSSDADC1=(FDB Max Daily Dose or Dose Form)*Conversion Factor
S PSSCMDDA=PSSDADC1*PSSDADM I 'PSSCMDDA Q ""
Q PSSCMDDA
;
MAXDMSG(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDADH,PSSDADU,PSSDADC1,PSSDADFF,PSSDBCAR) ; -- in 2.1 build customized max daily dose message
;PSSDADO - Order Number
;PSSDADB - Base
;PSSDADNM - Drug Name
;PSSDADI - Drug IEN
;PSSDADH - Calculated Daily Dose or Dose Form Amount
;PSSDADU - FDB Dose Unit
;PSSDADC1- FDB Max Daily Dose or Dose Form Amount
;PSSDADFF - Dose Form Unit Flag (Optional)
;PSSDBCAR - array documented in PSSDSEXC
;
;Return: If message is built set show custom max daily dose message flag
; $P(PSSDBCAR(PSSDADO),"^",28)=1
;
N PSSERRN,PSSMSG,PSSDWL1
; -- check for missing variables, exit if not defined
I $G(PSSDADO)']""!($G(PSSDADB)']"")!($G(PSSDADNM)']"")!($G(PSSDADI)'>0)!($G(PSSDADH)'>0)!($G(PSSDADU)']"")!($G(PSSDADC1)'>0) Q
I $G(PSSDADO)]"",'$D(PSSDBCAR(PSSDADO)) Q
; -- check if Calculated Daily Dose or Dose Form (PSSDADH) is greater than FDB Max Daily Dose or Dose Form (PSSDADC1)
I PSSDADH>PSSDADC1 D
. ; -- build customized max daily dose message
. S PSSMSG="Total dose"_$S($G(PSSDADFF):" form",1:"")_" amount of "_$$FMTNUM($G(PSSDADH))_" "_$G(PSSDADU)_"/DAY exceeds the maximum daily dose"_$S($G(PSSDADFF):" form",1:"")_" amount of "_$$FMTNUM($G(PSSDADC1))_" "_$G(PSSDADU)_"/DAY."
. ; -- set message
. S ^TMP($J,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX","MESSAGE",PSSDADI)=PSSMSG
. ; -- set show custom max daily dose message flag=1
. S $P(PSSDBCAR(PSSDADO),"^",28)=1
; -- initialize error number
S PSSERRN=0
; -- search for FDB max daily dose frequency check error to delete
S PSSDWL1=""
F S PSSDWL1=$O(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1)) Q:PSSDWL1=""!(PSSERRN>0) D
. ; -- check for FDB max daily dose frequency check error
. I $G(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Max Daily" D
. . ; -- set error number to error to delete
. . S PSSERRN=PSSDWL1
; -- delete FDB max daily dose frequency check error
I PSSERRN>0 K ^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSERRN)
Q
;
FMTNUM(X,PSSGDIF) ; -- in 2.1 format number for display
;X - Number
;PSSGDIF - General Dosing Information Flag (Optional)
;
;Return: Formatted Number or 0
;
;Format Criteria:
; - If after a decimal only zeros exist, do not display (i.e. 600.0 or 600.00 display 600)
; - Maintain leading zeros (i.e. 0.25)
; - For Customized Max Daily Dose (MDD):
; -- Round calculated value to 3 decimal places.
; -- If result is '0' after 3 decimals places, return 5 decimal places or all decimal places.
; - For General Dosing Information (GDI):
; -- Round calculated value to 5 decimal places.
; -- If result is '0' after 5 decimals places, return 6 decimal places or all decimal places.
;
; Examples:
; - If calculated MDD was 0.0001234
; rounding to 3 decimals was 0.000 then display 0.00012.
; - If calculated MDD was 0.000678
; rounding to 3 decimals was 0.001 then display 0.001.
; - If calculated GDI was 0.000001234
; rounding to 5 decimals was 0.00000 then display 0.000001.
; - If calculated MDD was 0.00000678
; rounding to 5 decimals was 0.00001 then display 0.00001.
N ND,X2,X3
; -- check for missing variable, exit if not defined
I $G(X)'>0 Q 0
; -- get number of decimals, exclude trailing zeros
S ND=$L($P(+X,".",2))
; -- calculate number of decimals for rounding
I $G(PSSGDIF) D
. S X2=$S(X'[".":0,$J(X,"",5)<.00001:$S(ND<6:ND,1:6),ND<5:ND,1:5)
ELSE D
. S X2=$S(X'[".":0,$J(X,"",3)<.001:$S(ND<5:ND,1:5),ND<3:ND,1:3)
; -- if value of X is zero, use entire decimal value
I +$J(X,"",X2)=0 S X2=$L($P(X,".",2))
; -- format number
S X=$J(X,"",X2)
; -- strip leading and trailing zeros
S X=+X
; -- add leading 0 for decimal value
I $E(X)="." S X="0"_X
; -- include commas in number format
I $L($P(X,".",1))>3 S:X'["." X2=0 S X3=$L(X) D COMMA^%DTC
Q $G(X)
;
ERRMSG(PSSDADO,PSSDADB,PSSERRT) ; -- in 2.1 update max daily dose error message if BSA or weight missing
;PSSDADO - Order Number
;PSSDADB - Base
;PSSERRT - Type of Error [Weight or Body surface area]
N PSSDWL1,PSSERRN,PSSERRM
; -- check for missing variables, exit if not defined
I $G(PSSDADO)']""!($G(PSSDADB)']"")!($G(PSSERRT)']"") Q
; -- initialize error number
S PSSERRN=0
; -- initialize error message
S PSSERRM=$G(PSSERRT)_" required"
; -- search for FDB max daily dose error to update
S PSSDWL1=""
F S PSSDWL1=$O(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1)) Q:PSSDWL1=""!(PSSERRN>0) D
. ; -- check for FDB max daily dose error
. I $G(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Max Daily" D
. . ; -- set error number to error to update
. . S PSSERRN=PSSDWL1
. ; -- check for FDB maximum single dose error, if contains type of error get message
. I $G(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Maximum Single",$G(^("TEXT"))[PSSERRT D
. . ; -- get FDB maximum single error message
. . S PSSERRM=$G(^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"TEXT"))
; -- update FDB max daily dose error message
I PSSERRN>0,$G(PSSERRM)]"" S ^TMP($J,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSERRN,"TEXT")=PSSERRM
Q
;
CHKCFREQ(PSSDADO,PSSDBASE,PSSDBASG,PSSDBCAR) ; -- in 2.1 check for custom frequency -- called from PSSDSAPA
;PSSDADO - Order Number
;PSSDBASE - Base
;PSSDBASG - Base for Pharmacy
;PSSDBCAR - array documented in PSSDSEXC
N PSSCFMSG,PSSCNTR,PSSDADNM,PSSDWIEN
; -- check for missing variables, exit if not defined
I $G(PSSDADO)']""!($G(PSSDBASE)']"")!($G(PSSDBASG)']"") Q
I $G(PSSDADO)]"",'$D(PSSDBCAR(PSSDADO)) Q
; -- if exclude from Daily Dose check based on Schedule=1 or indicate this Dosing sequence is part of a complex order=1
; or dosing sequence to do Daily Dose check, based on sum of previous Dosing sequences in complex order=1, exit don't include custom frequency
I $P(PSSDBCAR(PSSDADO),"^",15)!($P(PSSDBCAR(PSSDADO),"^",16))!($P(PSSDADO,";",5)) Q
; -- set PSSDADNM=Drug Name, PSSDWIEN=Drug IEN, PSSCNTR=Counter
S PSSDADNM=$P(PSSDBCAR(PSSDADO),"^",2),PSSDWIEN=+$P(PSSDBCAR(PSSDADO),"^",3),PSSCNTR=$P(PSSDADO,";",4)
; -- check for custom frequency
I $G(^TMP($J,PSSDBASE,"OUT","DOSE",PSSDADO,PSSDADNM,"FREQ","FREQUENCYCUSTOMMESSAGE",PSSDWIEN))]"" S PSSCFMSG=$G(^(PSSDWIEN)) D
.S ^TMP($J,PSSDBASG,"OUT",PSSCNTR,PSSDADO,"MESSAGE","4_TRAIL")=PSSCFMSG
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSSDSUTA 16928 printed Nov 22, 2024@17:41:25 Page 2
PSSDSUTA ;BIR/RTR-Dosing Utility Routine ;11/24/14
+1 ;;1.0;PHARMACY DATA MANAGEMENT;**178,224**;9/30/97;Build 3
+2 ;
FCY() ;Validate Frequency, leading and trailing spaces already stripped off, and uppercase conversion done
+1 NEW PSSFCYF,PSSFCYL,PSSFCY1,PSSFCY2,PSSFCYA,PSSFCYB
+2 SET PSSFCYF=$PIECE(PSSDBEB2,"^",8)
+3 IF $DATA(PSSDBCAZ(PSSDBEB1,"FRQ_ERROR"))!(PSSFCYF="")!(PSSFCYF[".")
QUIT 1
+4 IF PSSFCYF?.N
QUIT 0
+5 IF PSSFCYF="QD"!(PSSFCYF="BID")!(PSSFCYF="TID")!(PSSFCYF="QID")!(PSSFCYF="QAM")!(PSSFCYF="QSHIFT")!(PSSFCYF="QOD")!(PSSFCYF="QHS")!(PSSFCYF="QPM")
QUIT 0
+6 SET PSSFCYL=$LENGTH(PSSFCYF)
IF PSSFCYL'=3
IF PSSFCYL'=4
QUIT 1
+7 SET PSSFCY1=$EXTRACT(PSSFCYF)
SET PSSFCY2=$EXTRACT(PSSFCYF,PSSFCYL)
+8 IF PSSFCY1'="Q"
IF PSSFCY1'="X"
QUIT 1
+9 IF PSSFCY1="Q"
IF "DWLH"'[PSSFCY2
QUIT 1
+10 IF PSSFCY1="X"
IF "DWL"'[PSSFCY2
QUIT 1
+11 SET PSSFCYA=$EXTRACT(PSSFCYF,2)
IF PSSFCYA'?1N
QUIT 1
+12 IF PSSFCYL=3
QUIT 0
+13 SET PSSFCYB=$EXTRACT(PSSFCYF,3)
IF PSSFCYB'?1N
QUIT 1
+14 QUIT 0
+15 ;
MAXD(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDBCAR) ; -- in 2.1 Perform Max Daily Dose check when Frequency is Out of Range - called from PSSHRQ24
+1 ;PSSDADO - Order Number
+2 ;PSSDADB - Base
+3 ;PSSDADNM - Drug Name
+4 ;PSSDADI - Drug IEN
+5 ;PSSDBCAR - array documented in PSSDSEXC
+6 ;
+7 ;Return: If message is built, show custom max daily dose message flag is set to 1
+8 ; $P(PSSDBCAR(PSSDADO),"^",28)=1
+9 ; If unable to complete max daily dose check, set frequency flag to 0
+10 ; $P(PSSDBCAR(PSSDADO),"^",4)=0
+11 ;
+12 NEW PSSCMDDF,PSSDADD,PSSDADZ,PSSDADU,PSSDADH,PSSDADC1,PSSDADE,PSSDADF,PSSDADFF,PSSFDBU
+13 ; -- check for missing variables, exit if not defined
+14 IF $GET(PSSDADO)']""!($GET(PSSDADB)']"")!($GET(PSSDADNM)']"")!($GET(PSSDADI)'>0)
QUIT
+15 IF $GET(PSSDADO)]""
IF '$DATA(PSSDBCAR(PSSDADO))
QUIT
+16 ; -- initialize custom max daily dose check flag
+17 SET PSSCMDDF=0
+18 ; -- set PSSDADZ=Input Parameters
+19 SET PSSDADZ=$GET(^TMP($JOB,PSSDADB,"IN","DOSE",PSSDADO))
+20 ; -- set PSSDADD=Dose Amount, PSSDADU=FDB Dose Unit, PSSDADF=Frequency
+21 SET PSSDADD=$PIECE(PSSDADZ,"^",5)
SET PSSDADU=$PIECE(PSSDADZ,"^",6)
SET PSSDADF=$PIECE(PSSDADZ,"^",8)
+22 ; -- check key variables, exit if not defined
+23 IF PSSDADD=""!(PSSDADU="")!(PSSDADF="")
GOTO MAXDQ
+24 ; -- get dose form unit flag
+25 SET PSSDADFF=$PIECE(PSSDADZ,"^",14)
+26 ; -- Calculated Daily Dose or Dose Form Amount
+27 ; -- if numeric PSSDADH=frequency*dose amount, otherwise call function to determine
+28 SET PSSDADH=$SELECT(PSSDADF?.N:PSSDADF*PSSDADD,1:$$CALCDDA(PSSDADF,PSSDADD))
+29 ; -- exit if not defined
+30 IF 'PSSDADH
GOTO MAXDQ
+31 ; -- set PSSDADE=FDB Max Daily Dose or Dose Form Unit
+32 SET PSSDADE=$GET(^TMP($JOB,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX",$SELECT(PSSDADFF:"DOSEFORMUNIT",1:"DOSEUNIT"),PSSDADI))
+33 ; -- set PSSDADC1=FDB Max Daily Dose or Dose Form Amount
+34 SET PSSDADC1=$GET(^TMP($JOB,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX",$SELECT(PSSDADFF:"DOSEFORM",1:"DOSE"),PSSDADI))
+35 ; -- exit if not defined
+36 IF PSSDADE=""!(PSSDADC1="")
GOTO MAXDQ
+37 ;
+38 ; -- FDB not sending FDB Max Daily Dose or Dose Form Unit in Standard format try and derive
+39 SET PSSFDBU=$$GETUNIT(PSSDADE,PSSDADU)
+40 ; -- exit if not defined
+41 IF PSSFDBU=""
GOTO MAXDQ
+42 ;
+43 ; -- if FDB Dose Unit is different than FDB Max Daily Dose or Dose Form Unit see if FDB Max Daily Dose or Dose Form Amount can be converted, exit if not defined
+44 IF PSSDADU'=PSSFDBU
SET PSSDADC1=$$CONVMDDA(PSSDADU,PSSFDBU,PSSDADC1)
IF PSSDADC1=""
GOTO MAXDQ
+45 ;
+46 ; -- if FDB Max Daily Dose or Dose Form Unit Value contains "PER KILOGRAM"
+47 ; weight is required to derive the maximum daily dose, exit if not defined
+48 IF $$UP^XLFSTR(PSSDADE)["PER KILOGRAM"
Begin DoDot:1
+49 ; -- check weight
+50 IF $GET(^TMP($JOB,PSSDADB,"IN","DOSE","WT"))>0
Begin DoDot:2
+51 ; -- Calculate FDB Max Daily Dose or Dose Form as PSSDADC1=PSSDADC1*patient weight (in kg)
+52 SET PSSDADC1=PSSDADC1*$GET(^TMP($JOB,PSSDADB,"IN","DOSE","WT"))
End DoDot:2
+53 IF '$TEST
Begin DoDot:2
+54 ; -- if unable to calculate set FDB Max Daily Dose or Dose Form Unit=""
+55 SET PSSDADC1=""
+56 ; -- update max daily dose error message if weight missing
+57 DO ERRMSG(PSSDADO,PSSDADB,"Weight")
End DoDot:2
End DoDot:1
if PSSDADC1=""
GOTO MAXDQ
+58 ;
+59 ; -- if FDB Max Daily Dose or Dose Form Unit Value contains "PER METER SQUARED"
+60 ; BSA is required to derive the maximum daily dose, exit if not defined
+61 IF $$UP^XLFSTR(PSSDADE)["PER METER SQUARED"
Begin DoDot:1
+62 ; -- check BSA
+63 IF $GET(^TMP($JOB,PSSDADB,"IN","DOSE","BSA"))>0
Begin DoDot:2
+64 ; -- Calculate FDB Max Daily Dose or Dose Form as PSSDADC1=PSSDADC1*patient BSA (in m2)
+65 SET PSSDADC1=PSSDADC1*$GET(^TMP($JOB,PSSDADB,"IN","DOSE","BSA"))
End DoDot:2
+66 IF '$TEST
Begin DoDot:2
+67 ; -- if unable to calculate set FDB Max Daily Dose or Dose Form Unit=""
+68 SET PSSDADC1=""
+69 ; -- update max daily dose error message if BSA missing
+70 DO ERRMSG(PSSDADO,PSSDADB,"Body surface area")
End DoDot:2
End DoDot:1
if PSSDADC1=""
GOTO MAXDQ
+71 ;
+72 ; -- build customized max daily dose message, kill FDB message, set message flag
+73 DO MAXDMSG(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDADH,PSSDADU,PSSDADC1,PSSDADFF,.PSSDBCAR)
+74 ; -- set custom max daily dose check flag completed=1
+75 SET PSSCMDDF=1
MAXDQ ; -- set frequency flag=0 if unable to complete max daily dose check
+1 IF '$GET(PSSCMDDF)
SET $PIECE(PSSDBCAR(PSSDADO),"^",4)=0
+2 QUIT
+3 ;
CALCDDA(PSSDADF,PSSDADD) ; -- in 2.1 calculate daily dose amount by converting FDB frequency patterns into numeric daily dose amount
+1 ;PSSDADF - Frequency Pattern
+2 ;PSSDADD - Dose Amount
+3 ;
+4 ;Return: Calculated Daily Dose Amount or 0
+5 ;
+6 NEW PSSDADL,PSSDADN,PSSDADTM,PSSDADS
+7 ; -- check for missing variables, exit if not defined
+8 IF $GET(PSSDADF)']""!($GET(PSSDADD)'>0)
QUIT 0
+9 ; -- every day, in morning, at bed time, in evening
+10 IF PSSDADF="QD"!(PSSDADF="QAM")!(PSSDADF="QHS")!(PSSDADF="QPM")
QUIT PSSDADD
+11 ; -- every other day
+12 IF PSSDADF="QOD"
QUIT .5*PSSDADD
+13 ; -- twice a day
+14 IF PSSDADF="BID"
QUIT $$CALCDDAT("D",2,PSSDADD)
+15 ; -- three times per day
+16 IF PSSDADF="TID"
QUIT $$CALCDDAT("D",3,PSSDADD)
+17 ; -- four times per day
+18 IF PSSDADF="QID"
QUIT $$CALCDDAT("D",4,PSSDADD)
+19 ; -- set PSSDADL=Frequency Length, exit if not equal to 3 or 4
+20 SET PSSDADL=$LENGTH(PSSDADF)
IF PSSDADL'=3
IF PSSDADL'=4
QUIT 0
+21 ; -- set PSSDADS=Action associated with frequency Q=every, X=times
+22 SET PSSDADS=$EXTRACT(PSSDADF)
+23 ; -- check action associated with frequency, exit if not "Q" or "X"
+24 IF PSSDADS'="Q"
IF PSSDADS'="X"
QUIT 0
+25 ; -- set PSSDADN=Frequency Number
+26 SET PSSDADN=$EXTRACT(PSSDADF,2,$LENGTH(PSSDADF)-1)
+27 ; -- check if PSSDADN is numeric, exit if it is not
+28 IF PSSDADN'?.N
QUIT 0
+29 ; -- set PSSDADTM=period of time associated with frequency H=hour, D=day, W=week, L=month
+30 SET PSSDADTM=$EXTRACT(PSSDADF,PSSDADL)
+31 ; -- calculate times per day, week, month
+32 IF PSSDADS="X"
QUIT $$CALCDDAT(PSSDADTM,PSSDADN,PSSDADD)
+33 ; -- check for period of time, exit if not defined
+34 IF PSSDADTM'="H"
IF PSSDADTM'="D"
IF PSSDADTM'="W"
IF PSSDADTM'="L"
QUIT 0
+35 ; -- calculate 24 hours/Frequency Number*Dose Amount
+36 IF PSSDADTM="H"
QUIT 24/PSSDADN*PSSDADD
+37 ; -- calculate 1 day/Frequency Number*Dose Amount
+38 ;PSSDADD/PSSDADN
IF PSSDADTM="D"
QUIT 1/PSSDADN*PSSDADD
+39 ; -- calculate 1/(7 days*Frequency Number)*Dose Amount
+40 IF PSSDADTM="W"
QUIT 1/(7*PSSDADN)*PSSDADD
+41 ; -- calculate 1/(30 days*Frequency Number)*Dose Amount
+42 QUIT 1/(30*PSSDADN)*PSSDADD
+43 ;
CALCDDAT(PSSDADTM,PSSDADN,PSSDADD) ; -- in 2.1 calculate daily dose amount based on time per day, week or month
+1 ;PSSDADTM - Period of Time [D=day, W=week, L=month]
+2 ;PSSDADN - Frequency Number
+3 ;PSSDADD - Dose Amount
+4 ;
+5 ;Return: Calculated Daily Dose Amount or 0
+6 ;
+7 ; -- check for missing variables, exit if not defined
+8 IF $GET(PSSDADTM)']""!($GET(PSSDADN)'>0)!($GET(PSSDADD)'>0)
QUIT 0
+9 ; -- check for period of time, exit if not defined
+10 IF PSSDADTM'="D"
IF PSSDADTM'="W"
IF PSSDADTM'="L"
QUIT 0
+11 ; -- times per day calculate Frequency Number*Dose Amount
+12 IF PSSDADTM="D"
QUIT PSSDADN*PSSDADD
+13 ; -- times per week calculate (Frequency Number/7)*Dose Amount
+14 IF PSSDADTM="W"
QUIT (PSSDADN/7)*PSSDADD
+15 ; -- times per month calculate (Frequency Number/30)*Dose Amount
+16 QUIT (PSSDADN/30)*PSSDADD
+17 ;
GETUNIT(PSSDADE,PSSDADU) ; -- in 2.1 FDB not sending Dose Unit in Standard format try and derive
+1 ;PSSDADE - FDB Max Daily Dose or Dose Form Unit String
+2 ; [Ex. "milliliter per day"]
+3 ;PSSDADU - FDB Dose Unit
+4 ;
+5 ;Return: First Databank Dose Unit or ""
+6 ;
+7 ; -- check for missing variables, exit if not defined
+8 IF $GET(PSSDADE)']""!($GET(PSSDADU)']"")
QUIT ""
+9 ; -- parse PSSDADE string to get text for Dose Unit before first space
+10 NEW PSSDADL,PSSDUIEN,PSSFDBU
+11 IF PSSDADE[" "
Begin DoDot:1
+12 FOR PSSDADL=1:1:$LENGTH(PSSDADE)
if $EXTRACT(PSSDADE,PSSDADL)'=" "
QUIT
+13 IF $LENGTH(PSSDADE)=PSSDADL
SET PSSDADE=""
QUIT
+14 SET PSSDADE=$EXTRACT(PSSDADE,PSSDADL,$LENGTH(PSSDADE))
+15 SET PSSDADE=$PIECE(PSSDADE," ")
End DoDot:1
IF PSSDADE=""
QUIT ""
+16 ; -- convert text to upper case
+17 SET PSSDADE=$$UP^XLFSTR(PSSDADE)
+18 ; -- if text matches FDB Dose Unit, return FDB Dose Unit and exit
+19 IF PSSDADE=PSSDADU
QUIT PSSDADU
+20 ; -- check Dose Unit file (#51.24) for a matching First Databank Dose Unit
+21 ; -- if text matches First Databank Dose Unit, return First Databank Dose Unit and exit
+22 SET PSSDUIEN=$ORDER(^PS(51.24,"C",PSSDADE,0))
IF PSSDUIEN
QUIT PSSDADE
+23 ; -- if text matches Name, return First Databank Dose Unit and exit
+24 SET PSSDUIEN=$ORDER(^PS(51.24,"UPCASE",PSSDADE,0))
IF PSSDUIEN
Begin DoDot:1
+25 SET PSSFDBU=$PIECE($GET(^PS(51.24,PSSDUIEN,0)),"^",2)
End DoDot:1
QUIT PSSFDBU
+26 ; -- if text matches a Synonym, return First Databank Dose Unit and exit
+27 SET PSSDUIEN=$ORDER(^PS(51.24,"D",PSSDADE,0))
IF PSSDUIEN
Begin DoDot:1
+28 SET PSSFDBU=$PIECE($GET(^PS(51.24,PSSDUIEN,0)),"^",2)
End DoDot:1
QUIT PSSFDBU
+29 QUIT ""
+30 ;
CONVMDDA(PSSDADU,PSSFDBU,PSSDADC1) ; -- in 2.1 Convert FDB Max Daily Dose or Dose Form Amount using Dose Unit Conversion file (#51.25)
+1 ;PSSDADU - FDB Dose Unit
+2 ;PSSFDBU - FDB Max Daily Dose or Dose Form Unit
+3 ;PSSDADC1- FDB Max Daily Dose or Dose Form Amount
+4 ;
+5 ;Return: Converted FDB Max Daily Dose or Dose Form Amount or ""
+6 ;
+7 NEW PSSCMDDA,PSSDADM,PSSDUCI,PSSDUC2I
+8 ; -- check for missing variables, exit if not defined
+9 IF $GET(PSSDADU)']""!($GET(PSSFDBU)']"")!($GET(PSSDADC1)'>0)
QUIT ""
+10 ; -- If FDB Dose Unit is the same as the FDB Max Daily Dose or Dose Form Unit
+11 ; return the FDB Max Daily Dose or Dose Form Amount
+12 IF PSSDADU=PSSFDBU
QUIT PSSDADC1
+13 ; -- set PSSDUCI=Dose Unit Conversion file (#51.25) IEN, exit if not defined
+14 SET PSSDUCI=$ORDER(^PS(51.25,"B",PSSFDBU,0))
IF 'PSSDUCI
QUIT ""
+15 ; -- set PSSDUC2I=Dose Unit 2 sub-file (#51.251) IEN, exit if not defined
+16 SET PSSDUC2I=$ORDER(^PS(51.25,PSSDUCI,1,"B",PSSDADU,0))
IF 'PSSDUC2I
QUIT ""
+17 ; -- set PSSDADM=Conversion Factor field (#1) in Dose Unit 2 sub-file (#51.251), exit if not defined
+18 SET PSSDADM=$PIECE($GET(^PS(51.25,PSSDUCI,1,PSSDUC2I,0)),"^",2)
IF 'PSSDADM
QUIT ""
+19 ; -- set PSSDADC1=(FDB Max Daily Dose or Dose Form)*Conversion Factor
+20 SET PSSCMDDA=PSSDADC1*PSSDADM
IF 'PSSCMDDA
QUIT ""
+21 QUIT PSSCMDDA
+22 ;
MAXDMSG(PSSDADO,PSSDADB,PSSDADNM,PSSDADI,PSSDADH,PSSDADU,PSSDADC1,PSSDADFF,PSSDBCAR) ; -- in 2.1 build customized max daily dose message
+1 ;PSSDADO - Order Number
+2 ;PSSDADB - Base
+3 ;PSSDADNM - Drug Name
+4 ;PSSDADI - Drug IEN
+5 ;PSSDADH - Calculated Daily Dose or Dose Form Amount
+6 ;PSSDADU - FDB Dose Unit
+7 ;PSSDADC1- FDB Max Daily Dose or Dose Form Amount
+8 ;PSSDADFF - Dose Form Unit Flag (Optional)
+9 ;PSSDBCAR - array documented in PSSDSEXC
+10 ;
+11 ;Return: If message is built set show custom max daily dose message flag
+12 ; $P(PSSDBCAR(PSSDADO),"^",28)=1
+13 ;
+14 NEW PSSERRN,PSSMSG,PSSDWL1
+15 ; -- check for missing variables, exit if not defined
+16 IF $GET(PSSDADO)']""!($GET(PSSDADB)']"")!($GET(PSSDADNM)']"")!($GET(PSSDADI)'>0)!($GET(PSSDADH)'>0)!($GET(PSSDADU)']"")!($GET(PSSDADC1)'>0)
QUIT
+17 IF $GET(PSSDADO)]""
IF '$DATA(PSSDBCAR(PSSDADO))
QUIT
+18 ; -- check if Calculated Daily Dose or Dose Form (PSSDADH) is greater than FDB Max Daily Dose or Dose Form (PSSDADC1)
+19 IF PSSDADH>PSSDADC1
Begin DoDot:1
+20 ; -- build customized max daily dose message
+21 SET PSSMSG="Total dose"_$SELECT($GET(PSSDADFF):" form",1:"")_" amount of "_$$FMTNUM($GET(PSSDADH))_" "_$GET(PSSDADU)_"/DAY exceeds the maximum daily dose"_$SELECT(...
... $GET(PSSDADFF):" form",1:"")_" amount of "_$$FMTNUM($GET(PSSDADC1))_" "_$GET(PSSDADU)_"/DAY."
+22 ; -- set message
+23 SET ^TMP($JOB,PSSDADB,"OUT","DOSE",PSSDADO,PSSDADNM,"DAILYMAX","MESSAGE",PSSDADI)=PSSMSG
+24 ; -- set show custom max daily dose message flag=1
+25 SET $PIECE(PSSDBCAR(PSSDADO),"^",28)=1
End DoDot:1
+26 ; -- initialize error number
+27 SET PSSERRN=0
+28 ; -- search for FDB max daily dose frequency check error to delete
+29 SET PSSDWL1=""
+30 FOR
SET PSSDWL1=$ORDER(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1))
if PSSDWL1=""!(PSSERRN>0)
QUIT
Begin DoDot:1
+31 ; -- check for FDB max daily dose frequency check error
+32 IF $GET(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Max Daily"
Begin DoDot:2
+33 ; -- set error number to error to delete
+34 SET PSSERRN=PSSDWL1
End DoDot:2
End DoDot:1
+35 ; -- delete FDB max daily dose frequency check error
+36 IF PSSERRN>0
KILL ^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSERRN)
+37 QUIT
+38 ;
FMTNUM(X,PSSGDIF) ; -- in 2.1 format number for display
+1 ;X - Number
+2 ;PSSGDIF - General Dosing Information Flag (Optional)
+3 ;
+4 ;Return: Formatted Number or 0
+5 ;
+6 ;Format Criteria:
+7 ; - If after a decimal only zeros exist, do not display (i.e. 600.0 or 600.00 display 600)
+8 ; - Maintain leading zeros (i.e. 0.25)
+9 ; - For Customized Max Daily Dose (MDD):
+10 ; -- Round calculated value to 3 decimal places.
+11 ; -- If result is '0' after 3 decimals places, return 5 decimal places or all decimal places.
+12 ; - For General Dosing Information (GDI):
+13 ; -- Round calculated value to 5 decimal places.
+14 ; -- If result is '0' after 5 decimals places, return 6 decimal places or all decimal places.
+15 ;
+16 ; Examples:
+17 ; - If calculated MDD was 0.0001234
+18 ; rounding to 3 decimals was 0.000 then display 0.00012.
+19 ; - If calculated MDD was 0.000678
+20 ; rounding to 3 decimals was 0.001 then display 0.001.
+21 ; - If calculated GDI was 0.000001234
+22 ; rounding to 5 decimals was 0.00000 then display 0.000001.
+23 ; - If calculated MDD was 0.00000678
+24 ; rounding to 5 decimals was 0.00001 then display 0.00001.
+25 NEW ND,X2,X3
+26 ; -- check for missing variable, exit if not defined
+27 IF $GET(X)'>0
QUIT 0
+28 ; -- get number of decimals, exclude trailing zeros
+29 SET ND=$LENGTH($PIECE(+X,".",2))
+30 ; -- calculate number of decimals for rounding
+31 IF $GET(PSSGDIF)
Begin DoDot:1
+32 SET X2=$SELECT(X'[".":0,$JUSTIFY(X,"",5)<.00001:$SELECT(ND<6:ND,1:6),ND<5:ND,1:5)
End DoDot:1
+33 IF '$TEST
Begin DoDot:1
+34 SET X2=$SELECT(X'[".":0,$JUSTIFY(X,"",3)<.001:$SELECT(ND<5:ND,1:5),ND<3:ND,1:3)
End DoDot:1
+35 ; -- if value of X is zero, use entire decimal value
+36 IF +$JUSTIFY(X,"",X2)=0
SET X2=$LENGTH($PIECE(X,".",2))
+37 ; -- format number
+38 SET X=$JUSTIFY(X,"",X2)
+39 ; -- strip leading and trailing zeros
+40 SET X=+X
+41 ; -- add leading 0 for decimal value
+42 IF $EXTRACT(X)="."
SET X="0"_X
+43 ; -- include commas in number format
+44 IF $LENGTH($PIECE(X,".",1))>3
if X'["."
SET X2=0
SET X3=$LENGTH(X)
DO COMMA^%DTC
+45 QUIT $GET(X)
+46 ;
ERRMSG(PSSDADO,PSSDADB,PSSERRT) ; -- in 2.1 update max daily dose error message if BSA or weight missing
+1 ;PSSDADO - Order Number
+2 ;PSSDADB - Base
+3 ;PSSERRT - Type of Error [Weight or Body surface area]
+4 NEW PSSDWL1,PSSERRN,PSSERRM
+5 ; -- check for missing variables, exit if not defined
+6 IF $GET(PSSDADO)']""!($GET(PSSDADB)']"")!($GET(PSSERRT)']"")
QUIT
+7 ; -- initialize error number
+8 SET PSSERRN=0
+9 ; -- initialize error message
+10 SET PSSERRM=$GET(PSSERRT)_" required"
+11 ; -- search for FDB max daily dose error to update
+12 SET PSSDWL1=""
+13 FOR
SET PSSDWL1=$ORDER(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1))
if PSSDWL1=""!(PSSERRN>0)
QUIT
Begin DoDot:1
+14 ; -- check for FDB max daily dose error
+15 IF $GET(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Max Daily"
Begin DoDot:2
+16 ; -- set error number to error to update
+17 SET PSSERRN=PSSDWL1
End DoDot:2
+18 ; -- check for FDB maximum single dose error, if contains type of error get message
+19 IF $GET(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"MSG"))["Maximum Single"
IF $GET(^("TEXT"))[PSSERRT
Begin DoDot:2
+20 ; -- get FDB maximum single error message
+21 SET PSSERRM=$GET(^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSDWL1,"TEXT"))
End DoDot:2
End DoDot:1
+22 ; -- update FDB max daily dose error message
+23 IF PSSERRN>0
IF $GET(PSSERRM)]""
SET ^TMP($JOB,PSSDADB,"OUT","DOSE","ERROR",PSSDADO,PSSERRN,"TEXT")=PSSERRM
+24 QUIT
+25 ;
CHKCFREQ(PSSDADO,PSSDBASE,PSSDBASG,PSSDBCAR) ; -- in 2.1 check for custom frequency -- called from PSSDSAPA
+1 ;PSSDADO - Order Number
+2 ;PSSDBASE - Base
+3 ;PSSDBASG - Base for Pharmacy
+4 ;PSSDBCAR - array documented in PSSDSEXC
+5 NEW PSSCFMSG,PSSCNTR,PSSDADNM,PSSDWIEN
+6 ; -- check for missing variables, exit if not defined
+7 IF $GET(PSSDADO)']""!($GET(PSSDBASE)']"")!($GET(PSSDBASG)']"")
QUIT
+8 IF $GET(PSSDADO)]""
IF '$DATA(PSSDBCAR(PSSDADO))
QUIT
+9 ; -- if exclude from Daily Dose check based on Schedule=1 or indicate this Dosing sequence is part of a complex order=1
+10 ; or dosing sequence to do Daily Dose check, based on sum of previous Dosing sequences in complex order=1, exit don't include custom frequency
+11 IF $PIECE(PSSDBCAR(PSSDADO),"^",15)!($PIECE(PSSDBCAR(PSSDADO),"^",16))!($PIECE(PSSDADO,";",5))
QUIT
+12 ; -- set PSSDADNM=Drug Name, PSSDWIEN=Drug IEN, PSSCNTR=Counter
+13 SET PSSDADNM=$PIECE(PSSDBCAR(PSSDADO),"^",2)
SET PSSDWIEN=+$PIECE(PSSDBCAR(PSSDADO),"^",3)
SET PSSCNTR=$PIECE(PSSDADO,";",4)
+14 ; -- check for custom frequency
+15 IF $GET(^TMP($JOB,PSSDBASE,"OUT","DOSE",PSSDADO,PSSDADNM,"FREQ","FREQUENCYCUSTOMMESSAGE",PSSDWIEN))]""
SET PSSCFMSG=$GET(^(PSSDWIEN))
Begin DoDot:1
+16 SET ^TMP($JOB,PSSDBASG,"OUT",PSSCNTR,PSSDADO,"MESSAGE","4_TRAIL")=PSSCFMSG
End DoDot:1
+17 QUIT