maintenance: title: Dosing recommendations based on age, weight, or total dose;; mlmname: SCH_Other_Dosing_Recommendations;; arden: version 2;; version: 5.50;; institution: St Clair;; author: Teresa Spicuzza, Allscripts Corp;; specialist: Teresa Spicuzza;; date: 2012-08-20;; validation: testing;; library: purpose: Dosing Recommendations and Warnings for select medications ;; explanation: MLM will read table for drug and suggest dosing as stated in logic. Change history 06.12.2013 TMS Created CSR 31334 06.09.2015 TMS Updated for allopurinol alert. CSR 33467 05.16.2018 TMS Add "With Dialysis Treatment" to Frequency retrievals that contain As Ordered. CSR 33940 Drugs included in MLM: Methotrexate; Allopurinol ;; keywords: Dosing ;; knowledge: type: data-driven;; data: // Specify which .NET assemblies need to be loaded for ObjectsPlus standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; error_occurred := false; error_message := ""; str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; log_execution_info := false; //Set the text for this variable to indicate whether to send the message or not send_alert := "DoNotSend"; //-------------------------------------------------------------------- if called_by_editor then EvokingObject := read last {Order: THIS where Name="Ketorolac Inj" }; endif; doalert := false; order_enter_event := event { OrderEnter User Order: where TypeCode = "Medication"}; (CatalogItemObj, FrequencyValue, UOMValue, DoseValue, OrderName, AdminIns, UserSchedType ,UserSchedDays, UserSchedDoses, OrderingProviderGuid) := read last {Order: OrderCatalogMasterItem, FrequencyCode, UOM, DosageLow, Name, AdminInstructions, Interval, DaysInInterval, DoseMultiplier, CareProviderGuid REFERENCING EvokingObject}; CatalogClassTypeValueObj := read last {OrderCatalogMasterItem: CatalogClassTypeValue, REFERENCING CatalogItemObj}; ClassTypeValue_code_list, ClassTypeValue_value_list := read {CatalogClassTypeValue: Code, Value REFERENCING CatalogClassTypeValueObj where code = "PRX_DosingAlerts"}; /* Get the OrderAdditionalInfo object pointer */ OrderAdditionalInfoObj := read last { Order: OrderAdditionalInfo REFERENCING EvokingObject }; /* Get information from the OrderAdditionalInfo object */ (SummaryLine, FreqfromTime,FreqUOM, StopAfterValue, StopAfterOption ) := read last { OrderAdditionalInfo: FreqSummaryLine, FreqFromTime, FreqUOM, StopAfterValue, StopAfterOption REFERENCING OrderAdditionalInfoObj }; dose_alert_dest := destination {alert} with [alert_type := "Warning", short_message := "Dosing Recommendation", priority := "Low", scope := "Chart", rule_group := "Dosing Recommendations", rule_number := 4081, send_with_order := send_alert, alert_dialog_settings := "", display_alert := true]; for r in (1 seqto 1) do classvaluelist := call str_parse with ClassTypeValue_value_list [r],","; classvalue := classvaluelist[1]; enddo; // if EvokingEvent = order_enter_event then if "PRX_DosingAlerts" in ClassTypeValue_code_list then continue := "yes"; else continue := "no"; endif; endif; If continue = "yes" then (schedtime, freqcode, timefrom, timeuom) := read last {" select fsd.ScheduledTime, cft.FrequencyCode, cft.TimeFromValue, cft.TimeUom from CV3CodedFreqTranslation cft" || " join CV3FixedScheduleDefinition fsd on fsd.ParentGUID = cft.guid " || " where cft.FrequencyCode = " || sql(frequencyvalue) || " and FrequencyClass = {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} and cft.Active = 1" || " order by fsd.ScheduledTime " }; (TimesPerDay) := read last {" select count (fsd.ScheduledTime) from CV3CodedFreqTranslation cft" || " join CV3FixedScheduleDefinition fsd on fsd.ParentGUID = cft.guid " || " where cft.FrequencyCode = " || sql(frequencyvalue) || " and FrequencyClass = {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} and cft.Active = 1" }; Oncegroup := ("Now", "STAT", "Once", "One Time", "Today,", "Load", "Pre-procedure", "Post-procedure","Pre-Transfusion", "Post-Transfusion","Between Blood", "PRE OP,", "POST OP", "As Ordered", "As Directed", "Given in Infusion Center", "Given in Delivery Room","With Dialysis Treatment"); If frequencyvalue in Oncegroup then frequencygroup := "OneTime"; else frequencygroup := "Other"; endif; If frequencyvalue <> "" and frequencygroup <> "OneTime" then If timefrom = 1 and timeuom = "day" then If TimesPerDay = 1 then frequencygroup := "Q24H"; Freqfactor := 24; Weeklydoses := 7; endif; If TimesPerDay = 2 then frequencygroup := "Q12H"; Freqfactor := 12; Weeklydoses := 14; endif; If TimesPerDay = 3 then frequencygroup := "Q8H"; Freqfactor := 8; Weeklydoses := 21; endif; If TimesPerDay = 4 then frequencygroup := "Q6H"; Freqfactor := 6; Weeklydoses := 28; endif; If TimesPerDay = 6 then frequencygroup := "Q4H"; Freqfactor := 4; Weeklydoses := 42; endif; If TimesPerDay = 8 then frequencygroup := "Q3H"; Freqfactor := 3; Weeklydoses := 56; endif; If TimesPerDay = 12 then frequencygroup := "Q2H"; Freqfactor := 2; Weeklydoses := 84; endif; If TimesPerDay = 24 then frequencygroup := "Q1H"; Freqfactor := 1; Weeklydoses := 168; endif; elseif timefrom = 2 and timeuom = "day" then If TimesPerDay = 1 then frequencygroup := "Q48H"; Weeklydoses := 4; endif; endif; endif; If frequencyvalue = "" then If UserSchedType = "Weekly" then If UserSchedDays <= 2 and UserSchedDoses = 1 then frequencygroup := "Q7D"; elseif UserSchedDays >2 or UserSchedDoses > 1 then Weeklydoses := ((UserSchedDays as number) - 1) * (UserSchedDoses as number); frequencygroup := "Other"; endif; elseif UserSchedType = "Daily" and UserSchedDays = 1 and FreqFromTime = 1 and FreqUom = "day" then If UserSchedDoses = 1 then frequencygroup := "Q24H"; Freqfactor := 24; Weeklydoses := 7; endif; If UserSchedDoses = 2 then frequencygroup := "Q12H"; Freqfactor := 12; Weeklydoses := 14; endif; If UserSchedDoses = 3 then frequencygroup := "Q8H"; Freqfactor := 8; Weeklydoses := 21; endif; If UserSchedDoses = 4 then frequencygroup := "Q6H"; Freqfactor := 6; Weeklydoses := 27; endif; If UserSchedDoses = 6 then frequencygroup := "Q4H"; Freqfactor := 4; Weeklydoses := 42; endif; If UserSchedDoses = 8 then frequencygroup := "Q3H"; Freqfactor := 3; Weeklydoses := 56; endif; If UserSchedDoses = 12 then frequencygroup := "Q2H"; Freqfactor := 2; Weeklydoses := 84; endif; If UserSchedDoses = 24 then frequencygroup := "Q1H"; Freqfactor := 1; Weeklydoses := 168; endif; elseif UserSchedType = "Daily" and UserSchedDays = 1 and FreqFromTime = 2 and FreqUom = "day" then If UserSchedDoses = 1 then frequencygroup := "Q48H"; Weeklydoses := 4; endif; endif; endif; //If frequencyvalue = "" DurationFactor := StopAfterValue; If StopAfterOption = 2 then DurationType := "Hours"; OrderDuration := StopAfterValue || DurationType; endif; If StopAfterOption = 3 then DurationType := "Mins"; OrderDuration := StopAfterValue || DurationType; endif; If StopAfterOption = 4 then DurationType := "Times"; OrderDuration := StopAfterValue || DurationType; endif; If StopAfterOption = 1 then DurationType := "Days"; OrderDuration := StopAfterValue || DurationType; endif; If StopAfterOption = 0 then DurationFactor := 1; DurationType := "Days"; endif; // Calculate the Total Daily Dose // If (DoseValue as number) > 0 then If (UserSchedDoses as number) > 0 and UserSchedType = "Daily" and UserSchedDays = 1 then If DurationType = "Days" and StopAfterOption = 0 then TotalDailyDose := ((UserSchedDoses as number) * (DoseValue as number)); TotalWeeklyDose := ((TotalDailyDose as number) * 7); elseif DurationType = "Days" and StopAfterOption = 1 then // TotalDailyDose := ((UserSchedDoses as number) * (DoseValue as number)); If (DurationFactor as number) < 7 then TotalWeeklyDose := ((TotalDailyDose as number) * (DurationFactor as number)); else TotalWeeklyDose := ((TotalDailyDose as number) * 7); endif; // elseif DurationType = "Times" and (DurationFactor as number) < (UserSchedDoses as number) then TotalDailyDose := ((DurationFactor as number) * (DoseValue as number)); TotalWeeklyDose := TotalDailyDose; elseif DurationType = "Times" and (DurationFactor as number) > (UserSchedDoses as number) then If (DurationFactor as number) > (WeeklyDoses as number) then TotalWeeklyDose := (DoseValue as number) * (WeeklyDoses as number); else TotalWeeklyDose := (DoseValue as number) * (DurationFactor as number); endif; // elseif DurationType = "Hours" and (DurationFactor as number) <= 24 then TotalDailyDose := (Int((DurationFactor as number)/(FreqFactor as number))) * (DoseValue as number); elseif DurationType = "Mins" and (DurationFactor as number) <= 999 then TotalDailyDose := (Int((DurationFactor as number) / 60)/(FreqFactor as number)) * (DoseValue as number); endif; elseif UserSchedType = "Weekly" and frequencygroup = "Other" then TotalWeeklyDose := ((DoseValue as number) * WeeklyDoses); elseif (TimesPerDay as number) > 0 then If DurationType = "Days" and StopAfterOption = 0 then TotalDailyDose := ((TimesPerDay as number) * (DoseValue as number)); TotalWeeklyDose := ((TotalDailyDose as number) * 7); elseif DurationType = "Days" and StopAfterOption = 1 then TotalDailyDose := ((TimesPerDay as number) * (DoseValue as number)); If (DurationFactor as number) < 7 then TotalWeeklyDose := ((TotalDailyDose as number) * (DurationFactor as number)); else TotalWeeklyDose := ((TotalDailyDose as number) * 7); endif; elseif DurationType = "Times" and (DurationFactor as number) < (TimesPerDay as number) then TotalDailyDose := ((DurationFactor as number) * (DoseValue as number)); TotalWeeklyDose := TotalDailyDose; elseif DurationType = "Times" and (DurationFactor as number) > (TimesPerDay as number) then If (DurationFactor as number) > (WeeklyDoses as number) then TotalWeeklyDose := (DoseValue as number) * (WeeklyDoses as number); else TotalWeeklyDose := (DoseValue as number) * (DurationFactor as number); endif; elseif DurationType = "Hours" and (DurationFactor as number) <= 24 then TotalDailyDose := (Int((DurationFactor as number)/(FreqFactor as number))) * (DoseValue as number); elseif DurationType = "Mins" and (DurationFactor as number) <= 999 then TotalDailyDose := (Int((DurationFactor as number) / 60)/(FreqFactor as number)) * (DoseValue as number); endif; else TotalDailyDose := "Unknown"; endif; endif; //If (DoseValue as number) > 0 (ClientVisitGuid, ChartGuid, ClientGuid, CurrentLocation, LocationGuid, VisitStatus) := read last {ClientVisit: GUID, ChartGUID, ClientGUID, CurrentLocation, CurrentLocationGUID, VisitStatus }; (UserGUID ) := read last { UserInfo: GUID }; // Get the patient age (birthdate,dobM,dobD,birth_year, patientgender ) := read last { ClientInfo: BirthDate, BirthMonthNum, BirthDayNum, BirthYearNum, gendercode }; patientAge := (NOW - birthdate) / (1 year); patientage:= (int (patientage)); // Get the patient weight wtgm := read last { " Select Text from CV3PhysicalNoteDeclaration " || " where ClientGUID = " || SQL(ClientGuid) || " and ClientVisitGUID = " || SQL(ClientVisitGuid) || " and TypeCode = {{{SINGLE-QUOTE}}}weight{{{SINGLE-QUOTE}}} " || " order by Entered asc " }; patientwt := (wtgm as number) / 1000; if continue = "yes" then // Compare ordering info with rule info and process when match found. If Classvalue = "Methotrexate" then If ((TotalWeeklyDose as number) < 25) and UOMValue = "mg" then If (Frequencygroup <> "Q7D") then if (Frequencygroup = "Q12H" and OrderDuration = "3Times")and TotalWeeklyDose <= 25 then doalert := false; else Rulemsg := "For autoimmune indications, methotrexate is usually dosed weekly OR the weekly dose may be divided q12hr x 3 doses." ||"\n Please review frequency, dosing, and indication carefully."; alert_message := "{{+B}} Ordered: "||OrderName || " " || DoseValue || UomValue|| ", " || SummaryLine || "\n\n {{+R}}" || Rulemsg || "{{-R}} {{-B}}"; doalert := true; endif; endif; elseIf (((DoseValue as number)> 25)or ((TotalWeeklyDose as number) > 25)) and UOMValue = "mg" then If Frequencygroup = "Q7D" then Rulemsg := "Methotrexate doses greater than 25mg PO weekly for autoimmune conditions" || " are not usually recommended due to increased risk of toxicity."; alert_message := "{{+B}} Ordered: "||OrderName || " " || DoseValue || UomValue|| ", " || SummaryLine || " \n\n {{+R}}" || Rulemsg || "{{-R}} {{-B}}"; doalert := true; else Rulemsg := "Methotrexate doses >25 mg (or Total Weekly Dose > 25mg) PO are associated with increased toxicity and" || " should be reviewed or prescribed by Hematology/Oncology."; alert_message := "{{+B}} Ordered: "||OrderName || " " || DoseValue || UomValue|| ", " || SummaryLine || " \n\n {{+R}}" || Rulemsg || "{{-R}} {{-B}}"; doalert := true; endif; elseIf ((TotalWeeklyDose as number)> 25) and UOMValue = "mg" then If Frequencygroup <> "Q7D" then Rulemsg := "Methotrexate doses >25 mg (or Total Weekly Dose > 25mg) PO associated with increased toxicity and" || " should be reviewed or prescribed by Hematology/Oncology."; alert_message := "{{+B}} Ordered: "||OrderName || " " || DoseValue || UomValue|| ", " || SummaryLine || " \n\n {{+R}}" || Rulemsg || "{{-R}} {{-B}}"; doalert := true; endif; endif; elseif Classvalue = "Allopurinol" then if frequencygroup = "Q24H" and (DoseValue as number)> 300 then Rulemsg := "Doses greater than 300mg/day should be administered in divided doses."; alert_message := "{{+B}} Ordered: "||OrderName || " " || DoseValue || UomValue|| ", " || SummaryLine || " \n\n {{+R}}" || Rulemsg || "{{-R}} {{-B}}"; doalert := true; endif; else doalert := false; endif; // endif; endif; endif; ;; priority: 50 ;; evoke: order_enter_event; ;; logic: if called_by_editor then conclude false; endif; //---------------------------------------------------------------- // If there is no evoking object then do nothing, this can // only be true for the MLM Editor //---------------------------------------------------------------- if EvokingObject is null then conclude false; endif; if continue = "no" then conclude false; endif; conclude doalert; ;; action: write alert_message at dose_alert_dest ;; Urgency: 50;; end: