Initial Checking with all 820 MLMs
This commit is contained in:
752
MLMStripper/bin/Debug/STD/STD_FUNC_RETRIEVE_MEDICATIONS.mlm
Normal file
752
MLMStripper/bin/Debug/STD/STD_FUNC_RETRIEVE_MEDICATIONS.mlm
Normal file
@@ -0,0 +1,752 @@
|
||||
maintenance:
|
||||
|
||||
title: Active medications retrieved with class type and value matching result;;
|
||||
mlmname: STD_FUNC_RETRIEVE_MEDICATIONS;;
|
||||
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 a list of medications to return to the calling MLM.
|
||||
;;
|
||||
explanation: This MLM processes information received to return matching medications
|
||||
from the database or the current result returned via HL7.
|
||||
The retrieval is performed based on a SQL query or a pointer to the object.
|
||||
If a pointer is sent in from the calling MLM, an object query for the
|
||||
current order is performed.
|
||||
|
||||
If a pointer is not sent, then a SQL query is performed based on the chart
|
||||
guid, visit guid, and a list of medications or a list of class types and
|
||||
values. All active orders that match are returned.
|
||||
|
||||
If a pointer is sent, the order pointed to is compared to a list of medications
|
||||
or class types and values. If the order matches the information is returned.
|
||||
|
||||
This information is received from the calling MLM in the following parameters:
|
||||
- a STRING indicating SQL query
|
||||
OR
|
||||
- pointer to Evoking Object
|
||||
|
||||
AND
|
||||
- a list of medications to match
|
||||
OR
|
||||
- a list of class types and values to match
|
||||
|
||||
AND
|
||||
- a client guid
|
||||
AND
|
||||
- a chart guid to match
|
||||
OR
|
||||
- a visit guid to match
|
||||
|
||||
|
||||
This MLM returns lists of medication order information that contain:
|
||||
- an indicator for whether this is an order or component,
|
||||
- the chart guid of the order,
|
||||
- the client guid of the order,
|
||||
- the visit guid of the order,
|
||||
- the high dosage for the order,
|
||||
- the low dosage for the order,
|
||||
- the date and time the order was entered,
|
||||
- the form of the medication, ie, {{{SINGLE-QUOTE}}}Tablet{{{SINGLE-QUOTE}}}
|
||||
- the frequency for the order,
|
||||
- the order guid,
|
||||
- a flag for whether the order is conditional,
|
||||
- a flag for whether the order is held,
|
||||
- a flag for whether the order is prn,
|
||||
- a flag for whether the order is suspended,
|
||||
- the order name,
|
||||
- the order catalog master item guid,
|
||||
- the order priority,
|
||||
- the order route,
|
||||
- the order status code,
|
||||
- the order status description as defined by the site,
|
||||
- the order status level number,
|
||||
- the requested date and time of the order,
|
||||
- the significant date and time(requested, scheduled, or performed,
|
||||
- the stop date and time of the order,
|
||||
- the order summary line as defined by the site,
|
||||
- the associated system order priority,
|
||||
- the unit of measure for the order,
|
||||
- a flag indicating whether this order is a match;
|
||||
|
||||
;;
|
||||
keywords:
|
||||
;;
|
||||
knowledge:
|
||||
type: data-driven;;
|
||||
data:
|
||||
|
||||
(med_info, // STRING indicating SQL query or pointer to Evoking Object
|
||||
|
||||
medications_list, // Only return information on medications in this list
|
||||
// If Null, returns all active medications for scope/class
|
||||
|
||||
class_type, // Class type list used to validate against via SQL query
|
||||
// If Null, returns all active medications for scope/med list)
|
||||
|
||||
class_value, // Class value used to validate against via SQL query
|
||||
// If Null returns all active medications for scope/med list)
|
||||
|
||||
client_guid, // Chart Guid used to filter db query
|
||||
|
||||
chart_guid, // Chart Guid used to filter db query if medication_scope = Chart
|
||||
|
||||
client_visit_guid, // Visit Guid used to filter db query if medication_scope = Visit
|
||||
|
||||
medication_scope) // Indicator to check all visits, this visit, or this chart.
|
||||
:= ARGUMENT;
|
||||
|
||||
// Set to true if logging is needed.
|
||||
log_execution_info := false;
|
||||
|
||||
/* Set this flag to true to include historical session type orders
|
||||
when checking the current order */
|
||||
include_historical_session_type_orders := FALSE;
|
||||
|
||||
/* Set this flag to false to exclude discharge session type orders
|
||||
when checking the current order */
|
||||
include_discharge_session_type_orders := TRUE;
|
||||
|
||||
/* Set this flag to false to exclude standard session type orders
|
||||
when checking the current order */
|
||||
include_in_house_session_type_orders := TRUE;
|
||||
|
||||
/* Set this flag to false to exclude outpatient rx type orders
|
||||
when checking the current order */
|
||||
include_outpatient_rx_session_type_orders := TRUE;
|
||||
|
||||
/* Set this flag to false to exclude outpatient hx type orders
|
||||
when checking the current order */
|
||||
include_outpatient_hx_session_type_orders := FALSE;
|
||||
|
||||
/* Declare MLMs that can be called */
|
||||
func_session_type_filter := MLM {{{SINGLE-QUOTE}}}STD_FUNC_SESSION_TYPE_FILTER{{{SINGLE-QUOTE}}};
|
||||
|
||||
if med_info is string then
|
||||
|
||||
// Set scope for SQL search
|
||||
if medication_scope = "All" then
|
||||
scope_info := " WHERE O.ClientGUID = " || SQL(client_guid);
|
||||
|
||||
elseif medication_scope = "Chart" then
|
||||
scope_info := " WHERE O.ClientGUID = " || SQL(client_guid) ||
|
||||
" AND O.ChartGUID = " || SQL(chart_guid);
|
||||
else
|
||||
scope_info := " WHERE O.ClientGUID = " || SQL(client_guid) ||
|
||||
" AND O.ChartGUID = " || SQL(chart_guid) ||
|
||||
" AND O.ClientVisitGUID = " || SQL(client_visit_guid);
|
||||
endif; // Set scope for SQL search
|
||||
|
||||
if exist medications_list
|
||||
then
|
||||
// Set the med list into a string so it can be used in the
|
||||
// "Where" statement below to return current ORDERS
|
||||
sql_medications_list_string := "";
|
||||
counter:= 0;
|
||||
for temp_med in medications_list do
|
||||
counter:= counter + 1;
|
||||
If counter = 1
|
||||
then
|
||||
sql_medications_list_string := "(" || SQL(temp_med) || ")";
|
||||
else
|
||||
sql_medications_list_string := sql_medications_list_string || ", (" || SQL(temp_med) || ")";
|
||||
endif;
|
||||
enddo;
|
||||
|
||||
order_med_list_filter:= " AND Exists (select 1 from @Tmp T where CV3OrderComponent.Name = T.Name OR CV3Order.Name = T.Name) ";
|
||||
|
||||
component_med_list_filter:= " AND Exists (select 1 from @Tmp T where CV3OrderComponent.Name = T.Name) ";
|
||||
|
||||
elseif exist class_type and exist class_value
|
||||
then
|
||||
if exist class_value then
|
||||
|
||||
// Set the med list into a string so it can be used in the
|
||||
// "Where" statement below to return current ORDERS
|
||||
|
||||
sql_class_value_string := "";
|
||||
counter := 0;
|
||||
for temp_value in class_value do
|
||||
counter := counter + 1;
|
||||
If counter = 1
|
||||
then
|
||||
sql_class_value_string := SQL(temp_value);
|
||||
else
|
||||
sql_class_value_string := sql_class_value_string || ", " || SQL(temp_value);
|
||||
endif;
|
||||
enddo;
|
||||
|
||||
// Set up the SQL query for the order items and their components
|
||||
// that match the classes and values
|
||||
order_med_list_filter:= " AND CV3CatalogClassTypeValue.Value IN ("
|
||||
|| sql_class_value_string || " )"
|
||||
|| " AND CV3CatalogClassTypeValue.ClassTypeGUID = "
|
||||
|| "(SELECT guid from CV3ClassType where Code ="
|
||||
|| SQL(class_type)||")";
|
||||
|
||||
component_med_list_filter:= " AND CV3CatalogClassTypeValue.Value IN ("
|
||||
|| sql_class_value_string || " )"
|
||||
|| " AND CV3CatalogClassTypeValue.ClassTypeGUID = "
|
||||
|| "(SELECT guid from CV3ClassType where Code = "
|
||||
|| SQL(class_type)||")" ;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if (sql_medications_list_string is null) OR (sql_medications_list_string = "") then
|
||||
sql_insert_values_string := " ";
|
||||
else
|
||||
sql_insert_values_string := " INSERT INTO @Tmp VALUES " || sql_medications_list_string;
|
||||
endif;
|
||||
|
||||
sql_query1 := "DECLARE @Tmp TABLE (Name varchar(200) primary key) "
|
||||
|| sql_insert_values_string
|
||||
|| " SELECT an_order_or_component = {{{SINGLE-QUOTE}}}order{{{SINGLE-QUOTE}}}, O.ChartGUID, "
|
||||
|| " O.ClientGUID, O.ClientVisitGUID, "
|
||||
|| " CombinedDoseHigh = DosageHigh, CombinedDose = DosageLow, Entered, "
|
||||
|| " CombinedForm = FormCode, FrequencyCode, O.GUID, IsConditional, "
|
||||
|| " IsHeld, IsPRN, IsSuspended, CombinedName = O.Name, "
|
||||
|| " CombinedOCMItemGUID = O.OrderCatalogMasterItemGUID, "
|
||||
|| " OrderPriorityCode, CombinedRoute = OrderRouteCode, "
|
||||
|| " OrderStatusCode, CV3OrderStatus.Description, OrderStatusLevelNum, "
|
||||
|| " RequestedDtm, SignificantDtm, StopDtm, CombinedSummary = SummaryLine,"
|
||||
|| " SystemOrderPriorityCode, CombinedUOM = CV3MedicationExtension.UOM "
|
||||
|| " FROM CV3AllOrdersVw as O " || " JOIN CV3MedicationExtension "
|
||||
|| " ON O.GUID = CV3MedicationExtension.GUID "
|
||||
|| " LEFT OUTER JOIN CV3OrderComponent "
|
||||
|| " ON (O.ClientGUID = CV3OrderComponent.ClientGUID "
|
||||
|| " AND O.GUID = CV3OrderComponent.OrderGUID) "
|
||||
|| " LEFT OUTER JOIN CV3OrderAddnlInfo AS OAI "
|
||||
|| " ON ( O.ClientGUID = OAI.ClientGUID AND O.GUID = OAI.GUID ) "
|
||||
|| " JOIN CV3CatalogClassTypeValue "
|
||||
|| " ON (O.OrderCatalogMasterItemGUID = CV3CatalogClassTypeValue.CatalogMasterGUID "
|
||||
|| " OR CV3OrderComponent.OrderCatalogMasterItemGUID = CV3CatalogClassTypeValue.CatalogMasterGUID) "
|
||||
|| " JOIN CV3OrderStatus "
|
||||
|| " ON O.OrderStatusCode = CV3OrderStatus.Code"
|
||||
|| scope_info
|
||||
|| " AND O.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} "
|
||||
|| " AND OrderStatusLevelNum <= 50 "
|
||||
|| order_med_list_filter;
|
||||
|
||||
sql_query2 := " UNION "
|
||||
|| " SELECT an_order_or_component = {{{SINGLE-QUOTE}}}component{{{SINGLE-QUOTE}}}, O.ChartGUID, "
|
||||
|| " O.ClientGUID, O.ClientVisitGUID, "
|
||||
|| " CombinedDoseHigh = NULL, CombinedDose = CV3OrderComponent.Dosage,"
|
||||
|| " Entered, CombinedForm = NULL, FrequencyCode, O.GUID, "
|
||||
|| " IsConditional, IsHeld, IsPRN, IsSuspended, "
|
||||
|| " CombinedName = CV3OrderComponent.Name,"
|
||||
|| " CombinedOCMItemGUID = CV3OrderComponent.OrderCatalogMasterItemGUID, "
|
||||
|| " OrderPriorityCode, CombinedRoute = NULL, OrderStatusCode, "
|
||||
|| " CV3OrderStatus.Description, OrderStatusLevelNum, RequestedDtm, "
|
||||
|| " SignificantDtm, StopDtm = NULL, CombinedSummary = NULL,"
|
||||
|| " SystemOrderPriorityCode, CombinedUOM = CV3OrderComponent.UOM "
|
||||
|| " FROM CV3AllOrdersVw as O " || " JOIN CV3OrderComponent "
|
||||
|| " ON (O.ClientGUID = CV3OrderComponent.ClientGUID "
|
||||
|| " AND O.GUID = CV3OrderComponent.OrderGUID ) "
|
||||
|| " LEFT OUTER JOIN CV3OrderAddnlInfo AS OAI "
|
||||
|| " ON ( O.ClientGUID = OAI.ClientGUID AND O.GUID = OAI.GUID ) "
|
||||
|| " JOIN CV3CatalogClassTypeValue "
|
||||
|| " ON CV3OrderComponent.OrderCatalogMasterItemGUID = CV3CatalogClassTypeValue.CatalogMasterGUID "
|
||||
|| " JOIN CV3OrderStatus "
|
||||
|| " ON O.OrderStatusCode = CV3OrderStatus.Code "
|
||||
|| scope_info
|
||||
|| " AND O.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} "
|
||||
|| " AND OrderStatusLevelNum <= 50 "
|
||||
|| " AND (CV3OrderComponent.Type = 0 "
|
||||
|| " OR CV3OrderComponent.Type = 3) "
|
||||
|| component_med_list_filter;
|
||||
|
||||
if (not include_in_house_session_type_orders)
|
||||
then
|
||||
sql_query1 := sql_query1 || " AND (O.AlternateOrderType <> 0 OR O.IsForDischarge = 1) ";
|
||||
sql_query2 := sql_query2 || " AND (O.AlternateOrderType <> 0 OR O.IsForDischarge = 1) ";
|
||||
endif;
|
||||
|
||||
if (not include_historical_session_type_orders)
|
||||
then
|
||||
sql_query1 := sql_query1 || " AND O.AlternateOrderType <> 1 ";
|
||||
sql_query2 := sql_query2 || " AND O.AlternateOrderType <> 1 ";
|
||||
endif;
|
||||
|
||||
if (not include_discharge_session_type_orders)
|
||||
then
|
||||
sql_query1 := sql_query1 || " AND O.IsForDischarge = 0 ";
|
||||
sql_query2 := sql_query2 || " AND O.IsForDischarge = 0 ";
|
||||
endif;
|
||||
|
||||
if (not include_outpatient_rx_session_type_orders)
|
||||
then
|
||||
sql_query1 := sql_query1 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 1) ";
|
||||
sql_query2 := sql_query2 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 1) ";
|
||||
endif;
|
||||
|
||||
if (not include_outpatient_hx_session_type_orders)
|
||||
then
|
||||
sql_query1 := sql_query1 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 0) ";
|
||||
sql_query2 := sql_query2 || " AND NOT(O.AlternateOrderType = 2 AND OAI.IsScript = 0) ";
|
||||
endif;
|
||||
|
||||
// Get medication orders(including additives) from DB using SQL query
|
||||
(an_order_or_component,
|
||||
chart_guid,
|
||||
client_guid,
|
||||
client_visit_guid,
|
||||
dosage_high,
|
||||
dosage_low,
|
||||
entereddtm,
|
||||
form_code,
|
||||
frequency_code,
|
||||
guid,
|
||||
is_conditional,
|
||||
is_held,
|
||||
is_prn,
|
||||
is_suspend,
|
||||
name,
|
||||
order_catalog_master_item_guid,
|
||||
order_priority_code,
|
||||
order_route_code,
|
||||
order_status_code,
|
||||
order_status_desc,
|
||||
order_status_level_num,
|
||||
request_dtm,
|
||||
significant_dtm,
|
||||
stop_dtm,
|
||||
summary_line,
|
||||
system_order_priority_code,
|
||||
uom) := read { " " || sql_query1 || sql_query2 || " order by SignificantDtm, O.GUID, an_order_or_component desc, CombinedName" };
|
||||
//,PrimaryTime = SignificantDtm };
|
||||
//end - Get medication orders(including additives) from DB using SQL query
|
||||
|
||||
// Initialize variables
|
||||
match_med_found := ();
|
||||
item_class_value := ();
|
||||
|
||||
// For each item indicate whether the item or component is the match.
|
||||
|
||||
// Mark matches found for medication lists
|
||||
if exist medications_list then
|
||||
list_index := 1 seqto (count name);
|
||||
for A in list_index do
|
||||
temp_name := last(first A from name);
|
||||
if temp_name is in (medications_list) then
|
||||
match_med_found := match_med_found, TRUE;
|
||||
else
|
||||
match_med_found := match_med_found, FALSE;
|
||||
endif;
|
||||
enddo;
|
||||
|
||||
// Mark matches found for class types
|
||||
elseif exists class_type then
|
||||
list_index := 1 seqto (count name);
|
||||
for A in list_index do
|
||||
|
||||
// Get the Master GUID for this component item
|
||||
temp_ocmi_guid := last(first A from order_catalog_master_item_guid);
|
||||
temp_name := last(first A from name);
|
||||
|
||||
// Get the real class type and value for each item returned on lists
|
||||
(the_name,
|
||||
the_type,
|
||||
the_value)
|
||||
:= read
|
||||
{" SELECT Name, Code, Value "
|
||||
|| " FROM CV3OrderCatalogMasterItem LEFT OUTER JOIN CV3CatalogClassTypeValue "
|
||||
|| " ON CV3OrderCatalogMasterItem.GUID = CV3CatalogClassTypeValue.CatalogMasterGUID "
|
||||
|| " JOIN CV3ClassType "
|
||||
|| " ON CV3ClassType.GUID = CV3CatalogClassTypeValue.ClassTypeGUID "
|
||||
|| " WHERE CV3OrderCatalogMasterItem.GUID = "
|
||||
|| SQL(temp_ocmi_guid )
|
||||
|| " AND CV3ClassType.Code = "
|
||||
|| SQL(class_type)};
|
||||
|
||||
if last(the_value) is in class_value
|
||||
then
|
||||
// Mark the match as found and add value to list
|
||||
match_med_found := match_med_found, TRUE;
|
||||
item_class_value := item_class_value, the_value;
|
||||
else
|
||||
// Mark the match as not found and set value to NULL
|
||||
match_med_found := match_med_found, FALSE;
|
||||
item_class_value := item_class_value, NULL;
|
||||
endif;
|
||||
enddo;
|
||||
endif;
|
||||
|
||||
elseif exist med_info
|
||||
then
|
||||
//Get medication orders from object if the item name
|
||||
// or the component name(additive) is in med filter list
|
||||
|
||||
//Initialize variables
|
||||
chart_guid := ();
|
||||
client_guid :=();
|
||||
client_visit_guid := ();
|
||||
dosage_high := ();
|
||||
dosage_low := ();
|
||||
entereddtm := ();
|
||||
form_code := ();
|
||||
frequency_code := ();
|
||||
guid := ();
|
||||
is_conditional := ();
|
||||
is_held := ();
|
||||
is_prn := ();
|
||||
is_suspend := ();
|
||||
name := ();
|
||||
order_catalog_master_item_guid := ();
|
||||
order_component := ();
|
||||
order_route_code := ();
|
||||
order_status_code := ();
|
||||
order_status_desc := ();
|
||||
order_status_level_num := ();
|
||||
significant_dtm := ();
|
||||
stop_dtm := ();
|
||||
summary_line := ();
|
||||
uom := ();
|
||||
match_med_found := ();
|
||||
item_class_value := ();
|
||||
|
||||
|
||||
// Get main order data from Evoking Object
|
||||
(temp_chart_guid,
|
||||
temp_client_guid,
|
||||
temp_client_visit_guid,
|
||||
temp_dosage_high,
|
||||
temp_dosage_low,
|
||||
temp_entereddtm,
|
||||
temp_form_code,
|
||||
temp_frequency_code,
|
||||
temp_guid,
|
||||
temp_is_conditional,
|
||||
temp_is_held,
|
||||
temp_is_prn,
|
||||
temp_is_suspended,
|
||||
temp_order_name,
|
||||
temp_order_catalog_master_item_guid,
|
||||
temp_order_priority_code,
|
||||
temp_order_component,
|
||||
temp_order_route_code,
|
||||
temp_order_status_code,
|
||||
temp_order_status_level_num,
|
||||
temp_request_dtm,
|
||||
temp_significant_dtm,
|
||||
temp_stop_dtm,
|
||||
temp_summary_line,
|
||||
temp_order_sys_priority,
|
||||
temp_uom ) := read last
|
||||
{Order: ChartGUID, ClientGUID, ClientVisitGUID,
|
||||
DosageHigh, DosageLow, Entered, FormCode, FrequencyCode, GUID,
|
||||
IsConditional, IsHeld, IsPRN, IsSuspended,
|
||||
Name, OrderCatalogMasterItemGUID, OrderPriorityCode, OrderComponent,
|
||||
OrderRouteCode, OrderStatusCode, OrderStatusLevelNum, RequestedDtm,
|
||||
SignificantDtm, StopDtm, SummaryLine, SystemOrderPriorityCode, UOM
|
||||
REFERENCING med_info };
|
||||
|
||||
// put the order definitions found into their place in the lists
|
||||
an_order_or_component := "order";
|
||||
chart_guid := temp_chart_guid;
|
||||
client_guid := temp_client_guid;
|
||||
client_visit_guid := temp_client_visit_guid;
|
||||
dosage_high := temp_dosage_high;
|
||||
dosage_low := temp_dosage_low;
|
||||
entereddtm := temp_entereddtm;
|
||||
form_code := temp_form_code;
|
||||
frequency_code := temp_frequency_code;
|
||||
guid := temp_guid;
|
||||
is_conditional := temp_is_conditional;
|
||||
is_held := temp_is_held;
|
||||
is_prn := temp_is_prn;
|
||||
is_suspend := temp_is_suspended;
|
||||
name := temp_order_name;
|
||||
order_catalog_master_item_guid := temp_order_catalog_master_item_guid;
|
||||
order_priority_code := temp_order_priority_code;
|
||||
order_route_code := temp_order_route_code;
|
||||
order_status_code := temp_order_status_code;
|
||||
order_status_desc := read
|
||||
{"SELECT Description FROM CV3OrderStatus "
|
||||
||"WHERE Code = "||SQL(temp_order_status_code)};
|
||||
order_status_level_num := temp_order_status_level_num;
|
||||
request_dtm := temp_request_dtm;
|
||||
significant_dtm := temp_significant_dtm;
|
||||
stop_dtm := temp_stop_dtm;
|
||||
summary_line := temp_summary_line;
|
||||
system_order_priority_code := temp_order_sys_priority;
|
||||
uom := temp_uom;
|
||||
|
||||
// Check to see if medication list or class type is used
|
||||
If exists medications_list then
|
||||
// If order name in list, then set flag.
|
||||
if name is in medications_list
|
||||
then
|
||||
match_med_found := (TRUE);
|
||||
else
|
||||
match_med_found := (FALSE);
|
||||
endif;
|
||||
else
|
||||
if exists class_type then
|
||||
(the_type,
|
||||
the_value)
|
||||
:= read
|
||||
{" SELECT Code, Value "
|
||||
||" FROM CV3OrderCatalogMasterItem JOIN CV3CatalogClassTypeValue "
|
||||
||" ON CV3OrderCatalogMasterItem.GUID = CV3CatalogClassTypeValue.CatalogMasterGUID "
|
||||
||" JOIN CV3ClassType "
|
||||
||" ON CV3ClassType.GUID = CV3CatalogClassTypeValue.ClassTypeGUID "
|
||||
||" WHERE CV3OrderCatalogMasterItem.GUID = "
|
||||
||SQL(temp_order_catalog_master_item_guid)};
|
||||
|
||||
// If there is class assigned to the item, check to see if it is a match
|
||||
if exists the_type then
|
||||
class_index := 1 seqto (count the_type);
|
||||
for I in class_index do
|
||||
temp_med_class_type := last(first I from the_type);
|
||||
temp_med_class_value := last(first I from the_value);
|
||||
if temp_med_class_type = class_type then
|
||||
if (temp_med_class_value is in class_value)
|
||||
then
|
||||
match_med_found := (TRUE);
|
||||
item_class_value := (temp_med_class_value);
|
||||
else
|
||||
match_med_found := (FALSE);
|
||||
item_class_value := (NULL);
|
||||
endif;
|
||||
endif;
|
||||
// Mark as found if class and value match
|
||||
enddo;
|
||||
else
|
||||
// If there is no class assigned to the item, set match to FALSE
|
||||
match_med_found := (FALSE);
|
||||
endif;
|
||||
|
||||
else
|
||||
match_med_found := (FALSE);
|
||||
item_class_value := (NULL);
|
||||
endif;
|
||||
endif;
|
||||
|
||||
// Retrieve medication IV Additive data if OrderComponent objects exist
|
||||
if exist temp_order_component
|
||||
then
|
||||
// Get the additive names from order component object
|
||||
(iv_dosage_list,
|
||||
iv_dosage_to_list,
|
||||
iv_name_list,
|
||||
iv_order_catalog_master_item_guid_list,
|
||||
iv_uom_list,
|
||||
component_type) := read
|
||||
{OrderComponent: Dosage, DosageTo, Name,
|
||||
OrderCatalogMasterItemGUID, Uom, Type
|
||||
REFERENCING temp_order_component
|
||||
where (Dosage AS Number) > 0 };
|
||||
|
||||
|
||||
index_iv := 1 seqto (count iv_name_list);
|
||||
|
||||
// Get additive list for those that match medications list
|
||||
if exist medications_list then
|
||||
for A in index_iv do
|
||||
temp_iv_name := last(first A from iv_name_list);
|
||||
if temp_iv_name is in medications_list then
|
||||
// Synch the field lists of components to the order
|
||||
an_order_or_component := an_order_or_component,"component";
|
||||
chart_guid := chart_guid, temp_chart_guid;
|
||||
client_guid := client_guid, temp_client_guid;
|
||||
client_visit_guid := client_visit_guid, temp_client_visit_guid;
|
||||
dosage_high := dosage_high, last(first A from iv_dosage_to_list);
|
||||
dosage_low := dosage_low, last(first A from iv_dosage_list);
|
||||
entereddtm := entereddtm, NULL;
|
||||
form_code := form_code, NULL;
|
||||
frequency_code := frequency_code, NULL;
|
||||
guid := guid, temp_guid;
|
||||
is_conditional := is_conditional, NULL;
|
||||
is_held := is_held, NULL;
|
||||
is_prn := is_prn, temp_is_prn;
|
||||
is_suspend := is_suspend, NULL;
|
||||
name := name, temp_iv_name;
|
||||
order_catalog_master_item_guid := order_catalog_master_item_guid,
|
||||
last(first A from iv_order_catalog_master_item_guid_list);
|
||||
order_priority_code := order_priority_code, NULL;
|
||||
order_route_code := order_route_code, NULL;
|
||||
order_status_code := order_status_code, NULL;
|
||||
order_status_desc := order_status_desc, NULL;
|
||||
order_status_level_num := order_status_level_num, NULL;
|
||||
request_dtm := request_dtm, NULL;
|
||||
significant_dtm := significant_dtm, temp_significant_dtm;
|
||||
stop_dtm := stop_dtm, temp_stop_dtm;
|
||||
summary_line := summary_line, NULL;
|
||||
system_order_priority_code := system_order_priority_code, NULL;
|
||||
uom := uom, last(first A from iv_uom_list);
|
||||
|
||||
// If order name in list, then set flag.
|
||||
if name is in medications_list then
|
||||
match_med_found := match_med_found, TRUE;
|
||||
else
|
||||
match_med_found := match_med_found, FALSE;
|
||||
endif;
|
||||
endif; // If med in list
|
||||
enddo; // Get additive list for those that match medications list
|
||||
|
||||
elseif exists class_type then
|
||||
|
||||
// Get additive list for those that match class type and value
|
||||
for A in index_iv do
|
||||
// Get the Master GUID for this component item
|
||||
temp_ocmi_guid := last(first A from iv_order_catalog_master_item_guid_list);
|
||||
|
||||
// Get the class type and value for this components master item
|
||||
(the_name,
|
||||
the_type,
|
||||
the_value)
|
||||
:= read
|
||||
{" SELECT Name, Code, Value "
|
||||
||" FROM CV3OrderCatalogMasterItem JOIN CV3CatalogClassTypeValue "
|
||||
||" ON CV3OrderCatalogMasterItem.GUID = CV3CatalogClassTypeValue.CatalogMasterGUID "
|
||||
||" JOIN CV3ClassType "
|
||||
||" ON CV3ClassType.GUID = CV3CatalogClassTypeValue.ClassTypeGUID "
|
||||
||" WHERE CV3OrderCatalogMasterItem.GUID = "
|
||||
||SQL(temp_ocmi_guid)};
|
||||
|
||||
class_index := 1 seqto (count the_type);
|
||||
// Check each class type and value for each item.
|
||||
for I in class_index do
|
||||
temp_med_class_type := last(first I from the_type);
|
||||
temp_med_class_value := last(first I from the_value);
|
||||
|
||||
if temp_med_class_type = class_type then
|
||||
if temp_med_class_value is in class_value then
|
||||
|
||||
// Add and synch the field lists of components to the order
|
||||
match_med_found := match_med_found, TRUE;
|
||||
item_class_value := item_class_value, temp_med_class_value;
|
||||
an_order_or_component := an_order_or_component,"component";
|
||||
chart_guid := chart_guid, temp_chart_guid;
|
||||
client_guid := client_guid, temp_client_guid;
|
||||
client_visit_guid := client_visit_guid, temp_client_visit_guid;
|
||||
dosage_high := dosage_high, last(first A from iv_dosage_to_list);
|
||||
dosage_low := dosage_low, last(first A from iv_dosage_list);
|
||||
entereddtm := entereddtm, NULL;
|
||||
form_code := form_code, NULL;
|
||||
frequency_code := frequency_code, NULL;
|
||||
guid := guid, temp_guid;
|
||||
is_conditional := is_conditional, NULL;
|
||||
is_held := is_held, NULL;
|
||||
is_prn := is_prn, temp_is_prn;
|
||||
is_suspend := is_suspend, NULL;
|
||||
name := name, last(first A from iv_name_list);
|
||||
order_catalog_master_item_guid := order_catalog_master_item_guid,
|
||||
temp_ocmi_guid;
|
||||
order_priority_code := order_priority_code, NULL;
|
||||
order_route_code := order_route_code, NULL;
|
||||
order_status_code := order_status_code, NULL;
|
||||
order_status_desc := order_status_desc, NULL;
|
||||
order_status_level_num := order_status_level_num, NULL;
|
||||
request_dtm := request_dtm, NULL;
|
||||
significant_dtm := significant_dtm, temp_significant_dtm;
|
||||
stop_dtm := stop_dtm, temp_stop_dtm;
|
||||
summary_line := summary_line, NULL;
|
||||
system_order_priority_code := system_order_priority_code, NULL;
|
||||
uom := uom, last(first A from iv_uom_list);
|
||||
endif;
|
||||
endif;
|
||||
enddo; // Check each class type and value for each item.
|
||||
enddo; // Get additive list for those that match class type and value
|
||||
|
||||
else
|
||||
// Get the entire list of additives
|
||||
for A in index_iv do
|
||||
temp_component_type := last(first A from component_type);
|
||||
|
||||
// // Type of 0 or 3 are IV additives
|
||||
if temp_component_type is in (0,3) then
|
||||
chart_guid := chart_guid, temp_chart_guid;
|
||||
client_visit_guid := client_visit_guid, temp_client_visit_guid;
|
||||
dosage_high := dosage_high, last(first A from iv_dosage_to_list);
|
||||
dosage_low := dosage_low, last(first A from iv_dosage_list);
|
||||
frequency_code := frequency_code, NULL;
|
||||
guid := guid, temp_guid;
|
||||
is_conditional := is_conditional, NULL;
|
||||
is_prn := is_prn, temp_is_prn;
|
||||
name := name, last(first A from iv_name_list);
|
||||
order_catalog_master_item_guid := order_catalog_master_item_guid,
|
||||
last(first A from iv_order_catalog_master_item_guid_list);
|
||||
order_component := temp_order_component;
|
||||
order_route_code := order_route_code, NULL;
|
||||
order_status_code := order_status_code, NULL;
|
||||
order_status_desc := order_status_desc, NULL;
|
||||
order_status_level_num := order_status_level_num, NULL;
|
||||
significant_dtm := significant_dtm, temp_significant_dtm;
|
||||
stop_dtm := stop_dtm, temp_stop_dtm;
|
||||
summary_line := summary_line, NULL;
|
||||
uom := uom, last(first A from iv_uom_list);
|
||||
endif; // Type of 0 or 3 are IV additives
|
||||
enddo; // Get the entire list of additives
|
||||
endif; // Exist medicaitons list else class type else all additives.
|
||||
endif; //exist temp_order_component
|
||||
|
||||
//end - Get medication orders from object if the item name
|
||||
// or the component name(additive) is in med filter list
|
||||
|
||||
endif;
|
||||
;;
|
||||
evoke:
|
||||
;;
|
||||
logic:
|
||||
if exist med_info
|
||||
then conclude TRUE;
|
||||
else conclude FALSE;
|
||||
endif;
|
||||
|
||||
;;
|
||||
action:
|
||||
return
|
||||
an_order_or_component,
|
||||
chart_guid,
|
||||
client_guid,
|
||||
client_visit_guid,
|
||||
dosage_high,
|
||||
dosage_low,
|
||||
entereddtm,
|
||||
form_code,
|
||||
frequency_code,
|
||||
guid,
|
||||
is_conditional,
|
||||
is_held,
|
||||
is_prn,
|
||||
is_suspend,
|
||||
name,
|
||||
order_catalog_master_item_guid,
|
||||
order_priority_code,
|
||||
order_route_code,
|
||||
order_status_code,
|
||||
order_status_desc,
|
||||
order_status_level_num,
|
||||
request_dtm,
|
||||
significant_dtm,
|
||||
stop_dtm,
|
||||
summary_line,
|
||||
system_order_priority_code,
|
||||
uom,
|
||||
match_med_found,
|
||||
item_class_value;
|
||||
|
||||
;;
|
||||
|
||||
end:
|
||||
Reference in New Issue
Block a user