337 lines
14 KiB
Plaintext
337 lines
14 KiB
Plaintext
maintenance:
|
||
|
||
title: SCH_Tikosyn_EKG_auto_order ;;
|
||
mlmname: SCH_Tikosyn_EKG_auto_order;;
|
||
arden: version 2.5;;
|
||
version: 1.00;;
|
||
institution: St. Clair Hospital ;;
|
||
author: Sandy Zhang ;;
|
||
specialist: Amy Georgulis ;;
|
||
date: 2018-09-18;;
|
||
validation: testing;;
|
||
|
||
library:
|
||
purpose: This MLM auto-orders EKG 12 lead into worksheet in response to a Tikosyn order. Excludes ED patients and ED STAT orders of Tikosyn.
|
||
This is meant to address the lack of EKG being ordered with the Tikosyn orders from Tikosyn OS. Tikosyn OS is linked to the MLM: FORM_Set_Tikosyn_Electrolyte.
|
||
Previous name: SCH_Tikosyn_EKG_STAT_NOW. Changed to (SCH_Tikosyn_EKG_auto_order) due to expanded scope, ie. no longer restricted to only stat/now doses of Tikosyn.
|
||
;;
|
||
explanation:
|
||
|
||
Change history
|
||
|
||
09.13.2018 SZ CSR 36407 Created (CSR #36407 - auto order EKG with Tikosyn from Tikosyn Order Set)
|
||
|
||
;;
|
||
keywords:
|
||
;;
|
||
citations:
|
||
;;
|
||
knowledge:
|
||
type: data-driven;;
|
||
data:
|
||
|
||
|
||
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
|
||
include standard_libs;
|
||
|
||
error_occurred := false;
|
||
error_message := "";
|
||
log_execution_info := false;
|
||
|
||
if called_by_editor
|
||
then EvokingObject := read last {OrderSet: THIS where Name="intraabdominal antibiotics" };
|
||
endif;
|
||
|
||
tikosyn_order_enter_event := event { OrderEnter User Order: where TypeCode = "Medication"
|
||
and InitialSessionTypeCode <> "Discharge"
|
||
and (Name = "Dofetilide 125mcg Cap"
|
||
or Name = "Dofetilide 250mcg Cap"
|
||
or Name = "Dofetilide 500mcg Cap")
|
||
};
|
||
|
||
using "ObjectsPlusXA.SCM.Forms";
|
||
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
|
||
|
||
//Assign GUIDs
|
||
client_guid := EvokingObject.ClientGUID;
|
||
visit_guid := EvokingObject.ClientVisitGUID;
|
||
chart_guid := EvokingObject.ChartGUID;
|
||
user_guid := EvokingObject.userGUID;
|
||
|
||
Evoking_order_frequency_code := EVOKINGOBJECT.FrequencyCode;
|
||
|
||
// set to {{{SINGLE-QUOTE}}}RTN{{{SINGLE-QUOTE}}} (Routine) for default orders
|
||
// set to {{{SINGLE-QUOTE}}}TIMEC{{{SINGLE-QUOTE}}} (Scheduled/Start Time) for STAT scheduled orders
|
||
Sys_Order_priority_code := EVOKINGOBJECT.SystemOrderPriorityCode;
|
||
STAT_NOW_order_trigger := false;
|
||
|
||
if Sys_Order_priority_code = "TIMEC" then
|
||
STAT_NOW_order_trigger := true;
|
||
endif;
|
||
|
||
|
||
//Object to create an order to add to Order Entry Worksheet
|
||
UnsubmittedOrder_obj := OBJECT [order_type,
|
||
item_name,
|
||
item_modifier,
|
||
item_version,
|
||
coded_time,
|
||
requested_time_hour,
|
||
requested_time_min,
|
||
order_field_name,
|
||
order_field_value];
|
||
|
||
//MLM call to create order to add to Order Entry Worksheet
|
||
create_ekg_order := MLM {{{SINGLE-QUOTE}}}SCH_Func_Create_Unsubmitted_Order_Diagnostic_Prefilled{{{SINGLE-QUOTE}}};
|
||
|
||
//Retrieve user occupation
|
||
( orderRoleType, user_guid ) := READ LAST { UserInfo : OrderRoleType, GUID };
|
||
|
||
//Retrieve order class type
|
||
( ocmi, orderSessionType, orderSource ) := READ LAST { Order : OrderCatalogMasterItem, InitialSessionTypeCode, SourceCode REFERENCING EvokingObject };
|
||
|
||
|
||
//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;
|
||
|
||
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
// Filter - Unsubmitted order for ekg filter
|
||
////////////////////////////////////////////////////////////////////////////
|
||
// check for unsubmitted orders of EKG 12 Lead x 6
|
||
// If exist, then end without creating worksheet order
|
||
(unsubmitted_ekg) := READ {UnsubmittedOrders: Name WHERE (Name MATCHES PATTERN "%EKG%12%lead%")} ;
|
||
number_unsub_ekg := count (unsubmitted_ekg);
|
||
create_order := true;
|
||
if (number_unsub_ekg >= 6) then
|
||
create_order := false;
|
||
endif;
|
||
|
||
|
||
if (create_order = true) then
|
||
|
||
|
||
(er_patient) := READ LAST {"SELECT a.ColumnNewValue"
|
||
|| " FROM CV3Client c WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)"
|
||
|| " ON c.GUID = cv.ClientGUID"
|
||
|| " JOIN SXAEDLOCATIONAUDIT a WITH (NOLOCK)"
|
||
|| " ON cv.GUID = a.ClientVisitGUID"
|
||
|| " WHERE c.GUID = " || Sql(client_guid)
|
||
|| " AND cv.GUID = " || Sql(visit_guid)
|
||
|| " AND cv.ChartGUID = " || Sql(chart_guid)
|
||
|| " AND (cv.CurrentLocation = {{{SINGLE-QUOTE}}}ER Major{{{SINGLE-QUOTE}}}"
|
||
|| " or cv.CurrentLocation like {{{SINGLE-QUOTE}}}%ER%{{{SINGLE-QUOTE}}})"
|
||
|| " AND a.ColumnName = {{{SINGLE-QUOTE}}}location{{{SINGLE-QUOTE}}}"
|
||
|| " ORDER BY a.TouchedWhen"};
|
||
|
||
// 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 generate EKG orders
|
||
// only proceed if tikosyn is NOT a home med and patient is NOT in ER
|
||
if (not exist tikosyn_home_med) and ( er_patient is null ) then
|
||
|
||
// prompt user only if the reorder of tikosyn is a different dose (not a reorder)
|
||
// if user selects Yes, then create EKGs
|
||
// if user selects No, do not create EKGs
|
||
if (Evoking_order_frequency_code <> "Now") and (Evoking_order_frequency_code <> "STAT") then
|
||
|
||
if (first_tikosyn_order = false and tikosyn_reorder = false) then
|
||
|
||
Messagetext := "Patient has already received Tikosyn this visit and is ordered all required ECGs after the first 6 doses. Do you want to order ADDITIONAL ECG’s after the next 6 doses with this Tikosyn order? " ||
|
||
"\n\nSelecting {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} will add it to the order worksheet."
|
||
;
|
||
|
||
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with Messagetext ,"Dofetilide (Tikosyn) ECG Orders","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
|
||
|
||
if((dialogResult as string) = "Yes") then
|
||
order_six_EKG := true;
|
||
endif; //if((dialogResult as string) = "Yes") then
|
||
|
||
endif; //if (first_tikosyn_order = false and tikosyn_reorder = false) then
|
||
|
||
endif; //if (Evoking_order_frequency_code <> "Now") and (Evoking_order_frequency_code <> "STAT") then
|
||
|
||
|
||
// only order 6 x EKG if this is: 1) first tikosyn order
|
||
// or 2) reorder of a different dose and user selected {{{SINGLE-QUOTE}}}yes{{{SINGLE-QUOTE}}} to prompt
|
||
if (first_tikosyn_order = true) or (first_tikosyn_order = false and order_six_EKG = true) then
|
||
|
||
if (Evoking_order_frequency_code = "Now") or (Evoking_order_frequency_code = "STAT") then
|
||
// generate an EKG for 2.5 hours ahead of order time
|
||
|
||
target_time := EVOKINGOBJECT.RequestedDtm + 2 hours + 30 minutes;
|
||
|
||
target_hour := extract hour target_time;
|
||
target_min := extract minute target_time;
|
||
|
||
// create the order here
|
||
//Construct Object to pass to Unsubmitted Order Creation MLM
|
||
EKG_12_lead := NEW UnsubmittedOrder_obj WITH
|
||
[order_type := "Diagnostic",
|
||
item_name := "EKG 12 Lead",
|
||
item_modifier := "- for Tikosyn Order (STAT/Now dose)",
|
||
item_version := "",
|
||
coded_time := "Scheduled Time",
|
||
requested_time_hour := target_hour,
|
||
requested_time_min := target_min,
|
||
order_field_name := ("CARD EKG Indication 1", "Card Peformed By"),
|
||
order_field_value := ("Assess DrugThera Dysrhythmia", "South Hills Cardiology - M/S/Mac/F/G/G/L/P")
|
||
];
|
||
|
||
EKG_ISO_date_STAT := (extract year target_time) formatted with "%04d" || "-" ||
|
||
(extract month target_time) formatted with "%02d" || "-" ||
|
||
(extract day target_time) formatted with "%02d";
|
||
|
||
return_value := call create_ekg_order WITH (visit_guid, user_guid, client_guid, orderSessionType, "", EKG_12_lead, EKG_ISO_date_STAT);
|
||
|
||
endif; // if (Evoking_order_frequency_code = "Now") or (Evoking_order_frequency_code = "STAT") then
|
||
|
||
|
||
if (Evoking_order_frequency_code = "BID (09-21)" or Evoking_order_frequency_code = "BID" or Evoking_order_frequency_code = "Q12H") then
|
||
|
||
|
||
if (STAT_NOW_order_trigger = true) then
|
||
|
||
ordersneeded := 6;
|
||
|
||
target_dtm := EVOKINGOBJECT.RequestedDtm + 2 hours;
|
||
target_hour := extract hour target_dtm;
|
||
|
||
else // if (STAT_NOW_order_trigger = false) then
|
||
|
||
requested_hour := extract hour EVOKINGOBJECT.RequestedDtm;
|
||
|
||
ordersneeded := 6;
|
||
|
||
target_dtm := EVOKINGOBJECT.RequestedDtm;
|
||
|
||
if (requested_hour < 9) then
|
||
target_hour := 11;
|
||
elseif (requested_hour >= 9) and (requested_hour < 21) then
|
||
target_hour := 23;
|
||
elseif (requested_hour >= 21) then
|
||
target_hour := 11;
|
||
target_dtm := EVOKINGOBJECT.RequestedDtm + 1 day;
|
||
endif;
|
||
|
||
|
||
endif; // if (STAT_NOW_order_trigger = false) then
|
||
|
||
|
||
zero_zero := 00;
|
||
timeString_test := target_hour formatted with "%02d" || ":" || zero_zero formatted with "%02d" || ":" || zero_zero formatted with "%02d" ;
|
||
full_dtm_string := (extract month target_dtm) formatted with "%02d" || "-" || (extract day target_dtm) formatted with "%02d" || "-" || (extract year target_dtm) formatted with "%04d" || " " || timeString_test;
|
||
full_dtm := full_dtm_string as time;
|
||
k := ();
|
||
|
||
for k in (1 seqto ordersneeded) do
|
||
|
||
tikosyn_hour := extract hour full_dtm;
|
||
tikosyn_min := extract minute full_dtm;
|
||
|
||
// create the order here
|
||
//Construct Object to pass to Unsubmitted Order Creation MLM
|
||
EKG_12_lead_v2 := NEW UnsubmittedOrder_obj WITH
|
||
[order_type := "Diagnostic",
|
||
item_name := "EKG 12 Lead",
|
||
item_modifier := "- for tikosyn doses",
|
||
item_version := "",
|
||
coded_time := "Scheduled Time",
|
||
requested_time_hour := tikosyn_hour,
|
||
requested_time_min := tikosyn_min,
|
||
//requestedDate := requested_date,
|
||
order_field_name := ("CARD EKG Indication 1", "Card Peformed By"),
|
||
order_field_value := ("Assess DrugThera Dysrhythmia", "South Hills Cardiology - M/S/Mac/F/G/G/L/P")
|
||
];
|
||
|
||
EKG_ISO_date := (extract year full_dtm) formatted with "%04d" || "-" ||
|
||
(extract month full_dtm) formatted with "%02d" || "-" ||
|
||
(extract day full_dtm) formatted with "%02d";
|
||
|
||
return_value := call create_ekg_order WITH (visit_guid, user_guid, client_guid, orderSessionType, "", EKG_12_lead_v2, EKG_ISO_date);
|
||
//return_value := call create_ekg_order WITH (visit_guid, user_guid, client_guid, orderSessionType, "", EKG_12_lead_v2);
|
||
|
||
full_dtm := full_dtm + 12 hour;
|
||
|
||
enddo; // for k in (1 seqto ordersneeded) do
|
||
|
||
endif; // if (Evoking_order_frequency_code = "BID (09-21)" or Evoking_order_frequency_code = "BID" or Evoking_order_frequency_code = "Q12H") then
|
||
|
||
endif; // if (first_tikosyn_order = true) or (first_tikosyn_order = false and order_six_EKG = true) then
|
||
|
||
endif; // if (not exist tikosyn_home_med) and ( er_patient is null ) then
|
||
|
||
endif; // if (create_order = true) then
|
||
|
||
;;
|
||
evoke:
|
||
tikosyn_order_enter_event;
|
||
;;
|
||
logic:
|
||
|
||
if (called_by_editor) then
|
||
conclude false;
|
||
endif;
|
||
|
||
if (EvokingObject is null) then
|
||
conclude false;
|
||
endif;
|
||
|
||
|
||
conclude true;
|
||
|
||
|
||
;;
|
||
action:
|
||
|
||
|
||
;;
|
||
Urgency: 50;;
|
||
end:
|