361 lines
12 KiB
Plaintext
361 lines
12 KiB
Plaintext
maintenance:
|
|
|
|
title: Allergy Checking Using the Item-Catalog;;
|
|
mlmname: STD_FUNC_ALLERGY_CAT;;
|
|
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: Checks for Drug Allergies via Item-Catalog.
|
|
;;
|
|
explanation: See STD_ALLERGY MLM for an explanation.
|
|
;;
|
|
keywords: allergy; IV additives; Item-Catalog;;
|
|
|
|
knowledge:
|
|
type: data-driven;;
|
|
data:
|
|
(
|
|
order_name,
|
|
order_is_additive,
|
|
patient_allergy_names,
|
|
OrderCatalogMasterItemGUID,
|
|
Generic_name_id,
|
|
patient_allergy_category_types,
|
|
patient_allergy_adverse_event_date_year,
|
|
patient_allergy_adverse_event_date_month,
|
|
patient_allergy_adverse_event_date_day,
|
|
input_parameter_xml,
|
|
allergen_guid,
|
|
client_guid,
|
|
allergy_category_type,
|
|
rx_other_allergen_check,
|
|
is_reverse_check,
|
|
reverse_check_order,
|
|
reverse_check_rx,
|
|
reverse_check_med_orders,
|
|
reverse_check_outpatient_orders_flag):= ARGUMENT;
|
|
|
|
/*******************Make Changes To Spelling And Flags In This Section*******************/
|
|
|
|
/* Set to true if logging is needed.*/
|
|
log_execution_info := false;
|
|
|
|
/***************************************************************************************/
|
|
//Declare the Med_Data_Object
|
|
Med_Data_Object := OBJECT [
|
|
rx_hx_typecode,
|
|
sort_field,
|
|
OrderName,
|
|
OrderOrAdditiveName,
|
|
PrescriptionName,
|
|
ComponentName,
|
|
ComboDrugName,
|
|
OrderGUID,
|
|
AdditiveGUID,
|
|
PrescriptionID,
|
|
StartDate,
|
|
StatusType,
|
|
TypeCode,
|
|
IsUnmapped,
|
|
allergen_msg,
|
|
msg_type,
|
|
IsComboDrug
|
|
];
|
|
|
|
|
|
// list that holds all of the objects that will be returned
|
|
mdo_list := ();
|
|
|
|
if is_reverse_check
|
|
then
|
|
|
|
( rx_hx_typecode_list,
|
|
allergen_msg_list,
|
|
order_guid_list,
|
|
additive_guid_list,
|
|
prescription_id_list,
|
|
order_name_list,
|
|
order_or_additive_name_list,
|
|
prescription_name_list,
|
|
start_date_list,
|
|
status_type_list,
|
|
type_code_list,
|
|
IsDnumLevel_list,
|
|
FormularyBrandKey_list
|
|
) := read { "EXEC SXACatalogAllergyAlertSelPr "
|
|
|| SQL(input_parameter_xml)|| ", "
|
|
|| SQL(allergen_guid) || ", "
|
|
|| SQL(client_guid) || ", "
|
|
|| SQL(allergy_category_type) || ", "
|
|
|| SQL(rx_other_allergen_check) || ", "
|
|
|| SQL(reverse_check_order) || ", "
|
|
|| SQL(reverse_check_rx) || ", "
|
|
|| SQL(reverse_check_med_orders) || ", "
|
|
|| SQL(reverse_check_outpatient_orders_flag) };
|
|
|
|
if exist allergen_msg_list
|
|
then
|
|
|
|
num_msgs := count (allergen_msg_list);
|
|
//num_msgs := num_msgs + 1;
|
|
for JJ in (1 seqto num_msgs ) do
|
|
instance := new Med_Data_Object;
|
|
|
|
instance.rx_hx_typecode := rx_hx_typecode_list[JJ];
|
|
instance.OrderName := order_name_list[JJ];
|
|
instance.OrderOrAdditiveName := order_or_additive_name_list[JJ];
|
|
instance.PrescriptionName := prescription_name_list[JJ];
|
|
instance.ComponentName := "";
|
|
instance.ComboDrugName := "";
|
|
instance.OrderGUID := order_guid_list[JJ];
|
|
instance.AdditiveGUID := additive_guid_list[JJ];
|
|
instance.PrescriptionID := prescription_id_list[JJ];
|
|
instance.StartDate := start_date_list[JJ];
|
|
instance.StatusType := status_type_list[JJ];
|
|
instance.TypeCode := type_code_list[JJ];
|
|
instance.msg_type := "Catalog";
|
|
instance.IsComboDrug := false;
|
|
instance.IsUnmapped := false;
|
|
|
|
if (instance.PrescriptionID is not null and instance.PrescriptionID <> -1)
|
|
then
|
|
instance.sort_field :=
|
|
instance.PrescriptionName || "|" || instance.PrescriptionID
|
|
|| "|{2}";
|
|
|
|
//[MU2][SNOMEDCT]
|
|
current_FormularyBrandKey := FormularyBrandKey_list[JJ];
|
|
|
|
IsDnumLevel := IsDnumLevel_list[JJ];
|
|
if IsDnumLevel = false
|
|
then
|
|
IsDnumLevel:=0;
|
|
else
|
|
IsDnumLevel:=1;
|
|
endif;
|
|
tempallergen_msg := allergen_msg_list[JJ];
|
|
(one_allergen_msg) := read last { "EXEC SXACatalogAllergenMessageTextSelPr "
|
|
|| SQL(IsDnumLevel)|| ", "
|
|
|| SQL(instance.PrescriptionName) || ", "
|
|
|| SQL(current_FormularyBrandKey) || ", "
|
|
|| SQL(allergen_guid) || ", "
|
|
|| SQL(1) || ", "
|
|
|| SQL(NULL) };
|
|
|
|
|
|
if one_allergen_msg <> ""
|
|
then
|
|
instance.allergen_msg := allergen_msg_list[JJ] || one_allergen_msg;
|
|
mdo_list := mdo_list, instance;
|
|
endif;
|
|
|
|
elseif (instance.AdditiveGUID is not null)
|
|
then
|
|
instance.sort_field :=
|
|
instance.OrderOrAdditiveName || "|" || instance.AdditiveGUID
|
|
|| "|{2}";
|
|
instance.allergen_msg := allergen_msg_list[JJ];
|
|
mdo_list := mdo_list, instance;
|
|
|
|
else
|
|
instance.sort_field :=
|
|
instance.OrderName || "|" || instance.OrderGUID
|
|
|| "|{2}";
|
|
instance.allergen_msg := allergen_msg_list[JJ];
|
|
mdo_list := mdo_list, instance;
|
|
endif;
|
|
enddo;
|
|
endif;
|
|
/* Only retrieves data if the patient has allergies */
|
|
elseIf exist patient_allergy_names
|
|
then
|
|
|
|
if OrderCatalogMasterItemGUID is not null
|
|
then
|
|
/* Gets the allergen codes and other relevant data associated with the order{{{SINGLE-QUOTE}}}s
|
|
catalog item allergens */
|
|
(allergen_codes,
|
|
allergen_msg_texts) := read
|
|
{ "SELECT Code, MessageText,CV3OrderCatalogMasterItem.Name "
|
|
|| " FROM CV3Allergen JOIN CV3CatalogItemAllergen"
|
|
|| " ON CV3Allergen.GUID = CV3CatalogItemAllergen.AllergenGUID"
|
|
|| " INNER JOIN CV3OrderCatalogMasterItem ON"
|
|
|| " CV3CatalogItemAllergen.ItemGUID = CV3OrderCatalogMasterItem.GUID"
|
|
|| " WHERE CV3CatalogItemAllergen.ItemGUID = "
|
|
|| SQL(OrderCatalogMasterItemGUID)};
|
|
|
|
if (order_is_additive)
|
|
then
|
|
order_or_prescription_string := " additive.";
|
|
else
|
|
order_or_prescription_string := " order.";
|
|
endif;
|
|
|
|
else
|
|
/* Gets the allergen codes and other relevant data associated with the
|
|
prescription{{{SINGLE-QUOTE}}}s catalog item allergens */
|
|
num_allergies := count (patient_allergy_names);
|
|
for J in (1 seqto num_allergies ) do
|
|
if J=1
|
|
then
|
|
one_patient_allergy_name:= patient_allergy_names[J];
|
|
else
|
|
one_patient_allergy_name:= one_patient_allergy_name || "," || patient_allergy_names[J];
|
|
endif;
|
|
enddo;
|
|
(allergen_codes,
|
|
allergen_msg_texts) := read { "EXEC SXACatalogAllergenMessageTextSelPr "
|
|
|| SQL(NULL)|| ", "
|
|
|| SQL(order_name) || ", "
|
|
|| SQL(EVOKINGOBJECT.FormularyBrandKey) || ", "
|
|
|| SQL(allergen_guid) || ", "
|
|
|| SQL(0) || ", "
|
|
|| SQL(one_patient_allergy_name) };
|
|
order_or_prescription_string := " prescription.";
|
|
endif;
|
|
|
|
endif; /* If exist patient_allergy_names */
|
|
;;
|
|
evoke: ;;
|
|
|
|
logic:
|
|
if (is_reverse_check)
|
|
then
|
|
conclude true;
|
|
endif;
|
|
|
|
/* Stops processing when the patient does not have any allergies */
|
|
if not (exist order_name or exist patient_allergy_names)
|
|
then
|
|
xxx_debug_check:= "patient does not have allergies";
|
|
conclude false;
|
|
endif;
|
|
|
|
/* Initializes variables */
|
|
alert_msg_list:= ();
|
|
alert_allergen_list:= ();
|
|
alert_category_type_list := ();
|
|
alert_adverse_event_year_list := ();
|
|
alert_adverse_event_month_list := ();
|
|
alert_adverse_event_day_list := ();
|
|
|
|
allergies_found := patient_allergy_names is in allergen_codes ;
|
|
|
|
if any allergies_found
|
|
then
|
|
|
|
num_allergies := count (patient_allergy_names);
|
|
for J in (1 seqto num_allergies ) do
|
|
one_patient_allergy_name:= patient_allergy_names[J];
|
|
if (one_patient_allergy_name is in allergen_codes)
|
|
then
|
|
category_type := patient_allergy_category_types[J];
|
|
adverse_event_date_year := patient_allergy_adverse_event_date_year[J];
|
|
adverse_event_date_month := patient_allergy_adverse_event_date_month[J];
|
|
adverse_event_date_day := patient_allergy_adverse_event_date_day[J];
|
|
allergen_code := one_patient_allergy_name;
|
|
|
|
if (category_type = "Adverse Event" and
|
|
category_type = prev_category_type and
|
|
allergen_code = prev_allergen_code)
|
|
then
|
|
alert_allergen_list := alert_allergen_list, null;
|
|
alert_msg_list:= alert_msg_list, null;
|
|
alert_category_type_list := alert_category_type_list, null;
|
|
alert_adverse_event_year_list := alert_adverse_event_year_list, null;
|
|
alert_adverse_event_month_list := alert_adverse_event_month_list, null;
|
|
alert_adverse_event_day_list := alert_adverse_event_day_list, null;
|
|
else
|
|
/* Creates the list of matching allergens
|
|
to return to the calling MLM */
|
|
alert_allergen_list:= alert_allergen_list, allergen_code;
|
|
|
|
/* Creates a portion of the alert message */
|
|
if (category_type = "Allergy" or category_type is null)
|
|
then
|
|
temp_alert_msg:=
|
|
"The patient is allergic to " || allergen_code
|
|
|| ". A reaction may occur with the "
|
|
|| order_name || order_or_prescription_string;
|
|
elseif (category_type = "Adverse Event")
|
|
then
|
|
temp_alert_msg:=
|
|
"The patient had an adverse event with " || allergen_code
|
|
|| ". A reaction may occur with the "
|
|
|| order_name || order_or_prescription_string ;
|
|
elseif (category_type = "Intolerance")
|
|
then
|
|
temp_alert_msg:=
|
|
"The patient has an intolerance to " || allergen_code
|
|
|| ". A reaction may occur with the "
|
|
|| order_name || order_or_prescription_string ;
|
|
endif;
|
|
/* Extracts the freetext message in the item-catalog that is */
|
|
/* assocated with the allergen code */
|
|
|
|
allergy_freetext_msg:= first(allergen_msg_texts
|
|
where allergen_code = allergen_codes);
|
|
|
|
|
|
/* Adds the item-catalog{{{SINGLE-QUOTE}}}s freetext message to the alert */
|
|
if exist allergy_freetext_msg
|
|
then
|
|
temp_alert_msg:= temp_alert_msg || " " || allergy_freetext_msg;
|
|
endif;
|
|
|
|
/* Creates the alert message that is returned to the calling MLM */
|
|
alert_msg_list:= alert_msg_list, temp_alert_msg;
|
|
alert_category_type_list := alert_category_type_list, category_type;
|
|
alert_adverse_event_year_list := alert_adverse_event_year_list,
|
|
adverse_event_date_year;
|
|
alert_adverse_event_month_list := alert_adverse_event_month_list,
|
|
adverse_event_date_month;
|
|
alert_adverse_event_day_list := alert_adverse_event_day_list,
|
|
adverse_event_date_day;
|
|
endif;
|
|
prev_category_type := category_type;
|
|
prev_allergen_code := allergen_code;
|
|
endif;
|
|
enddo;
|
|
endif; /* if any allergies_found */
|
|
|
|
|
|
/* Always conclude true to return information to the calling MLM */
|
|
conclude true;
|
|
;;
|
|
action:
|
|
if is_reverse_check
|
|
then
|
|
return mdo_list;
|
|
else
|
|
return (alert_allergen_list,
|
|
alert_msg_list,
|
|
alert_category_type_list,
|
|
alert_adverse_event_year_list,
|
|
alert_adverse_event_month_list,
|
|
alert_adverse_event_day_list);
|
|
endif;
|
|
;;
|
|
end:
|