1014 lines
44 KiB
Plaintext
1014 lines
44 KiB
Plaintext
maintenance:
|
|
|
|
title: Order Retrievals for Advanced Duplicate Order Checking;;
|
|
mlmname: STD_FUNC_DUP_RETRIEVE_ORDERS;;
|
|
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: Retrieves the UNSUBMITTED and DATABASE orders according to the rules
|
|
stated in std_duplicate.mlm. Returns order information to std_func_dup_rules.mlm.
|
|
;;
|
|
explanation: See additionial explanation and rules in std_duplicate.mlm
|
|
|
|
;;
|
|
keywords: Duplicate Order;
|
|
;;
|
|
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;
|
|
/********************************************************************************/
|
|
|
|
/* Arguments that are passed by the calling MLM */
|
|
(client_guid,
|
|
chart_guid,
|
|
client_visit_guid,
|
|
order_guid,
|
|
order_name,
|
|
order_is_conditional,
|
|
order_scope,
|
|
past_time,
|
|
future_time,
|
|
check_medication_like_orders,
|
|
lowest_status_level_for_diagnostics,
|
|
highest_status_level_for_diagnostics,
|
|
lowest_status_level_for_meds,
|
|
highest_status_level_for_meds,
|
|
hold_code,
|
|
canc_code,
|
|
canp_code,
|
|
cand_code,
|
|
cant_code,
|
|
compa_code,
|
|
disc_code,
|
|
discd_code,
|
|
disct_code,
|
|
hisi_code,
|
|
hise_code,
|
|
iv_additive_type_list,
|
|
complex_master_order_type,
|
|
complex_child_order_type,
|
|
order_is_for_discharge,
|
|
order_alternate_order_type,
|
|
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,
|
|
evoking_object,
|
|
evoking_object_type) := ARGUMENT;
|
|
|
|
/* Declare the MLMs that can be called by this MLM */
|
|
func_dup_suppress_checking := MLM {{{SINGLE-QUOTE}}}STD_FUNC_DUP_SUPPRESS_CHECKING{{{SINGLE-QUOTE}}};
|
|
func_session_type_filter := MLM {{{SINGLE-QUOTE}}}STD_FUNC_SESSION_TYPE_FILTER{{{SINGLE-QUOTE}}};
|
|
|
|
community_data_excluded_triggers_list := ();
|
|
|
|
/* Get the order table and filter query to filter the existing
|
|
database orders that will be checked against the entered order.
|
|
Get the session type bit flags to filter the unsubmitted orders
|
|
that will be checked against the entered order. */
|
|
|
|
(order_table_name,
|
|
filter_orders_query,
|
|
session_type_bit_flags,
|
|
filter_prescriptions_query,
|
|
prescription_type_list,
|
|
include_in_house_session_type_orders,
|
|
include_historical_session_type_orders,
|
|
include_discharge_session_type_orders,
|
|
include_outpatient_rx_session_type_orders,
|
|
include_outpatient_hx_session_type_orders,
|
|
include_community_medication) :=
|
|
call func_session_type_filter with
|
|
(at_in_house_session_list,
|
|
at_historical_session_list,
|
|
at_discharge_session_list,
|
|
at_outpatient_session_list,
|
|
NULL,
|
|
NULL,
|
|
FALSE,
|
|
order_is_for_discharge,
|
|
order_alternate_order_type,
|
|
NULL);
|
|
|
|
If exist client_guid
|
|
then
|
|
/* Sets variable values to retrieve orders from the database */
|
|
If order_scope = "This Chart"
|
|
then
|
|
ID_equals_patient_GUID := "O.ClientGUID = " || SQL(client_guid)
|
|
|| " AND O.ChartGUID = " || SQL(chart_guid);
|
|
elseif order_scope = "This Visit"
|
|
then
|
|
ID_equals_patient_GUID := "O.ClientGUID = " || SQL(client_guid)
|
|
|| " AND O.ChartGUID = " || SQL(chart_guid)
|
|
|| " AND O.ClientVisitGUID = " || SQL(client_visit_guid);
|
|
else
|
|
ID_equals_patient_GUID := "O.ClientGUID = " || SQL(client_guid);
|
|
endif;
|
|
|
|
If order_is_conditional
|
|
then
|
|
order_conditional := 1;
|
|
else
|
|
order_conditional := 0;
|
|
endif;
|
|
|
|
/*---------------------------------------------------------*/
|
|
/* Creates the Order Set GUIDs that Should NOT be Retrieved
|
|
/*---------------------------------------------------------*/
|
|
|
|
// Call the MLM that determines which Order Set GUIDs need Suppressing
|
|
(avoid_parent_order_set_GUID,
|
|
avoid_child_order_set_GUID ) := call func_dup_suppress_checking
|
|
with order_name, order_guid ;
|
|
|
|
/* Create a fragment of the SQL code that avoids retrieving certain OrderSetGUIDs */
|
|
/* By NOT retrieving these orders from the database, */
|
|
/* we are "suppressing" the duplicate checking on these orders. */
|
|
/* This is needed when the CDS Trigger is one of the order maintenance triggers */
|
|
|
|
// Initialize variable to empty string
|
|
AND_avoid_these_order_set_guids := "";
|
|
|
|
// Concatenate a fragment of the SQL code to the initalized variable
|
|
if exist avoid_parent_order_set_GUID
|
|
OR exist avoid_child_order_set_GUID
|
|
then
|
|
//Exclude the parent order set guid when it exists
|
|
if exist avoid_parent_order_set_GUID
|
|
then
|
|
AND_avoid_these_order_set_guids := AND_avoid_these_order_set_guids
|
|
|| " AND ((O.OrderSetGUID <> " || SQL(avoid_parent_order_set_GUID)
|
|
|| " OR O.OrderSetGUID is NULL ))" ;
|
|
endif;
|
|
|
|
//Exlude the child order set guid when it exists
|
|
if exist avoid_child_order_set_GUID
|
|
then
|
|
AND_avoid_these_order_set_guids := AND_avoid_these_order_set_guids
|
|
|| " AND ((O.OrderSubsetGUID <> " || SQL(avoid_child_order_set_GUID)
|
|
|| " OR O.OrderSubsetGUID is NULL ))" ;
|
|
endif;
|
|
else
|
|
//DO NOT exclude ANY Order Set GUIDs
|
|
//DO NOT exclude ANY SINGLE Orders
|
|
AND_avoid_these_order_set_guids := "";
|
|
endif;
|
|
|
|
|
|
/*-----------------------------*/
|
|
/* Gets the UNSUBMITTED ORDERS */
|
|
/*-----------------------------*/
|
|
// If check_medication_like_orders is true then look for "conflicting orders"
|
|
// else look for orders that are "wasting resources"
|
|
If check_medication_like_orders
|
|
then
|
|
(unsub_order_name_list,
|
|
unsub_order_guid_list,
|
|
unsub_significant_date_list,
|
|
unsub_requested_date_list,
|
|
unsub_entered_date_list,
|
|
unsub_stop_date_list,
|
|
unsub_is_conditional_list,
|
|
unsub_is_suspended_list,
|
|
unsub_order_status_code_list,
|
|
unsub_order_status_level_list,
|
|
unsub_order_type_code_list,
|
|
unsub_alternate_order_type_list,
|
|
unsub_order_additional_info_list,
|
|
unsub_summary_list,
|
|
unsub_master_GUID_list,
|
|
unsub_additive_obj_list,
|
|
unsub_this_list ):= read
|
|
{Unsubmitted Order:
|
|
Name, GUID, SignificantDtm, RequestedDtm, Entered, StopDtm,
|
|
IsConditional, IsSuspended, OrderStatusCode, OrderStatusLevelNum,
|
|
TypeCode, AlternateOrderType, OrderAdditionalInfo, SummaryLine, OrderCatalogMasterItemGUID, OrderComponent,
|
|
THIS
|
|
WHERE IsConditional = order_is_conditional
|
|
AND OrderStatusLevelNum >= lowest_status_level_for_meds
|
|
AND RepeatOrder <> 1
|
|
AND GUID <> order_guid
|
|
AND (IntendedAction IS NULL
|
|
OR IntendedAction IS IN ("Add New", "Modify", "Suspend"))
|
|
AND OrderSetGUID IS NOT IN avoid_parent_order_set_GUID
|
|
AND OrderSubsetGUID IS NOT IN avoid_child_order_set_GUID
|
|
AND ComplexOrderType IS NOT IN complex_child_order_type
|
|
AND not( (not include_in_house_session_type_orders AND (AlternateOrderType = 0 AND IsForDischarge = false)) OR
|
|
(not include_historical_session_type_orders AND AlternateOrderType = 1) OR
|
|
(not include_discharge_session_type_orders AND IsForDischarge) OR
|
|
(not include_outpatient_rx_session_type_orders AND (AlternateOrderType = 2 AND OrderAdditionalInfo.IsScript = true)) OR
|
|
(not include_outpatient_hx_session_type_orders AND (AlternateOrderType = 2 AND OrderAdditionalInfo.IsScript = false)))
|
|
};
|
|
else
|
|
(unsub_order_name_list,
|
|
unsub_order_guid_list,
|
|
unsub_significant_date_list,
|
|
unsub_requested_date_list,
|
|
unsub_entered_date_list,
|
|
unsub_stop_date_list,
|
|
unsub_is_conditional_list,
|
|
unsub_is_suspended_list,
|
|
unsub_order_status_code_list,
|
|
unsub_order_status_level_list,
|
|
unsub_order_type_code_list,
|
|
unsub_alternate_order_type_list,
|
|
unsub_order_additional_info_list,
|
|
unsub_summary_list,
|
|
unsub_master_GUID_list,
|
|
unsub_additive_obj_list,
|
|
unsub_this_list ):= read
|
|
{Unsubmitted Order:
|
|
Name, GUID, SignificantDtm, RequestedDtm, Entered, StopDtm,
|
|
IsConditional, IsSuspended,OrderStatusCode, OrderStatusLevelNum,
|
|
TypeCode, AlternateOrderType, OrderAdditionalInfo, SummaryLine, OrderCatalogMasterItemGUID,
|
|
OrderComponent, THIS
|
|
WHERE SignificantDtm >= past_time
|
|
AND SignificantDtm <= future_time
|
|
AND IsConditional = order_is_conditional
|
|
AND OrderStatusLevelNum >= lowest_status_level_for_diagnostics
|
|
AND RepeatOrder <> 1
|
|
AND GUID <> order_guid
|
|
AND (IntendedAction IS NULL
|
|
OR IntendedAction IS IN ("Add New", "Modify", "Suspend"))
|
|
AND OrderSetGUID IS NOT IN avoid_parent_order_set_GUID
|
|
AND OrderSubsetGUID IS NOT IN avoid_child_order_set_GUID
|
|
AND not( (not include_in_house_session_type_orders AND (AlternateOrderType = 0 AND IsForDischarge = false)) OR
|
|
(not include_historical_session_type_orders AND AlternateOrderType = 1) OR
|
|
(not include_discharge_session_type_orders AND IsForDischarge) OR
|
|
(not include_outpatient_rx_session_type_orders AND (AlternateOrderType = 2 AND OrderAdditionalInfo.IsScript = true)) OR
|
|
(not include_outpatient_hx_session_type_orders AND (AlternateOrderType = 2 AND OrderAdditionalInfo.IsScript = false)))
|
|
};
|
|
endif;
|
|
|
|
unsub_indices := 1 SEQTO count(unsub_order_guid_list);
|
|
temp_unsub_is_script_list := ();
|
|
for i in unsub_indices do
|
|
temp_order_additional_info := unsub_order_additional_info_list[i];
|
|
(temp_unsub_is_script) := read last {OrderAdditionalInfo: IsScript REFERENCING temp_order_additional_info};
|
|
temp_unsub_is_script_list := temp_unsub_is_script_list, temp_unsub_is_script;
|
|
enddo;
|
|
|
|
/*----------------------------------------------------*/
|
|
/* Gets IV-ADDITIVE Information on Unsubmitted Orders */
|
|
/*----------------------------------------------------*/
|
|
|
|
// Initialize variables
|
|
unsub_additive_name_list:= ();
|
|
unsub_additive_master_guid_list:= ();
|
|
unsub_additive_order_guid_list:= ();
|
|
|
|
// Gets the IV-additive information one object at a time and
|
|
// appends the information to a larger list
|
|
for temp_unsub_additive_object in unsub_additive_obj_list do
|
|
if temp_unsub_additive_object is present
|
|
then
|
|
(temp_unsub_IV_name_list,
|
|
temp_unsub_IV_master_GUID_list,
|
|
temp_unsub_IV_order_GUID_list):= read
|
|
{OrderComponent: Name, OrderCatalogMasterItemGUID, OrderGUID
|
|
REFERENCING temp_unsub_additive_object
|
|
where (Dosage AS Number) > 0 };
|
|
|
|
unsub_additive_name_list:= unsub_additive_name_list,
|
|
temp_unsub_IV_name_list;
|
|
unsub_additive_master_guid_list:= unsub_additive_master_guid_list,
|
|
temp_unsub_IV_master_GUID_list;
|
|
unsub_additive_order_guid_list:= unsub_additive_order_guid_list,
|
|
temp_unsub_IV_order_GUID_list;
|
|
endif;
|
|
enddo;
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
/* Create a fragment of the SQL code that avoids retrieving the same orders */
|
|
/* from the database that are in the unsubmitted list. */
|
|
/* This is needed when the CDS Trigger is one of the order maintenance triggers */
|
|
/* and the user is performing a multi-order function */
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
// Initialize variable to empty string
|
|
AND_avoid_these_unsubmitted_order_guids := "";
|
|
|
|
// Concatenate a fragment of the SQL code to the initalized variable
|
|
if exist unsub_order_guid_list
|
|
then
|
|
if (count(unsub_order_guid_list) = 1)
|
|
then
|
|
//Set up to exclude this single order item
|
|
single_unsub_order_guid := last of (unsub_order_guid_list);
|
|
AND_avoid_these_unsubmitted_order_guids := AND_avoid_these_unsubmitted_order_guids
|
|
|| " AND (O.GUID <> " || SQL(single_unsub_order_guid) || ")";
|
|
|
|
else
|
|
//Set up to exclude the these order guids
|
|
AND_avoid_these_unsubmitted_order_guids := AND_avoid_these_unsubmitted_order_guids
|
|
|| " AND (O.GUID NOT IN (" || SQL(unsub_order_guid_list) || "))";
|
|
endif;
|
|
else
|
|
AND_avoid_these_unsubmitted_order_guids :="";
|
|
endif;
|
|
|
|
/* Set up common query variables */
|
|
SELECT_FROM_common_columns := "SELECT DISTINCT O.Name, O.GUID, "
|
|
|| " ConvSignificantDtm.TimeValue as SignificantDtmOffset, "
|
|
|| " ConvRequestedDtm.TimeValue as RequestedDtmOffset, "
|
|
|| " ConvEntered.TimeValue as EnteredOffset, "
|
|
|| " ConvStopDtm.TimeValue as StopDtmOffset, "
|
|
|| " O.IsConditional, "
|
|
|| " O.IsSuspended, O.OrderStatusCode, O.OrderStatusLevelNum, "
|
|
|| " O.TypeCode, O.AlternateOrderType, OAI.IsScript, O.SummaryLine, O.OrderCatalogMasterItemGUID, "
|
|
|| " ComponentName = CASE when (A.Type IS NULL) "
|
|
|| " OR (A.Type IN (" || iv_additive_type_list || "))"
|
|
|| " then A.Name "
|
|
|| " else NULL "
|
|
|| " end, "
|
|
|| " ComponentCatalogGUID = CASE when (A.Type IS NULL) "
|
|
|| " OR (A.Type IN (" || iv_additive_type_list || "))"
|
|
|| " then A.OrderCatalogMasterItemGUID "
|
|
|| " else null "
|
|
|| " end ";
|
|
|
|
SELECT_FROM_common := SELECT_FROM_common_columns
|
|
|| " FROM "|| order_table_name ||" AS O "
|
|
|| " INNER JOIN CV3ClientVisit AS V ON ( V.GUID = O.ClientVisitGUID )"
|
|
|| " LEFT OUTER JOIN CV3OrderComponent AS A "
|
|
|| " ON ( O.ClientGUID=A.ClientGUID "
|
|
|| " AND O.GUID= A.OrderGUID )"
|
|
|| " LEFT OUTER JOIN CV3OrderAddnlInfo AS OAI "
|
|
|| " ON ( O.ClientGUID = OAI.ClientGUID AND O.GUID = OAI.GUID ) "
|
|
||" CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.SignificantDtm) AS ConvSignificantDtm "
|
|
||" CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.RequestedDtm) AS ConvRequestedDtm "
|
|
||" CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.Entered) AS ConvEntered "
|
|
||" CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.StopDtm) AS ConvStopDtm ";
|
|
|
|
WHERE_conditions_common := " " || ID_equals_patient_GUID
|
|
|| " AND ISNULL (A.ClientGUID, "||SQLEX(client_guid)||") = "|| SQLEX(client_guid)
|
|
|| " AND O.IsConditional = " || SQLEX(order_conditional)
|
|
|| " AND O.IsSuspended = 0 "
|
|
|| " AND O.Active = 1"
|
|
|| " AND O.GUID <> " || SQLEX(order_guid)
|
|
|| " AND O.RepeatOrder <> 1 "
|
|
|| AND_avoid_these_unsubmitted_order_guids
|
|
|| AND_avoid_these_order_set_guids
|
|
|| " AND O.OrderStatusCode NOT IN (" || SQLEX(hold_code) ||","
|
|
|| SQLEX(disc_code)||","|| SQLEX(discd_code)||","|| SQLEX(disct_code)||","
|
|
|| SQLEX(canc_code)||","|| SQLEX(canp_code)||","
|
|
|| SQLEX(cand_code)||","|| SQLEX(cant_code)||","
|
|
|| SQLEX(hisi_code)||","|| SQLEX(hise_code)||","
|
|
|| SQLEX(compa_code)|| ")";
|
|
|
|
SELECT_FROM_result_columns := " SELECT Name, GUID, SignificantDtmOffset, RequestedDtmOffset, EnteredOffset, StopDtmOffset, "
|
|
|| " IsConditional, IsSuspended, OrderStatusCode, OrderStatusLevelNum, TypeCode, AlternateOrderType, "
|
|
|| " IsScript, SummaryLine, OrderCatalogMasterItemGUID, ComponentName, ComponentCatalogGUID ";
|
|
|
|
Filter_by_policy_datetime_range := " SignificantDtmOffset >= " || SQLEX(past_time)
|
|
|| " AND SignificantDtmOffset <= " || SQLEX(future_time);
|
|
|
|
/*--------------------------*/
|
|
/* Gets the DATABASE ORDERS */
|
|
/*--------------------------*/
|
|
/* If check_medication_like_orders is true then look for "conflicting orders" */
|
|
/* else look for orders that are "wasting resources" */
|
|
|
|
sql_query1 := "";
|
|
sql_query2 := "";
|
|
sql_query3 := "";
|
|
|
|
If check_medication_like_orders
|
|
then
|
|
/* Gets all potential duplicate medication orders */
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
/* For Complex Dosing Option orders using sequential schedule, if the master */
|
|
/* order has been discontinued or cancelled, get the active child order with the*/
|
|
/* latest stop date/time for duplicate checking. Since no complex dosing option*/
|
|
/* child orders are generated for historical and outpatient orders, only get */
|
|
/* dosing option order from CV3Order, not from CV3AllOrdersVw. */
|
|
/*------------------------------------------------------------------------------*/
|
|
sequential_complex_master_order_type := (1,5);
|
|
|
|
sql_query1 := ";With CTEComplexDosingChildOrders AS ( "
|
|
|| SELECT_FROM_common_columns || ","
|
|
|| " ROW_NUMBER() over (PARTITION BY ovc.OrderGUID ORDER BY O.StopDtm DESC) RowID "
|
|
|| " FROM CV3OrderVariableComponent ovc "
|
|
|| " INNER JOIN CV3Order Parent "
|
|
|| " on (parent.GUID = ovc.OrderGUID)"
|
|
|| " INNER JOIN CV3Order O "
|
|
|| " ON (O.GUID = ovc.ChildOrderGUID) "
|
|
|| " INNER JOIN CV3ClientVisit AS V "
|
|
|| " ON ( V.GUID = O.ClientVisitGUID ) "
|
|
|| " LEFT OUTER JOIN CV3OrderComponent AS A "
|
|
|| " ON ( O.ClientGUID=A.ClientGUID AND O.GUID= A.OrderGUID ) "
|
|
|| " LEFT OUTER JOIN CV3OrderAddnlInfo AS OAI "
|
|
|| " ON ( O.ClientGUID = OAI.ClientGUID AND O.GUID = OAI.GUID ) "
|
|
|| " CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.SignificantDtm) AS ConvSignificantDtm "
|
|
|| " CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.RequestedDtm) AS ConvRequestedDtm "
|
|
|| " CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.Entered) AS ConvEntered "
|
|
|| " CROSS APPLY dbo.SXADBConvertLocalToOffsetTblFn(V.TimeZone, O.StopDtm) AS ConvStopDtm "
|
|
|| " WHERE Parent.ClientGUID = " || SQLEX(client_guid)
|
|
|| " AND Parent.GUID <> " || SQLEX(order_guid)
|
|
|| " AND Parent.OrderStatusLevelNum >= 69 "
|
|
|| " AND Parent.OrderStatusLevelNum <= 100 "
|
|
|| " AND Parent.OrderStatusCode IN ("
|
|
|| SQLEX(disc_code)||","|| SQLEX(discd_code)||","|| SQLEX(disct_code)||","
|
|
|| SQLEX(canc_code)||","|| SQLEX(canp_code)||","
|
|
|| SQLEX(cand_code)||","|| SQLEX(cant_code)||")"
|
|
|| " AND Parent.ComplexOrderType IN (" || sequential_complex_master_order_type || ")"
|
|
|| " AND ovc.ChildOrderGUID is not NULL"
|
|
|| " AND " || WHERE_conditions_common
|
|
|| " AND O.OrderStatusLevelNum >= " || SQLEX(lowest_status_level_for_meds)
|
|
|| " AND O.OrderStatusLevelNum <= " || SQLEX(highest_status_level_for_meds);
|
|
|
|
sql_query2 := SELECT_FROM_common
|
|
|| " WHERE " || WHERE_conditions_common
|
|
|| " AND O.OrderStatusLevelNum >= " || SQLEX(lowest_status_level_for_meds)
|
|
|| " AND O.OrderStatusLevelNum <= " || SQLEX(highest_status_level_for_meds)
|
|
|| " AND O.ComplexOrderType NOT IN (" || complex_child_order_type|| ")";
|
|
|
|
sql_query3 := " UNION "
|
|
|| SELECT_FROM_result_columns
|
|
|| " FROM CTEComplexDosingChildOrders "
|
|
|| " WHERE RowID = 1";
|
|
else
|
|
/* Create 2 tables temporary result sets of potential duplicate orders within the range of maximum time zone difference */
|
|
/* These results will then be filtered by the datetime range based on the Duplicate Policy */
|
|
max_hours_differece_between_time_zones := 26 as number;
|
|
AND_filter_potential_orders := " AND O.SignificantDtm >= dateadd( hour, -" || SQLEX(max_hours_differece_between_time_zones)
|
|
|| ", " || SQL(past_time) || " )" // filter out potential orders based on unconverted datetime
|
|
|| " AND O.SignificantDtm <= dateadd( hour, " || SQLEX(max_hours_differece_between_time_zones)
|
|
|| ", " || SQL(future_time) || " )"; // filter out potential orders based on unconverted datetime;
|
|
|
|
sql_query1 := ";With CteAllOrders AS ( "
|
|
|| SELECT_FROM_common
|
|
|| " WHERE " || WHERE_conditions_common
|
|
|| " AND O.OrderStatusLevelNum >= "||SQLEX(lowest_status_level_for_diagnostics)
|
|
|| " AND O.OrderStatusLevelNum <= "||SQLEX(highest_status_level_for_diagnostics)
|
|
|| AND_filter_potential_orders
|
|
|| " AND O.ComplexOrderType NOT IN (" || complex_master_order_type|| ")";
|
|
|
|
sql_query2 := " ), CteAllOrdersComp AS ( "
|
|
|| SELECT_FROM_common
|
|
|| " INNER JOIN CV3OrderVariableComponent AS OVC"
|
|
|| " ON O.GUID = OVC.OrderGUID "
|
|
|| " WHERE " || WHERE_conditions_common
|
|
|| " AND O.OrderStatusLevelNum >= "||SQLEX(lowest_status_level_for_diagnostics)
|
|
|| " AND O.OrderStatusLevelNum <= "||SQLEX(highest_status_level_for_diagnostics)
|
|
|| AND_filter_potential_orders
|
|
|| " AND O.ComplexOrderType IN (" || complex_master_order_type|| ")"
|
|
|| " AND ChildOrderGUID is NULL ";
|
|
|
|
/* Query on the temporary result sets to filter duplicate orders based on the datetime range specified by the Duplicate Policy */
|
|
sql_query3 := SELECT_FROM_result_columns
|
|
|| " FROM CteAllOrders WHERE "
|
|
|| Filter_by_policy_datetime_range
|
|
|| " UNION "
|
|
|| SELECT_FROM_result_columns
|
|
|| " FROM CteAllOrdersComp WHERE "
|
|
|| Filter_by_policy_datetime_range;
|
|
endif;
|
|
|
|
if (not include_in_house_session_type_orders)
|
|
then
|
|
sql_query1 := sql_query1 || " AND (O.AlternateOrderType <> 0 OR O.IsForDischarge = 1) ";
|
|
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " AND (O.AlternateOrderType <> 0 OR O.IsForDischarge = 1) ";
|
|
endif;
|
|
endif;
|
|
|
|
if (not include_historical_session_type_orders)
|
|
then
|
|
sql_query1 := sql_query1 || " AND O.AlternateOrderType <> 1 ";
|
|
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " AND O.AlternateOrderType <> 1 ";
|
|
endif;
|
|
endif;
|
|
|
|
if (not include_discharge_session_type_orders)
|
|
then
|
|
sql_query1 := sql_query1 || " AND O.IsForDischarge = 0 ";
|
|
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " AND O.IsForDischarge = 0 ";
|
|
endif;
|
|
endif;
|
|
|
|
if (not include_outpatient_rx_session_type_orders)
|
|
then
|
|
sql_query1 := sql_query1 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 1) ";
|
|
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 1) ";
|
|
endif;
|
|
endif;
|
|
|
|
if (not include_outpatient_hx_session_type_orders)
|
|
then
|
|
sql_query1 := sql_query1 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 0) ";
|
|
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 0) ";
|
|
endif;
|
|
endif;
|
|
|
|
if check_medication_like_orders
|
|
then
|
|
if (sql_query1 <> "")
|
|
then
|
|
sql_query1 := sql_query1 || ") ";
|
|
endif;
|
|
else
|
|
if (sql_query2 <> "")
|
|
then
|
|
sql_query2 := sql_query2 || " ) ";
|
|
endif;
|
|
endif;
|
|
|
|
(db_order_name_list,
|
|
db_order_guid_list,
|
|
db_significant_date_list,
|
|
db_requested_date_list,
|
|
db_entered_date_list,
|
|
db_stop_date_list,
|
|
db_is_conditional_list,
|
|
db_is_suspended_list,
|
|
db_order_status_code_list,
|
|
db_order_status_level_list,
|
|
db_order_type_code_list,
|
|
db_alternate_order_type_list,
|
|
db_order_is_script_list,
|
|
db_summary_list,
|
|
db_master_GUID_list,
|
|
db_additive_list,
|
|
db_additive_master_GUID_list ):= read { "" || sql_query1 || sql_query2 || sql_query3, PrimaryTime = SignificantDtmOffset};
|
|
|
|
if ( enable_community_data_results_alerts )
|
|
then
|
|
// ep setting
|
|
(enable_comm_data) := read { "SELECT Value FROM HVCEnvProfile WHERE HierarchyCode = {{{SINGLE-QUOTE}}}DataXchg|Community Data Import|Results{{{SINGLE-QUOTE}}} AND Code = {{{SINGLE-QUOTE}}}EnableCommunityData{{{SINGLE-QUOTE}}}" };
|
|
|
|
if ( UPPERCASE(last(enable_comm_data)) = "YES" )
|
|
then
|
|
func_community_data_retrieve_rules := MLM {{{SINGLE-QUOTE}}}STD_FUNC_COMMUNITY_DATA_RETRIEVAL_RULES{{{SINGLE-QUOTE}}};
|
|
mlm_Name := "STD_DUPLICATE";
|
|
|
|
(can_perform,
|
|
can_retrieve_data_obj) := call func_community_data_retrieve_rules with
|
|
(evoking_object, evoking_object_type, mlm_Name, community_data_excluded_triggers_list);
|
|
if (can_perform AND can_retrieve_data_obj.ImportedResults)
|
|
then
|
|
// get community data
|
|
(comm_order_name_list,
|
|
comm_order_guid_list,
|
|
comm_significant_date_list,
|
|
comm_requested_date_list,
|
|
comm_order_status_code_list,
|
|
comm_order_status_level_list,
|
|
comm_order_type_code_list,
|
|
comm_master_GUID_list ):= read { "exec SXAExternalObservationOrganizerCDSSelPr " || SQLEX(client_guid)
|
|
|| "," || SQLEX(past_time) || "," || SQLEX(future_time)
|
|
|| "," || SQLEX(enable_Diagnostic_Duplicate_Check_by_Community_Order_Name)
|
|
, PrimaryTime = SignificantDtmUTC };
|
|
endif;
|
|
endif;
|
|
endif;
|
|
|
|
endif; /* If exist client_guid */
|
|
|
|
;;
|
|
evoke:
|
|
;;
|
|
logic:
|
|
If NOT exist db_order_name_list
|
|
AND NOT exist unsub_order_name_list
|
|
AND NOT exist comm_order_name_list
|
|
then conclude false;
|
|
endif;
|
|
|
|
/*-----------------------*/
|
|
/* Initializes Variables */
|
|
/*-----------------------*/
|
|
order_name_list:= ();
|
|
order_guid_list:= ();
|
|
significant_date_list := ();
|
|
requested_date_list := ();
|
|
entered_date_list := ();
|
|
stop_date_list:= ();
|
|
is_conditional_list:= ();
|
|
is_suspended_list:= ();
|
|
order_status_code_list:= ();
|
|
order_status_level_list:= ();
|
|
order_type_code_list:= ();
|
|
alternate_order_type_list := ();
|
|
is_script_list := ();
|
|
summary_list:= ();
|
|
master_GUID_list:= ();
|
|
aoa_action_item_status_list := ();
|
|
|
|
order_status_code_list_to_exclude := (hold_code, canc_code, canp_code, cand_code, cant_code, compa_code, hisi_code, hise_code);
|
|
|
|
/*-------------------------------------------------------------*/
|
|
/* Combines information on "unsubmitted" and "database" orders */
|
|
/*-------------------------------------------------------------*/
|
|
/*----------------------------*/
|
|
/* Process UNSUBMITTED Orders */
|
|
/*----------------------------*/
|
|
If exist unsub_master_guid_list
|
|
then
|
|
// Replace some of the main-order information with the IV-additive information
|
|
temp_unsub_index_list:= 1 SEQTO count(unsub_order_guid_list);
|
|
for JJ in temp_unsub_index_list do
|
|
|
|
// Get one piece of information from each list
|
|
temp_unsub_order_name:= last(first JJ from unsub_order_name_list);
|
|
temp_unsub_order_guid:= last(first JJ from unsub_order_guid_list);
|
|
temp_unsub_significant_date:= last(first JJ from unsub_significant_date_list);
|
|
temp_unsub_requested_date := last(first JJ from unsub_requested_date_list);
|
|
temp_unsub_entered_date := last(first JJ from unsub_entered_date_list);
|
|
temp_unsub_stop_date:= last(first JJ from unsub_stop_date_list);
|
|
temp_unsub_is_conditional:= last(first JJ from unsub_is_conditional_list);
|
|
temp_unsub_is_suspended:= last(first JJ from unsub_is_suspended_list);
|
|
temp_unsub_order_status_code := last(first JJ from unsub_order_status_code_list);
|
|
temp_unsub_order_status_level:= last(first JJ from unsub_order_status_level_list);
|
|
temp_unsub_order_type_code:= last(first JJ from unsub_order_type_code_list);
|
|
temp_unsub_alternate_order_type := last(first JJ from unsub_alternate_order_type_list);
|
|
temp_unsub_summary:= last(first JJ from unsub_summary_list);
|
|
temp_unsub_master_GUID:= last(first JJ from unsub_master_GUID_list);
|
|
temp_unsub_additive_obj:= last(first JJ from unsub_additive_obj_list);
|
|
temp_unsub_is_script := temp_unsub_is_script_list[JJ];
|
|
|
|
if check_medication_like_orders
|
|
then
|
|
order_status_lower_limit := lowest_status_level_for_meds;
|
|
order_status_upper_limit := highest_status_level_for_meds;
|
|
else
|
|
order_status_lower_limit := lowest_status_level_for_diagnostics;
|
|
order_status_upper_limit := highest_status_level_for_diagnostics;
|
|
endif;
|
|
|
|
// We only want to retrieve non-suspended order(s)
|
|
if ( temp_unsub_is_suspended = false AND (temp_unsub_order_status_code NOT IN order_status_code_list_to_exclude) AND
|
|
temp_unsub_order_status_level >= order_status_lower_limit AND temp_unsub_order_status_level <= order_status_upper_limit )
|
|
then
|
|
// Add the "main" UNSUBMITTED orders onto the lists for processing
|
|
order_name_list := order_name_list, temp_unsub_order_name;
|
|
order_guid_list := order_guid_list, temp_unsub_order_guid;
|
|
significant_date_list := significant_date_list, temp_unsub_significant_date;
|
|
requested_date_list := requested_date_list, temp_unsub_requested_date;
|
|
entered_date_list := entered_date_list, temp_unsub_entered_date;
|
|
stop_date_list := stop_date_list, temp_unsub_stop_date;
|
|
is_conditional_list := is_conditional_list, temp_unsub_is_conditional;
|
|
is_suspended_list := is_suspended_list, temp_unsub_is_suspended;
|
|
order_status_code_list := order_status_code_list, "Unsubmitted";
|
|
order_status_level_list := order_status_level_list, temp_unsub_order_status_level;
|
|
order_type_code_list := order_type_code_list, temp_unsub_order_type_code;
|
|
alternate_order_type_list := alternate_order_type_list, temp_unsub_alternate_order_type;
|
|
is_script_list := is_script_list, temp_unsub_is_script;
|
|
summary_list := summary_list, temp_unsub_summary;
|
|
master_GUID_list := master_GUID_list, temp_unsub_master_GUID;
|
|
|
|
// If the order has an IV-additive, add the Additives to the list for proessing
|
|
if exist temp_unsub_additive_obj
|
|
then
|
|
// Use the OrderGUID to find the additive information
|
|
additives_found:= temp_unsub_order_guid = unsub_additive_order_guid_list;
|
|
temp_unsub_additive_names:= unsub_additive_name_list where additives_found;
|
|
temp_unsub_additive_master_guids:= unsub_additive_master_guid_list
|
|
where additives_found;
|
|
|
|
// Add the list of additives and their GUIDs to the processing lists
|
|
order_name_list:= order_name_list,temp_unsub_additive_names;
|
|
master_GUID_list:= master_GUID_list,temp_unsub_additive_master_guids;
|
|
|
|
// Transfer the unsubmitted order information onto the main processing lists
|
|
// One-at-a-time to keep the list length in synch with the order_name_list
|
|
for MM in temp_unsub_additive_names do
|
|
order_guid_list := order_guid_list,temp_unsub_order_guid;
|
|
significant_date_list := significant_date_list, temp_unsub_significant_date;
|
|
requested_date_list := requested_date_list, temp_unsub_requested_date;
|
|
entered_date_list := entered_date_list, temp_unsub_entered_date;
|
|
stop_date_list := stop_date_list, temp_unsub_stop_date;
|
|
is_conditional_list := is_conditional_list,temp_unsub_is_conditional;
|
|
is_suspended_list := is_suspended_list,temp_unsub_is_suspended;
|
|
order_status_code_list := order_status_code_list,temp_unsub_order_status_code;
|
|
order_status_level_list := order_status_level_list,temp_unsub_order_status_level;
|
|
order_type_code_list := order_type_code_list,temp_unsub_order_type_code;
|
|
alternate_order_type_list := alternate_order_type_list, temp_unsub_alternate_order_type;
|
|
is_script_list := is_script_list, temp_unsub_is_script;
|
|
|
|
// Add extra information to the order summary and avoid printing NULL
|
|
if exist temp_unsub_summary
|
|
then
|
|
summary_list := summary_list, "(IV-additive in " || temp_unsub_order_name || ": " ||temp_unsub_summary || ")";
|
|
else
|
|
summary_list := summary_list, "(IV-additive in " || temp_unsub_order_name || ")";
|
|
endif;
|
|
enddo;
|
|
endif;
|
|
endif;
|
|
enddo;
|
|
endif;
|
|
|
|
/*----------------------------------------*/
|
|
/* Count the Number of UNSUBMITTED Orders */
|
|
/*----------------------------------------*/
|
|
// After the Unsubmitted Orders are placed on the order_name_list,
|
|
// the count of items in this list can be used to generate the Unsubmitted Orders list
|
|
// called aoa_action_item_status_list, later in this MLM.
|
|
|
|
if exist order_name_list
|
|
then num_unsubmitted_orders := count order_name_list;
|
|
else num_unsubmitted_orders := 0;
|
|
endif;
|
|
|
|
/*-------------------------*/
|
|
/* Process DATABASE Orders */
|
|
/*-------------------------*/
|
|
If exist db_master_guid_list
|
|
then
|
|
// Replace some of the main-order information with the IV-additive information
|
|
temp_db_index_list:= 1 SEQTO count(db_order_guid_list);
|
|
for KK in temp_db_index_list do
|
|
|
|
// Get one piece of information from each list
|
|
temp_db_order_name:= last(first KK from db_order_name_list);
|
|
|
|
temp_db_order_guid:= last(first KK from db_order_guid_list);
|
|
temp_db_significant_date:= last(first KK from db_significant_date_list);
|
|
temp_db_requested_date := last(first KK from db_requested_date_list);
|
|
temp_db_entered_date := last(first KK from db_entered_date_list);
|
|
temp_db_stop_date:= last(first KK from db_stop_date_list);
|
|
temp_db_is_conditional:= last(first KK from db_is_conditional_list);
|
|
temp_db_is_suspended:= last(first KK from db_is_suspended_list);
|
|
temp_db_order_status_code:= last(first KK from db_order_status_code_list);
|
|
temp_db_order_status_level:= last(first KK from db_order_status_level_list);
|
|
temp_db_order_type_code:= last(first KK from db_order_type_code_list);
|
|
temp_db_alternate_order_type := last(first KK from db_alternate_order_type_list);
|
|
|
|
temp_db_order_summary:= last(first KK from db_summary_list);
|
|
temp_db_master_guid:= last(first KK from db_master_GUID_list);
|
|
temp_db_additive_name:= last(first KK from db_additive_list);
|
|
temp_db_additive_master_guid:= last(first KK from db_additive_master_GUID_list);
|
|
|
|
temp_db_is_script := db_order_is_script_list[KK];
|
|
|
|
/* If the order has an IV-additive, then replace the main-order information */
|
|
/* with the IV-additive info */
|
|
if temp_db_additive_name is present
|
|
then
|
|
if temp_db_order_guid is in order_guid_list
|
|
then
|
|
/* The main-order has already been added to the lists, so */
|
|
/* Replace the main-order info with the additive information */
|
|
/* Add extra information to the order summary and avoid printing NULL */
|
|
|
|
if exist temp_db_order_summary
|
|
then temp_db_order_summary:=
|
|
" (IV-additive in " || temp_db_order_name
|
|
|| ": " ||temp_db_order_summary || ")";
|
|
else temp_db_order_summary:=
|
|
" (IV-additive in " || temp_db_order_name || ")";
|
|
endif; /* if exist temp_db_order_summary */
|
|
|
|
temp_db_order_name:= temp_db_additive_name;
|
|
temp_db_master_GUID:= temp_db_additive_master_guid;
|
|
else
|
|
/* Put the main-order and the additive information onto the lists */
|
|
/* Add extra information to the order summary and avoid printing NULL */
|
|
|
|
if exist temp_db_order_summary
|
|
then temp_db_order_summary:= temp_db_order_summary,
|
|
" (IV-additive in " || temp_db_order_name
|
|
|| ": " ||temp_db_order_summary || ")";
|
|
else temp_db_order_summary:= temp_db_order_summary,
|
|
" (IV-additive in " || temp_db_order_name || ")";
|
|
endif;
|
|
|
|
temp_db_order_name:= temp_db_order_name, temp_db_additive_name;
|
|
temp_db_order_guid:= temp_db_order_guid, temp_db_order_guid;
|
|
temp_db_significant_date := temp_db_significant_date, temp_db_significant_date;
|
|
temp_db_requested_date := temp_db_requested_date, temp_db_requested_date;
|
|
temp_db_entered_date := temp_db_entered_date, temp_db_entered_date;
|
|
temp_db_stop_date:= temp_db_stop_date, temp_db_stop_date;
|
|
temp_db_is_conditional:= temp_db_is_conditional, temp_db_is_conditional;
|
|
temp_db_is_suspended:= temp_db_is_suspended, temp_db_is_suspended;
|
|
temp_db_order_status_code:=
|
|
temp_db_order_status_code, temp_db_order_status_code;
|
|
temp_db_order_status_level:=
|
|
temp_db_order_status_level, temp_db_order_status_level;
|
|
temp_db_order_type_code:=
|
|
temp_db_order_type_code, temp_db_order_type_code;
|
|
temp_db_alternate_order_type := temp_db_alternate_order_type, temp_db_alternate_order_type;
|
|
temp_db_is_script := temp_db_is_script, temp_db_is_script;
|
|
temp_db_master_GUID:= temp_db_master_GUID, temp_db_additive_master_guid;
|
|
endif; /* if temp_db_order_guid is in... */
|
|
endif; /* if temp_db_additive_name... */
|
|
|
|
/* Add the orders retrieved from the database onto the lists for processing */
|
|
order_name_list:= order_name_list, temp_db_order_name;
|
|
order_guid_list:= order_guid_list, temp_db_order_guid;
|
|
significant_date_list := significant_date_list, temp_db_significant_date;
|
|
requested_date_list := requested_date_list, temp_db_requested_date;
|
|
entered_date_list := entered_date_list, temp_db_entered_date;
|
|
stop_date_list:= stop_date_list, temp_db_stop_date;
|
|
is_conditional_list:= is_conditional_list, temp_db_is_conditional;
|
|
is_suspended_list:= is_suspended_list, temp_db_is_suspended;
|
|
order_status_code_list:= order_status_code_list, temp_db_order_status_code;
|
|
order_status_level_list:= order_status_level_list, temp_db_order_status_level;
|
|
order_type_code_list:= order_type_code_list, temp_db_order_type_code;
|
|
alternate_order_type_list := alternate_order_type_list, temp_db_alternate_order_type;
|
|
is_script_list := is_script_list, temp_db_is_script;
|
|
summary_list:= summary_list, temp_db_order_summary;
|
|
master_GUID_list:= master_GUID_list, temp_db_master_GUID;
|
|
|
|
enddo; /* for KK */
|
|
endif; /* if (exist db_master_guid_list)or... */
|
|
|
|
/*--------------------------*/
|
|
/* Process COMMUNITY Orders */
|
|
/*--------------------------*/
|
|
If exist comm_master_GUID_list
|
|
then
|
|
temp_comm_index_list := 1 SEQTO count(comm_master_GUID_list);
|
|
for LL in temp_comm_index_list do
|
|
|
|
// Get one piece of information from each list
|
|
temp_comm_order_name := last(first LL from comm_order_name_list);
|
|
temp_comm_order_guid := last(first LL from comm_order_guid_list);
|
|
temp_comm_significant_date := last(first LL from comm_significant_date_list);
|
|
temp_comm_requested_date := last(first LL from comm_requested_date_list);
|
|
temp_comm_order_status_code := last(first LL from comm_order_status_code_list);
|
|
temp_comm_order_status_level := last(first LL from comm_order_status_level_list);
|
|
temp_comm_order_type_code := last(first LL from comm_order_type_code_list);
|
|
temp_comm_master_guid := last(first LL from comm_master_GUID_list);
|
|
|
|
// Add the orders retrieved from the database onto the lists for processing
|
|
order_name_list := order_name_list, temp_comm_order_name;
|
|
order_guid_list := order_guid_list, temp_comm_order_guid;
|
|
significant_date_list := significant_date_list, temp_comm_significant_date;
|
|
requested_date_list := requested_date_list, temp_comm_requested_date;
|
|
entered_date_list := entered_date_list, null;
|
|
stop_date_list := stop_date_list, null;
|
|
is_conditional_list := is_conditional_list, false;
|
|
is_suspended_list := is_suspended_list, false;
|
|
order_status_code_list := order_status_code_list, temp_comm_order_status_code;
|
|
order_status_level_list := order_status_level_list, temp_comm_order_status_level;
|
|
order_type_code_list := order_type_code_list, temp_comm_order_type_code;
|
|
alternate_order_type_list := alternate_order_type_list, 3;
|
|
is_script_list := is_script_list, false;
|
|
summary_list := summary_list, "";
|
|
master_GUID_list := master_GUID_list, temp_comm_master_guid;
|
|
|
|
enddo;
|
|
endif;
|
|
|
|
/*----------------------------*/
|
|
/* DATA FOR ACTIONS ON ALERTS */
|
|
/*----------------------------*/
|
|
// The following sections are used to collect and process data for
|
|
// Actions on Alerts.
|
|
|
|
/*--------------------------------------------------------*/
|
|
/* Set the Status for the UNSUBMITTED and EXISTING Orders */
|
|
/* for Use With Actions on Alerts */
|
|
/*--------------------------------------------------------*/
|
|
// After the Unsubmitted Orders are placed on the order_name_list,
|
|
// the count of items in this list can be used to generate the Unsubmitted Orders list
|
|
// called aoa_action_item_status_list.
|
|
|
|
// Add the Unsubmitted Statuses
|
|
if exist order_name_list
|
|
then
|
|
for UU in (1 SEQTO num_unsubmitted_orders ) do
|
|
aoa_action_item_status_list := aoa_action_item_status_list, "Unsubmitted";
|
|
enddo; // for UU
|
|
endif; //if exist order_name_list
|
|
|
|
|
|
// Add the Existing Statuses
|
|
if exist db_order_name_list
|
|
then
|
|
num_existing_orders := (count order_name_list) - num_unsubmitted_orders ;
|
|
for EE in (1 SEQTO num_existing_orders) do
|
|
aoa_action_item_status_list := aoa_action_item_status_list, "Existing";
|
|
enddo; // for EE
|
|
endif; //if exist db_order_name_list
|
|
|
|
|
|
/*----------------------------------------------------*/
|
|
/* Create A List of the Original Order Names */
|
|
/* For Use With Actions on Alerts */
|
|
/*----------------------------------------------------*/
|
|
// The order_name_list contains the names of the regular orders
|
|
// and their IV-Additives. It cannot be used for Actions on Alerts
|
|
// because the actions require the MAIN order, not its additive.
|
|
// The list will need to be a parallel list of the Order_GUID_List.
|
|
|
|
// Initialize a variable to collect the original order names
|
|
aoa_order_name_list := ();
|
|
|
|
// Create lists of the original order names and their GUIDs
|
|
// that have NOT had the IV-Additive Names substituted.
|
|
aoa_temp_order_name_list := unsub_order_name_list, db_order_name_list;
|
|
aoa_temp_order_guid_list := unsub_order_guid_list, db_order_guid_list;
|
|
|
|
|
|
// Create a list of Order Names that is the same length as the order_guid_list
|
|
for FF in (1 SEQTO (count order_guid_list)) do
|
|
temp_aoa_guid := last(first FF from order_guid_list);
|
|
found_aoa_matching_guid := aoa_temp_order_guid_list is in temp_aoa_guid;
|
|
matching_aoa_name_list := aoa_temp_order_name_list where found_aoa_matching_guid;
|
|
aoa_order_name_list := aoa_order_name_list, (first matching_aoa_name_list);
|
|
enddo; // for FF
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
/* Create A List of the Original CV3OrderCatalogMasterItemGUIDs */
|
|
/* For Use With Actions on Alerts */
|
|
/*-----------------------------------------------------------------------*/
|
|
// The Master_GUID_List contains the Catalog GUIDs of the regular orders
|
|
// and their IV-Additives. It cannot be used for Actions on Alerts
|
|
// because the actions require the GUIDs of the MAIN order, not its additive.
|
|
// The list will need to be a parallel list of the Master_GUID_List.
|
|
|
|
|
|
// Initialize a variable to collect the original catalog GUIDs
|
|
aoa_master_guid_list := ();
|
|
|
|
// Create lists of the original CV3OrderCatalogMasterItemGUIDs and
|
|
// their CV3OrderGUIDs that have NOT had the IV-Additive GUIDs substituted.
|
|
aoa_temp_master_guid_list := unsub_master_guid_list, db_master_guid_list;
|
|
aoa_temp_order_guid_list := unsub_order_guid_list, db_order_guid_list;
|
|
|
|
|
|
// Create a list of CV3OrderCatalogMasterItemGUIDs that is
|
|
// the same length as the order_guid_list
|
|
for GG in (1 SEQTO (count order_guid_list)) do
|
|
temp_aoa_order_guid := last(first GG from order_guid_list);
|
|
found_aoa_matching_guid := aoa_temp_order_guid_list is in temp_aoa_order_guid;
|
|
matching_aoa_master_guid_list := aoa_temp_master_guid_list where found_aoa_matching_guid;
|
|
aoa_master_guid_list := aoa_master_guid_list, (first matching_aoa_master_guid_list);
|
|
enddo; // for GG
|
|
|
|
/*--------------------------------------------------------*/
|
|
/* Conclude True to Return Information to the Calling MLM */
|
|
/*--------------------------------------------------------*/
|
|
conclude true;
|
|
;;
|
|
action:
|
|
|
|
Return ( order_name_list,
|
|
order_guid_list,
|
|
significant_date_list,
|
|
requested_date_list,
|
|
entered_date_list,
|
|
stop_date_list,
|
|
is_conditional_list,
|
|
is_suspended_list,
|
|
order_status_code_list,
|
|
order_status_level_list,
|
|
order_type_code_list,
|
|
alternate_order_type_list,
|
|
is_script_list,
|
|
summary_list,
|
|
master_GUID_list,
|
|
aoa_action_item_status_list,
|
|
aoa_order_name_list,
|
|
aoa_master_guid_list
|
|
);
|
|
;;
|
|
end:
|