maintenance: title: Cardiac Protocol Heparin Dosing ;; mlmname: FORM_Heparin_Cardiac_Protocol;; arden: version 2;; version: 4.50;; institution: St. Clair Hospital ;; author: Teresa Spicuzza;; specialist: Robert Spence, St. Clair Hospital ;; date: 2008-06-25;; validation: testing;; library: purpose: Calculates Heparin Dose based on Patient Weight. ;; explanation: On any event, this MLM gathers information from the fields on the Weight-based heparing order entry form and sets a fatal error flag is needed. Processing continues only if there are no errors on the form. On the FormOpen event, the MLM will transfer the value of hte rate field to the current rate field. On the FieldChange event the fields "Current Rate Action" and "Adjustment in units/kg/hr" are considered. Form to which to attach: PRX_IvDrpHepWtBased Calling Event: FormOpen Calling Event: FieldChange Calling Field: PRX_HepWbRateAdjust Calling Field: PRX_HepChgValue History 07/18/2008 RS Added logic to cap the variable used for calculating the Rate ml/hr 11/21/2012 TMS Added PRX_HepWbCurrentRate as call field to logic to start calculation of adjustment and new rate - Ticket 154292 07.23.2019 TMS CSR 37676 - Change log_execution_info to false per upgrade analysis. ;; keywords: Heparin, dosage,; ;; knowledge: type: data-driven;; data: /*-----------------------------------------------------------------------*/ /* This MLM receives three objects from the system, of types shown below */ /*-----------------------------------------------------------------------*/ (this_comm, // Communication type object this_form, // Form type object client_obj // Arden ClientInfo type object ) := argument; /************* Make Changes To Spelling And Flags In This Section *************/ /*------------------------------------*/ /* Set to true if a CDS log is needed.*/ /*------------------------------------*/ log_execution_info := false; /*-------------------------*/ /* set flags and variables */ /*-------------------------*/ fatal_error := false; hep_soln_conc := 50; // "standard" concentration in units/ml Measurements_di := "CombinedMeasurements"; APTT_val_sec_di := "PRX_HepWtBase_APTTvalue"; curr_rate_u_h_di := "PRX_HepWbCurrentRate"; curr_rate_adj_di := "PRX_HepWbRateAdjust"; adj_val_u_h_di := "PRX_HepChgUnitsPerHr"; calc_rate_di := "PRX_Generic_CB"; iv_rate_u_h_di := "PRX_DRIPINIT"; iv_rate_ml_comp := "OrderIVRate"; route_di := "OrderRouteCode"; // iv_rate_ml_h_di := "PRX_DRIPINIT"; // iv_rate_uom_di := "PRX_DRIPINITUOM"; /******************************************************************************/ /*--------------------------*/ /* set up testing variables */ /*--------------------------*/ if called_by_editor then visit_obj := read last {ClientVisit: THIS}; // client_obj := read last {ClientInfo: THIS}; endif; /*-------------------------------------------*/ /* get information from Communication object */ /*-------------------------------------------*/ called_by := this_comm.CallingEvent; call_field := this_comm.CallingFieldName; if called_by_editor then client_guid := visit_obj.clientguid; visit_guid := visit_obj.GUID; chart_guid := visit_obj.chartguid; orderId := "1000002689073001"; called_by := "FormOpen"; else client_guid := this_comm.ClientGUID; visit_guid := this_comm.ClientVisitGUID; chart_guid := this_comm.ChartGuid; orderid := this_comm.ItemID; endif; /*------------------------------------------------------------*/ /* Assign pointers to the Field list and to individual fields */ /*------------------------------------------------------------*/ field_list := this_form.fields; comb_ht_wt_fld := first of (field_list where field_list.DataItemName = Measurements_di); APTT_val_sec_fld := first of (field_list where field_list.DataItemName = APTT_val_sec_di); curr_rate_u_h_fld := first of (field_list where field_list.DataItemName = curr_rate_u_h_di); curr_rate_adj_fld := first of (field_list where field_list.DataItemName = curr_rate_adj_di); adj_val_u_h_fld := first of (field_list where field_list.DataItemName = adj_val_u_h_di); calc_rate_fld := first of (field_list where field_list.DataItemName = calc_rate_di); iv_rate_u_h_fld := first of (field_list where field_list.DataItemName = iv_rate_u_h_di); iv_rate_ml_h_fld :=first of (field_list where field_list.DataItemName = iv_rate_ml_comp ); EdLocFld := first of (field_list where field_list.DataItemName = "ED Location"); FromOrderSet := first of (field_list where field_list.DataItemName = "MLM_From Order Set"); /*--------------------------------------*/ /* RS: 06/12 get location */ /*--------------------------------------*/ If (called_by = "FormOpen") or (call_field = "MLM_From Order Set") then //Retrieve Patient{{{SINGLE-QUOTE}}}s Current Location LocName:= read last {"SELECT currentlocation " || " FROM cv3clientvisit " || " WHERE ClientGUID = " || SQL(client_guid ) || " And GUID = " || SQL(visit_guid)}; EdLocFld.Value := LocName; ApttVal := read last {"Select top 1 bo.value " || " From cv3order as o with (nolock) " || " join cv3basicobservation as bo with (nolock) " || " on o.clientguid = bo.clientguid " || " and o.chartguid = bo.chartguid " || " and o.guid = bo.orderguid " || " and bo.status = {{{SINGLE-QUOTE}}}F{{{SINGLE-QUOTE}}} " || " and bo.Active = 1 " || " And bo.IsHistory = 0 " || " join cv3ordercatalogmasteritem as ocmi with (nolock) " || " on ocmi.guid = o.ordercatalogmasteritemguid " || " and ocmi.active = 1 " || " and ocmi.name = {{{SINGLE-QUOTE}}}APTT{{{SINGLE-QUOTE}}} " || " where o.clientguid = " || SQL(client_guid) || " and o.chartguid = " || SQL(chart_guid) || " and o.performeddtm >= (DATEADD(hour, -28, getdate())) " || " order by o.performeddtm desc " }; CompVal := ApttVal As Number; APTT_val_sec_fld.VALUE := CompVal; If (FromOrderSet.Value = True) then orderlist := read {" Select guid from cv3ordercatalogmasteritem " || " where (name = {{{SINGLE-QUOTE}}}Heparin 25,000 Units+ D5W 500ml{{{SINGLE-QUOTE}}}) or " || " (name = {{{SINGLE-QUOTE}}}Heparin 25,000 Units+ 0.9% NaCl 500ml{{{SINGLE-QUOTE}}}) " || " and active = 1 " }; orderid1:=First(orderlist); orderid2:=Last(orderlist); OldRate := read last {" Select top 1 oud.value " || " from cv3order as o with (nolock) " || " join cv3orderuserdata as oud with (nolock) " || " on oud.orderguid= o.guid " || " and oud.userdatacode = {{{SINGLE-QUOTE}}}PRX_DRIPINIT{{{SINGLE-QUOTE}}} " || " where o.clientguid = " || SQL(client_guid) || " and o.chartguid = " || SQL (chart_guid) || " and (o.ordercatalogmasteritemguid = " || SQL(orderid1) || " or o.ordercatalogmasteritemguid = " || SQL(orderid2) || ") " || " and o.requesteddtm <= getdate() " || " order by o.requesteddtm desc, o.createdwhen desc" }; else OldRate := read last {" Select top 1 oud.value " || " from cv3order as o with (nolock) " || " join cv3orderuserdata as oud with (nolock) " || " on oud.orderguid= o.guid " || " and oud.userdatacode = {{{SINGLE-QUOTE}}}PRX_DRIPINIT{{{SINGLE-QUOTE}}} " || " where o.clientguid = " || SQL(client_guid) || " and o.chartguid = " || SQL (chart_guid) || " and o.ordercatalogmasteritemguid = " || SQL(orderid) || " and o.requesteddtm <= getdate() " || " order by o.requesteddtm desc, o.createdwhen desc" }; endif; /* test := (curr_rate_adj_fld.value is null) or (curr_rate_adj_fld.Value <> "Initial") ; this_comm.Message := "Old Rate Set to " || OldRate || "\n\n Rate Adjust set to \n" || curr_rate_adj_fld.Value || "If statement would return " ||test; this_comm.MessageType := "Error"; */ If (curr_rate_adj_fld.value is null) or (curr_rate_adj_fld.Value <> "Initial") then curr_rate_u_h_fld.value := OldRate; iv_rate_ml_h_fld.control_read_only := True; iv_rate_u_h_fld.control_read_only := True; else curr_rate_u_h_fld.value := NULL; endif; // now for the suggested calculations /* test := curr_rate_adj_fld.Value <> "Initial" ; this_comm.Message := "Called by " || called_by || "\nCalling field " || call_field || "\nexists APTT_val_sec_Fld " || exists APTT_val_sec_Fld || "\nexists curr_rate_u_h_fld " || exists curr_rate_u_h_fld || "\ncurr_rate_adj_fld.Value is" || curr_rate_adj_fld.value ; this_comm.MessageType := "Error"; curr_rate_adj_fld.value := "Increase"; */ If (exists APTT_val_sec_Fld) and (exists curr_rate_u_h_fld) then If (curr_rate_adj_fld.Value <> "Initial" or curr_rate_adj_fld.Value is null) then If CompVal < 66 then curr_rate_adj_fld.value := "Increase"; adj_val_u_h_fld.value := 200; elseif (CompVal >= 66) and (CompVal <= 76) then curr_rate_adj_fld.value := "Increase"; adj_val_u_h_fld.value := 100; elseif (CompVal >= 77) and (CompVal <= 115) then curr_rate_adj_fld.value := "No Change"; adj_val_u_h_fld.value := null; elseif (CompVal >= 116) and (CompVal <= 134) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 100; elseif (CompVal >= 135) and (CompVal <= 154) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 200; elseif (CompVal > 154) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 200; fatal_error := true; this_comm.Message := "Please Note that recent APTT above 154 Seconds \n\n" ||"Please STOP HEPARIN INFUSION for 1 hour... \n\n" ||"Then resume at new rate as calculated on this order"; this_comm.MessageType := "Error"; endif; endif; else curr_rate_adj_fld.value := null; adj_val_u_h_fld.value := null; endif; endif; If EdLocFld.Value matches pattern "ER%" then IsED := True; else IsED := False; endif; /*------------------------*/ /* get values from fields */ /*------------------------*/ if exists comb_ht_wt_fld then // comb_ht_wt_fld.control_read_only := true; comb_ht_wt_val := comb_ht_wt_fld.Value; wt := comb_ht_wt_val.weight; ht := comb_ht_wt_val.height; wt_type := comb_ht_wt_val.weighttype; bsa := comb_ht_wt_val.bsa; bmi := comb_ht_wt_val.bmi; endif; if exist APTT_val_sec_fld then APTT_val_sec_fld.Control_Mandatory := false; endif; if exist curr_rate_u_h_fld then if curr_rate_u_h_fld.Value is null then curr_rate_u_h := 0; else curr_rate_u_h := curr_rate_u_h_fld.Value; endif; endif; if exist curr_rate_adj_fld then adj_action := curr_rate_adj_fld.Value; endif; if exist adj_val_u_h_fld then adj_amt_u_h := adj_val_u_h_fld.Value as number; endif; if exist iv_rate_u_h_fld then iv_rate_u_h := iv_rate_u_h_fld.Value; // iv_rate_amt := iv_rate_u_h.AMOUNT as number; // iv_rate_uom := iv_rate_u_h.UOM; endif; if exist iv_rate_ml_h_fld then iv_rate_ml_h := iv_rate_ml_h_fld.Value; endif; /*----------------------------------*/ /* process form fields and settings */ /* only if no errors are found */ /*----------------------------------*/ if not fatal_error then // if (called_by = "FormOpen") or (call_field = "MLM_From Order Set" ) then // curr_rate_u_h_fld.Control_Read_Only := false; // curr_rate_u_h_fld.Value := iv_rate_u_h.Amount; // curr_rate_u_h_fld.Control_Read_Only := true; /// APTT_val_sec_fld.Control_Mandatory := false; // APTT_val_sec_fld.Value := null; If (call_field = "PRX_DRIPINIT") then marker:=true; checkrate := iv_rate_u_h_fld.Value ; if ((floor (checkrate /50)) <> (ceiling(checkrate /50)) or (checkrate is null) or (checkrate =0)) then this_comm.Message := "Your IV Rate Must Be Divisible by 50" || "\n\n" || "You Entered: " || checkrate; this_comm.MessageType := "Error"; iv_rate_u_h_fld.value:=null; iv_rate_ml_h.Amount := null; else iv_rate_ml_h.Amount := checkrate /50; endif; // TMS added PRX_HepWbCurrentRate to logic to prevent looping when current rate is changed // elseif (call_field ="PRX_HepWtBase_APTTvalue") and (curr_rate_adj_fld.value is null or curr_rate_adj_fld.Value <> "Initial") then elseif ((call_field ="PRX_HepWtBase_APTTvalue") or (call_field = "PRX_HepWbCurrentRate")) and (curr_rate_adj_fld.value is null or curr_rate_adj_fld.Value <> "Initial") then iv_rate_u_h_fld.Value:= null; iv_rate_ml_h.Amount := null; If (curr_rate_adj_fld.value is null or curr_rate_adj_fld.Value <> "Initial") then APTT_val_sec_fld.Control_Mandatory := true; curr_rate_adj_fld.value := null; adj_val_u_k_h_fld.value := null; endif; CompVal := APTT_val_sec_fld.VALUE As Number; If CompVal is not null then If (exists APTT_val_sec_Fld) and (exists curr_rate_u_h_fld) then If CompVal < 66 then curr_rate_adj_fld.value := "Increase"; adj_val_u_h_fld.value := 200; elseif (CompVal >= 66) and (CompVal <= 76) then curr_rate_adj_fld.value := "Increase"; adj_val_u_h_fld.value := 100; elseif (CompVal >= 77) and (CompVal <= 115) then curr_rate_adj_fld.value := "No Change"; adj_val_u_h_fld.value := null; elseif (CompVal >= 116) and (CompVal <= 134) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 100; elseif (CompVal >= 135) and (CompVal <= 154) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 200; elseif (CompVal > 154) then curr_rate_adj_fld.value := "Decrease"; adj_val_u_h_fld.value := 200; endif; endif; else curr_rate_adj_fld.value := null; adj_val_u_k_h_fld.value := null; endif; elseif (call_field = calc_rate_di) or (called_by = "FormOpen") or (FromOrderSet.Value = True) then calc_rate_fld.Value := False; CompVal := APTT_val_sec_fld.VALUE As Number; if (CompVal > 154) then fatal_error := true; this_comm.Message := "Please Note that recent APTT above 154 Seconds \n\n" ||"Please STOP HEPARIN INFUSION for 1 hour... \n\n" ||"Then resume at new rate as calculated on this order"; this_comm.MessageType := "Error"; endif; if adj_action = "Initial" then /* clear adjustment field and make read only */ adj_val_u_h_fld.Value := null; adj_val_u_h_fld.Control_Mandatory := false; adj_val_u_h_fld.Control_Read_Only := true; /* calculate initial rate units/hr */ calc_rate_u_h := (wt * 12) + curr_rate_u_h; round_rate_u_h := int((calc_rate_u_h + 25)/50) * 50; If round_rate_u_h >= 1000 then iv_rate_u_h_fld.Value := 1000; round_rate_u_h := 1000; else iv_rate_u_h_fld.Value := round_rate_u_h; endif; // iv_rate_u_h.Amount := round_rate_u_h; // iv_rate_u_h.UOM := "units/hr"; /* calculate rate ml/hr */ calc_rate_ml_h := round_rate_u_h / hep_soln_conc; iv_rate_ml_h.Amount := calc_rate_ml_h as number; elseif adj_action = "No Change" then /* clear adjustment field and make read only */ adj_val_u_h_fld.Value := null; adj_val_u_h_fld.Control_Mandatory := false; adj_val_u_h_fld.Control_Read_Only := true; /* make APTT field mandatory */ APTT_val_sec_fld.Control_Mandatory := true; /* calculate "new" rate units/hr */ calc_rate_u_h := (wt * 0) + curr_rate_u_h; round_rate_u_h := int((calc_rate_u_h + 25)/50) * 50; iv_rate_u_h_fld.Value := round_rate_u_h; // iv_rate_u_h.Amount := round_rate_u_h; // iv_rate_u_h.UOM := "units/hr"; /* calculate rate ml/hr */ calc_rate_ml_h := round_rate_u_h / hep_soln_conc; iv_rate_ml_h.Amount := calc_rate_ml_h as number; elseif (adj_action = "Increase") or (adj_action = "Decrease") then if adj_action = "Decrease" then adj_amt_u_h := -adj_amt_u_h ; endif; iv_rate_u_h_fld.Value := curr_rate_u_h + adj_amt_u_h ; // iv_rate_u_h.Amount := round_rate_u_h; // iv_rate_u_h.UOM := "units/hr"; /* calculate rate ml/hr */ calc_rate_ml_h := iv_rate_u_h_fld.Value / hep_soln_conc; iv_rate_ml_h.Amount := calc_rate_ml_h as number; endif; endif; // called_by = ... endif; // not fatal error ;; evoke: // No evoke statement ;; logic: conclude true; // always, to return modified objects ;; action: /*-----------------------------------------------------------*/ /* return communication_type and form_type objects to system */ /*-----------------------------------------------------------*/ return this_comm, this_form; ;; end: