Initial Checking with all 820 MLMs

This commit is contained in:
2020-02-02 00:54:01 -05:00
parent c59dc6de2e
commit 840d0432f4
828 changed files with 239162 additions and 0 deletions

View File

@@ -0,0 +1,775 @@
maintenance:
title: FORM_SET_INTRA_ABDOMINAL_ANTIBIOTICS;;
mlmname: FORM_SET_INTRA_ABDOMINAL_ANTIBIOTICS;;
arden: version 2.5;;
version: 15.10;;
institution: St Clair Hospital;;
author: Juliet M. Law, Allscripts ;;
specialist: Peggy Leschak, Allscripts;;
date: 2016-05-09;;
validation: testing;;
library:
purpose: Used for Intra-Abdominal Antibiotics order set
;;
explanation: This MLM is called from Intra-Abdominal Antibiotics Order Set
Change history
05.09.2016 JML CSR 34091: Created for Intra-Abdominal Antibiotic Order Set
04.12.2017 JML CSR 35566: Change default Zosyn selection to lower dose.
02.13.2018 JML CSR 26163: Replaced cefepime / ceftriaxone with mini-syringes due to drug shortage
03.09.2018 TMS CSR 34822: Update Zosyn selections to use extended infusion logic
;;
keywords: Called MLMs, Antibiotic Intra-Abdominal, 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}}};
crcl_mlm := mlm {{{SINGLE-QUOTE}}}FORM_MLM_Creatinine_Clearance_OS{{{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}}};
antibiotic_guideline_mlm := mlm {{{SINGLE-QUOTE}}}FORM_FUNC_DISPLAY_ANTIBIOTIC_GUIDELINES{{{SINGLE-QUOTE}}};
AutoMedScheduling := MLM {{{SINGLE-QUOTE}}}FORM_Antibiotic_Scheduling{{{SINGLE-QUOTE}}};
exceptFld := ();
cefazolin_logic_run := false;
// Assigns fields passed in the Form object to the Field object
field_list:= this_form.fields;
CallingEvent := this_communication.CallingEvent;
CallingField := this_communication.CallingFieldName;
//Define fields
Augmentin_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 1 );
Levaquin_Flagyl_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 2 );
Zosyn_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 3 );
Cefepime_Flagyl_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 5 );
Zosyn2_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 4 );
Cipro_Flagyl_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 7 );
Ancef_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 8 );
Zosyn3_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 9 );
Cipro_Flagyl2_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 11 );
Fluconazole_Chk := first of ( field_list WHERE field_list.DataItemName = "PRX_Checkbox1" AND field_list.Control_MultiFieldOccNum = 16 );
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 );
Antibiotics_Grid := first of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 1 );
Antibiotics_Grid_Value := Antibiotics_Grid.Value;
Augmentin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Amoxicillin/Clavulanic Acid 875mg Tab" );
Levaquin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Levofloxacin 750mg Tab" );
Flagyl_Oral := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Metronidazole 500mg Tab" );
Flagyl_IV := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Metronidazole:" );
Zosyn := last of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Piperacillin/Tazobactam:" );
Zosyn_Low := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Piperacillin/Tazobactam:" );
Cefepime := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Cefepime:" OR Antibiotics_Grid_Value.Name = "Cefepime Mini-Syringe" );
Ciprofloxacin := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Ciprofloxacin;" );
Ancef := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Cefazolin:" );
Fluconazole_Now := first of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Fluconazole:" );
Fluconazole := last of ( Antibiotics_Grid_Value WHERE Antibiotics_Grid_Value.Name = "Fluconazole:" );
Ancef_Dose := first of ( field_list WHERE field_list.DataItemName = "DosageLow" AND field_list.Control_MultiFieldOccNum = 1 );
Override_ABX_Schedule := first of ( field_list WHERE field_list.DataItemname = "PRX_Override_Abx_Scheduling" AND field_list.Control_MultiFieldOccNum = 1 );
Load_ReqDate := last of ( field_list WHERE field_list.DataItemName = "RequestedDate"
and field_list.Control_MultiFieldOccNum = 12);
Load_ReqTime := last of ( field_list WHERE field_list.DataItemName = "RequestedTime"
and field_list.Control_MultiFieldOccNum = 12);
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 = 1);
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 = 13);
Maint_ReqTime := last of ( field_list WHERE field_list.DataItemName = "RequestedTime"
and field_list.Control_MultiFieldOccNum = 13);
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 = 9);
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");
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 ("Piperacillin/Tazobactam:", "Fluconazole:") ) then
if ( item.Name NOT IN ("Fluconazole:") ) then
item.IsReadonly := true;
endif;
enddo;
If OrderSetName = "IntraAbdominal 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 ( Ancef_Chk.Value = true ) then
cefazolin_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;
endif;
//*********** AUGMENTIN ********************
if ( CallingField = "PRX_Checkbox1|1" ) then
fieldValue := Augmentin_Chk.Value;
if ( fieldValue = true ) then
Augmentin.IsSelected := true;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, "";
elseif ( fieldValue = false ) then
Augmentin.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//********** LEVAQUIN + FLAGYL **************
if ( CallingField = "PRX_Checkbox1|2" ) then
fieldValue := Levaquin_Flagyl_Chk.Value;
if ( fieldValue = true ) then
Levaquin.IsSelected := true;
Flagyl_Oral.IsSelected := true;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, "";
elseif ( fieldValue = false ) then
Levaquin.IsSelected := false;
Flagyl_Oral.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//************ ZOSYN *****************
if ( OrderSetName = "IntraAbdominal Antibiotic ED" and
( CallingField = "PRX_Checkbox1|3" OR CallingField = "PRX_Checkbox1|4" OR CallingField = "PRX_Checkbox1|9" ) ) then
if ( CallingField = "PRX_Checkbox1|3" ) then
fieldValue := Zosyn_Chk.Value;
exceptFld := exceptFld, Fluconazole_Chk.DataItemName || "|" || Fluconazole_Chk.Control_MultiFieldOccNum;
elseif ( CallingField = "PRX_Checkbox1|4" ) then
fieldValue := Zosyn2_Chk.Value;
elseif ( CallingField = "PRX_Checkbox1|9" ) then
fieldValue := Zosyn3_Chk.Value;
endif;
if ( fieldValue = true ) then
Zosyn_Low.IsSelected := true;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld;
elseif ( fieldValue = false ) then
Zosyn.IsSelected := false;
Zosyn_Low.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//*********** ZOSYN EXTENDED INFUSION ***************************
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 = "IntraAbdominal Antibiotic" and
( CallingField = "PRX_Checkbox1|3" OR CallingField = "PRX_Checkbox1|4" OR CallingField = "PRX_Checkbox1|9" )
or ( CallingField = "PRX_Zosyn_Ext_Inf_Freq|1" and (Zosyn_Chk.Value= true or Zosyn2_Chk.Value= true or Zosyn3_Chk.Value= true) )
or (CallingField = "PRX_Generic_CB|1" and (Zosyn_Chk.Value= true or Zosyn2_Chk.Value= true or Zosyn3_Chk.Value= true) )
or (CallingField = "PRX_Generic_CB|2" and (Zosyn_Chk.Value= true or Zosyn2_Chk.Value= true or Zosyn3_Chk.Value= true) ) then
if ( CallingField = "PRX_Checkbox1|3" or Zosyn_Chk.Value= true ) then
fieldValue := Zosyn_Chk.Value;
exceptFld := exceptFld, Fluconazole_Chk.DataItemName || "|" || Fluconazole_Chk.Control_MultiFieldOccNum;
elseif ( CallingField = "PRX_Checkbox1|4" or Zosyn2_Chk.Value= true) then
fieldValue := Zosyn2_Chk.Value;
elseif ( CallingField = "PRX_Checkbox1|9" or Zosyn3_Chk.Value= true ) then
fieldValue := Zosyn3_Chk.Value;
endif;
if ( fieldValue = true ) then
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld;
//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;
Zosyn_Low.IsSelected := false;
rtnValue := call enable_chkbx_mlm with this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//*********** CEFEPIME + FLAGYL ****************
if ( CallingField = "PRX_Checkbox1|5" ) then
fieldValue := Cefepime_Flagyl_Chk.Value;
if ( fieldValue = true ) then
Cefepime.IsSelected := true;
Flagyl_IV.IsSelected := true;
exceptFld := exceptFld, Fluconazole_Chk.DataItemName || "|" || Fluconazole_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;
Flagyl_IV.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//************ CIPROFLOXACIN + FLAGYL ********************
if ( CallingField = "PRX_Checkbox1|7" OR CallingField = "PRX_Checkbox1|11" ) then
if ( CallingField = "PRX_Checkbox1|7" ) then
fieldValue := Cipro_Flagyl_Chk.Value;
elseif ( CallingField = "PRX_Checkbox1|11" ) then
fieldValue := Cipro_Flagyl2_Chk.Value;
endif;
if ( fieldValue = true ) then
Ciprofloxacin.IsSelected := true;
Flagyl_IV.IsSelected := true;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, "";
elseif ( fieldValue = false ) then
Ciprofloxacin.IsSelected := false;
Flagyl_IV.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//************ CEFAZOLIN (ANCEF) ******************
if ( CallingField = "PRX_Checkbox1|8" ) then
fieldValue := Ancef_Chk.Value;
if ( fieldValue = true ) then
Ancef.IsSelected := true;
cefazolin_logic_run := true;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, "";
elseif ( fieldValue = false ) then
cefazolin_logic_run := false;
Ancef.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//******** FLUCONAZOLE ********
if ( CallingField = "PRX_Checkbox1|16" ) then
fieldValue := Fluconazole_Chk.Value;
if ( fieldValue = true ) then
//Determine if loading dose should be given
//Check if fluconazole has been given in last 24 hours
fluconazole_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}}}FLUCONAZOLE%{{{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 fluconazole_exists ) then
Fluconazole_Now.IsSelected := false;
Override_ABX_Schedule.Value := false;
else
Fluconazole_Now.IsSelected := true;
Override_ABX_Schedule.Value := true;
endif;
Fluconazole.IsSelected := true;
exceptFld := exceptFld, Zosyn_Chk.DataItemName || "|" || Zosyn_Chk.Control_MultiFieldOccNum;
exceptFld := exceptFld, Cefepime_Flagyl_Chk.DataItemName || "|" || Cefepime_Flagyl_Chk.Control_MultiFieldOccNum;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, true, exceptFld;
elseif ( fieldValue = false ) then
Fluconazole_Now.IsSelected := false;
Fluconazole.IsSelected := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
endif;
//******* ANTIBIOTICS GRID ***************
if ( CallingField = "MultiOrderGrid|1" ) then
if ( ( Zosyn.IsSelected = true OR Zosyn_Low.IsSelected = true ) AND ( Zosyn_Chk.Value = false AND Zosyn2_Chk.Value = false AND Zosyn3_Chk.Value = false ) ) then
Zosyn.IsSelected := false;
Zosyn_Low.IsSelected := false;
elseif ( ( Zosyn.IsSelected = false AND Zosyn_Low.IsSelected = false ) AND ( Zosyn_Chk.Value = true OR Zosyn2_Chk.Value = true OR Zosyn3_Chk.Value = true ) ) then
Zosyn_Chk.Value := false;
Zosyn2_Chk.Value := false;
Zosyn3_Chk.Value := false;
rtnValue := call enable_chkbx_mlm WITH this_communication, this_form, client_info_obj, CallingField, false, "";
endif;
if ( Fluconazole.IsSelected = true OR Fluconazole_Now.IsSelected = true ) then
if ( Fluconazole_Chk.Value = false ) then
Fluconazole_Chk.Value := true;
endif;
elseif ( Fluconazole.IsSelected = false AND Fluconazole_Now.IsSelected = false ) then
Fluconazole_Chk.Value := false;
endif;
if ( Fluconazole_Now.IsSelected = false AND Fluconazole.IsSelected = true ) then
Override_ABX_Schedule.Value := false;
endif;
if ( Fluconazole_Now.IsSelected = true AND Fluconazole.IsSelected = true ) then
Override_ABX_Schedule.Value := true;
endif;
endif;
endif; //End FieldChange
if ( cefazolin_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
Ancef_Dose.Value := ( 1 as number );
elseif ( weightvalue >= 80 ) then
Ancef_Dose.Value := ( 2 as number );
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: