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,482 @@
maintenance:
title: Set Tikosyn order set with automatic electrolyte lab ordering date ;;
mlmname: FORM_Set_Tikosyn_Electrolyte ;;
arden: version 2.5;;
version: 1.00;;
institution: St. Clair Hospital ;;
author: Sandy Zhang ;;
specialist: Sarah Nelson, Amy Georgulis ;;
date: 2017-08-28;;
validation: testing;;
library:
purpose:
;;
explanation: This MLM is called from the Tikosyn order set, form: PRX_OsTikosynElectro
Change history
08.28.2017 SZ CSR #34930 - Tikosyn Automatic Electrolyte Ordering - Initial build - derived from FORM_Set_Lovenox_Orders_Inj as a model
;;
keywords: Tikosyn, dofetilide, serum creatinine, potassium, magnesium, electrolyte lab ordering, automatic
;;
citations:
;;
knowledge:
type: data-driven;;
data:
// 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;
primary_obj := this_communication.PrimaryObj;
// Use String parse
str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}};
// Initialize error message
error_message:="";
// Assigns fields passed in the Form object to the Field object
field_list:= this_form.fields;
client_guid := this_communication.ClientGUID;
visit_guid := this_communication.ClientVisitGUID;
chart_guid := this_communication.ChartGuid;
user_guid := this_communication.UserGuid;
CallingEvent := this_communication.CallingEvent;
CallingField := this_communication.CallingFieldName;
current_time := NOW as time;
current_hour := extract hour NOW;
//Find the baseline order checkbox that may need to be ordered with this protocol
Labs_Baseline_field := last of (field_list where field_list.DataItemName = "MultiOrderCheckBox" and field_List.Control_MultiFieldOccNum = 1);
Labs_Baseline_List := Labs_Baseline_field.Value;
Baseline_BMP := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "Basic Metabolic Panel");
Baseline_CMP := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "Comprehensive Metabolic Panel");
Baseline_Creatinine := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "Creatinine");
Baseline_Potassium := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "Potassium Plasma/Serum");
Baseline_Magnesium := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "Magnesium Plasma/Serum");
Baseline_ECG := first of (Labs_Baseline_list where Labs_Baseline_list.Name = "EKG 12 Lead");
//Find the daily lab orders for creatinine, potassium, and magnesium that need to accompany the
//creatinine lab orders
Lab_Daily_Order_field_1 := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 2);
Lab_Daily_Order_List_1 := Lab_Daily_Order_field_1.Value;
//potassium lab orders
Lab_Daily_Order_field_2 := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 3);
Lab_Daily_Order_List_2 := Lab_Daily_Order_field_2.Value;
//magnesium lab orders
Lab_Daily_Order_field_3 := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 4);
Lab_Daily_Order_List_3 := Lab_Daily_Order_field_3.Value;
// Find the 5 Requested Date fields - #1 is visible, #2 - #5 are hidden
primreqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 1);
secreqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 2);
thirdreqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 3);
//Grab the order info box
order_info_box := first of (field_list where field_list.DataItemName = "PRX_OrderSet_Duplicate_Info");
//Find if any of the med boxes are checked...if so, set Med_Was_Selected to "yes"
Med_Grid := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 1);
// Med_GridC := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 4);
Med_List := Med_Grid.Value;
//Med_ListC :=Med_GridC.Value;
Med_SelList := Med_List.IsSelected;
//Med_SelListC := Med_ListC.IsSelected;
Med_Selected := true in Med_SelList;
//Med_SelectedC := true in Med_SelListC;
If (Med_Selected = True) then
Med_Was_Selected := "yes";
else Med_Was_Selected := "no" ;
endif;
// identify each tikosyn order item
tikosyn_125 := Med_List[1];
tikosyn_250 := Med_List[2];
tikosyn_500 := Med_List[3];
/**************************** rules start below *************************************************/
// if user selects any of the tikosyn orders then gray out other options and prevent selection
If (CallingEvent = "FieldChange") and (CallingField = "MultiOrderGrid|1") Then
if tikosyn_125.IsSelected = true then
//tikosyn_125.IsReadOnly := true;
tikosyn_250.IsSelected := false;
tikosyn_250.IsReadOnly := true;
tikosyn_500.IsSelected := false;
tikosyn_500.IsReadOnly := true;
elseif tikosyn_250.IsSelected = true then
//tikosyn_250.IsReadOnly := true;
tikosyn_125.IsReadOnly := true;
tikosyn_125.IsSelected := false;
tikosyn_500.IsReadOnly := true;
tikosyn_500.IsSelected := false;
elseif tikosyn_500.IsSelected = true then
//tikosyn_500.IsReadOnly := true;
tikosyn_125.IsReadOnly := true;
tikosyn_125.IsSelected := false;
tikosyn_250.IsReadOnly := true;
tikosyn_250.IsSelected := false;
else
tikosyn_125.IsReadOnly := false;
tikosyn_125.IsSelected := false;
tikosyn_250.IsReadOnly := false;
tikosyn_250.IsSelected := false;
tikosyn_500.IsReadOnly := false;
tikosyn_500.IsSelected := false;
endif;
endif;
// if a tikosyn order was selected then auto-select all daily lab orders and allow selection/removal of them
If (CallingEvent = "FieldChange") then
if (Med_Was_Selected = "yes") then
// New feature: If Tikosyn is a home med in the OMR, then do not check boxes for daily labs, only necessary baseline labs
tikosyn_home_med := read last {
"SELECT p.DrugName"
||" FROM SXAAMBClientPrescription p with (nolock) JOIN SXAAMBDrugCategoryXRef xr with (nolock)"
||" ON p.GenericNameID = xr.GenericNameID"
||" JOIN SXAAMBDrugCategory dc with (nolock)"
||" ON xr.DrugCategoryID = dc.DrugCategoryID"
||" WHERE p.ClientGUID = " || sql(client_guid)
||" and (p.DrugName like {{{SINGLE-QUOTE}}}%dofetilide%{{{SINGLE-QUOTE}}} or p.DrugName like {{{SINGLE-QUOTE}}}%tikosyn%{{{SINGLE-QUOTE}}})"
||" and StatusType <> 8"
};
// if tikosyn is a home med then do not check the boxes for daily lab orders
if (exist tikosyn_home_med) then
Lab_Daily_Order_List_1.IsReadOnly := (false, false, false);
Lab_Daily_Order_List_2.IsReadOnly := (false, false, false);
Lab_Daily_Order_List_3.IsReadOnly := (false, false, false);
Baseline_BMP.IsReadOnly := false;
Baseline_CMP.IsReadOnly := false;
Baseline_Creatinine.IsReadOnly := false;
Baseline_Potassium.IsReadOnly := false;
Baseline_Magnesium.IsReadOnly := false;
Baseline_ECG.IsReadOnly := false;
order_info_box.Value := "Tikosyn (dofetilide) found in OMR, patient is resuming therapy here. Daily labs are NOT required, but baseline labs are.";
else
Lab_Daily_Order_List_1.IsSelected := (True,True,True);
Lab_Daily_Order_List_2.IsSelected := (True,True,True);
Lab_Daily_Order_List_3.IsSelected := (True,True,True);
Lab_Daily_Order_List_1.IsReadOnly := (false, false, false);
Lab_Daily_Order_List_2.IsReadOnly := (false, false, false);
Lab_Daily_Order_List_3.IsReadOnly := (false, false, false);
Baseline_BMP.IsReadOnly := false;
Baseline_CMP.IsReadOnly := false;
Baseline_Creatinine.IsReadOnly := false;
Baseline_Potassium.IsReadOnly := false;
Baseline_Magnesium.IsReadOnly := false;
Baseline_ECG.IsReadOnly := false;
order_info_box.Value := "Tikosyn (dofetilide) NOT found in OMR, patient is new to therapy. Daily and baseline labs may be required for ongoing monitoring.";
endif;
// feature: SQL for baseline labs that were ordered within the past 24 hours, if they were ordered then do not reorder (uncheck).
// example: if magnesium plasma ordered 4 hours ago then do not check that on the list
(baseline_existing_list) := read {
"select "
||" case when ocmi.name like {{{SINGLE-QUOTE}}}Basic Metabolic Panel{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}"
||" when ocmi.name like {{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}}"
||" when ocmi.name like {{{SINGLE-QUOTE}}}%Creatinine%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}"
||" when ocmi.name = {{{SINGLE-QUOTE}}}Potassium Plasma/Serum{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}}"
||" when ocmi.name = {{{SINGLE-QUOTE}}}Magnesium Plasma/Serum{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}5{{{SINGLE-QUOTE}}}"
||" when ocmi.name = {{{SINGLE-QUOTE}}}EKG 12 Lead{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}6{{{SINGLE-QUOTE}}}"
||" end"
||" from cv3ordercatalogmasteritem ocmi with (nolock)"
||" join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid"
||" where"
||" o.clientguid = " || sql(client_guid)
||" and o.chartguid = " || sql(chart_guid)
||" and o.clientvisitguid = " || sql(visit_guid)
||" and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70)"
||" and (ocmi.name like {{{SINGLE-QUOTE}}}Basic Metabolic Panel{{{SINGLE-QUOTE}}} "
||" or ocmi.name like {{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel{{{SINGLE-QUOTE}}}"
||" or ocmi.name like {{{SINGLE-QUOTE}}}%Creatinine%{{{SINGLE-QUOTE}}}"
||" or ocmi.name = {{{SINGLE-QUOTE}}}Potassium Plasma/Serum{{{SINGLE-QUOTE}}}"
||" or ocmi.name = {{{SINGLE-QUOTE}}}Magnesium Plasma/Serum{{{SINGLE-QUOTE}}}"
||" or ocmi.name = {{{SINGLE-QUOTE}}}EKG 12 Lead{{{SINGLE-QUOTE}}})"
||" and o.entered >= DATEADD(day, -1, GETDATE())"
};
basline_bmp_existing := 1 IS IN (baseline_existing_list as number);
basline_cmp_existing := 2 IS IN (baseline_existing_list as number);
basline_creatinine_existing := 3 IS IN (baseline_existing_list as number);
basline_potassium_existing := 4 IS IN (baseline_existing_list as number);
basline_magnesium_existing := 5 IS IN (baseline_existing_list as number);
basline_ECG_existing := 6 IS IN (baseline_existing_list as number);
/**************** true/false switches ************************/
// if baseline BMP and baseline CMP do not exist (being false)
// then check if baseline creatinine or potassium exist
//if either is missing as well then check the box to order them
if (basline_bmp_existing = false) and (basline_cmp_existing = false) then
if (basline_creatinine_existing = false) then
Baseline_Creatinine.IsSelected := true;
endif;
if (basline_potassium_existing = false) then
Baseline_Potassium.IsSelected := true;
endif;
endif;
// notifying user if any baseline labs were not selected to be ordered
if true in (basline_bmp_existing, basline_cmp_existing, basline_creatinine_existing, basline_potassium_existing, basline_magnesium_existing) then
if exists order_info_box.Value then
order_info_box.Value := order_info_box.Value || " Baseline labs were already ordered within the past 24 hours. Therefore, they do not need to be reordered.";
else
order_info_box.Value := "Baseline labs were already ordered within the past 24 hours. Therefore, they do not need to be reordered.";
endif;
endif;
if (basline_magnesium_existing = false) then
Baseline_Magnesium.IsSelected := true;
endif;
if (basline_ECG_existing = false) then
Baseline_ECG.IsSelected := true;
endif;
// this happens when Tikosyn order is unchecked in order grid 1
else
Lab_Daily_Order_List_1.IsSelected := (False,False,False);
Lab_Daily_Order_List_2.IsSelected := (False,False,False);
Lab_Daily_Order_List_3.IsSelected := (False,False,False);
Baseline_BMP.IsSelected := false;
Baseline_CMP.IsSelected := false;
Baseline_Creatinine.IsSelected := false;
Baseline_Potassium.IsSelected := false;
Baseline_Magnesium.IsSelected := false;
Baseline_ECG.IsSelected := false;
order_info_box.Value := "";
endif; // if (Med_Was_Selected = "yes") then
endif; // If (CallingEvent = "FieldChange")
/**************************** Remove Labs rules ***************************************************/
// when "remove labs" is selected all daily order labs are deselected
if (CallingField) = "Checkbox|1" then
Lab_Daily_Order_List_1.IsSelected := (false, false, false);
Lab_Daily_Order_List_2.IsSelected := (false, false, false);
Lab_Daily_Order_List_3.IsSelected := (false, false, false);
endif;
/**************************** Requested Date rules ***************************************************/
// if the requested date field changes then update all of the orders
If (CallingEvent = "FieldChange") and (CallingField = "RequestedDate|1") then
//Sets the 2 remaining order set date fields based on the starting date
//First lab orders are directly mapped to the "Requested Date" field that user can change
yr := extract year now;
mn := extract month now; if mn < 10 then mn := "0" || mn; endif;
dd := extract day now; if dd < 10 then dd := "0" || dd; endif;
today:= yr || "-" || mn || "-" || dd || "T00:00:00";
tomorrow := (today as time) +1 day;
tom_list := call str_parse with tomorrow, " "; // sets tomorrow{{{SINGLE-QUOTE}}}s date/time in string format
tom_dte := first(tom_list);
lesstomorrow := primreqdate.value < tomorrow;
// if the "requested date" is set to anything before tomorrow, it throws a dialog box error
If lesstomorrow = true then
this_communication.DisplayForm := "Yes";
this_communication.Message := "You may not enter a date earlier than tomorrow (" || tom_dte || ")";
this_communication.MessageType := "Error";
primreqdate.value := tomorrow;
endif; // If lesstomorrow = true then
startdate:= primreqdate.value; // used to calculate dates for hidden fields below
secreqdate.value := startdate + 1 days; // sets hidden field "RequestedDate - Lab 2", that field is mapped to lab orders "scheduled date"
thirdreqdate.value := startdate + 2 days; // sets hidden field "RequestedDate - Lab 3", that field is mapped to lab orders "scheduled date"
endif; // If (CallingEvent = "FieldChange") and (CallingField = "RequestedDate|1") then
/**************************** Form Open rules ***************************************************/
// upon FormOpen, make all daily lab orders and baseline labs read only
// also sets hidden fields so that when a med is selected, the dates populate up to the orders "Scheduled Date"
If (CallingEvent = "FormOpen") then
Lab_Daily_Order_List_1.IsReadOnly := (True,True,True);
Lab_Daily_Order_List_2.IsReadOnly := (True,True,True);
Lab_Daily_Order_List_3.IsReadOnly := (True,True,True);
Baseline_BMP.IsReadOnly := true;
Baseline_CMP.IsReadOnly := true;
Baseline_Creatinine.IsReadOnly := true;
Baseline_Potassium.IsReadOnly := true;
Baseline_Magnesium.IsReadOnly := true;
Baseline_ECG.IsReadOnly := true;
startdate:= primreqdate.value; // used to calculate dates for hidden fields below
secreqdate.value := startdate + 1 days; // sets hidden field "RequestedDate - Lab 2", that field is mapped to lab orders "scheduled date"
thirdreqdate.value := startdate + 2 days; // sets hidden field "RequestedDate - Lab 3", that field is mapped to lab orders "scheduled date"
endif; // If CallingEvent = "FormOpen" then
/**************************** Form Close rules ***************************************************/
// upon form close
// create a prompt asking user if they would like to reorder additional electrolytes
// if {{{SINGLE-QUOTE}}}yes{{{SINGLE-QUOTE}}} is selected, then continue
If (CallingEvent = "FormClose") then
// feature: If Tikosyn is a home med in the OMR, then do not present prompt upon form close
tikosyn_home_med := read last {
"SELECT p.DrugName"
||" FROM SXAAMBClientPrescription p with (nolock) JOIN SXAAMBDrugCategoryXRef xr with (nolock)"
||" ON p.GenericNameID = xr.GenericNameID"
||" JOIN SXAAMBDrugCategory dc with (nolock)"
||" ON xr.DrugCategoryID = dc.DrugCategoryID"
||" WHERE p.ClientGUID = " || sql(client_guid)
||" and (p.DrugName like {{{SINGLE-QUOTE}}}%dofetilide%{{{SINGLE-QUOTE}}} or p.DrugName like {{{SINGLE-QUOTE}}}%tikosyn%{{{SINGLE-QUOTE}}})"
||" and StatusType <> 8"
};
if (not exist tikosyn_home_med) then
//Retrieve last tikosyn orders
(tikosyn_active_order) := READ {
"select o.name"
||" from cv3ordercatalogmasteritem as ocmi with (nolock)"
||" join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid"
||" and o.ClientGUID = " || client_guid || " and o.ChartGUID = " || chart_guid || " and o.ClientVisitGUID= " || visit_guid || " "
||" and (o.name like {{{SINGLE-QUOTE}}}%dofetilide%{{{SINGLE-QUOTE}}})"
||" and o.OrderStatusLevelNum >= 15"
};
tikosyn_order_build_variants := ("Dofetilide 250mcg Cap", "Dofetilide 125mcg Cap", "Dofetilide 500mcg Cap");
build_variant_count := count tikosyn_order_build_variants;
x := ();
first_tikosyn_order := true;
// checks if this would be the patient{{{SINGLE-QUOTE}}}s first tikosyn order
// by checking SQL to see if it matches any of the tikosyn order build variants
for x in (1 seqto build_variant_count) do
this_order := tikosyn_order_build_variants[x];
if (this_order is in tikosyn_active_order) then
first_tikosyn_order := false;
endif;
enddo;
// if it{{{SINGLE-QUOTE}}}s not the first tikosyn order, ask user if they would like EKGs for first 3 days
if (first_tikosyn_order = false) then
// checks if this would be a reorder
if (EVOKINGOBJECT.Name is in tikosyn_active_order) then
tikosyn_reorder := true;
else
tikosyn_reorder := false;
endif;
endif;
// prompt user only if the reorder of tikosyn is a different dose (not a reorder)
// if user selects Yes, then create labs
// if user selects No, do not create labs
if (first_tikosyn_order = false and tikosyn_reorder = false) then
// check to see if any daily lab orders are selected, if so then continue with prompt.
all_daily_lab_orders := (Lab_Daily_Order_List_1.IsSelected, Lab_Daily_Order_List_2.IsSelected, Lab_Daily_Order_List_3.IsSelected);
// check to see if any daily lab orders are selected, if so then continue with prompt.
if (true is in all_daily_lab_orders) then
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
Messagetext := "Patient has already received Tikosyn this visit and is ordered all required electrolytes for the first 3 days of therapy. Do you want to order ADDITIONAL electrolytes for the next 3 days? " ||
"\n\nSelecting {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} will add it to the order worksheet." ||
"\n\nSelecting {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} will uncheck them from order form."
;
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with Messagetext ,"Dofetilide (Tikosyn) Electrolyte Orders","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult as string) = "No") then
Lab_Daily_Order_List_1.IsSelected := (False,False,False);
Lab_Daily_Order_List_2.IsSelected := (False,False,False);
Lab_Daily_Order_List_3.IsSelected := (False,False,False);
Baseline_Creatinine.IsSelected := false;
Baseline_Potassium.IsSelected := false;
Baseline_Magnesium.IsSelected := false;
Baseline_ECG.IsSelected := false;
endif; // if((dialogResult as string) = "No") then
endif; // if (true is in all_daily_lab_orders) then
endif; //if (first_tikosyn_order = false and tikosyn_reorder = false) then
endif; //if (not exist tikosyn_home_med) then
endif; // If (CallingEvent = "FormClose") then
Order_management_mlm := mlm {{{SINGLE-QUOTE}}}FORM_SET_Rx_Medication_Order_Mgt{{{SINGLE-QUOTE}}};
(this_communication, this_form) := call Order_management_mlm with this_communication, this_form, client_info_obj;
;;
priority: 50
;;
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;
;;
Urgency: 50;;
end:', N'f929b0d7-5142-4bcf-9599-a29f6416d3d4', 2, N'Set Tikosyn order set with automatic electrolyte lab ordering date', N'2.5', N'1.00', CAST(N'2017-08-28T00:00:00.000' AS DateTime), N'78ab2d8a-220d-e911-80f9-005056ad099c')