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,792 @@
maintenance:
title: Advanced Duplicate Order Checking;;
mlmname: STD_DUPLICATE;;
arden: version 2.5;;
version: 18.4;;
institution: Allscripts, Standard MLM;;
author: Allscripts Healthcare Solutions, Inc.;;
specialist: ;;
date: 2018-10-26;;
validation: testing;;
/* P r o p r i e t a r y N o t i c e */
/* Unpublished (c) 2013 - 2018 Allscripts Healthcare, LLC. and/or its affiliates. All Rights Reserved.
P r o p r i e t a r y N o t i c e: This software has been provided pursuant to a License Agreement, with
Allscripts Healthcare, LLC. and/or its affiliates, containing restrictions on its use. This software contains
valuable trade secrets and proprietary information of Allscripts Healthcare, LLC. and/or its affiliates and is
protected by trade secret and copyright law. This software may not be copied or distributed in any form or medium,
disclosed to any third parties, or used in any manner not provided for in said License Agreement except with prior
written authorization from Allscripts Healthcare, LLC. and/or its affiliates. Notice to U.S. Government Users:
This software is {{{SINGLE-QUOTE}}}Commercial Computer Software{{{SINGLE-QUOTE}}}.
All product names are the trademarks or registered trademarks of Allscripts Healthcare, LLC. and/or its affiliates.
*/
/* P r o p r i e t a r y N o t i c e */
library:
purpose: Provide Advanced Duplicate-Order Checking and Actions on Alerts.
The checking will include:
1. Orders of the same name or type within a pre-defined date range,
which will be varied by patient location.
2. Active orders of the same type/class.
3. IV-additives.
4. Resulted orders of community results of the same name within a pre-defined date range.
;;
explanation: An Evoking-Order is considered a duplicate of Other-Orders when all of
the criteria listed below are met:
a. The evoking-order is one of the following events: new order or outpatient order, released from hold,
activated from a conditional order, unsuspended, verified, or an order or outpatient order that
has been modified.
b. If the evoking object is a modified order or outpatient order, only an order with changes to the
SignificantDtm or the StopDtm will be checked for duplicate orders.
c. The evoking-order has an order status level number between 0-50 (AWPA-AUA10),
excluding 15 = HOLD.
d. The evoking-order is not excluded from duplicate checking
(over-all or by patient location).
e. The orders have identical Item Names, or the other-order matches the Item or
Class-Name & Value listed in the evoking-order{{{SINGLE-QUOTE}}}s item-catalog
duplicate-checking panel.
f. The other-orders are within the scoping rules for the patient location listed
in the evoking-order{{{SINGLE-QUOTE}}}s Duplicate Policy. The patient{{{SINGLE-QUOTE}}}s location is based on
the location-business-rules established by the facility for other parts of
Sunrise Clinical Manager.
g. The IsConditional status match between the evoking-order and the other-order.
h. Neither the evoking-order or the other-order are suspended.
i. Neither the evoking-order or the other-order are Master Repeat Orders.
j. The evoking-order conflicts with another current/active order,
or resources could be wasted if both orders are completed.
The radio-buttons in the item-catalog--duplicate panel determine
which situation may be occurring.
* CONFLICTING ORDER: If the radio-button for
"Based on Start and Stop Date (like medication orders)"
is selected, then only "current" orders with over-lapping
start (significant) & stop-times are considered conflicting orders.
Current orders have an order status level number
between 0-50, excluding HOLD, CANC, CANP, CAND, CANT, COMPA,
HISE, HISI, DISC, DISCD and DISCT.
These orders can be unsubmitted orders or orders already in the database.
* WASTING RESOURCES: If the radio-button for
"Based on Significant Date and Time (like diagnostic orders)"
is selected, then other "current, scheduled, or completed" orders within
the pre-defined time ranges are potential duplicates that could
waste resources. These other-orders will have an order status level
number between 0-100, excluding HOLD, CANC, CANP, CAND, CANT, COMPA,
HISE, HISI, DISC, DISCD and DISCT.
They can be unsubmitted orders or orders already in the database
or resulted orders from community
k. The evoking-order conflicts with existing orders belonging to the session
types as defined in the following list variables (e.g.
at_discharge_session_list, at_in_house_session_list,
at_historical_session_list, or at_outpatient_session_list).
The list variable corresponding to the session type of the entered order is used.
l. The facility can set MLM flag to allow the site to determine whether they want to
see Duplicate alerts for resulted orders from Community Results upon an order being
entered or modified. Set the flag to True to turn on Community Results checking.
The default = False;
enable_community_data_results_alerts := False;
m. The facility can set MLM flag to allow the site to match the resulted
order of community results using the order name if the resulted order cannot
be mapped to an item catalog item.
The default = False;
enable_Diagnostic_Duplicate_Check_by_Community_Order_Name := False;
n. The facility can set MLM flag to allow the site to control the "text" that is displayed in
the alert message for Community Results workflows versus Sunrise Orders.
The default = "Community". The alert text is configurable.
community_resultedOrder_alert_text := "Community";
Once a duplicate-order has been identified, selection of the appropriate message
is based on: (1) the defined MESSAGE TYPE in the item-catalog, (2) if appropriate,
the time period of the significant date (performed, exact, or scheduled), and
(3)if the message type is "exact" and the time period is "performed" or "scheduled,"
then a third criteria of "order without specific stop-date" will be added to
select the correct message.
The SEND_ALERT variable indicates whether to send the message or not.
The values are:
"", or blank = use the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag set in the AlertTypes dictionary
(NOTE that default setting of flag is unchecked. If the flag is
checked and this variable is left blank or "" all of the alerts
for this MLM will be sent with the order.)
"DoNotSend" = do not send the alert regardless of the AlertTypes dictionary
setting for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
"Send" = send the alert regardless of the AlertTypes dictionary setting
for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
The GENERATE_ACTIONS_ON_ALERTS variable indicates whether to generate
Actions on Alerts. The values are:
* TRUE = Generate Actions on Alerts
* FALSE = Do NOT generate Actions on Alerts
The ORDER STATUS LEVEL FLAGS determine what order statuses are retrieved
from the database and the unsubmitted orders. A facility may wish to
increase/decrease the order status numbers to retrieve more/less
order statuses that should be checked for duplicates.
However, increasing the "highest_status_level_for_meds" beyond 50
for MEDS may slow performance since large numbers of orders are returned
and are eventually discarded because their start and stop dates do not overlap.
Examples of setting are:
* 0-100 includes all order statuses
* 0-50 includes all "active/current" orders
* 40-50 includes orders from Pending to Active (excludes Pending Verification)
Complex and Multiple Frequencies Orders:
When retrieving unsubmitted and existing database orders, this MLM will consider
whether the order is:
- that have a start and stop time (like medication orders)
- that have a Significant date and time like (diagnositic orders)
This configuration is set in the Item Catalog Duplicate Checking option
Orders that have a start and stop time (like medication orders) will check
not check child orders (ComplexOrderType of 2,4,6)that exist in the database
or in the unsubmitted orders list.
Orders that have a Significant date and time like (diagnositic orders) will not
check Master orders (ComplexOrderType of 1,3,5) that exist in the database.
The following ComplexOrderType values define the type of order:
0 or NULL - regular order
1 - Sequential Complex Dose Master
2 - Sequential Complex Dose Child Order
3 - Concurrent Complex Dose Master
4 - Concurrent Complex Dose Child Order
5 - Multiple Frequencies Master
6 - Multiple Frequencies Child Order
;;
keywords: Duplicate Order;
;;
citations:
{{+B}}Development{{-B}}: Allscripts Healthcare Solutions, Inc. Clinical Information can be customized and configured by local facility.
{{+B}}Funding{{-B}}: None specific to the development of this alert
{{+B}}Release{{-B}}: None
{{+B}}Revision Date{{-B}}: 2012-11-07
{{+B}}Citations{{-B}}: None
;;
knowledge:
type: data-driven;;
data:
/***************Make Changes To Spelling And Flags In This Section***************/
/* Set to true if logging is needed.*/
log_execution_info := false;
/* Set the text for the variable below to indicate whether to send the message or not. */
send_alert := "DoNotSend";
/* Set a flag indicating whether or not Actions on Alerts should be generated */
generate_actions_on_alerts := TRUE;
alert_if_initial_error:= FALSE;
/* Set the ORDER STATUS LEVEL FLAGS to a different Order Status Level */
/* if more or fewer order statuses should be included */
lowest_status_level_for_diagnostics:= 0;
highest_status_level_for_diagnostics:= 100;
lowest_status_level_for_meds:= 0;
highest_status_level_for_meds:= 50;
// The duplicate checking flag for community results is as follows:
// Set this flag to TRUE to include resulted orders from community results in the evaluation.
// Set this flag to FALSE to exclude resulted orders from community results in the evaluation
enable_community_data_results_alerts := false;
// Set this flag to TRUE to match resulted orders from community results to
// the order name if the diagnostic order cannot be mapped to a catalog item.
// Set this flag to FALSE to match resulted orders from commmunity results only
// if the diagnostic order is mapped to a catalog item. (default)
enable_Diagnostic_Duplicate_Check_by_Community_Order_Name := false;
// Enter the text to differentiate resulted orders from community results in duplicate alerts:
// Set this flag to "Community" to include with the resulted order from community results
// data for MLM shown in brackets after the community data.
community_resultedOrder_alert_text := "Community";
/* Change the message within the quotes if a different short-message is needed.*/
duplicate_order_alert:= destination { Alert: warning,
"Duplicate Order", low, chart,
"HVC Duplicate", 1005, send_alert };
/* Change the spelling within the quotes to match the order item-catalog.*/
any_new_order:= event {OrderEnter User Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_new_patient_group_order:= event {OrderEnter Batch Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE
AND IsCreatedFromPatientGroupOrderTemplate = TRUE};
any_modified_order:= event {OrderModify User Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_released_order:= event {OrderRelease User Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_unsuspended_order:= event {OrderUnsuspend User Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_verified_order:= event {OrderVerify User Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
// --------------------------------------------------
// Outpatient Prescription and Home Medication Orders
//---------------------------------------------------
// Comment out below triggers to exclude checking all Outpatient Orders
// To include Home Medications remove the code {{{SINGLE-QUOTE}}}AND OrderAddtionalInfo.IsScript <> FALSE{{{SINGLE-QUOTE}}}
outpatient_order_entry_trigger := event {OutpatientOrderEnterNoIVAdditive User Order:
WHERE OrderAdditionalInfo.IsScript <> FALSE};
outpatient_order_modify_trigger := event {OutpatientOrderModify User Order:
WHERE OrderAdditionalInfo.IsScript <> FALSE};
/* Pharmacy Trigger Events */
any_OrderEnterPharmacyPerfect:= event {OrderEnterPharmacyPerfect Any Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_OrderModifyPharmacyPerfect:= event {OrderModifyPharmacyPerfect Any Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
any_OrderModifyPharmacy:= event {OrderModifyPharmacy Any Order:
WHERE OrderStatusLevelNum >= 0
AND OrderStatusLevelNum <= 50
AND OrderStatusCode <> "HOLD"
AND IsSuspended = FALSE };
/* Uncomment this section if you would like historical session type orders
to evoke this MLM, otherwise keep it commented out and this MLM will
ignore historical session type orders. If you uncomment this section make
sure to also uncomment the equivalent in the evoke clause.
order_alternate_enter_IV:= event{OrderAlternateEnterWithIVAdditive User Order:
where AlternateOrderType = 1};
order_alternate_enter_NOIV:= event{OrderAlternateEnterNoIVAdditive User Order:
where AlternateOrderType = 1};
order_alternate_modify:= event{OrderAlternateModify User Order:
where AlternateOrderType = 1
AND OrderStatusCode <> "HISE"
AND OrderStatusCode <> "HISI"}; */
// Set the list variables with the session types of existing orders against which
// the current order will be checked. The possible values for these variables are
// one or more types from the following list ("Discharge", "Inhouse", "Outpatient Rx", "Outpatient Hx", "Historical").
//
// The default setting is to check for duplicates between
// - current order entered during a discharge session type and existing discharge orders
// - current order entered during an in-house session type and existing in-house orders
// - current order entered during historical session type and existing historical orders
// - current outpatient orders entered and existing outpatient orders
at_discharge_session_list := ("Discharge");
at_in_house_session_list := ("Inhouse");
at_historical_session_list := ("Historical");
at_outpatient_session_list := ("Outpatient Rx", "Outpatient Hx");
/********************************************************************************/
/* Executes only when this MLM is called by the editor */
if called_by_editor then
/* Get current selected client visit in MLM Editor. */
(client_visit_guid,
current_visit) := read last {ClientVisit: GUID, This };
/* Search for example order in the current visit. */
EvokingObject:= read last
{Order: This
WHERE Name = "CBC" AND OrderStatusLevelNum > 40 };
endif;
/* Declares MLMs which can be called */
func_dup_message:= MLM {{{SINGLE-QUOTE}}}std_func_dup_messages{{{SINGLE-QUOTE}}};
func_check_for_duplicates:= MLM {{{SINGLE-QUOTE}}}std_func_dup_rules{{{SINGLE-QUOTE}}};
func_dup_actions := MLM {{{SINGLE-QUOTE}}}Std_Func_Dup_Actions{{{SINGLE-QUOTE}}};
/* Initialize variable */
continue_checking_order := true;
/* Set the order type to check */
complex_child_order_type := (2,4,6);
complex_master_order_type := (1,3,5);
regular_order_type := (NULL, 0);
/* Gets the Client GUID */
client_guid := read last {ClientInfo: GUID};
/* Gets information from the evoking Order */
(main_order_name,
evoking_object_guid,
order_status_code,
order_level_num,
order_summary_line,
main_item_catalog_guid,
order_catalog_master_item_obj,
chart_guid,
client_visit_guid,
order_significant_date,
order_requested_date,
order_entered_date,
order_stop_date,
order_is_conditional,
order_component_obj,
order_complex_type,
order_variable_component_obj,
order_is_for_discharge,
order_alternate_order_type,
evoking_order_additional_info,
back_up_obj) := read last
{Order: Name, GUID, OrderStatusCode, OrderStatusLevelNum, SummaryLine,
OrderCatalogMasterItemGUID, OrderCatalogMasterItem, ChartGUID,
ClientVisitGUID, SignificantDtm, RequestedDtm, Entered, StopDtm, IsConditional, OrderComponent,
ComplexOrderType, OrderVariableComponent, IsForDischarge, AlternateOrderType, OrderAdditionalInfo,
Backup REFERENCING EvokingObject};
(evoking_order_is_script) := read last {OrderAdditionalInfo: IsScript REFERENCING evoking_order_additional_info};
if exists EvokingObject
and (order_significant_date is null)
then
alert_if_initial_error := TRUE;
endif;
order_without_specific_stop_date := false;
if (order_alternate_order_type <> 2) //if not an outpatient order
then
// Get information about ongoing diagnostic order vs medication order
(order_without_specific_stop_date) := read last
{OrderCatalogMasterItem: IsOngoingOrder REFERENCING order_catalog_master_item_obj};
endif;
// This is a diagnostic like order
if order_without_specific_stop_date
then
/* Check to see if this is a master order and if so whether children exist */
if exists order_complex_type
and order_complex_type IS IN complex_master_order_type
then
/* Gets information from the order variable components */
(component_child_order_guid_list) := read
{OrderVariableComponent: ChildOrderGUID
REFERENCING order_variable_component_obj};
/* Check to see if children exist */
if exists component_child_order_guid_list
then
child_orders_generated := true;
/* If children exist, this MLM should not run on Master order on modify or unsuspend */
If EvokingEventType = any_modified_order.type
OR EvokingEventType = any_unsuspended_order.type
then
continue_checking_order := false;
endif; //If EvokingEventType = any_modified_order.type
/* This is a master order without children*/
else
continue_checking_order := true;
endif; //if exists component_child_order_guid_list
/* This is a child diagnositic order event continue check for modify, unsuspend... */
else
continue_checking_order := true;
endif; //if exists order_complex_type
else
/* This is a medication like order */
/* Check to see if this is a child order and if so stop processing as */
/* data will be alerted on at master order update */
if exists order_complex_type
and order_complex_type IS IN complex_child_order_type
then
continue_checking_order := false;
endif; //if exists order_complex_type
endif; //if order_without_specific_stop_date
// Determines if a modified order should be checked for duplicates
if EvokingEventType = any_modified_order.type
or EvokingEventType = any_OrderModifyPharmacy.type
or EvokingEventType = order_alternate_modify.type
or EvokingEventType = outpatient_order_modify_trigger.type
and continue_checking_order
then
if exist back_up_obj
then
(back_up_obj_signif_date,
back_up_obj_stop_date) := read last
{Order: SignificantDtm, StopDtm REFERENCING back_up_obj};
if (back_up_obj_signif_date <> order_significant_date)
OR (back_up_obj_stop_date <> order_stop_date)
OR (back_up_obj_stop_date is null and order_stop_date is time)
OR (back_up_obj_stop_date is time and order_stop_date is null)
then
continue_checking_order := true;
else
continue_checking_order := false;
endif;
else
continue_checking_order := false;
endif;
endif;
if continue_checking_order
then
/* Places the main-order on the lists to process */
order_list:= ,main_order_name;
cat_item_guid_list:= ,main_item_catalog_guid;
/* Only retrieves data if the Order has IV additives */
If exist order_component_obj
then
/* Gets the catalog item from the order component object */
(additive_cat_item_guid_list,
additive_name_list) := read
{ OrderComponent: OrderCatalogMasterItemGUID, Name
REFERENCING order_component_obj
where (Dosage AS Number) > 0 };
/* Places the additive information on the lists to process */
order_list:= order_list, additive_name_list;
cat_item_guid_list:= cat_item_guid_list, additive_cat_item_guid_list;
endif;
/* Gets the patient{{{SINGLE-QUOTE}}}s location group */
If called_by_editor
Then
/* Get visit information from the current selected visit in MLM Editor. */
patient_loc_group:= read last
{ ClientVisit: BusinessRuleLocationGUID
REFERENCING current_visit};
Else
patient_loc_group:= read last
{ ClientVisit: BusinessRuleLocationGUID };
Endif;
endif; /* continue_checking_order */
;;
evoke:
/* Uncomment this section if you would like historical session type orders
to evoke this mlm,otherwise keep it commented out.
If you uncomment this section please make sure to also uncomment the
equivalent event clauses
order_alternate_enter_IV OR
order_alternate_enter_NOIV OR
order_alternate_modify OR */
any_new_order;
any_new_patient_group_order;
any_modified_order;
any_released_order;
any_unsuspended_order;
any_verified_order;
outpatient_order_entry_trigger;
outpatient_order_modify_trigger;
any_OrderEnterPharmacyPerfect;
any_OrderModifyPharmacyPerfect;
any_OrderModifyPharmacy;
;;
logic:
If EvokingObject is NULL
then conclude false;
endif;
if alert_if_initial_error
then conclude true; /* generate an alert */
endif;
If NOT continue_checking_order
then conclude false;
endif;
/* Initialize variables */
indent:= " ";
dash_line:= "-----";
printable_alert_msg:= "";
index_list:= 1 SEQTO count(order_list);
/* Process the main order or the IV-additives */
for J in index_list do
order_name:= last(first J from order_list);
item_catalog_guid:= last(first J from cat_item_guid_list);
(exact_msg,
performed_msg,
scheduled_msg,
exact_type,
subset_type,
superset_type,
same_order_type,
partial_match_type,
conflict_type,
possible_conflict_type,
no_std_message_type,
order_without_specific_stop_date,
matching_name_list,
matching_order_guid_list,
matching_significant_date_list,
matching_requested_date_list,
matching_entered_date_list,
matching_stop_date_list,
matching_msg_type_list,
matching_msg_text_list,
matching_time_msg_list,
matching_class_list,
matching_summary_list,
matching_order_status_code_list,
matching_order_type_code_list,
matching_alternate_order_type_list,
matching_is_script_list,
matching_aoa_action_item_status_list,
matching_aoa_order_guid_list,
matching_aoa_order_name_list,
matching_aoa_master_guid_list ) := call func_check_for_duplicates with
(order_name,
evoking_object_guid,
order_status_code,
order_level_num,
order_summary_line,
item_catalog_guid,
chart_guid,
client_visit_guid,
order_significant_date,
order_requested_date,
order_entered_date,
order_stop_date,
order_is_conditional,
patient_loc_group,
lowest_status_level_for_diagnostics,
highest_status_level_for_diagnostics,
lowest_status_level_for_meds,
highest_status_level_for_meds,
complex_master_order_type,
complex_child_order_type,
order_is_for_discharge,
order_alternate_order_type,
evoking_order_is_script,
at_in_house_session_list,
at_discharge_session_list,
at_historical_session_list,
at_outpatient_session_list,
enable_community_data_results_alerts,
enable_Diagnostic_Duplicate_Check_by_Community_Order_Name,
EvokingObject,
EvokingEventType);
/*--------------------------------------------------------------*/
/* Calls an MLM to select the appropriate message and format it */
/*--------------------------------------------------------------*/
If exist matching_name_list
then
(order_status_msg,
alert_msg,
matching_short_message_list):= call func_dup_message with
(order_name,
order_status_code,
order_without_specific_stop_date,
exact_msg,
performed_msg,
scheduled_msg,
exact_type,
subset_type,
superset_type,
same_order_type,
partial_match_type,
conflict_type,
possible_conflict_type,
no_std_message_type,
matching_name_list,
matching_significant_date_list,
matching_requested_date_list,
matching_entered_date_list,
matching_stop_date_list,
matching_msg_type_list,
matching_msg_text_list,
matching_time_msg_list,
matching_class_list,
matching_summary_list,
matching_order_status_code_list,
matching_order_type_code_list,
matching_alternate_order_type_list,
matching_is_script_list,
community_resultedOrder_alert_text);
/* Format date, removing milliseconds */
order_significant_date_formatted := order_significant_date formatted with "%.4t";
/* Create one long message to print */
printable_alert_msg:= printable_alert_msg || alert_msg;
endif; /* If exist matching_name_list */
enddo; /* for J */
/* Create a printable list of additives */
if exist additive_name_list
then
if count(additive_name_list) = 1
then additive_message:= indent || "IV-Additives: " || first (additive_name_list)|| "\n";
else additive_message:= indent || "IV-Additives: " || additive_name_list || "\n";
endif; /* if count */
else additive_message:= "";
endif; /* if exist additive_name_list */
/* Set the printable text for the order summary line */
if exist order_summary_line
then
summary_line:= dash_line || order_summary_line;
else
summary_line:= "";
endif; /* if exist order_summary_line */
/*-------------------------------*/
/* Create the Actions On Alerts */
/*-------------------------------*/
// Only create actions for alerts when the flag, generate_actions_on_alerts, is TRUE
// and the evoking object is a new order.
// Since the MLM Editor does NOT have an evoking trigger,
// Check that the EvokingEventType is a new order or the MLM is running the the MLM Editor
if generate_actions_on_alerts
AND exist alert_msg
AND (EvokingEventType = any_new_order.type or EvokingEventType = any_new_patient_group_order.type or Called_By_Editor)
then
// Correct the sort sequence of the SHORT MESSAGES.
// The MLM that created the messages places them in the wrong sequence.
/* Initialize */
matching_aoa_short_message_list := ();
position_list := 1 SEQTO count (matching_aoa_order_guid_list);
// Use the matching_aoa_order_guid_list to place them in the right sequence
for GG in position_list do
//Get the OrderGUID and the Duplicate{{{SINGLE-QUOTE}}}s Name (order name or additive name)
aoa_order_guid := matching_aoa_order_guid_list[GG];
aoa_order_name := matching_aoa_order_name_list[GG];
//Use the GUID and the NAME to find a matching position for a regular order
found_match := (matching_order_guid_list = aoa_order_guid
and matching_name_list = aoa_order_name);
//Use just the GUID to find a matching position for orders with IV Additives
If NOT ANY found_match
then found_match := matching_order_guid_list = aoa_order_guid;
endif;
//Match the position to get the short message
temp_message := first (matching_short_message_list where found_match);
//Put the short message in its correct order in the list
matching_aoa_short_message_list := matching_aoa_short_message_list, temp_message;
enddo; //for GG
// Call the MLM that Generates the Actions
alert_action_object_list := call func_dup_actions WITH
evoking_object_guid,
matching_aoa_action_item_status_list,
matching_aoa_order_guid_list,
matching_aoa_order_name_list,
matching_aoa_master_guid_list,
matching_aoa_short_message_list ;
// Set a flag to attach the alert to the destination when there are alert actions
if exist alert_action_object_list
then continue_action := True;
else continue_action := False;
endif; // if exist
endif; //if generate_actions_on_alerts
/*---------------*/
/* Clinical Rule */
/*---------------*/
If exist alert_msg
then conclude true;
endif;
;;
action:
current_order_alert_msg := "The current ";
if (order_alternate_order_type = 2)
then
if (evoking_order_is_script)
then
current_order_alert_msg := current_order_alert_msg || "prescription: \n";
order_status_msg := order_status_msg || " Prescription";
else
current_order_alert_msg := current_order_alert_msg || "home medication: \n";
order_status_msg := order_status_msg || " Home Medication";
endif;
else
current_order_alert_msg := current_order_alert_msg || "order: \n";
order_status_msg := order_status_msg || " Order";
endif;
if alert_if_initial_error
then
write "Your order for {{+B}}{{+C}}" || main_order_name
|| "{{-B}}{{-C}} was{{+B}}{{+R}} not checked for possible duplicates {{-B}}{{-R}}"
|| "with other patient medications."
|| " Please use an alternate plan to do the check."
|| " \n\nThis drug was not checked because it does not have a start date or a stop date."
at duplicate_order_alert;
else
write current_order_alert_msg
|| indent || main_order_name || summary_line || "\n"
|| indent || "Date: " || order_significant_date_formatted ||"\n"
|| indent || "Status: " || order_status_msg || "\n"
|| additive_message
|| "\n"
|| "May be duplicate with: \n\n"
|| printable_alert_msg
at duplicate_order_alert;
if continue_action
then attach alert_action_object_list to duplicate_order_alert;
endif;
endif;
;;
Urgency: 50;;
end: