maintenance: title: FORM_SET_PNEUMONIA_ANTIBIOTICS;; mlmname: FORM_SET_PNEUMONIA_ANTIBIOTICS;; arden: version 2.5;; version: 15.10;; institution: St Clair Hospital;; author: Juliet M. Law, Allscripts ;; specialist: Peggy Leschak, Allscripts;; date: 2016-03-23;; validation: testing;; library: purpose: Used for Pneumonia Antibiotics order set ;; explanation: This MLM is called from Pneumonia Antibiotics Order Set Change history 03.23.2016 JML CSR 34091: Created for Pneumonia Antibiotic Order Set 08.18.2016 JML Adding Ceftazidime / removing Cefepime due to shortage. 04.12.2017 JML CSR 35213 / 35566: Add Cefepime back; add Azithro. PO x 5 days for Community acquired NON-ICU and allow to toggle between PO and IV Azithro 02.13.2018 JML CSR 26163: Replaced Cefepime / Ceftriaxone with mini-syringe due to drug shortage 03.09.2018 TMS CSR 34822: Update Zosyn selections to use extended infusion logic ;; keywords: Called MLMs, Antibiotic Pneumonia, Weight Based Dosing ;; knowledge: type: data-driven;; data: standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; DiscontinueOrder := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_DISCONTINUE_BY_ORDERGUID{{{SINGLE-QUOTE}}}; // This MLM is passed three arguments, of types // communication_type, form_type and client info object respectively. (this_communication, // Communication object this_form, // Form object client_info_obj //Arden ClientInfo object ) := argument; ClientGuid := this_communication.ClientGUID; ChartGuid := this_communication.ChartGUID; ClientVisitGuid := this_communication.ClientVisitGUID; PrimaryObjdetail:=this_communication.PrimaryObj; OrderSetName := PrimaryObjdetail.OrderSetName; /*******************Make Changes To Spelling And Flags In This Section*******************/ /* Set to True if a decision.log is needed.*/ log_execution_info := False; /***************************************************************************************/ // Initialize error message error_message:=""; enable_chkbx_mlm := mlm {{{SINGLE-QUOTE}}}FORM_Func_Disable_OS_Checkboxes{{{SINGLE-QUOTE}}}; calc_abw_mlm := mlm {{{SINGLE-QUOTE}}}FORM_FUNC_CALC_ADJUSTED_BODY_WEIGHT{{{SINGLE-QUOTE}}}; crcl_mlm := mlm {{{SINGLE-QUOTE}}}FORM_MLM_Creatinine_Clearance_OS{{{SINGLE-QUOTE}}}; antibiotic_guideline_mlm := mlm {{{SINGLE-QUOTE}}}FORM_FUNC_DISPLAY_ANTIBIOTIC_GUIDELINES{{{SINGLE-QUOTE}}}; //Bring in Session variables local_session := cds_session.local; // Assigns fields passed in the Form object to the Field object field_list:= this_form.fields; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; exceptFld := (); vanco_logic_run := false; tobra_logic_run := false; ceftriaxone_logic_run := false; //Define fields Ceftria_Azithro_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 1); Ampicillin_Azithro_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 2); Levaquin_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 3); Zosyn_Azithro_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 5); Azithro_Merop_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 4); Aztreonam_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 7); Aztreonam_Levaquin_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 14); Meropenem_Tobramycin_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 10); Vanco_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 8); Vanco2_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 16); Cefepime_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 17 ); Cefepime_Azithro_Chk := first of ( field_list WHERE field_list.DataItemname = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 18); Cefepime_Tobramycin_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 19 ); CrCl_MgDl := first of ( field_list WHERE field_list.DataItemName = "PRX_CrCl_mg_dl" AND field_list.Control_MultiFieldOccNum = 1 ); CrCl_Estd := first of (field_list where field_list.DataItemName = "PRX_CrCl_Estimated" and field_List.Control_MultiFieldOccNum = 1); CrCl_Calc := first of ( field_list WHERE field_list.DataItemName = "PRX_Generic_CB" AND field_list.Control_MultiFieldOccNum = 1 ); ABW_Val := first of (field_list WHERE field_list.DataItemName = "PRX_ADJBodyWeight" AND field_list.Control_MultiFieldOccNum = 1 ); Override_ABX_Sched := first of ( field_list WHERE field_list.DataItemName = "PRX_Override_Abx_Scheduling" AND field_list.Control_MultiFieldOccNum = 1 ); Fire_Trough_MLM := first of ( field_list WHERE field_list.DataItemName = "MLM Generic Checkbox" AND field_list.Control_MultiFieldOccNum = 1 ); Antibiotic_Grid := first of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 1); Antibiotics_Grid_Value := Antibiotic_Grid.Value; Vancomycin_Grid := first of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 2); Vancomycin_Grid_Value := Vancomycin_Grid.Value; Ceftriaxone_Dose := first of ( field_list WHERE field_list.DataItemName = "DosageLow" AND field_list.Control_MultiFieldOccNum = 1 ); Ceftriaxone_WORX_Code := first of ( field_list WHERE field_list.DataItemName = "PRX_DRUGIDCODE" AND field_list.Control_MultiFieldOccNum = 1 ); Tobramycin_Dose := first of ( field_list WHERE field_list.DataItemName = "DosageLow" AND field_list.Control_MultiFieldOccNum = 10 ); Vancomycin_Freq := first of ( field_list WHERE field_list.DataItemName = "FrequencyCode" AND field_list.Control_MultiFieldOccNum = 1 ); Vancomycin_Freq_Val := Vancomycin_Freq.Value; Ceftriaxone := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Ceftriaxone:" OR Antibiotics_Grid_Value.Name = "Ceftriaxone Mini-Syringe" ); Azithromycin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Azithromycin:" ); Azithromycin_PO := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Azithromycin 250mg Tab" ); Ampicillin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Ampicillin:" ); Levaquin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Levofloxacin:" ); Zosyn_Low := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Piperacillin/Tazobactam:" ); Zosyn := last of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Piperacillin/Tazobactam:" ); Meropenem := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Meropenem:" ); Aztreonam := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Aztreonam:" ); Cefepime := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Cefepime:" OR Antibiotics_Grid_Value.Name = "Cefepime Mini-Syringe" ); Ceftazidime := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Ceftazidime:" ); Tobramycin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Tobramycin:" ); Vancomycin_Load := first of ( Vancomycin_Grid_Value WHERE Vancomycin_Grid_Value.Name = "Vancomycin:" ); Vancomycin := last of ( Vancomycin_Grid_Value WHERE Vancomycin_Grid_Value.Name = "Vancomycin:" ); Vancomycin_Trough := first of ( Vancomycin_Grid_Value WHERE Vancomycin_Grid_Value.Name = "Vancomycin Trough Plasma/Serum" ); Vancomycin_Nursing_Instr := first of ( Vancomycin_Grid_Value WHERE Vancomycin_Grid_Value.Name = "Nurse Instruction:" ); PCN_Allergy := first of ( field_list WHERE field_list.DataItemName = "PRX_PCN Allergy" AND field_list.Control_MultiFieldOccNum = 1 ); MRSA := first of ( field_list WHERE field_list.DataItemName = "PRX_MRSA" AND field_list.Control_MultiFieldOccNum = 1 ); Load_ReqDate := last of ( field_list WHERE field_list.DataItemName = "RequestedDate" and field_list.Control_MultiFieldOccNum = 1); Load_ReqTime := last of ( field_list WHERE field_list.DataItemName = "RequestedTime" and field_list.Control_MultiFieldOccNum = 1); Load_ReqDate_Val := Load_ReqDate.Value; Load_ReqTime_Val := Load_ReqTime.Value; Zosyn_Freq := last of ( field_list WHERE field_list.DataItemName = "FrequencyCode" and field_list.Control_MultiFieldOccNum = 3); FreqValue := Zosyn_Freq.Value; Zosyn_Freq_Dictionary := last of ( field_list WHERE field_list.DataItemName = "PRX_Zosyn_Ext_Inf_Freq" and field_list.Control_MultiFieldOccNum = 1); Maint_ReqDate := last of ( field_list WHERE field_list.DataItemName = "RequestedDate" and field_list.Control_MultiFieldOccNum = 2); Maint_ReqTime := last of ( field_list WHERE field_list.DataItemName = "RequestedTime" and field_list.Control_MultiFieldOccNum = 2); Maint_ReqDate_Val := Maint_ReqDate.Value; Maint_ReqTime_Val := Maint_ReqTime.Value; Override:= last of ( field_list WHERE field_list.DataItemName = "PRX_Generic_CB" and field_list.Control_MultiFieldOccNum = 2); ZosynMsg := last of ( field_list WHERE field_list.DataItemName = "NUR_GenAdditiionalLabel" and field_list.Control_MultiFieldOccNum = 10); NoLoad := false; ZOSYNGuid := read last { "select guid from cv3ordercatalogmasteritem where Name = {{{SINGLE-QUOTE}}}Piperacillin/Tazobactam:{{{SINGLE-QUOTE}}}" }; StdZOSYNGuid := read last { "select guid from cv3ordercatalogmasteritem where Name = {{{SINGLE-QUOTE}}}Piperacillin/Tazobactam;{{{SINGLE-QUOTE}}}" }; CRRTGuid := read last { "select guid from cv3ordercatalogmasteritem where Name = {{{SINGLE-QUOTE}}}Renal Replacement Treatment Type{{{SINGLE-QUOTE}}}"}; CRRT := read last {" select summaryline from cv3order where name = {{{SINGLE-QUOTE}}}Renal Replacement Treatment Type{{{SINGLE-QUOTE}}} and ClientGUID = " || SQL(clientguid) || " and ClientVisitGUID = " || SQL(clientvisitguid) || " and orderstatuscode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} "}; If override.value = true then Zosyn_Freq_Dictionary.Control_Read_Only := false; else Zosyn_Freq_Dictionary.Control_Read_Only := true; endif; // Get patient weight comb_ht_wt_field := first of (field_list where field_list.DataItemName = "CombinedMeasurements" AND field_list.Control_MultiFieldOccNum = 1 ); if exists comb_ht_wt_field then comb_ht_wt_val := comb_ht_wt_field.value; wt := comb_ht_wt_val.weight; ht := comb_ht_wt_val.height; weightvalue := (wt as number); endif; // Get patient age (birthDate) := read last {ClientInfo: BirthDate REFERENCING client_info_obj}; patientAge := (NOW - birthDate) / (1 year); If patientage < 11.99 and CallingEvent = "FormOpen" then; dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Patient under 12 years of age." ||"\n Please call physician for dosing. " ,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; endif; if ( CallingEvent = "FormOpen" ) then //Retrieve CrCl values (this_communication, this_form) := call crcl_mlm WITH this_communication, this_form, client_info_obj; //Populate Guidelines ( this_communication, this_form ) := call antibiotic_guideline_mlm WITH this_communication, this_form, client_info_obj; for item IN Antibiotics_Grid_Value do if ( item.Name NOT IN ( "Tobramycin:") ) then item.IsReadonly := true; endif; enddo; //Retrieve PCN Allergy information // Obtain Coded Allergen Guids (AllergenGuids) := READ {"SELECT GUID" || " FROM CV3Allergen a WITH (NOLOCK)" || " WHERE a.Code like {{{SINGLE-QUOTE}}}Penicill%{{{SINGLE-QUOTE}}} OR a.Code like {{{SINGLE-QUOTE}}}Cef%{{{SINGLE-QUOTE}}} OR a.Code like {{{SINGLE-QUOTE}}}%cillin{{{SINGLE-QUOTE}}} OR a.Code like {{{SINGLE-QUOTE}}}Cephalex%{{{SINGLE-QUOTE}}}"}; (PCNAllergyReaction) := READ {"SELECT ad.SvrtyLevelDisplay" || " FROM CV3AllergyDeclaration ad WITH (NOLOCK)" || " WHERE ad.ClientGUID = " || SQL(ClientGuid) || " AND ((ad.Text LIKE {{{SINGLE-QUOTE}}}penicil%{{{SINGLE-QUOTE}}} OR ad.Text LIKE {{{SINGLE-QUOTE}}}%pcn%{{{SINGLE-QUOTE}}} OR ad.Text LIKE {{{SINGLE-QUOTE}}}%cephalexin%{{{SINGLE-QUOTE}}} OR ad.Text LIKE {{{SINGLE-QUOTE}}}%cillin%{{{SINGLE-QUOTE}}} OR ad.Text LIKE {{{SINGLE-QUOTE}}}cef%{{{SINGLE-QUOTE}}}) " || " AND ad.Status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} AND ad.TypeCodeForOther = {{{SINGLE-QUOTE}}}drug{{{SINGLE-QUOTE}}})" || " OR (ad.ClientGUID = " || SQL(ClientGuid) || " AND ad.AllergenGUID IN (" || SQL(AllergenGuids) || ") AND ad.Status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}})"}; a := ""; for i IN 1 seqto ( count PCNAllergyReaction ) do a := a || PCNAllergyReaction[i]; enddo; if ( a <> "" ) then PCN_Allergy.Value := ( a as String ); else PCN_Allergy.Value := "NO ALLERGY"; endif; //Check for MRSA flag MRSA_result := READ LAST { "SELECT CASE WHEN ecd.EnterpriseClientCol8 = {{{SINGLE-QUOTE}}}MRSA{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}MRSA{{{SINGLE-QUOTE}}}" || " WHEN ecd.EnterpriseClientCol8 = {{{SINGLE-QUOTE}}}VRE{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}VRE{{{SINGLE-QUOTE}}}" || " WHEN ecd.EnterpriseClientCol8 = {{{SINGLE-QUOTE}}}BOTH{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}BOTH{{{SINGLE-QUOTE}}}" || " ELSE {{{SINGLE-QUOTE}}}NO FLAG{{{SINGLE-QUOTE}}}" || " END" || " FROM CV3EnterpriseClientData ecd WITH (NOLOCK)" || " WHERE ecd.ClientGUID = " || SQL(ClientGuid) }; if ( MRSA_result is null ) then MRSA.Value := "NO FLAG"; else MRSA.Value := ( MRSA_Result as String ); endif; If OrderSetName = "Pneumonia Antibiotic ED" then Zosyn_Freq_Dictionary.control_visible := FALSE; Override.control_visible := FALSE; ZosynMsg.control_visible := FALSE; endif; endif; if ( CallingEvent = "FieldChange" ) then //********* Height / Weight Measurements ******* if ( CallingField = "CombinedMeasurements|1" ) then if ( Vanco_Chk.Value = true OR Vanco2_Chk.Value = true ) then vanco_logic_run := true; endif; if ( Cefepime_Tobramycin_Chk.Value = true OR Meropenem_Tobramycin_Chk.Value = true ) then tobra_logic_run := true; endif; if (Ceftria_Azithro_Chk.Value = true ) then ceftriaxone_logic_run := true; endif; endif; //********* Creatinine Calculate ******** if ( CallingField = "PRX_CrCl_mg_dl|1" OR CallingField = "PRX_Generic_CB|1" ) then (this_communication, this_form) := call crcl_mlm WITH this_communication, this_form, client_info_obj; CrCl_Calc.Value := false; if ( Vanco_Chk.Value = true OR Vanco2_Chk.Value = true ) then vanco_logic_run := true; endif; endif; //********* CEFTRIAXONE + AZITHROMYCIN ************* if ( CallingField = "PRX_Checkbox1|1" ) then fieldValue := Ceftria_Azithro_Chk.Value; if ( fieldValue = true ) then Ceftriaxone.IsSelected := true; ceftriaxone_logic_run := true; Azithromycin.IsReadonly := false; Azithromycin_PO.IsReadonly := false; Azithromycin_PO.IsSelected := true; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, ""; elseif ( fieldValue = false ) then ceftriaxone_logic_run := false; Ceftriaxone.IsSelected := false; Azithromycin.IsReadonly := true; Azithromycin_PO.IsReadonly := true; Azithromycin_PO.IsSelected := false; Azithromycin.IsSelected := false; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //********** AMPICILLIN + AZITHROMYCIN ******************* if ( CallingField = "PRX_Checkbox1|2" ) then fieldValue := Ampicillin_Azithro_Chk.Value; if ( fieldValue = true ) then Ampicillin.IsSelected := true; Azithromycin.IsReadOnly := false; Azithromycin_PO.IsReadOnly := false; Azithromycin_PO.IsSelected := true; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, ""; elseif ( fieldValue = false ) then Ampicillin.IsSelected := false; Azithromycin.IsReadOnly := true; Azithromycin_PO.IsReadOnly := true; Azithromycin_PO.IsSelected := false; Azithromycin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //*********** LEVAQUIN ************************ if ( CallingField = "PRX_Checkbox1|3" ) then fieldValue := Levaquin_Chk.Value; if ( fieldValue = true ) then Levaquin.IsSelected := true; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, ""; elseif ( fieldValue = false ) then Levaquin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //*************** AZITHROMYCIN + MEROPENEM ******************** if ( CallingField = "PRX_Checkbox1|4" ) then fieldValue := Azithro_Merop_Chk.Value; if ( fieldValue = true ) then Azithromycin.IsSelected := true; Meropenem.IsSelected := true; exceptFld := exceptFld, Vanco_Chk.DataItemName || "|" || Vanco_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Azithromycin.IsSelected := false; Meropenem.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //*********** ZOSYN + AZITHROMYCIN *************************** if ( OrderSetName = "Pneumonia Antibiotic ED" and CallingField = "PRX_Checkbox1|5" ) then fieldValue := Zosyn_Azithro_Chk.Value; if ( fieldValue = true ) then Zosyn.IsSelected := true; Azithromycin.IsSelected := true; exceptFld := exceptFld, Vanco_Chk.DataItemName || "|" || Vanco_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Zosyn.IsSelected := false; Azithromycin.IsSelected := false; Zosyn_Low.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //*********** ZOSYN + AZITHROMYCIN *************************** if ( CallingField = "PRX_Zosyn_Ext_Inf_Freq|1" ) then override.value := true; if Zosyn_Freq_Dictionary.value = "Q12H" then FreqValue.FrequencySummary := "Q12H"; elseif Zosyn_Freq_Dictionary.value = "Q8H" then FreqValue.FrequencySummary := "Q8H"; endif; endif; if (OrderSetName = "Pneumonia Antibiotic" and ( CallingField = "PRX_Checkbox1|5" or ( CallingField = "PRX_Zosyn_Ext_Inf_Freq|1" and Zosyn_Azithro_Chk.Value = true) or (CallingField = "PRX_Generic_CB|1" and Zosyn_Azithro_Chk.Value = true) or (CallingField = "PRX_Generic_CB|2" and Zosyn_Azithro_Chk.Value = true)) ) then fieldValue := Zosyn_Azithro_Chk.Value; if ( fieldValue = true ) then Azithromycin.IsSelected := true; exceptFld := exceptFld, Vanco_Chk.DataItemName || "|" || Vanco_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; // **** Zosyn extended infusion ****** //Retrieve possible load orders LoadOrderDose, LoadOrderGuid, LoadSigDtm, LoadStopDtm, LoadOrderStatus:= read { " select me.dosagelow, o.guid, o.SignificantDtm, o.stopdtm, o.orderstatuscode from cv3order o join cv3clientvisit cv on cv.guid = o.ClientVisitGUID and cv.ClientGUID = o.ClientGUID join CV3MedicationExtension me on me.guid = o.guid where o.ClientVisitGUID = " || SQL(clientvisitguid) || " and o.ClientGuid = " || SQL(clientguid) || " and o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} and o.orderstatuscode in ({{{SINGLE-QUOTE}}}COMP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}}) and (me.dosagelow = {{{SINGLE-QUOTE}}}4.5{{{SINGLE-QUOTE}}} or me.dosagelow = {{{SINGLE-QUOTE}}}3.375{{{SINGLE-QUOTE}}}) and ( (o.OrderCatalogMasterItemGUID = " || zosynguid || " and o.frequencycode in ({{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRE OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}POST OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Pre-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Post-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Today{{{SINGLE-QUOTE}}})) or (o.OrderCatalogMasterItemGUID = " || stdzosynguid || " and o.frequencycode in ({{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRE OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}POST OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Pre-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Post-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Today{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Q6H{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Q8H{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Q12H{{{SINGLE-QUOTE}}})) ) order by o.orderstatuscode, o.SignificantDtm asc"}; //Retrieve possible maintenance orders MaintOrderDose, MaintOrderGuid := read { " select me.dosagelow, o.guid from cv3order o join CV3MedicationExtension me on me.guid = o.guid where ClientVisitGUID = " || SQL(clientvisitguid) || " and o.ClientGuid = " || SQL(clientguid) || " and o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} and o.OrderCatalogMasterItemGUID = " || ZosynGuid || " and o.frequencycode not in ({{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRE OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}POST OP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Pre-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Post-Procedure{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Today{{{SINGLE-QUOTE}}}) and o.orderstatuscode in ({{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}}) order by o.CreatedWhen asc"}; numorders := count LoadOrderDose; LoadOrderList := 1 seqto numorders; NumberMaintOrders := count MaintOrderDose; MaintOrderList := 1 seqto NumberMaintOrders; if NumberMaintOrders = 1 then MaintOrderGuid := MaintOrderGuid [1]; endif; // Check task status of maintenance orders if NumberMaintOrders > 0 then (MaintOrderLastGiven, MaintOrderHoursSinceGiven, MaintNextScheduled, MaintTaskStatus) := read {" select oto.performedfromdtm, DATEDIFF (HH, oto.performedfromdtm, getdate()), DATEDIFF (HH, oto.ScheduledDtm, getdate()), oto.TaskStatusCode from cv3ordercatalogmasteritem ocmi with (nolock) join cv3order o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid and o.ClientGUID = " || SQL(clientguid) || " and ClientVisitGuid = " || SQL(clientvisitguid) || " and o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} and ocmi.guid = " || ZosynGuid || " join cv3ordertask ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid and oto.ordertaskguid = ot.guid and o.guid in (" ||MaintOrderGuid || ") and oto.ScheduledDtm > DATEadd (HH, -14, getdate()) and oto.TaskStatusCode <> {{{SINGLE-QUOTE}}}Canceled{{{SINGLE-QUOTE}}} order by oto.taskstatuscode, oto.performedfromdtm, oto.ScheduledDtm desc" }; endif; for i in 1 seqto (count MaintTaskStatus)do if MaintTaskStatus [i] = "Overdue" then Overduetime := MaintNextScheduled [i]; elseif MaintTaskStatus [i] = "Pending" then Nextduetime := MaintNextScheduled [i]; elseif MaintTaskStatus [i] = "Performed" then HoursSinceGiven := MaintOrderHoursSinceGiven [i]; LastGivenTime := MaintOrderlastGiven [i]; endif; enddo; if numorders = 1 then LoadOrderGuid := LoadOrderGuid [1]; endif; // Check task status of load orders if numorders > 0 then (LoadOrderLastGiven, LoadOrderHoursSinceGiven, ExistingSchedule, LoadTaskStatus, LoadFrequency) := read last { " select top 1 oto.performedfromdtm, DATEDIFF (HH, oto.performedfromdtm, getdate()), oto.ScheduledDtm, oto.TaskStatusCode,o.FrequencyCode from cv3ordercatalogmasteritem ocmi join cv3order o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid and o.ClientGUID = " || SQL(clientguid) || " and o.clientvisitguid = " || SQL(clientvisitguid) || " join cv3ordertask ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid where o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} and (ocmi.guid = " ||ZosynGuid || " or ocmi.guid = " || StdZosynGuid || ") and oto.ordertaskguid = ot.guid and o.guid in (" || LoadOrderGuid || ") and oto.SignificantDtm > DATEadd (HH, -8, getdate()) and oto.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} order by oto.performedfromdtm desc" }; (LoadOrderHoursSinceScheduled, ExistingSchedule, LoadTaskStatus, LoadGuid) := read last { " select top 1 DATEDIFF (HH, oto.ScheduledDtm, getdate()) Timespan, oto.ScheduledDtm, oto.TaskStatusCode, o.guid from cv3ordercatalogmasteritem ocmi with (nolock) join cv3order o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid and o.ClientGUID = " || SQL(clientguid) || " and o.ClientVisitGUID = " || SQL(clientvisitguid) || " join cv3ordertask ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid where o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} and ocmi.guid = " || ZosynGuid || " and oto.ordertaskguid = ot.guid and o.guid in (" ||LoadOrderGuid || ") and oto.SignificantDtm > DATEadd (HH, -12, getdate()) and oto.SignificantDtm < DATEadd (HH, 1, getdate()) and oto.TaskStatusCode in ({{{SINGLE-QUOTE}}}Pending{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Overdue{{{SINGLE-QUOTE}}}) order by oto.ScheduledDtm desc" }; endif; if LoadOrderLastGiven is not null then Zosyn.IsSelected := False; Zosyn_Low.IsSelected := True; // Determine if patient needs loaded or reloaded if (LoadOrderHoursSinceGiven >= 6 and (CrCl_Estd.value is null or CrCl_Estd.value >=20) and override.value = false) or (LoadOrderHoursSinceGiven >= 8 and CrCl_Estd.value < 20 and override.value = false) or (LoadOrderHoursSinceGiven >= 6 and Override.value = true and Zosyn_Freq_Dictionary.value = "Q8H" ) or (LoadOrderHoursSinceGiven >= 8 and Override.value = true and Zosyn_Freq_Dictionary.value = "Q12H" ) then StartDTM := now ; StartMin := extract minute now; Zosyn.IsSelected := True; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 2 hour; else LoadDoseDTM := StartDTM + 1 hour; endif; else startdtm := LoadOrderLastGiven ; startmin := extract minute LoadOrderLastGiven; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 1 hour; Else LoadDoseDTM := StartDTM ; Endif; endif; elseif ExistingSchedule is not null then // If load not given but ordered within past 2 hours then don{{{SINGLE-QUOTE}}}t reorder // If greater than 2 hours and not given discontinue and reorder If LoadOrderHoursSinceScheduled < 2 then Zosyn.IsSelected := False; Zosyn_Low.IsSelected := True; StartDTM := ExistingSchedule; StartMin := extract minute ExistingSchedule; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 1 hour; else LoadDoseDTM := StartDTM; endif; else MLMMessage := "This is where we discontinue old order"; Reason := "Change Administration Times"; Source := "CPOE Clarification"; dc_call := call DiscontinueOrder with LoadOrderGuid, this_communication.CareProviderGUID, ClientVisitGUID, Reason, Source; StartDTM := now ; StartMin := extract minute now; Zosyn.IsSelected := True; Zosyn_Low.IsSelected := True; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 2 hour; else LoadDoseDTM := StartDTM + 1 hour; endif; endif; elseif // If patient has loading dose or is transitioning from standard therapy scheduled maint dose ((HoursSinceGiven as number) > 9 and override.value = false and (CrCl_Estd.value >= 20 or CrCl_Estd.value is null)) or ((HoursSinceGiven as number) > 13 and override.value = false and CrCl_Estd.value < 20) or // ((Overduetime as number) >= 2 and HoursSinceGiven is null) or ((HoursSinceGiven as number) > 9 and Override.value = true and Zosyn_Freq_Dictionary.value = "Q8H" ) or ((HoursSinceGiven as number) > 13 and Override.value = true and Zosyn_Freq_Dictionary.value = "Q12H" ) then Zosyn.IsSelected := True; Zosyn_Low.IsSelected := True; NoLoad := False; FmtLoadDate := null; FmtLoadTime := null; StartDTM := now ; StartMin := extract minute now; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 2 hour; else LoadDoseDTM := StartDTM + 1 hour; endif; elseif // If patient needs reloaded order load and schedule maint dose ((HoursSinceGiven as number) <= 9 and override.value = false and (CrCl_Estd.value >= 20 or CrCl_Estd.value is null)) or ((HoursSinceGiven as number) <= 13 and override.value = false and CrCl_Estd.value < 20) or // ((Overduetime as number) < 2 ) or ((HoursSinceGiven as number) <= 9 and override.value = true and Zosyn_Freq_Dictionary.value = "Q8H") or ((HoursSinceGiven as number) <= 13 and override.value = true and Zosyn_Freq_Dictionary.value = "Q12H") then Zosyn.IsSelected := False; NoLoad := True; Zosyn_Low.IsSelected := True; Override_ABX_Sched.value := False; StartDTM := LastGivenTime ; StartMin := extract minute LastGivenTime; If (StartMin as number) >= 45 then MaintDoseDTM := StartDTM + 1 hour; else MaintDoseDTM := StartDTM ; endif; else // No prior zosyn orders schedule load and maint dose Zosyn.IsSelected := True; Zosyn_Low.IsSelected := True; StartDTM := now ; StartMin := extract minute now; If (StartMin as number) >= 45 then LoadDoseDTM := StartDTM + 2 hour; else LoadDoseDTM := StartDTM + 1 hour; endif; endif; // format all date and times MaintDose6HR := LoadDoseDTM + 6 hour; MaintDose8HR := LoadDoseDTM + 8 hour; MaintDoseQ8HR := MaintDoseDTM + 8 hour; MaintDoseQ12HR := MaintDoseDTM + 12 hour; loadhour := extract hour LoadDoseDTM; loadmon := extract month LoadDoseDTM; loadday := extract day LoadDoseDTM; loadyear := extract year LoadDoseDTM; due6hour := extract hour MaintDose6HR; due6mon := extract month MaintDose6HR; due6day := extract day MaintDose6HR; due6year := extract year MaintDose6HR; due8hour := extract hour MaintDose8HR; due8mon := extract month MaintDose8HR; due8day := extract day MaintDose8HR; due8year := extract year MaintDose8HR; maint8hour := extract hour MaintDoseQ8HR; maint8mon := extract month MaintDoseQ8HR; maint8day := extract day MaintDoseQ8HR; maint8year := extract year MaintDoseQ8HR; maint12hour := extract hour MaintDoseQ12HR; maint12mon := extract month MaintDoseQ12HR; maint12day := extract day MaintDoseQ12HR; maint12year := extract year MaintDoseQ12HR; FmtLoadTime := loadhour formatted with "%2.2d" || ":00"; FmtLoadDate := loadmon formatted with "%2.2d"||"-" ||loadday formatted with "%2.2d" ||"-" ||loadyear ; Fmt6HRTime := due6hour formatted with "%2.2d" || ":00"; Fmt6HRDate := due6mon formatted with "%2.2d"||"-" ||due6day formatted with "%2.2d" ||"-" ||due6year ; Fmt8HRTime := due8hour formatted with "%2.2d" || ":00"; Fmt8HRDate := due8mon formatted with "%2.2d"||"-" ||due8day formatted with "%2.2d" ||"-" ||due8year ; FmtQ8HRTime := maint8hour formatted with "%2.2d" || ":00"; FmtQ8HRDate := maint8mon formatted with "%2.2d"||"-" ||maint8day formatted with "%2.2d" ||"-" ||maint8year ; FmtQ12HRTime := maint12hour formatted with "%2.2d" || ":00"; FmtQ12HRDate := maint12mon formatted with "%2.2d"||"-" ||maint12day formatted with "%2.2d" ||"-" ||maint12year ; if NoLoad = false or noload is null then Load_ReqTime_Val.ReqTimeCode := "Scheduled/Start Time"; Load_ReqTime_Val.ReqTimeValue := FMTLoadTime; Load_ReqDate.value := FmtLoadDate; endif; // Select correct formatted time and frequency based upon CrCl, Load or No Load and if override the selected frequency If ((CrCl_Estd.value >= 20 or CrCl_Estd.value is null or CRRT is not null ) and override.value = false and NoLoad = False) or (override.value = true and Zosyn_Freq_Dictionary.value = "Q8H" and NoLoad = False ) then Maint_ReqDate.value := Fmt6HRDate; Maint_ReqTime_Val.ReqTimeCode := "Scheduled/Start Time"; Maint_ReqTime_Val.ReqTimeValue := Fmt6HRTime; FreqValue.FrequencySummary := "Q8H"; Zosyn_Freq_Dictionary.value := "Q8H"; elseif (CrCl_Estd.Value < 20 and CRRT is null and override.value = false and NoLoad = false) or (override.value = true and Zosyn_Freq_Dictionary.value = "Q12H" and noLoad = false) then Maint_ReqDate.value := Fmt8HRDate; Maint_ReqTime_Val.ReqTimeCode := "Scheduled/Start Time"; Maint_ReqTime_Val.ReqTimeValue := Fmt8HRTime; FreqValue.FrequencySummary := "Q12H"; Zosyn_Freq_Dictionary.value := "Q12H"; elseIf ((CrCl_Estd.value >= 20 or CrCl_Estd.value is null or CRRT is not null) and override.value = false and NoLoad = true) or (override.value = true and Zosyn_Freq_Dictionary.value = "Q8H" and NoLoad = true) then Maint_ReqDate.value := FmtQ8HRDate; Maint_ReqTime_Val.ReqTimeCode := "Scheduled/Start Time"; Maint_ReqTime_Val.ReqTimeValue := FmtQ8HRTime; FreqValue.FrequencySummary := "Q8H"; Zosyn_Freq_Dictionary.value := "Q8H"; elseif (CrCl_Estd.value < 20 and CRRT is null and override.value = false and NoLoad = true) or (override.value = true and Zosyn_Freq_Dictionary.value = "Q12H" and noLoad = true ) then Load_ReqDate.value := null; Load_ReqTime_Val.ReqTimeCode := null; Load_ReqTime_Val.ReqTimeValue := null; Maint_ReqDate.value := FmtQ12HRDate; Maint_ReqTime_Val.ReqTimeCode := "Scheduled/Start Time"; Maint_ReqTime_Val.ReqTimeValue := FmtQ12HRTime; FreqValue.FrequencySummary := "Q12H"; Zosyn_Freq_Dictionary.value := "Q12H"; endif; // **** end extended Zosyn infusion *********** elseif ( fieldValue = false ) then Zosyn.IsSelected := false; Azithromycin.IsSelected := false; Zosyn_Low.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //********** AZTREONAM *********************** //JML: Changed to include Levaquin if ( CallingField = "PRX_Checkbox1|7" ) then fieldValue := Aztreonam_Chk.Value; if ( fieldValue = true ) then Aztreonam.IsSelected := true; Levaquin.IsSelected := true; exceptFld := exceptFld, Vanco_Chk.DataItemName || "|" || Vanco_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Aztreonam.IsSelected := false; Levaquin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //************ CEFEPIME **************************** if ( CallingField = "PRX_Checkbox1|17" ) then fieldValue := Cefepime_Chk.Value; if ( fieldValue = true ) then Cefepime.IsSelected := true; exceptFld := exceptFld, Vanco2_Chk.DataItemName || "|" || Vanco2_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Cefepime.IsSelected := false; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //************ MEROPENEM + TOBRAMYCIN *********************************** if ( CallingField = "PRX_Checkbox1|10" ) then fieldValue := Meropenem_Tobramycin_Chk.Value; if ( fieldValue = true ) then //Determine if Tobramycin should be ordered //Check for dose given in last 24 hours tobramycin_exists := READ LAST { "SELECT 1" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" || " ON cv.ClientGUID = o.ClientGUID" || " AND cv.GUID = o.ClientVisitGUID" || " AND cv.ChartGUID = o.ChartGUID" || " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}TOBRAMYCIN%{{{SINGLE-QUOTE}}}" || " AND o.FrequencyCode IN ({{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}})" || " AND cv.ClientGUID = " || SQL(ClientGUID) || " AND cv.GUID = " || SQL(ClientVisitGUID) || " AND cv.ChartGUID = " || SQL(ChartGUID) || " AND DateDiff(hh, o.Entered, GETDATE()) <= 24" || " order by o.Entered desc" }; if ( exists tobramycin_exists ) then Tobramycin.IsSelected := false; else Tobramycin.IsSelected := true; endif; Meropenem.IsSelected := true; //Disable all other checkboxes EXCEPT Vanco exceptFld := exceptFld, Vanco2_Chk.DataItemName || "|" || Vanco2_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; tobra_logic_run := true; elseif ( fieldValue = false ) then tobra_logic_run := false; Meropenem.IsSelected := false; Tobramycin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //************** CEFEPIME + AZITHROMYCIN ********************* if ( CallingField = "PRX_Checkbox1|18" ) then fieldValue := Cefepime_Azithro_Chk.Value; if ( fieldValue = true ) then Cefepime.IsSelected := true; Azithromycin.IsSelected := true; exceptFld := exceptFld, Vanco2_Chk.DataItemName || "|" || Vanco2_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Cefepime.IsSelected := false; Azithromycin.IsSelected := false; rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //***************** AZTREONAM + LEVAQUIN *************************** if ( CallingField = "PRX_Checkbox1|14" ) then fieldValue := Aztreonam_Levaquin_Chk.Value; if ( fieldValue = true ) then Aztreonam.IsSelected := true; Levaquin.IsSelected := true; exceptFld := exceptFld, Vanco2_Chk.DataItemName || "|" || Vanco2_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; elseif ( fieldValue = false ) then Aztreonam.IsSelected := false; Levaquin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //*************** CEFEPIME + Tobramycin ************************ if ( CallingField = "PRX_Checkbox1|19" ) then fieldValue := Cefepime_Tobramycin_Chk.Value; if ( fieldValue = true ) then //Determine if Tobramycin should be ordered //Check for dose given in last 24 hours tobramycin_exists := READ LAST { "SELECT 1" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" || " ON cv.ClientGUID = o.ClientGUID" || " AND cv.GUID = o.ClientVisitGUID" || " AND cv.ChartGUID = o.ChartGUID" || " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}TOBRAMYCIN%{{{SINGLE-QUOTE}}}" || " AND o.FrequencyCode IN ({{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}})" || " AND cv.ClientGUID = " || SQL(ClientGUID) || " AND cv.GUID = " || SQL(ClientVisitGUID) || " AND cv.ChartGUID = " || SQL(ChartGUID) || " AND DateDiff(hh, o.Entered, GETDATE()) <= 24" || " order by o.Entered desc" }; if ( exists tobramycin_exists ) then Tobramycin.IsSelected := false; else Tobramycin.IsSelected := true; endif; Cefepime.IsSelected := true; exceptFld := exceptFld, Vanco2_Chk.DataItemName || "|" || Vanco2_Chk.Control_MultiFieldOccNum; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, true, exceptFld; tobra_logic_run := true; elseif ( fieldValue = false ) then tobra_logic_run := false; Cefepime.IsSelected := false; Tobramycin.IsSelected := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; //************ VANCOMYCIN ***************************** if ( CallingField = "PRX_Checkbox1|8" OR CallingField = "PRX_Checkbox1|16" ) then if ( CallingField = "PRX_Checkbox1|8" ) then fieldValue := Vanco_Chk.Value; elseif ( CallingField = "PRX_Checkbox1|16" ) then fieldValue := Vanco2_Chk.Value; endif; if ( fieldValue = true ) then vanco_logic_run := true; elseif ( fieldValue = false ) then vanco_logic_run := false; Vancomycin_Load.IsSelected := false; Vancomycin.IsSelected := false; Vancomycin_Trough.IsSelected := false; Vancomycin_Nursing_Instr.IsSelected := false; endif; endif; //********* ANTIBIOTICS GRID *********************** if ( CallingField = "MultiOrderGrid|1" ) then if ( Zosyn.IsSelected = true OR Zosyn_Low.IsSelected = true ) then if ( Zosyn_Azithro_Chk.Value = false ) then Zosyn_Azithro_Chk.Value := true; Azithromycin.IsSelected := true; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, "PRX_Checkbox1|5", true, ""; endif; elseif ( Zosyn.IsSelected = false AND Zosyn_Low.IsSelected = false ) then if ( NOT ( Ceftria_Azithro_Chk.Value = true OR Ampicillin_Azithro_Chk.Value = true ) ) then Azithromycin.IsSelected := false; Zosyn_Azithro_Chk.Value := false; rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, ""; endif; endif; if ( Tobramycin.IsSelected = true AND ( Cefepime_Tobramycin_Chk.Value = false OR Meropenem_Tobramycin_Chk.Value = false ) ) then Tobramycin.IsSelected := false; endif; if ( Ceftria_Azithro_Chk.Value = true OR Ampicillin_Azithro_Chk.Value = true ) then if ( Azithromycin.IsSelected = true AND Azithromycin_PO.IsSelected = true ) then Azithromycin_PO.IsSelected := false; Azithromycin.IsSelected := true; endif; endif; endif; //************ VANCOMYCIN GRID ******************* if ( CallingField = "MultiOrderGrid|2" ) then if ( Vancomycin_Load.IsSelected = false AND Vancomycin.IsSelected = false ) then Vanco_Chk.Value := false; Vanco2_Chk.Value := false; Vancomycin_Trough.IsSelected := false; Vancomycin_Nursing_Instr.IsSelected := false; endif; if ( Vancomycin_Load.IsSelected = true AND Vancomycin.IsSelected = false ) then Vancomycin_Trough.IsSelected := false; Vancomycin_Nursing_Instr.IsSelected := false; endif; if ( Vancomycin_Load.IsSelected = false AND Vancomycin.IsSelected = true ) then Override_ABX_Sched.Value := false; Vancomycin_Trough.IsSelected := true; endif; if ( Vancomycin_Load.IsSelected = true AND Vancomycin.IsSelected = true ) then vanco_logic_run := true; endif; endif; endif; //End Fieldchange //Handle vancomycin ordering if ( vanco_logic_run = true ) then if ( OrderSetName = "Pneumonia Antibiotic ED" ) then if ( weightvalue = 0 OR weightvalue IS NULL or ht = 0 OR ht IS NULL ) then DialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Weight Based Dosing Requires Height & Weight To Be Entered.", "Alert", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; Vanco_Chk.Value := false; Vanco2_Chk.Value := false; else Vancomycin_Load.IsSelected := true; this_communication, this_form, ABW := call calc_abw_mlm WITH this_communication, this_form, client_info_obj; ABW_Val.Value := ( ABW as number); endif; else if ( weightvalue = 0 OR weightvalue IS NULL OR ht = 0 OR ht IS NULL ) then dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Weight Based Dosing Requires Height & Weight To Be Entered.", "Alert", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; Vanco_Chk.Value := false; Vanco2_Chk.Value := false; elseif ( CrCl_Estd.Value IS NULL OR CrCl_Estd.Value = 0 ) then errormsg := "Creatinine is required to calculate Creatinine Clearance; Creatinine Clearance is required to calculate Vancomycin Dose."; this_communication.Message := errormsg; this_communication.MessageType := "Error"; Vanco_Chk.Value := false; Vanco2_Chk.Value := false; else //Determine if a Loading dose should be given //Check for existing Vanco on-time dose (vanco_load_exists, vanco_load_given, vanco_load_ordered, vanco_load_dtm, vanco_load_dosing) := READ LAST {"SELECT 1, CASE WHEN ot.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} THEN ot.TaskStatusCode" || " ELSE {{{SINGLE-QUOTE}}}Pending{{{SINGLE-QUOTE}}} END," || " CASE WHEN ot.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} THEN DateDiff(hour, ot.PerformedFromDtm, GETDATE())" || " ELSE DATEDIFF(HOUR, o.RequestedDtm, GETDATE()) END," || " CASE WHEN ot.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} THEN ot.PerformedFromDtm" || " ELSE o.RequestedDtm END," || " o.SummaryLine" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" || " ON cv.ClientGUID = o.ClientGUID" || " AND cv.GUID = o.ClientVisitGUID" || " AND cv.ChartGUID = o.ChartGUID" || " JOIN CV3OrderTaskOccurrence ot WITH (NOLOCK)" || " ON ot.ClientGUID = o.ClientGUID" || " AND ot.OrderGUID = o.GUID" || " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}VANCOMYCIN%{{{SINGLE-QUOTE}}}" || " AND o.FrequencyCode IN ({{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}})" || " AND cv.ClientGUID = " || Sql(ClientGUID) || " AND cv.GUID = " || Sql(ClientVisitGUID) || " AND cv.ChartGUID = " || Sql(ChartGUID) || " AND DateDiff(hh, o.Entered, GETDATE()) <= 48" || " AND (o.OrderStatusLevelNum > 15" || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" || " order by o.Entered ASC"}; if ( ( CrCl_Estd.Value as number ) >= 60 ) then frequencyValue := "Q12H"; elseif ( ( CrCl_Estd.Value as number ) >= 30 AND ( CrCl_Estd.Value as number ) < 60 ) then frequencyValue := "Q24H"; elseif ( ( CrCl_Estd.Value as number ) < 30 ) then frequencyValue := "Now"; endif; this_communication, this_form, ABW := call calc_abw_mlm WITH this_communication, this_form, client_info_obj; ABW_Val.Value := ( ABW as number); if ( frequencyValue = "Now" ) then if ( exists vanco_load_exists ) then if ( ( vanco_load_ordered as number ) < 24 ) then strMsg := "Patient was "; if ( vanco_load_given = "Performed" ) then strMsg := strMsg || "given "; else strMsg := strMsg || "ordered "; endif; strMsg := strMsg || "Vancomycin " || vanco_load_dosing || " dose less than 24 hours ago at " || vanco_load_dtm; strMsg := strMsg || "\n\nDo you want to proceed with the additional Vancomycin NOW dose?"; dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with strMsg, "Vancomycin Dose", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; if ( ( dialogRes as String ) = "Yes" ) then //Don{{{SINGLE-QUOTE}}}t order Loading Dose //Order {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}} Vanco maintenance dose //Order Nursing Instruction //Don{{{SINGLE-QUOTE}}}t order Trough Vancomycin_Load.IsSelected := false; Vancomycin.IsSelected := true; Vancomycin_Freq_Val.FrequencySummary := frequencyValue; Vancomycin_Nursing_Instr.IsSelected := true; Vancomycin_Trough.IsSelected := false; else Vanco_Chk.Value := false; Vanco2_Chk.Value := false; endif; else //Don{{{SINGLE-QUOTE}}}t order Loading Dose //Order {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}} Vanco maintenance dose //Order Nursing Instruction //Don{{{SINGLE-QUOTE}}}t order Trough Vancomycin_Load.IsSelected := false; Vancomycin.IsSelected := true; Vancomycin_Freq_Val.FrequencySummary := frequencyValue; Vancomycin_Nursing_Instr.IsSelected := true; Vancomycin_Trough.IsSelected := false; endif; else //Don{{{SINGLE-QUOTE}}}t order Loading Dose //Order {{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}} Vanco maintenance dose //Order Nursing Instruction //Don{{{SINGLE-QUOTE}}}t order Trough Vancomycin_Load.IsSelected := false; Vancomycin.IsSelected := true; Vancomycin_Freq_Val.FrequencySummary := frequencyValue; Vancomycin_Nursing_Instr.IsSelected := true; Vancomycin_Trough.IsSelected := false; endif; endif; //Loading dose previously ordered; don{{{SINGLE-QUOTE}}}t re-order if ( exists vanco_load_exists AND frequencyValue <> "Now" ) then Vancomycin_Load.IsSelected := false; //Vanco loading dose already exists, let Antibiotic scheduling work as normal // to determine maintenance dosing schedule Vancomycin.IsSelected := true; Vancomycin_Freq_Val.FrequencySummary := frequencyValue; //Determine if Vanco Load has been given; if not, then adjust Antibiotic Scheduling if ( exists vanco_load_exists ) then if ( vanco_load_given <> "Performed" AND ( vanco_load_ordered as number ) <= 8 ) then Override_ABX_Sched.Value := true; elseif ( vanco_load_given = "Performed" AND ( vanco_load_ordered as number ) <= 12 ) then Override_ABX_Sched.Value := true; else Override_ABX_Sched.Value := false; endif; endif; //Vanco_FreqVal.FrequencySummary := frequencyValue; local_session.SessionVancoTroughFrequency := frequencyValue; Vancomycin_Nursing_Instr.IsSelected := false; //Need to order a loading dose elseif ( NOT exists vanco_load_exists AND frequencyValue <> "Now" ) then Vancomycin_Load.IsSelected := true; //New vanco load scheduled, need to calculate vanco maint schedule //based on Now & Then logic Override_ABX_Sched.Value := true; Vancomycin.IsSelected := true; local_session.SessionVancoTroughFrequency := frequencyValue; Vancomycin_Nursing_Instr.IsSelected := false; endif; if ( frequencyValue <> "Now" ) then Vancomycin_Trough.IsSelected := true; Fire_Trough_MLM.Value := true; endif; endif; endif; endif; if ( tobra_logic_run = true ) then //Calculate Tobramycin dosing //Retrieve Adjusted Body Weight if ( weightvalue = 0 OR weightvalue IS NULL OR ht = 0 OR ht IS NULL ) then dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Weight Based Dosing Requires Height & Weight To Be Entered.", "Alert", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; else this_communication, this_form, ABW := call calc_abw_mlm WITH this_communication, this_form, client_info_obj; ABW_Val.Value := ( ABW as number); rawTobraDose := ( ( ABW as number ) * 5); roundingFactor := 20; halfRoundingFactor := 10; rounded_dose := int((rawTobraDose + halfRoundingFactor)/roundingFactor) * roundingFactor; Tobramycin_Dose.Value := rounded_dose; endif; endif; if ( ceftriaxone_logic_run = true ) then if ( weightvalue = 0 OR weightvalue IS NULL ) then //Display message that weight is missing dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Weight Based Dosing Requires Weight To Be Entered." , "Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; else if ( weightvalue < 80 ) then Ceftriaxone_Dose.Value := ( 1 as number ); if ( Ceftriaxone.Name = "Ceftriaxone:" ) then Ceftriaxone_WORX_Code.Value := "08561P"; elseif ( Ceftriaxone.Name = "Ceftriaxone Mini-Syringe" ) then Ceftriaxone_WORX_Code.Value := "08561"; endif; elseif ( weightvalue >= 80 ) then Ceftriaxone_Dose.Value := ( 2 as number ); if ( Ceftriaxone.Name = "Ceftriaxone:" ) then Ceftriaxone_WORX_Code.Value := "08555P"; elseif ( Ceftriaxone.Name = "Ceftriaxone Mini-Syringe" ) then Ceftriaxone_WORX_Code.Value := "08555"; endif; endif; endif; endif; ;; evoke: // No evoke statement ;; logic: conclude True; ;; action: // This MLM returns two parameters, of types communication_type and form_type respectively. return this_communication, this_form; ;; end: