Files
St.Clair/MLMStripper/bin/Debug/STD/STD_ALLERGY.mlm

4307 lines
169 KiB
Plaintext

maintenance:
title: General Allergy Checking and Reverse Allergy Checking;;
mlmname: STD_ALLERGY;;
arden: version 2.5;;
version: 18.4;;
institution: Allscripts, Standard MLM;;
author: Allscripts Healthcare Solutions, Inc.;;
specialist: ;;
date: 2018-11-05;;
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: Alerts the user if the patient is allergic, intolerant, or had an adverse reaction to the
order or prescription. Checking can occur when entering or modifying an order or prescription
and when entering, modifying, or importing an allergy, intolerance, or adverse event.
;;
explanation: The MLM checking occurs as follows:
1. The MLM checks for potential reactions to allergies, intolerances,
and adverse events for the following:
* Medication orders from Sunrise Clinical Manager or Sunrise Medication Manager
* Medication Outpatient orders from Order Reconciliation Manager
* Prescriptions from Prescription Writer
* Diagnostic orders
* Orders of the type Other, are not checked.
2. A Reverse-Check of prescriptions, medication orders, and diagnostic orders
can occur when:
* A user imports an allergy, intolerance, or adverse event from community data.
* A user enters or accepts an allergy, intolerance, or adverse event.
* A user modifies an allergy, intolerance, or adverse event to:
Reinstate it
Increase its reaction severity
Add a new reaction
Or switch between an intolerance and an allergy.
3. Allergies, Intolerances, and Adverse Events are checked at the following times
in these applications:
CLINICAL MANAGER - Order Entry, Orders Tab:
* OrderInit - Checking occurs when the Clinical Manager user selects an
order or an order set and clicks Add. At this point, the order
object is not fully populated since the order form has not been
completed. The order name and the order type
(Medication, Diagnostic, Other) are known.
* OrderEnter - Checking occurs when the Clinical Manager user selects a
pre-filled order form and clicks Add, or the user fills out an order form
for a selected order and clicks OK.
* OrderModify - Checking occurs when the Clinical Manager user selects an
existing IV order and modifies it, adding additional IV Additives
CLINICAL MANAGER - Order Reconciliation Outpatient Orders:
* OutpatientOrderInit - Checking occurs when the Clinical Manager user selects an
order or Home Medication in ORM and clicks Continue or Create Rx.
At this point, the order object is not fully populated since the
order form has not been completed. The order name and the order type
(Medication, Diagnostic, Other) are known.
MEDICATION MANAGER:
* OrderInitPharmacy - Checking occurs when the user selects an order.
At this point, the order object and pharmacy objects are not
fully populated since the order details have not been completed. The
order name and the order type (Medication) are known.
* OrderDispensePharmacyNew - Each medication component is checked for orders
written in Medication Manager, as the item is dispensed. The trigger can
occur at three points in the process: (1) when the Medication Manager
user clicks Submit on the Order Entry Worksheet for a "complete"
Mnemonic, which automatically populates the components and selects
Dispensable Items, (2) when the user enters a new generic item and dose
for an "incomplete" Mnemonic order on the Order Entry Form, which selects
a Dispensable Item, and (3) when the user manually adds a Dispensable
Item using a lookup dialog.
* OrderDispensePharmacyExisting - Each medication component is checked for
orders written in Clinical Manager, as the item is dispensed. This
trigger can occur at two points in the process: (1) during order
perfection on the Order Entry Form, when the user selects a generic item
and enters a dose, the Dispensable Item is selected automatically, and
(2)during order perfection on the Order Entry Form, when the user
manually selects a Dispensable Item using a lookup dialog.
PRESCRIPTION WRITER:
* PrescriptionInit - Checking occurs when an item is selected for Prescriptions
or Historical Prescriptions. Checking also occurs when an electronic item
is selected and the user clicks Copy to Med Hx(enter trigger also occurs
here)
* Prescription Renew - Checking occurs when an item is selected and the user
clicks Renew.
APPLICATIONS that support allergy entry and modifications:
* AllergyImport - Current Orders and Prescriptions are rechecked when an
Allergy, Intolerance, or Adverse Event is imported as community data.
* AllergyEnter - Current Orders and Prescriptions are rechecked for potential
reactions, when a new Allergy, Intolerance, or Adverse Event is entered.
* AllergyModify - Current Orders and Prescriptions are rechecked when an
Allergy, Intolerance, or Adverse Event is modified to reinstate it,
increase its reaction severity, add a new reaction, or switch between
an intolerance and an allergy.
4. Depending on the facility{{{SINGLE-QUOTE}}}s choice, patient ALLERGIES that are checked can include
Sunrise Allergies as well as community allergies that are available to Sunrise.
5. Depending on the facility{{{SINGLE-QUOTE}}}s choice, MEDICATIONS can be checked with one
of the following approaches:
* Drug Vendor Data - The medication and the patient{{{SINGLE-QUOTE}}}s allergies are used to
query the drug vendor information in the Sunrise environment.
Medication order names must be mapped to the drug vendor ID codes.
Allergen names must also have codes for the drug vendor ID.
Prescription names do not require addition mapping, since the names
are based on the drug vendor data.
* Item Catalog - The names of the patient{{{SINGLE-QUOTE}}}s allergy and the Item Catalog{{{SINGLE-QUOTE}}}s
allergen must match before an allergy, intolerance, or adverse event
alert is generated. When configured, medications can be checked for
other reactions that are not drug related, via the Item Catalog.
* Both - Medications can be checked with the drug vendor data and the
Item Catalog{{{SINGLE-QUOTE}}}s Allergy configuration.
6. DIAGNOSTIC orders are checked via the Item Catalog.
7. IV ADDITIVES are checked for allergies, intolerances, and adverse events
at OrderEnter, using the drug vendor or the Item Catalog. In addition,
each additive is checked individually during order perfection at the
OrderDispensePharmacyExisting event.
8. Allergy, intolerance, and adverse event checking tasks are separated
into 3 MLMs:
* STD_ALLERGY -- This MLM calls 2 FUNC MLMs that assist in checking.
If a reportable error or an allergen reaction is detected by one of
the FUNC MLMs, an alert will be generated. This is a required MLM.
* STD_FUNC_ALLERGY_DRUG_VENDOR_DATA -- Uses the Drug vendor{{{SINGLE-QUOTE}}}s data for
allergy, intolerance, and adverse event checking of medications.
This is an optional MLM for orders, but a required MLM for prescriptions.
An enterprise would only use this MLM if they wanted checking via
drug vendor data.
* STD_FUNC_ALLERGY_CAT -- Checks for allergies, intolerances, and
adverse events by comparing the patient{{{SINGLE-QUOTE}}}s allergies to the
order{{{SINGLE-QUOTE}}}s allergen in the Item-Catalog. This is a required MLM.
* STD_FUNC_COMMUNITY_DATA_RETRIEVAL_RULES- Checks for a user{{{SINGLE-QUOTE}}}s right to ignore
a patient{{{SINGLE-QUOTE}}}s pending community allergy data when an allergy check is performed.
Also can use triggers to excluded pending community allergy checking.
This is a required MLM.
9. The string " is allergic to " will be replaced with " has intolerance to "
or " had an adverse event with " in alert message for intolerances and adverse
events. For Drug Vendor Data allergy checking, this will be done in the
SXADrugVendorAllergyAlertSelPr stored procedure. For Item Catalog allergy
checking, this will be done in the MLM.
10. There are several flags which change how the MLM functions. A review should
be done to determine if the flags should be changed from their default settings.
The flags are located in the asterisk area of the DATA slot, with comments
on what the settings mean. The listing below group the flags bases on
their function:
* These high-level flags change what is checked:
alert_if_unmapped
DRUG_VENDOR_DATA_ALLERGY_CHECK
Order_Other_Allergen_Check
Rx_Other_Allergen_Check
Allergen_Classification_Check
check_outpatient_orders
* These flags change what is checked at the Orders, Pharmacy, and Prescription
Triggers:
display_order_alert_other_types
display_prescription_alert_other_types
display_pharmacy_alert_other_types
send_alert
* These flags change Reverse-Checking at the Allergy Triggers:
alert_if_new_uncoded_allergen
alert_if_severity_missing_in_sequence
enable_reverse_checking
recheck_reaction_listing
reverse_check_orders_for_other_allergen_types
reverse_check_rx_for_other_allergen_types
severity_sequence_listing
unchecked_allergen_type_warning_list
* These flags change how the Alert Dialog works and adds UDDD Comments
and Documents:
sync_alert_dialog
async_alert_dialog
alert_override_document_name
document_conditional_text_list
UDDD_dictionary_name
UDDD_is_restricted
* These flags affect the alerts for Community Allergies
enable_community_data_allergy_alerts
pending_community_allergy_alert_text
community_data_excluded_triggers_list
11. A new right can be used to control which users see alerts that contain allergy drug
conflicts with the patients pending community allergies. The right is titled:
NoAlert-Allergy MLM for ImportedAllergies
Change History:
01.13.2012 TMS Added User discipline as qualifier to fire allergy alert CSR 26893 moved to production 2/8/2012
02.29.2012 tms Updated IS users in Fire On User and users who no longer have active log on{{{SINGLE-QUOTE}}}s. Changed reactions
by class to >2 to remove diuretic order to sulfa allergy alerts.
09.13.2012 TMS Changed from User discipline to all physician and physician extenders. CSR 30865
10.25.2013 TMS Added changes from 5.5 version to 6.1 version. Combined STD_Allergy and STD_Allergy_NonCPOE into
same standard MLM. CSR 31299
02.24.2015 BB Modified MLM to present mandatory field when an Allergy Alert fires to an {{{SINGLE-QUOTE}}}RN{{{SINGLE-QUOTE}}} and {{{SINGLE-QUOTE}}}US{{{SINGLE-QUOTE}}}. Populated
{{{SINGLE-QUOTE}}}AllergenAckCommentOther{{{SINGLE-QUOTE}}} uddd with requested values for users to select from.
07.13.2014 TMS Added changes from 6.1 version to 15.1 version. CSR 33555
06.09.2016 TMS Added Angioedema and Stevens-Johnson Syndrome to physician alert qualifiers. CSR 34730
10.11.2017 TMS Added changes from 16.3 to 16.3 CU10-PR12 version. CSR 35942
05.21.2018 TMS Added call to FUNC_ACS_ALLERGY_SUPRESS_ALERT written by J Bickley, Professional Services to supress subsequent alert for the same
user (Physician, PA-C, CRNP) when they have already acknowledged the alert once. CSR 35068
08.03.2018 TMS Add swelling to list of reactions to present allergy alert to physicians. currently have throat swelling and tongue swelling
but not swelling alone. HD 3357088
03.20.2019 TMS Removed allergy alert from firing when entering home medication history. HD 3603600
07.28.2019 TMS Added changes from 16.3 Version to 18.4 Version. CSR 37676
10.30.2019 TMS Added Hallucinations to list of alerts that fire for physicians and physician extenders. HD 3944757
11.25.2019 TMS Remove supression of alert for particular reactions for CPOE, change reaction to list in bold and blue.
Require Non-CPOE users to acknowledge alert if proceeding. CSR 38958
;;
keywords: allergy; IV additives; Item-Catalog; Drug Vendor Data;;
citations:
{{+B}}Development{{-B}}: Drug information provided by Cerner Multum, Inc. Drug information can be customized and configured by local facility.
{{+B}}Funding{{-B}}: Cerner Multum, Inc.
{{+B}}Release{{-B}}: VantageRx Multum Database
;;
knowledge:
type: data-driven;;
data:
// Specify which .NET assemblies need to be loaded for ObjectsPlus
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
//***************Make Changes To Spelling And Flags In This Section*************
fire_on_UserCPOE := ("MD","DO","DDS","DPM","PA","PA-C","CRNP","IT");
fire_on_User := ("RN","RPh","US");
/* Get the current user{{{SINGLE-QUOTE}}}s occupation*/
(user_id,userguid) :=read last {UserInfo: idcode, guid};
UserCode := read last
{"Select occupationcode "
||" From cv3user with (nolock) "
||" Where Guid = " || SQL(userguid) };
If usercode in fire_on_UserCPOE then
sync_alert_dialog := "Must Comment";
UDDD_dictionary_name := "AllergenAckComment";
CPOElist := true;
continue_processing := true;
elseif usercode in fire_on_User then
sync_alert_dialog := "Must Acknowledge, Must Comment";
UDDD_dictionary_name := "AllergenAckCommentOther";
CPOElist := false;
continue_processing := true;
else continue_processing := false;
endif;
/*end of custom code from 5.0 */
// Set to true if logging is needed.
log_execution_info := false;
// Set to true if you want to display a message for any unmapped or intentionally
// ignored drugs. NOTE: This flag is used for Catalog based orders only
alert_if_unmapped:= false;
// Set the flag to FALSE if drug vendor data should NOT be used to check
// Medication orders for allergies. The default setting is TRUE
// NOTE: This flag is used for Catalog based orders only. Prescriptions
// will always use the drug vendor data for allergy checking
DRUG_VENDOR_DATA_ALLERGY_CHECK := true;
// Set the flag to true if the DRUG_VENDOR_DATA_ALLERGY_CHECK flag is TRUE and
// the site wants the Item Catalog used for other allergens that are not
// mapped to a drug vendor data allergen. NOTE: This flag is used for Catalog
// based orders only. Please use the Rx_Other_Allergen_Check flag
// for Prescriptions
Order_Other_Allergen_Check:= false;
// Set allergen types in this list if site wants to use mapped allergen from the specified allergen types in the Item Catalog.
// value specified in this list is used if the DRUG_VENDOR_DATA_ALLERGY_CHECK flag is TRUE and Order_Other_Allergen_Check is TRUE
// If Order_Other_Allergen_Check or DRUG_VENDOR_DATA_ALLERGY_CHECK is false, the value order_other_allergen_type_list is ignored.
//order_other_allergen_type_list = ("Drug"), the feature is turned on for mapped Drug Allergen
//order_other_allergen_type_list = ("Food"), the feature is turned on for mapped food Allergen
//order_other_allergen_type_list = ("Drug","Food"), the feature is turned on for both Durg and Food allergen type
//order_other_allergen_type_list = (), the feature is off, it will be the current behavior and alert will not be generated for mapped Allergen
order_other_allergen_type_list := ();
// Set allergen types in this list if site wants to display unmapped and <other> allergen from the specified allergen types in Unchecked Allergen Alert.
// value specified in this list is used if the alert_if_unmapped flag is TRUE
// If alert_if_unmapped is FALSE, the value unmapped_allergen_type_list is ignored.
//unmapped_allergen_type_list = ("Drug"), the unmapped Drug Allergen is displayed in the Unchecked Allergen Alert
//unmapped_allergen_type_list = ("Food"), the unmapped Food Allergen is displayed in the Unchecked Allergen Alert
//unmapped_allergen_type_list = ("Drug","Food"), both unmapped Drug and Food Allergen is displayed in the Unchecked Allergen Alert
//unmapped_allergen_type_list = (), the unmapped allergen will not be displayed. It will be the current behavior and Unchecked Allergen Alert is only displayed to the mapped allergens
unmapped_allergen_type_list:= ();
// Set this flag to true if the site wants prescriptions checked against
// the item Catalog for other allergens that are not available in
// drug vendor data allergen. NOTE: This flag is used for
// Prescriptions only. Please use the Order_Other_Allergen_Check flag
// for Catalog based orders
Rx_Other_Allergen_Check:= false;
// Set the flag to false if the site does not want Alerts issued that
// are based on the drug vendor data{{{SINGLE-QUOTE}}}s Allergy Classifications
Allergen_Classification_Check:= true;
// Allergy Alerts are always displayed and the site can set any of the
// following lists to an empty string("")to post Allergy Alerts only OR
// the lists can be set to include both "Intolerance" and "Adverse Event"
// in Allergy Alerting
// Example: display_order_alert_other_types:= ("Intolerance", "Adverse Event");
display_order_alert_other_types := ("Intolerance");
display_prescription_alert_other_types := ("Intolerance");
display_pharmacy_alert_other_types := ("Intolerance");
// Use this flag for Item-Catalog based orders only; it does not apply to Prescriptions.
// Set this flag to indicate whether the alert message should be sent to the
// ancillary system with the order. The choices are:
// "DoNotSend" = do not send the alert regardless of the Alert Types dictionary
// setting for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
// "Send" = send the alert regardless of the Alert Types dictionary setting
// "", or blank = use the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} setting in the Alert Types
// dictionary.
// (NOTE that the default setting of {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} is unchecked. If
// it is checked and the send_alert variable is set to blank or "" then
// all of the alerts for this MLM will be sent with the order.)
// for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
send_alert := "DoNotSend";
// The SYNC_ALERT_DIALOG flag controls the alert override, acknowledgement,
// comment, and document requirements in the Synchronous Alert Detail dialog.
// The variable is used to set the ALERT_DIALOG_SETTINGS for the synchronous alert.
// The following phrases must be placed in a single string:
// "No Override Allowed", "Must Acknowledge", "If Acknowledged",
// "Must Comment", "Must Document", "Conditionally Document", "Default", ""
// Example: "Must Acknowledge, Must Document"
// sync_alert_dialog := "";
// The ASYNC_ALERT_DIALOG flag controls the comment and document requirements when
// the alert is acknowledged in the Asynchronous Alert Detail dialog. The variable
// is used to set the ASYNC_ALERT_DIALOG_SETTINGS for the asynchronous alert.
// The following phrases must be placed in a single string:
// "If Acknowledged", "Must Comment",
// "Must Document", "Conditionally Document", "Default", ""
// Example: "If Acknowledged, Conditionally Document"
// async_alert_dialog := "";
// If a document can be attached to the alert, specify its name within the quotes.
// Example: "Alert Override Document"
alert_override_document_name := "";
// If you are using "Conditionally Document" for one of the alert dialog settings,
// specify the phrases that can make the document mandatory.
// Put quotes around each phrase. Put them in a list using parentheses and commas.
// Example: ("Using different protocol", "Other Reason")
document_conditional_text_list := ();
// If you are using a User Defined Data Dictionary (UDDD), specify its name within
// the quotes.
// Example: "My Restricted Dictionary"
// UDDD_dictionary_name := "";
// If you are using UDDD, specify if is a restricted dictionary or not.
// Selections are: TRUE, FALSE
UDDD_is_restricted := FALSE;
// Set the flag to TRUE if an UN-CODED ALLERGEN Warning should be displayed.
// Set the flag to FALSE if a warning should not be displayed.
// An UN-CODED ALLERGEN occurs when an allergy is created for the patient via HL7 and
// the allergy is new for the Allergen Dictionary. Since the allergen is new, it does
// not have a code to another coding system such as Multum. Consequently, orders
// and prescriptions cannot be checked for reactions to the un-coded allergen.
// The default is set to TRUE.
alert_if_new_uncoded_allergen := true;
// Set the flag to TRUE if a missing Severity Warning should be displayed.
// Set the flag to FALSE if a missing Severity Warning should not be displayed.
// If an enterprise has turned on alerting to recheck the allergen
// when the reaction severity is increasing, then a missing severity
// warning can occur when the severity is not listed in the
// Severity_Sequence_Listing variable.
// The default is set to TRUE.
alert_if_severity_missing_in_sequence := false;
// Set to true if you want the MLM to do a REVERSE CHECK for allergies,
// intolerances, and adverse events. This will occur when the user
// enters or modifies an allergy, intolerance, or adverse event.
// Existing and Unsubmitted Orders and Prescriptions
// are checked against the allergy, intolerance, or adverse event.
// When set to false, reverse-allergy checking will not occur.
enable_reverse_checking := false;
// This variable is used to determine if the addition of reaction(s) to an
// existing allergy, intolerance, or adverse event should cause a recheck
// of the orders and prescriptions for potential problems.
// The list should only contain reactions that should be rechecked.
// Reactions that are not in the list, will not be rechecked.
// ** To TURN-OFF the rechecking, use an empty list ().
// ** To TURN-ON the rechecking, add reactions to the list.
// To add reactions, create a list of reactions from your Reaction Dictionary.
// For example: ("Hives", "Anaphylaxis", "Wheezing")
recheck_reaction_listing:= ();
// If REVERSE CHECKING is enabled, Orders and Prescriptions are checked when a user
// enters or modifies an Allergy. A REVERSE CHECK of Intolerances or Adverse Events
// can be done for an order or a prescription or both, by listing the additional
// allergen types that should be checked for each flag, as follows:
// An empty string ("") to only check Allergies.
// ("Adverse Event") to include adverse event, but not intolerances. (Default)
// ("Intolerance") to include intolerances, but not adverse events.
// ("Intolerance", "Adverse Event") to include both.
reverse_check_orders_for_other_allergen_types := ("Adverse Event");
reverse_check_rx_for_other_allergen_types := ("Adverse Event");
// This variable is used to determine if the reaction severity is increasing,
// when an allergy, intolerance, or adverse event is modified. It is also used
// to determine if an enterprise wants an allergen to be rechecked when
// its severity increases.
// ** To TURN-OFF the allergen rechecking, use an empty list ().
// ** To TURN-ON the allergen rechecking, add severities to the list.
// To add severities, create a list of severities from your Severity Dictionary.
// Use a string for each severity and put them in a sequence of increasing severity
// from left to right.
// For example: ("Mild", "Moderate", "Severe", "Fatal")
severity_sequence_listing:= ();
// This flag is used to determine which ALLERGEN TYPE(S) should be screened for
// UNCHECKED ALLERGEN ALERTS when Reverse Allergy checking occurs.
// These alerts occur when a drug allergen or drug-category allergen
// is not mapped to a Multum allergen code in the Allergen Dictionary.
// * Allergen Types that should be checked are listed in the flag below.
// * Allergen Types that should NOT be checked, are not listed in the flag below.
// Enter the number(s) representing the Allergen Type in the flag below.
// Do not set the flag to an empty list (), strings, or null.
// The default checks type 0, which is the Standard allergen.
// The following numbers for Allergen Type are supported:
// 0 = Standard is an allergy from the Allergen dictionary, such as a drug, food, etc.
// 1 = <Other> is an allergy entered as a Free Text allergy.
// 2 = NoKnownAllergies
// 3 = AllergyStatusUnknown
// NOTE: As other Allergen Types are added or enhanced in the future, check the CDS Guide
// to determine if they can be added to this list to trigger an Unchecked Allergen Alert.
unchecked_allergen_type_warning_list := (0);
// Set this flag to TRUE to include community data in allergy checking
enable_community_data_allergy_alerts := FALSE;
// Enter the text to differentiate community data in allergy alerts.
pending_community_allergy_alert_text := " (Pending)";
// Enter the list of triggers that you want to exclude from community allergy checking.
// The trigger names must be strings. Use double-quotes around the trigger name.
// The following are triggers that can be placed in the list:
// ("OrderAlternateEnterNoIVAdditive", "OrderAlternateEnterWithIVAdditive")
// ("OrderAlternateModify")
// ("OrderDispensePharmacyExisting", "OrderDispensePharmacyNew", "OrderInitPharmacy")
// ("OutpatientOrderInitNoIVAdditive")
// ("PrescriptionInit", "PrescriptionRenew")
// Since this MLM only retrieves Pending Community Allergies when Medications trigger the MLM,
// placing the following triggers in the list below would have no effect on
// community allergy checking.
// ("AlertCheckingClientPrescription", "AlertCheckingOrder")
// ("AllergyEnter", "AllergyImport", "AllergyModify")
// The default is an empty list (). It means that no triggers are excluded.
community_data_excluded_triggers_list := ();
//Add "Outpatient Hx" to include Home Medications ("Outpatient Rx", "Outpatient Hx")
check_outpatient_orders := ("Outpatient Rx");
// Change the message within the quotes if a different short-message is needed.
allergy_alert:= destination { Alert } WITH
[alert_type := "Warning",
short_message :="Patient Allergy",
Priority :="HIGH",
Scope := "chart",
Rule_group :="HVC Allergy",
rule_number := 1005,
send_with_order := send_alert,
display_alert := TRUE,
alert_abstract:= "",
alert_dialog_settings := sync_alert_dialog,
async_alert_dialog_settings := async_alert_dialog,
document_name := alert_override_document_name,
document_conditional_text :=
document_conditional_text_list,
ack_comment_UDDD := UDDD_dictionary_name,
ack_comment_UDDD_is_restricted := UDDD_is_restricted ];
intolerance_alert := destination { Alert } WITH
[alert_type := "Warning",
short_message :="Patient Intolerance",
Priority :="HIGH",
Scope := "chart",
Rule_group :="Intolerance",
rule_number := 1015,
send_with_order := send_alert,
display_alert := TRUE,
alert_abstract:= "",
alert_dialog_settings := sync_alert_dialog,
async_alert_dialog_settings := async_alert_dialog,
document_name := alert_override_document_name,
document_conditional_text :=
document_conditional_text_list,
ack_comment_UDDD := UDDD_dictionary_name,
ack_comment_UDDD_is_restricted := UDDD_is_restricted ];
adverse_event_alert := destination { Alert } WITH
[alert_type := "Warning",
short_message :="Patient Adverse Event",
Priority :="HIGH",
Scope := "chart",
Rule_group :="Adverse Event",
rule_number := 1025,
send_with_order := send_alert,
display_alert := TRUE,
alert_abstract:= "",
alert_dialog_settings := sync_alert_dialog,
async_alert_dialog_settings := async_alert_dialog,
document_name := alert_override_document_name,
document_conditional_text :=
document_conditional_text_list,
ack_comment_UDDD := UDDD_dictionary_name,
ack_comment_UDDD_is_restricted := UDDD_is_restricted ];
uncoded_allergen_alert:= destination { Alert } WITH
[alert_type := "Warning",
short_message :="Patient Allergen is Un-Coded",
Priority :="HIGH",
Scope := "chart",
Rule_group :="Un-Coded Allergen",
rule_number := 1035,
send_with_order := send_alert,
display_alert := TRUE,
alert_abstract:= "",
alert_dialog_settings := sync_alert_dialog,
async_alert_dialog_settings := async_alert_dialog,
document_name := alert_override_document_name,
document_conditional_text := document_conditional_text_list,
ack_comment_UDDD := UDDD_dictionary_name,
ack_comment_UDDD_is_restricted := UDDD_is_restricted ];
unchecked_allergen_alert:= destination { Alert } WITH
[alert_type := "Warning",
short_message :="Patient Allergen Unchecked",
Priority :="HIGH",
Scope := "chart",
Rule_group :="Allergen Unchecked",
rule_number := 1045,
send_with_order := send_alert,
display_alert := TRUE,
alert_abstract:= "",
alert_dialog_settings := sync_alert_dialog,
async_alert_dialog_settings := async_alert_dialog,
document_name := alert_override_document_name,
document_conditional_text := document_conditional_text_list,
ack_comment_UDDD := UDDD_dictionary_name,
ack_comment_UDDD_is_restricted := UDDD_is_restricted ];
// Change the spelling within the quotes to match the Forms Dictionary
//"Medication" and "Diagnostic" type orders
initialized_order := event {OrderInitNoIVAdditives User Order:
where TypeCode <> "other" };
initialized_patient_group_order := event {OrderInitNoIVAdditives Batch Order:
where TypeCode <> "other"
and IsCreatedFromPatientGroupOrderTemplate = TRUE };
entered_order := event {OrderEnterWithIVAdditives User Order:
where TypeCode = "Medication" };
entered_patient_group_order := event {OrderEnterWithIVAdditives Batch Order:
where TypeCode = "Medication"
and IsCreatedFromPatientGroupOrderTemplate = TRUE };
modified_order := event {OrderModify User Order:
where TypeCode = "Medication" };
//"Outpatient Prescription and Home Medication Orders,
//Comment out below triggers to exclude checking all Outpatient Orders
//To include Home Medications remove the line {{{SINGLE-QUOTE}}}AND OrderAdditionalInfo.IsScript <> FALSE{{{SINGLE-QUOTE}}}
initialized_outpatient_order := event {OutpatientOrderInitNoIVAdditive User Order:
where TypeCode <> "other"
AND OrderAdditionalInfo.IsScript <> FALSE };
pharm_order_init:= event {OrderInitPharmacy User Order:
where TypeCode = "Medication" };
pharm_dispense_new := event {OrderDispensePharmacyNew Any Order:
where TypeCode = "Medication" };
pharm_dispense_exist := event {OrderDispensePharmacyExisting Any Order:
where TypeCode = "Medication" };
prescription_enter := event {PrescriptionInit Any ClientPrescription:
where PrescriptionTypeDescription
in ("Rx")
// in ("Rx", "Hx")
//and SourceApplicationType NOT in (10, 15)
};
prescription_renew := event {PrescriptionRenew User ClientPrescription:
where PrescriptionTypeDescription
in ("Rx") };
alert_check_order := event {AlertCheckingOrder User Order };
alert_check_prescription := event {AlertCheckingClientPrescription User
ClientPrescription };
entered_allergy := event {AllergyEnter Any Allergy };
modified_allergy := event {AllergyModify Any Allergy };
//Uncomment the imported_allergy event if you want the allergy alert
//to occur when community data is imported into the Sunrise database.
//Otherwise, keep it commented out.
//If you uncomment this event, please make sure to also uncomment
//the equivalent in the evoke slot.
//imported_allergy := event {AllergyImport Any Allergy };
// 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_trigger:=
event {OrderAlternateEnterWithIVAdditive User Order:
where TypeCode = "Medication"
AND AlternateOrderType = 1 };*/
/*order_alternate_enter_NOIV_trigger :=
event {OrderAlternateEnterNoIVAdditive User Order:
where TypeCode = "Medication"
AND AlternateOrderType = 1 };*/
/*order_alternate_modify_trigger :=
event {OrderAlternateModify User Order:
where TypeCode = "Medication"
AND AlternateOrderType = 1 };*/
//******************************************************************************
// This block executes only when this MLM is called by the editor
if called_by_editor
then
// Define object choice "Order", or "ClientPrescription"
Object_Choice :=
//"ClientPrescription";
"Allergy";
//"Order";
if (object_choice = "Order") then
EvokingObject:= read last
{Order: This
WHERE TypeCode = "Medication"
//AND Name = "Acetaminophen 650 mg suppository"
//AND Name = "Tylenol Caplet 500 mg - Oral"
//AND Name = "Acetaminophen-Codeine #3"
AND Name = "Acetaminophen"
};
EvokingEventType := entered_order.type;
elseif (object_choice = "Allergy") then
EvokingObject:= read last
{Allergy: This};
EvokingEventType := entered_allergy.type;
else
EvokingObject:= read last
{ClientPrescription: This
WHERE PrescriptionTypeDescription in ("Rx", "Hx")
};
EvokingEventType := prescription_enter.Type;
endif;
endif; // if called_by_editor
// Declare MLMs that can be called from this MLM
func_drug_vendor_data_allergy_check:= MLM {{{SINGLE-QUOTE}}}STD_func_allergy_drug_vendor_data{{{SINGLE-QUOTE}}};
func_item_catalog_allergy_check:= MLM {{{SINGLE-QUOTE}}}STD_func_allergy_cat{{{SINGLE-QUOTE}}};
func_community_data_retrieval_rules:= MLM {{{SINGLE-QUOTE}}}STD_FUNC_COMMUNITY_DATA_RETRIEVAL_RULES{{{SINGLE-QUOTE}}};
func_multum_references := MLM {{{SINGLE-QUOTE}}}STD_FUNC_MULTUM_REFERENCES{{{SINGLE-QUOTE}}};
/*St Clair Custom Logic
In keeping with alert reduction efforts,
work out a way in SCM that when an allergy
override has been addressed once, SCM retains
that information and no alert is fired again.
*/
FUNC_ACS_ALLERGY_SUPPRESS_ALERT := MLM {{{SINGLE-QUOTE}}}FUNC_ACS_ALLERGY_SUPPRESS_ALERT{{{SINGLE-QUOTE}}};
supressAlert := call FUNC_ACS_ALLERGY_SUPPRESS_ALERT with (EvokingObject);
if(supressAlert)then
continue_processing := false;
endif;
//END St Clair Cusotm Logic
// Initialize variables
// continue_processing := true;
complex_master_order_type := (1,3,5);
allergy_category_type_enum := 0;
adverse_event_category_type_enum := 1;
intolerance_category_type_enum := 2;
pending_community_allergy_text_with_formatting:= "{{-C}}" || pending_community_allergy_alert_text || "{{+C}}" ;
pending_community_allergy_abstract_alert_text := "(Community Data)";
mlmName := "STD_ALLERGY";
// This flag will eventually be set to one of the following values:
// allergy_alert, intolerance_alert or adverse_event_alert
alert_destination := "";
// Set during reverse checking. Generate an uncoded allergen alert
// if the allergy is a new allergy from HL7
is_uncoded_allergen := FALSE;
// indicates if we{{{SINGLE-QUOTE}}}re doing reverse allergy checking
is_reverse_checking := false;
// indicates if an allergy{{{SINGLE-QUOTE}}}s severity is not found in the
// severity listing
missing_severity := false;
// flag for which outpatient orders should be checked during reverse checking
outpatient_orders_flag := 0;
outpatient_rx_str := "Outpatient Rx";
outpatient_hx_str := "Outpatient Hx";
// used when displaying unchecked allergen message about severities that could
// not be checked.
previous_severity := "";
current_severity := "";
evoking_order_is_outpatient := false;
// Get the last revision date of the Multum database, strip out time portion
revision_date := read last { "select change_date from SXAMTdatabase_infoSYN" };
revision_date := revision_date formatted with "%.2t";
revision_date_string := "\n{{+B}}Revision Date{{-B}}: " || revision_date;
// Get the reference string for "Allergy" category type
allergen_type_string := read
{"SELECT ReferenceString FROM CV3EnumReference"
|| " WHERE CV3EnumReference.TableName = {{{SINGLE-QUOTE}}}CV3AllergyDeclaration{{{SINGLE-QUOTE}}}"
|| " AND CV3EnumReference.ColumnName = {{{SINGLE-QUOTE}}}CategoryType{{{SINGLE-QUOTE}}}"
|| " AND CV3EnumReference.EnumValue = 0"
};
allergy_name_with_status := "";
allergy_name_with_community := "";
//checking the flag enable_community_data_allergy_alerts
//to make sure that the below SUB MLM is called only when the flag is true.
if(enable_community_data_allergy_alerts)
then
(can_perform,can_retrieve_data_obj) := call func_community_data_retrieval_rules with
(
EvokingObject,
EvokingEventType,
mlmName,
community_data_excluded_triggers_list
);
can_retrieve_pending_imported_allergies := can_retrieve_data_obj.PendingImportedAllergies;
else
can_perform := true;
can_retrieve_pending_imported_allergies := false;
endif;
if can_perform
then
if (EvokingObject IS ClientPrescription)
then
evoked_from_prescriptions := true;
display_alert_types := display_prescription_alert_other_types,
allergen_type_string;
(evoking_prescription_description,
evoking_prescription_name,
evoking_prescription_NameID,
alert_on_demand_source,
client_guid
) := read last
{ ClientPrescription: PrescriptionTypeDescription, DrugName, GenericNameID, AlertOnDemandSource,
ClientGUID
REFERENCING EvokingObject };
elseif (EvokingObject IS Order)
then
evoked_from_prescriptions := false;
display_alert_types:= display_order_alert_other_types,
allergen_type_string;
// Get the order component object associated with the evoking order
(evoking_order_name,
evoking_cat_item_guid,
order_type,
OrdComponentObj,
PharmOrderObj,
evoking_complex_order_type,
OrderVariableComponentObj,
alert_on_demand_source,
client_guid,
alternate_order_type,
AdditionalInfoObj,
BackupObj
) := read last
{ Order: Name, OrderCatalogMasterItemGUID, TypeCode, OrderComponent,
PharmacyOrder, ComplexOrderType, OrderVariableComponent,
AlertOnDemandSource, ClientGUID,
AlternateOrderType, OrderAdditionalInfo, Backup
REFERENCING EvokingObject };
(evoking_order_is_script) := read last {OrderAdditionalInfo: IsScript
REFERENCING AdditionalInfoObj };
if (alternate_order_type = 2)
then
evoking_order_is_outpatient := true;
endif;
if (evoking_order_is_script is null)
then
evoking_order_is_script := 0;
endif;
elseif (EvokingObject IS AllergyDeclaration) and enable_reverse_checking
then
is_reverse_checking := TRUE;
(allergy_guid,
allergy_name,
allergy_type,
allergy_category_type,
allergen_guid,
allergy_severity,
allergy_confidence,
allergy_onset_day,
allergy_onset_month,
allergy_onset_year,
allergy_text,
allergy_status,
allergy_client_guid,
application_source,
BackupObj
) := read last
{ Allergy: GUID, AllergenCode, Type, CategoryType, AllergenGUID,
SvrtyLevelDisplay, ConfLevelCode, OnsetDayNum,
OnsetMonthNum, OnsetYearNum, Text, Status,
ClientGUID, ApplicSource,
Backup
REFERENCING EvokingObject };
allergy_text := TRIM(allergy_text);
//appending the "Pending" flag to the allergy name
allergy_name_with_status := allergy_name;
if ( allergy_status = "Pending")
then
allergy_name_with_status := allergy_name || pending_community_allergy_text_with_formatting;
endif;
//appending the "Community Data" flag to the allergy name for abstract message
allergy_name_with_community := allergy_name;
if ( allergy_status = "Pending")
then
allergy_name_with_community := allergy_name || pending_community_allergy_abstract_alert_text;
endif;
if (allergen_guid is null OR allergen_guid = "" OR allergen_guid = "null" OR allergen_guid = 0)
then
if EVOKINGOBJECT.Type = 0
then
is_uncoded_allergen := true;
endif;
endif;
// sanity check
if not ( (allergy_status="Active") OR (allergy_status = "Pending" AND enable_community_data_allergy_alerts = true AND can_perform = true) )
then
continue_processing := false;
else
// check whether the evoking allergy is from HL7
application_code:= READ LAST { StateInfo: ApplicationCode};
// check for uncoded allergen added from HL7
if ((application_code = "IL") or (application_code = "IF")) and (application_source = "ADT")
then
if (is_uncoded_allergen = false)
then
(allergy_external_drug_code,
allergy_external_drug_category,
DiffInMinute) := read last
{ "SELECT ExternalDrugCode, ExternalCategoryCode,DATEDIFF(mi,createdwhen,(select curDate FROM dbo.SXADBGetEnterpriseNowTblFn())) As DiffInMinute FROM CV3Allergen " ||
"WHERE GUID = " || SQL(allergen_guid) };
if (allergy_external_drug_code is null AND allergy_external_drug_category is null AND DiffInMinute <= 5 )
then
is_uncoded_allergen := TRUE;
endif;
endif;
elseif (allergy_type = 2) or (allergy_type = 3)
then
// don{{{SINGLE-QUOTE}}}t reverse allergy check if the allergy type is NoKnownAllergies=2
// or AllergyStatusUnknown=3.
continue_processing := FALSE;
elseif (allergy_category_type = adverse_event_category_type_enum)
then
// allergy is an adverse event
continue_processing :=
("Adverse Event" IS IN
reverse_check_orders_for_other_allergen_types)
or
("Adverse Event" IS IN
reverse_check_rx_for_other_allergen_types);
elseif (allergy_category_type = intolerance_category_type_enum)
then
// allergy is an intolerance
continue_processing :=
("Intolerance" IS IN
reverse_check_orders_for_other_allergen_types)
or
("Intolerance" IS IN
reverse_check_rx_for_other_allergen_types);
endif;
endif;
// if triggered on an allergy modification, then only continue reverse checking
// if certain fields have been modified
if (continue_processing
and not is_uncoded_allergen
and EvokingEventType = modified_allergy.Type)
then
(backup_allergy_category_type,
backup_severity,
backup_status
) := read last { Allergy: CategoryType, SvrtyLevelDisplay, Status
REFERENCING BackupObj };
// check if the type has not changed or has only been changed to and from
// an adverse event
perform_recheck := false;
if (allergy_status <> backup_status)
OR ((allergy_category_type <> backup_allergy_category_type)
and (allergy_category_type <> adverse_event_category_type_enum)
and (backup_allergy_category_type <> adverse_event_category_type_enum))
then
perform_recheck := true;
endif;
// perform the severity and reaction checking if required and
// either of the lists contain elements
if not perform_recheck
and (exist severity_sequence_listing or exist recheck_reaction_listing)
and allergy_severity is not null and allergy_severity <> ""
then
// check if patient allergy{{{SINGLE-QUOTE}}}s severity is increasing. An empty
// allergy severity implies that it has decreased
allergy_reaction_list := ();
allergy_severity_list := ();
backup_reaction_list := ();
backup_severity_list := ();
temp_severity_string_list := allergy_severity, backup_severity;
// parse out the current reactions first, then the backup
// reactions if they exist
indexList := 1 seqto count(temp_severity_string_list);
for J in indexList do
// verify that the patient{{{SINGLE-QUOTE}}}s severities are contained in the sequence
// listing don{{{SINGLE-QUOTE}}}t forget the re-check reaction list
temp_severity_string := temp_severity_string_list[J];
severity_length := length of temp_severity_string;
if (severity_length > 0)
then
// construct a list of allergy severities.
temp_severity_list := ();
// get the first string by finding the first semi-colon
allergy_index := find ";" in string temp_severity_string;
while (allergy_index > 0) do
// extract the reaction and its severity
temp_severity_list :=
temp_severity_list,
TRIM (substring (allergy_index - 1)
characters from temp_severity_string);
// remove the extracted reaction and severity from the string
temp_severity_string :=
TRIM(substring (severity_length)
characters starting at (allergy_index + 1)
from temp_severity_string);
// find the position marking the next reaction/severity in
// the string
allergy_index := find ";" in string temp_severity_string;
enddo;
// add the last remaining reaction to the list
if allergy_index = 0
then
temp_severity_list :=
temp_severity_list, TRIM(temp_severity_string);
endif;
// parse out the severities from the reactions. Also, update the
// reaction list at the same time
cnt := 1 seqto count(temp_severity_list);
parsed_reaction_list := ();
parsed_severity_list := ();
for JJ in cnt do
temp_str := temp_severity_list[JJ];
first_parentheses_idx := find "(" in string temp_str;
if first_parentheses_idx = 0
then
parsed_reaction_list := parsed_reaction_list, temp_str;
parsed_severity_list := parsed_severity_list, null;
else
temp_str_length := length of temp_str;
parsed_reaction_list :=
parsed_reaction_list,
trim (substring (first_parentheses_idx - 1)
characters from temp_str);
// get rid of the second parentheses
additional_drug_allergy_data_required:= read last {"SELECT VALUE FROM HVCEnvProfile WHERE Code ={{{SINGLE-QUOTE}}}CollectAdditionalDrugAllergyData{{{SINGLE-QUOTE}}}"};
if additional_drug_allergy_data_required MATCHES PATTERN "yes"
then
second_parentheses_idx := find ")" in string temp_str;
temp_str :=
trim(substring ((temp_str_length-(temp_str_length - second_parentheses_idx))-1)
characters from temp_str);
else
temp_str :=
trim(substring (temp_str_length - 1)
characters from temp_str);
endif;
// now extract the severity
// set the number of characters to be extracted to a large
// enough value so that the entire severity will be
// retrieved
parsed_severity_list :=
parsed_severity_list,
trim(substring (temp_str_length)
characters starting at
(first_parentheses_idx + 1) from temp_str);
endif;
enddo;
if (J = 1)
then
allergy_reaction_list := parsed_reaction_list;
allergy_severity_list := parsed_severity_list;
else
backup_reaction_list := parsed_reaction_list;
backup_severity_list := parsed_severity_list;
endif;
endif;
enddo;
// get list of true/false values that indicate whether a reaction is
// found in the backup list
allergy_reaction_comparison :=
allergy_reaction_list is in backup_reaction_list;
J := 1;
while J <= count(allergy_reaction_comparison)
and not perform_recheck
and not missing_severity do
reaction_found_in_backup := allergy_reaction_comparison[J];
temp_reaction := allergy_reaction_list[J];
temp_severity := allergy_severity_list[J];
temp_backup_reaction := "";
temp_backup_severity := "";
// check against backup object if it exists
if reaction_found_in_backup
and exist severity_sequence_listing
and temp_severity is not null and temp_severity <> ""
then
// get the severity of the reaction in the backup
K := 1;
found := false;
while (K <= count(backup_reaction_list)) and (not found) do
temp_backup_reaction := backup_reaction_list[K];
temp_backup_severity := backup_severity_list[K];
if (temp_backup_reaction = temp_reaction)
then
found := true;
endif;
K := K + 1;
enddo;
if ( ( temp_severity <> temp_backup_severity )
OR ( temp_severity is not null and temp_backup_severity is null )
)
then
if not (temp_severity is in severity_sequence_listing)
or ((temp_backup_severity is not null
and temp_backup_severity <> "")
and not (temp_backup_severity
is in severity_sequence_listing))
then
// check if the severity is not found in the severity list.
// if this is the case, then throw an unchecked
// allergen error
missing_severity := true;
// set the variables that will be used in the message
if (temp_severity is null or temp_severity = "")
then
current_severity := "Unspecified Severity";
else
current_severity := temp_severity;
endif;
if (temp_severity is null or temp_severity = "")
then
previous_severity := "Unspecified Severity";
else
previous_severity := temp_backup_severity;
endif;
elseif ( (temp_backup_severity is null
or temp_backup_severity = "")
and ( temp_reaction is in recheck_reaction_listing )
)
then
// severity has increased from nothing to something
perform_recheck := true;
else
// Check if the severity has increased. If it has,
// then we have to perform a reverse allergy check
severity_compare_list :=
temp_backup_severity, temp_severity;
severity_seq_list := ();
// we{{{SINGLE-QUOTE}}}re only comparing the modified allergy against
// the backup allergy, so we only need to run this iterative
// loop twice.
L := 1;
while L <= 2 do
temp_severity_str := severity_compare_list[L];
N := 1;
found_severity := false;
while N <= count(severity_sequence_listing)
and not found_severity do
temp_severity_str2 := severity_sequence_listing[N];
if (temp_severity_str = temp_severity_str2)
then
found_severity := true;
severity_seq_list := severity_seq_list, N;
endif;
N := N + 1;
enddo;
L := L + 1;
enddo;
if ( ( severity_seq_list[1] < severity_seq_list[2] )
and ( temp_reaction is in recheck_reaction_listing )
)
then
perform_recheck := true;
endif;
endif;
endif; // if temp_severity <> temp_backup_severity
elseif exist recheck_reaction_listing
and temp_reaction is in recheck_reaction_listing and temp_reaction not in backup_reaction_list
then
// check against the recheck_reaction_listing if it exists
perform_recheck := true;
endif;
J := J + 1; // get the next reaction comparison
enddo;
endif;
if not perform_recheck and not missing_severity
then
continue_processing := false;
endif;
endif;
else
continue_processing := FALSE;
endif;
else
continue_processing := false;
endif;
if continue_processing and not is_uncoded_allergen and not missing_severity
then
// Get patient ID (guid)
if client_guid is null or client_guid = 0
then
client_guid := read last {ClientInfo: GUID};
endif;
(preferred_date_format) := read
{"SELECT e.value as EnvValue "
|| " FROM HVCEnvProfile e "
|| " WHERE e.HierarchyCode="||SQL("Connect") ||" AND "
|| " e.Code=" || SQL("DateFormat") };
(preferred_partial_date_format) := read
{"SELECT e.value as EnvValue "
|| " FROM HVCEnvProfile e "
|| " WHERE e.HierarchyCode="||SQL("Connect") ||" AND "
|| " e.Code=" || SQL("PartialCompositeDateFormat") };
if is_reverse_checking
then
// determine whether to retrieve prescriptions/orders
// for reverse checking purposes only
if (allergy_category_type = adverse_event_category_type_enum)
then
// allergy is an adverse event
check_orders :=
("Adverse Event" IS IN
reverse_check_orders_for_other_allergen_types);
check_prescriptions :=
("Adverse Event" IS IN
reverse_check_rx_for_other_allergen_types);
elseif (allergy_category_type = intolerance_category_type_enum)
then
// allergy is an intolerance
check_orders :=
("Intolerance" IS IN
reverse_check_orders_for_other_allergen_types);
check_prescriptions :=
("Intolerance" IS IN
reverse_check_rx_for_other_allergen_types);
else
check_orders := true;
check_prescriptions := true;
endif;
if (not check_orders and not check_prescriptions)
then
continue_processing := false;
else
if (check_orders)
then
if (count (check_outpatient_orders) > 0) then
//set the outpatient_orders_flag to include outpatient rx and/or
//outpatient hx based on settings in check_outpatient_orders_list
if (outpatient_rx_str in check_outpatient_orders) then
outpatient_orders_flag := outpatient_orders_flag + 1;
endif;
if (outpatient_hx_str in check_outpatient_orders) then
outpatient_orders_flag := outpatient_orders_flag + 2;
endif;
endif;
// holds the retrieved non-medication orders in XML format
non_med_order_parameter_xml := "";
// holds retrieved medication orders in XML format
med_order_parameter_xml := "";
// Get the unsubmitted non-medication orders that should be checked
// for interactions. These are New or Modified orders
// These will only be checked by the catalog item MLM
( unsubmitted_order_name_list,
unsubmitted_order_guid_list,
unsubmitted_catalog_item_guid_list,
unsubmitted_order_start_date_list,
unsubmitted_order_status_type_list,
unsubmitted_order_type_code_list
) := read{ Unsubmitted Order: Name,
GUID,
OrderCatalogMasterItemGUID,
SignificantDtm,
OrderStatusCode,
TypeCode
WHERE TypeCode <> "Medication"
AND ( IntendedAction IS NULL
OR IntendedAction IS IN
("Add New","Modify","Modified","Suspend"))
};
// For each unsubmitted non-medication order, add the order-name
// and additive info (if any), to the list of unsubmitted order
// names to be processed.
index_list := 1 seqto count (unsubmitted_order_name_list);
for JJ in index_list do
unsubmitted_cat_guid :=
unsubmitted_catalog_item_guid_list[JJ];
unsubmitted_order_guid :=
unsubmitted_order_guid_list[JJ];
unsubmitted_order_name :=
unsubmitted_order_name_list[JJ];
unsubmitted_order_start_date :=
unsubmitted_order_start_date_list[JJ];
unsubmitted_order_status_type :=
unsubmitted_order_status_type_list[JJ];
unsubmitted_order_type_code :=
unsubmitted_order_type_code_list[JJ];
if ( unsubmitted_order_start_date is null )
then
unsubmitted_order_start_date := "";
endif;
non_med_order_parameter_xml := non_med_order_parameter_xml ||
" <Order " ||
" OrderName={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_name) || "{{{SINGLE-QUOTE}}} " ||
" OrderGUID={{{SINGLE-QUOTE}}}" || unsubmitted_order_guid || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || unsubmitted_cat_guid || "{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_start_date)
|| "{{{SINGLE-QUOTE}}}" ||
" StatusType={{{SINGLE-QUOTE}}}Unsubmitted{{{SINGLE-QUOTE}}}" ||
" TypeCode={{{SINGLE-QUOTE}}}" ||
xml(unsubmitted_order_type_code) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
enddo;
// Get the unsubmitted medication orders that should be checked for
// interactions. These are New or Modified orders and are not
// child complex orders
( unsubmitted_intended_action_list,
unsubmitted_order_name_list,
unsubmitted_order_guid_list,
unsubmitted_catalog_item_guid_list,
unsubmitted_order_additiveobj_list,
unsubmitted_order_start_date_list,
unsubmitted_order_status_type_list,
unsubmitted_order_type_code_list,
unsubmitted_alternate_order_type_list,
unsubmitted_order_additional_info_obj_list,
unsubmitted_order_entered_date_list
) := read{ Unsubmitted Order: IntendedAction,
Name,
GUID,
OrderCatalogMasterItemGUID,
OrderComponent,
SignificantDtm,
OrderStatusCode,
TypeCode,
AlternateOrderType,
OrderAdditionalInfo,
Entered
WHERE TypeCode = "Medication"
AND ComplexOrderType <> 2
AND ComplexOrderType <> 4
AND ComplexOrderType <> 6
AND ( IntendedAction IS NULL
OR IntendedAction IS IN
("Add New","Modify","Modified","Suspend"))
};
unsubmitted_order_is_script_list := ();
index_list := 1 seqto count (unsubmitted_order_additional_info_obj_list);
for JJ in index_list do
OrderAdditionalInfoObj := unsubmitted_order_additional_info_obj_list[jj];
(unsubmitted_order_additional_info_is_script) := read { OrderAdditionalInfo: IsScript
REFERENCING OrderAdditionalInfoObj};
unsubmitted_order_is_script_list := unsubmitted_order_is_script_list || unsubmitted_order_additional_info_is_script;
enddo;
// For each unsubmitted medication order, add the order-name and
// additive info (if any), to the list of unsubmitted order names to
// be processed.
index_list := 1 seqto count (unsubmitted_order_name_list);
for JJ in index_list do
unsubmitted_cat_guid :=
unsubmitted_catalog_item_guid_list[JJ];
unsubmitted_order_guid :=
unsubmitted_order_guid_list[JJ];
unsubmitted_additiveObj :=
unsubmitted_order_additiveobj_list[JJ];
unsubmitted_order_name :=
unsubmitted_order_name_list[JJ];
unsubmitted_order_start_date :=
unsubmitted_order_start_date_list[JJ];
unsubmitted_order_status_type :=
unsubmitted_order_status_type_list[JJ];
unsubmitted_order_type_code :=
unsubmitted_order_type_code_list[JJ];
if ( unsubmitted_order_start_date is null )
then
unsubmitted_order_start_date := "";
endif;
med_order_parameter_xml := med_order_parameter_xml ||
" <Order " ||
" OrderName={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_name) || "{{{SINGLE-QUOTE}}} " ||
" OrderGUID={{{SINGLE-QUOTE}}}" || unsubmitted_order_guid || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || xml(unsubmitted_cat_guid) || "{{{SINGLE-QUOTE}}} " ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_name)
|| "{{{SINGLE-QUOTE}}} " ||
" AdditiveGUID={{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_start_date)
|| "{{{SINGLE-QUOTE}}}" ||
" StatusType={{{SINGLE-QUOTE}}}Unsubmitted{{{SINGLE-QUOTE}}}" ||
" TypeCode={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_type_code)
|| "{{{SINGLE-QUOTE}}}" ||
"/>\n";
// If there are additives obtain the info
if exist unsubmitted_additiveObj
then
( temp_additive_name_list,
temp_item_guid_list,
temp_additive_guid_list
):= read{ OrderComponent: Name,
OrderCatalogMasterItemGUID,
GUID
REFERENCING unsubmitted_additiveObj
WHERE Dosage <> "0" AND Dosage IS NOT NULL};
additive_index_list := 1 seqto count(temp_additive_name_list);
for additive_ind in additive_index_list do
unsubmitted_additive_cat_GUID :=
temp_item_guid_list[additive_ind];
unsubmitted_additive_name :=
temp_additive_name_list[additive_ind];
unsubmitted_additive_guid :=
temp_additive_guid_list[additive_ind];
if (unsubmitted_additive_cat_GUID is null)
then
unsubmitted_additive_cat_GUID := 0;
endif;
if (unsubmitted_order_start_date is null)
then
unsubmitted_order_start_date := "";
endif;
med_order_parameter_xml := med_order_parameter_xml ||
" <Order " ||
" OrderName={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_name) || "{{{SINGLE-QUOTE}}} " ||
" OrderGUID={{{SINGLE-QUOTE}}}" || unsubmitted_order_guid || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || unsubmitted_additive_cat_GUID
|| "{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}"
|| xml(unsubmitted_additive_name)
|| "{{{SINGLE-QUOTE}}}" ||
" AdditiveGUID={{{SINGLE-QUOTE}}}" || unsubmitted_additive_guid
|| "{{{SINGLE-QUOTE}}} " ||
" StartDate={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_start_date)
|| "{{{SINGLE-QUOTE}}}" ||
" StatusType={{{SINGLE-QUOTE}}}Unsubmitted{{{SINGLE-QUOTE}}}" ||
" TypeCode={{{SINGLE-QUOTE}}}" || xml(unsubmitted_order_type_code)
|| "{{{SINGLE-QUOTE}}}" ||
"/>\n";
enddo; //for additive_index_list
endif; //if exist unsubmitted_additiveObj
enddo; //for for JJ
endif; // if check_orders
if (check_prescriptions)
then
// retrieved Rx results in XML format
Rx_parameter_xml := "";
// Get the unsubmitted prescription - New or Modified prescriptions
( unsubmitted_Rx_Hx_typecode_list,
unsubmitted_Rx_name_list,
unsubmitted_Rx_prescription_id_list,
unsubmitted_Rx_generic_name_id_list,
unsubmitted_Rx_start_date_list
) := read { Unsubmitted ClientPrescription: PrescriptionType,
DrugName,
PrescriptionID,
GenericNameID,
StartDate
WHERE PrescriptionTypeDescription <> "DC"
AND GenericItemID <> -1
AND GenericNameID <> -1};
unsubmitted_Rx_index_list :=
1 seqto count(unsubmitted_Rx_name_list);
for unsubmitted_Rx_ind in unsubmitted_Rx_index_list
do
unsubmitted_Rx_name :=
unsubmitted_Rx_name_list[unsubmitted_Rx_ind];
unsubmitted_Rx_generic_name_id :=
unsubmitted_Rx_generic_name_id_list[unsubmitted_Rx_ind];
unsubmitted_Rx_prescription_id :=
unsubmitted_Rx_prescription_id_list[unsubmitted_Rx_ind];
unsubmitted_Rx_start_date:=
unsubmitted_Rx_start_date_list[unsubmitted_Rx_ind];
unsubmitted_Rx_Hx_typecode_id :=
unsubmitted_Rx_Hx_typecode_list[unsubmitted_Rx_ind];
if (unsubmitted_rx_start_date is null)
then
unsubmitted_Rx_start_date := "";
endif;
Rx_parameter_xml := Rx_parameter_xml ||
" <Prescription " ||
" Name={{{SINGLE-QUOTE}}}" || xml(unsubmitted_Rx_name) || "{{{SINGLE-QUOTE}}} " ||
" PrescriptionID={{{SINGLE-QUOTE}}}" || unsubmitted_Rx_prescription_id
|| "{{{SINGLE-QUOTE}}} " ||
" GenericNameID={{{SINGLE-QUOTE}}}" || unsubmitted_Rx_generic_name_id
|| "{{{SINGLE-QUOTE}}} " ||
" StartDate={{{SINGLE-QUOTE}}}" || xml(unsubmitted_Rx_start_date)
|| "{{{SINGLE-QUOTE}}}" ||
" StatusType={{{SINGLE-QUOTE}}}Unsubmitted{{{SINGLE-QUOTE}}}" ||
" TypeCode={{{SINGLE-QUOTE}}}Prescription{{{SINGLE-QUOTE}}}" ||
" RxHxTypeCode={{{SINGLE-QUOTE}}}" || xml(unsubmitted_Rx_Hx_typecode_id) || "{{{SINGLE-QUOTE}}} " ||
"/>\n";
enddo; // END for unsubmitted_Rx_ind
endif; // if check_prescription
// Create the AllergyDecl XML object that will be passed to the
// drug vendor MLM
allergy_decl_xml := "<ROOT> <AllergyDecl " ||
" AllergenGUID={{{SINGLE-QUOTE}}}" || xml(allergen_guid) || "{{{SINGLE-QUOTE}}} " ||
" Status={{{SINGLE-QUOTE}}}" || allergy_status || "{{{SINGLE-QUOTE}}} " ||
" SvrtyLevelDisplay={{{SINGLE-QUOTE}}}" || xml(allergy_severity)
|| "{{{SINGLE-QUOTE}}} " ||
" CategoryType={{{SINGLE-QUOTE}}}" || allergy_category_type
|| "{{{SINGLE-QUOTE}}} " ||
" OnsetDayNum={{{SINGLE-QUOTE}}}" || allergy_onset_day || "{{{SINGLE-QUOTE}}} " ||
" OnsetMonthNum={{{SINGLE-QUOTE}}}" || allergy_onset_month
|| "{{{SINGLE-QUOTE}}} " ||
" OnsetYearNum={{{SINGLE-QUOTE}}}" || allergy_onset_year
|| "{{{SINGLE-QUOTE}}} " ||
" Type={{{SINGLE-QUOTE}}}" || allergy_type
|| "{{{SINGLE-QUOTE}}} " ||
" UncheckedAllergenTypeWarningList={{{SINGLE-QUOTE}}}" || unchecked_allergen_type_warning_list
|| "{{{SINGLE-QUOTE}}} " ||
"/>\n</ROOT>";
endif; // if not check_order and not check_prescription
else
if (enable_community_data_allergy_alerts AND can_retrieve_pending_imported_allergies)
then
status_values_list_sql_str := SQL("Active") || ", " || SQL("Pending");
else
status_values_list_sql_str := SQL("Active");
endif;
if ((exists unmapped_allergen_type_list) and (count unmapped_allergen_type_list > 0))
then
(allergy_decl_statuses,
patient_allergy_names,
patient_allergy_allergenTypes,
patient_allergy_severities,
patient_allergy_confidences,
allergy_external_drug_code_list,
allergy_external_drug_category_list,
patient_allergy_descriptions,
patient_allergy_category_types,
patient_allergy_category_type_descriptions,
allergy_onset_year_list,
allergy_onset_month_list,
allergy_onset_day_list) := read
{ " SELECT CV3Allergydeclaration.Status, "
|| " CASE WHEN Type = 1 THEN " || SQL("<Other>") || " ELSE Code END AS Code, "
|| " CASE WHEN Type = 1 THEN TypeCodeForOther ELSE TypeCode END AS TypeCode, "
|| " IsNull(SvrtyLevelDisplay, SvrtyLevelCode) AS SvrtyLevel, "
|| " ConfLevelCode, ExternalDrugCode, ExternalCategoryCode, Text, "
|| " IsNull(CategoryType, 0) as CategoryType, "
|| " IsNull(enumRef1.ReferenceString, "
|| " enumRef2.ReferenceString) as CategoryTypeDescription, "
|| " OnsetYearNum, OnsetMonthNum, OnsetDayNum "
|| " FROM CV3AllergyDeclaration LEFT JOIN CV3Allergen"
|| " ON AllergenGUID = CV3Allergen.GUID"
|| " LEFT OUTER JOIN CV3EnumReference enumRef1"
|| " ON (enumRef1.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef1.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef1.EnumValue = CategoryType) "
|| " LEFT OUTER JOIN CV3EnumReference enumRef2"
|| " ON (enumRef2.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef2.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef2.EnumValue = 0) "
|| " WHERE ClientGUID = " || SQL(client_guid)
|| " AND CV3AllergyDeclaration.Active = 1"
|| " AND CV3AllergyDeclaration.Status in (" || status_values_list_sql_str || ")"
|| " AND CV3AllergyDeclaration.Type IN (0,1) "
|| " ORDER BY Code, CategoryType ASC, OnsetYearNum DESC, "
|| " OnsetMonthNum DESC, OnsetDayNum DESC "};
elseif CPOElist = true then
// Get the patient{{{SINGLE-QUOTE}}}s allergies (drug and category) along with other
// relevant data for CPOE users
(allergy_decl_statuses,
patient_allergy_names,
patient_allergy_allergenTypes,
patient_allergy_severities,
patient_allergy_confidences,
allergy_external_drug_code_list,
allergy_external_drug_category_list,
patient_allergy_descriptions,
patient_allergy_category_types,
patient_allergy_category_type_descriptions,
allergy_onset_year_list,
allergy_onset_month_list,
allergy_onset_day_list) := read
{ " SELECT CV3Allergydeclaration.Status,Code,TypeCode, "
|| " IsNull(SvrtyLevelDisplay, SvrtyLevelCode) AS SvrtyLevel, "
|| " ConfLevelCode, ExternalDrugCode, ExternalCategoryCode, Text, "
|| " IsNull(CategoryType, 0) as CategoryType, "
|| " IsNull(enumRef1.ReferenceString, "
|| " enumRef2.ReferenceString) as CategoryTypeDescription, "
|| " OnsetYearNum, OnsetMonthNum, OnsetDayNum "
|| " FROM CV3AllergyDeclaration JOIN CV3Allergen"
|| " ON AllergenGUID = CV3Allergen.GUID"
|| " LEFT OUTER JOIN CV3EnumReference enumRef1"
|| " ON (enumRef1.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef1.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef1.EnumValue = CategoryType) "
|| " LEFT OUTER JOIN CV3EnumReference enumRef2"
|| " ON (enumRef2.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef2.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef2.EnumValue = 0) "
|| " WHERE ClientGUID = " || SQL(client_guid)
|| " AND CV3AllergyDeclaration.Active = 1"
|| " AND CV3AllergyDeclaration.Status in (" || status_values_list_sql_str || ")"
// tms add
/* || " AND SvrtyLevelDisplay IS NOT NULL "
|| " AND ((SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Anaphylaxis%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Hives%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Itch%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%S.O.B%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Wheezing%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Throat Swelling%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Throat Closes%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Tachycardia%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Chest Pain%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Palpitations%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Blisters%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Passed Out%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Cardiac Arrest%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Resp Arrest%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Seizure%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Rash%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Nausea%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Vomiting%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Confusion%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Unknown%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Tongue Swelling%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Swelling%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Thrombocytopen.%{{{SINGLE-QUOTE}}} or"
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Angioedema%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Stevens-Johnson%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Hallucinations%{{{SINGLE-QUOTE}}} or "
|| " SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%AcuteKidney Inj%{{{SINGLE-QUOTE}}}) "
|| " or (SvrtyLevelDisplay like {{{SINGLE-QUOTE}}}%Other%{{{SINGLE-QUOTE}}})) "
//tms end
*/
|| " ORDER BY Code, CategoryType ASC, OnsetYearNum DESC, "
|| " OnsetMonthNum DESC, OnsetDayNum DESC "};
else
(allergy_decl_statuses,
patient_allergy_names,
patient_allergy_allergenTypes,
patient_allergy_severities,
patient_allergy_confidences,
allergy_external_drug_code_list,
allergy_external_drug_category_list,
patient_allergy_descriptions,
patient_allergy_category_types,
patient_allergy_category_type_descriptions,
allergy_onset_year_list,
allergy_onset_month_list,
allergy_onset_day_list) := read
{ " SELECT CV3Allergydeclaration.Status,Code,TypeCode, "
|| " IsNull(SvrtyLevelDisplay, SvrtyLevelCode) AS SvrtyLevel, "
|| " ConfLevelCode, ExternalDrugCode, ExternalCategoryCode, Text, "
|| " IsNull(CategoryType, 0) as CategoryType, "
|| " IsNull(enumRef1.ReferenceString, "
|| " enumRef2.ReferenceString) as CategoryTypeDescription, "
|| " OnsetYearNum, OnsetMonthNum, OnsetDayNum "
|| " FROM CV3AllergyDeclaration JOIN CV3Allergen"
|| " ON AllergenGUID = CV3Allergen.GUID"
|| " LEFT OUTER JOIN CV3EnumReference enumRef1"
|| " ON (enumRef1.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef1.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef1.EnumValue = CategoryType) "
|| " LEFT OUTER JOIN CV3EnumReference enumRef2"
|| " ON (enumRef2.TableName = " || SQL("CV3AllergyDeclaration")
|| " AND enumRef2.ColumnName = "|| SQL("CategoryType")
|| " AND enumRef2.EnumValue = 0) "
|| " WHERE ClientGUID = " || SQL(client_guid)
|| " AND CV3AllergyDeclaration.Active = 1"
|| " AND CV3AllergyDeclaration.Status in (" || status_values_list_sql_str || ")"
|| " ORDER BY Code, CategoryType ASC, OnsetYearNum DESC, "
|| " OnsetMonthNum DESC, OnsetDayNum DESC "};
endif;
// Get the patient{{{SINGLE-QUOTE}}}s other allergies
if Order_Other_Allergen_Check or Rx_Other_Allergen_Check
then
// Create a TRUE/FALSE list of allergens that are not mapped to a drug
//vendor data allergen
allergen_is_not_drug :=
allergy_external_drug_code_list Is NULL
and allergy_external_drug_category_list Is NULL;
// Create a list with just the allergens that are not mapped to a drug
// vendor data allergen. These are the allergens that are to be checked
// via the Item Catalog even if drug vendor data is being used.
patient_nondrug_allergy_names :=
patient_allergy_names where allergen_is_not_drug;
patient_nondrug_category_types :=
patient_allergy_category_type_descriptions
where allergen_is_not_drug ;
patient_nondrug_allergy_years :=
allergy_onset_year_list where allergen_is_not_drug;
patient_nondrug_allergy_months :=
allergy_onset_month_list where allergen_is_not_drug;
patient_nondrug_allergy_days :=
allergy_onset_day_list where allergen_is_not_drug;
endif; // if Order_Other_Allergen_Check
// If the patient does not have any drug or other allergies, stop processing
if NOT (exist patient_allergy_names
or exist patient_nondrug_allergy_names)
then
continue_processing := false;
else
//for modify, only continue if IV additives have been added
if ( EvokingEventType = modified_order.type
OR EvokingEventType = order_alternate_modify_trigger.type )
then
BackupOrderComponentObj := BackupObj.OrderComponent;
(BackupComponentNamelist,
BackupComponentGUIDlist,
BackupComponentOrderCatalogMasterItemGUIDlist
) := read { OrderComponent: Name, GUID, OrderCatalogMasterItemGUID
REFERENCING BackupOrderComponentObj };
(NewComponentNamelist,
NewComponentGUIDlist,
NewComponentOrderCatalogMasterItemGUIDlist
) := read { OrderComponent: Name, GUID, OrderCatalogMasterItemGUID
REFERENCING OrdComponentObj };
if NewComponentGUIDlist IS NULL
then
continue_processing := FALSE;
else
NewComponents := ();
num_components :=
count (NewComponentOrderCatalogMasterItemGUIDlist);
for JJ in (1 seqto num_components ) do
one_new_component:=
NewComponentOrderCatalogMasterItemGUIDlist[JJ];
if NOT one_new_component
IN BackupComponentOrderCatalogMasterItemGUIDlist
then
NewComponents:= NewComponents, one_new_component;
endif;
enddo;
if count (NewComponents) = 0
then
continue_processing := FALSE;
endif;
endif; //if NewComponentGUIDlist is NULL
endif; //EvokingEventType = modified_order.type
if continue_processing
then
// Create lists for processing
if (evoked_from_prescriptions)
then
order_name_list := ,evoking_prescription_name;
generic_nameID_list := ,evoking_prescription_NameID;
else
order_name_list := ,evoking_order_name;
cat_item_guid_list := ,evoking_cat_item_guid;
order_is_additive_list := ,false;
endif;
// Get pharmacy order objects
if exists PharmOrderObj
then
is_pharmacy_order := true;
display_alert_types:= display_pharmacy_alert_other_types,
allergen_type_string;
pharm_OrderOption_Obj := read last
{ PharmacyOrder : PharmacyOrderOption
REFERENCING PharmOrderObj };
if exists pharm_OrderOption_Obj
then
(pharm_OrdOptComponent_obj,
pharm_OrdOptComponent_OVC_guid) := read first
{PharmacyOrderOption :
PharmacyOrderOptionComponent,
OrderVariableComponentGUID
REFERENCING pharm_OrderOption_Obj };
endif; //if exists pharm_OrdOptComponent
endif; // if exists PharmOrderObj
// Get all pharmacy order option component data
if is_pharmacy_order
and exists pharm_OrdOptComponent_obj
then
(opt_comp_ocmi_name_list,
opt_comp_ocmi_guid_list,
opt_comp_drug_catalog_key_list,
opt_comp_is_primary_list,
opt_comp_current_disp_item_list) := read
{PharmacyOrderOptionComponent :
OrderCatalogMasterItemName,
OrderCatalogMasterItemGUID,
DrugCatalogKey,
IsPrimary,
IsCurrentDispensedItem
REFERENCING pharm_OrdOptComponent_obj };
// Check to see if this is a complex order
if evoking_complex_order_type IS IN complex_master_order_type
AND exists OrderVariableComponentObj
then
this_is_complex_order := TRUE;
first_order_variable_component_guid := read first
{OrderVariableComponent: GUID
REFERENCING OrderVariableComponentObj};
If pharm_OrdOptComponent_OVC_guid =
first_order_variable_component_guid
then
this_is_matching_first_component := TRUE;
is_primary_first_opt_comp := opt_comp_is_primary_list[1];
is_current_dispensed_first_opt_comp :=
opt_comp_current_disp_item_list[1];
// Only process complex orders when primary item is
// dispensed
if is_primary_first_opt_comp
AND
is_current_dispensed_first_opt_comp
then
continue_processing := TRUE;
else
continue_processing := FALSE;
endif;
else
continue_processing := FALSE;
endif; // if matching OVC guids
endif; // if evoking_complex_order_type
// Processing continues if this is the primary component
if continue_processing
then
// Initialize lists
current_ocmi_name_list := ();
current_ocmi_guid_list := ();
current_drug_key_list := ();
rest_of_ocmi_name_list := ();
rest_of_drug_key_list := ();
// Get the current items being dispensed (there could be several)
current_ocmi_name_list :=
opt_comp_ocmi_name_list
where opt_comp_current_disp_item_list;
current_ocmi_guid_list :=
opt_comp_ocmi_guid_list
where opt_comp_current_disp_item_list;
current_drug_key_list :=
opt_comp_drug_catalog_key_list
where opt_comp_current_disp_item_list;
// Create separate list for those already processed
rest_of_ocmi_name_list :=
opt_comp_ocmi_name_list
where NOT opt_comp_current_disp_item_list;
rest_of_ocmi_guid_list :=
opt_comp_ocmi_guid_list
where NOT opt_comp_current_disp_item_list;
rest_of_drug_key_list :=
opt_comp_drug_catalog_key_list
where NOT opt_comp_current_disp_item_list;
if exists current_ocmi_guid_list
then
// Reset list to clear evoking order in order to add pharmacy
// components
order_name_list := ();
cat_item_guid_list := ();
drug_key_list := ();
order_is_additive_list := (); // leave this empty
// Loop through the list of current dispensed components to
// see if any items have already been processed.
i := 1;
for this_guid in current_ocmi_guid_list do
this_item_name := current_ocmi_name_list[i];
this_key := current_drug_key_list[i];
// Do not process if this is the same item checked at
// OrderPharmacyInit.
if this_guid = evoking_cat_item_guid
and EvokingEventType = pharm_dispense_new.type
then
no_alert_this_one:= true;
else
// Do not process if the same OCMI guid has been
// processed before
if (this_guid is in rest_of_ocmi_guid_list)
then
no_alert_this_one:= true;
else
// Do not process if item with same drug key
// previously processed
if (this_key is not null and this_key is in rest_of_drug_key_list)
then
no_alert_this_one:= true;
else
// Add this one to the list to check
order_name_list :=
order_name_list, this_item_name;
cat_item_guid_list :=
cat_item_guid_list, this_guid;
drug_key_list :=
drug_key_list, this_key;
endif; // if (this_key is in rest_of_drug_key_list
endif; // if (this_guid is in rest_of_ocmi_guid_
endif; // if this_guid = evoking_
i := i +1;
enddo; // for this_guid in current_list
endif; // if exists current_ocmi_guid
endif; // if continue_processing
else
// Only retrieve data if the Evoking Order has IV additives
If exist OrdComponentObj
AND EvokingEventType = entered_order.type
OR EvokingEventType = entered_patient_group_order.type
OR EvokingEventType = modified_order.type
OR EvokingEventType = order_alternate_enter_IV_trigger.type
OR EvokingEventType = order_alternate_modify_trigger.type
OR EvokingEventType = alert_check_order.type
then
// Get the catalog item from the order component object
(additive_name_list,
additive_cat_item_guid_list) := read
{ OrderComponent: Name, OrderCatalogMasterItemGUID
REFERENCING OrdComponentObj
where (Dosage AS Number) > 0 };
// Append additive information to the lists to be processed
order_name_list := order_name_list, additive_name_list;
cat_item_guid_list :=
cat_item_guid_list, additive_cat_item_guid_list;
// populate the order_is_additive flags
num_additives := 1 seqto count(additive_name_list);
for additive_index in num_additives do
order_is_additive_list := order_is_additive_list, true;
enddo;
endif; // If exist OrdComponentObj
endif; // is_pharmacy_order
endif; //if exist patient_drug_allergy_names
endif; // if is_reverse_checking
endif; //continue_processing = TRUE and is_uncoded_allergen = FALSE
endif;
//Declare the Med_Data_Object
Med_Data_Object := OBJECT [
Sort_field,
ExternalDrugCode,
TextTitle,
DrugClassID
];
;;
evoke: initialized_order;
initialized_patient_group_order;
entered_order;
entered_patient_group_order;
modified_order;
initialized_outpatient_order;
pharm_dispense_new;
pharm_dispense_exist;
pharm_order_init;
prescription_enter;
prescription_renew;
alert_check_order;
alert_check_prescription;
entered_allergy;
modified_allergy;
//Uncomment the imported_allergy trigger if you want the allergy alert
//to occur when community data is imported into the Sunrise database.
//Otherwise, keep it commented out.
//If you uncomment this trigger, please make sure to also uncomment
//the equivalent event clause.
//imported_allergy;
// 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_trigger;
order_alternate_enter_NOIV_trigger;
order_alternate_modify_trigger; */
;
;;
logic:
alert_abstract_string := "";
if not (continue_processing)
then
conclude false;
elseif is_reverse_checking
then
if is_uncoded_allergen
then
allergy_name_uncoded := allergy_name;
allergy_name_uncoded_status := allergy_name;
if (allergy_name is null OR allergy_name = "" OR allergy_name = "null" OR allergy_name = 0)
then
allergy_name_uncoded := allergy_text;
endif;
if ( allergy_status = "Pending")
then
allergy_name_uncoded_status := allergy_name_uncoded || pending_community_allergy_text_with_formatting;
alert_abstract_string := "Un-Coded Allergen - " || allergy_name_uncoded || pending_community_allergy_abstract_alert_text;
else
allergy_name_uncoded_status := allergy_name_uncoded;
alert_abstract_string := "Un-Coded Allergen - " || allergy_name_uncoded;
endif;
// construct the uncoded allergen msg and perform an early return
// since we cannot check against the allergen
uncoded_allergen_msg := "{{+B}}{{+C}}UN-CODED ALLERGEN ALERT - "
|| allergy_name_uncoded_status || "{{-B}}{{-C}}\n\n"
|| "{{+B}}{{+C}}" || allergy_name_uncoded
|| "{{-B}}{{-C}} is an Un-Coded Allergen "
|| "that was entered from another "
|| "system.\n"
|| "It does not have a coded identifier.\n"
|| "This Un-Coded Allergen cannot be checked for "
|| "possible reactions to existing Orders or "
|| "Prescriptions.\n"
|| "SAFETY OPTIONS:\n"
|| " 1. Replace " || allergy_name_uncoded || " with the "
|| "equivalent coded Allergen from the Allergen "
|| "List.\n"
|| " 2. Please use an alternative plan to do "
|| "the check.";
conclude true;
elseif missing_severity
then
unchecked_allergen_msg := "{{+B}}{{+C}}UNCHECKED ALLERGEN ALERT - "
|| allergy_name_with_status || "{{-B}}{{-C}}\n"
|| "Unable to determine if the severity change from {{{SINGLE-QUOTE}}}"
|| previous_severity || "{{{SINGLE-QUOTE}}} to {{{SINGLE-QUOTE}}}" || current_severity
|| "{{{SINGLE-QUOTE}}} is increasing. Consequently, "
|| allergy_name || " was not rechecked for "
|| "increasing severity of reactions to existing "
|| "Orders or Prescriptions. "
|| "Please use an alternative plan to do the "
|| "check.\n\n"
|| "Notify your system administrator that this "
|| "message occurred. The following information "
|| "is for the system administrator:\n"
|| "The ""Severity_Sequence_Listing"" variable "
|| "in the STD_Allergy MLM does not have one or "
|| "more of these severities: "
|| previous_severity || ", " || current_severity
|| ". Add the missing severity to the variable."
|| " Note that the severities in the variable are"
|| " listed in increasing severity, from left to "
|| "right.";
alert_abstract_string := "Unchecked Allergen - " || allergy_name_with_community;
conclude true;
endif;
endif;
// Initialize Variables
allergen_name_list:= ();
alert_message_list:= ();
alert_category_type_list :=();
reaction_order_list:= ();
adverse_event_year_list := ();
adverse_event_month_list := ();
adverse_event_day_list := ();
allergen_generic_name_list := ();
allergen_component_generic_name_list := ();
alert_allergen_id_list := ();
alert_allergen_id_citation_list := ();
alert_reaction_level_list := ();
alert_medication_category_name_list := ();
alert_medication_class_name_list := ();
alert_allergen_category_type_list := ();
alert_allergen_component_id_list := ();
alert_drug_vendor_text_id_list := ();
alert_medication_category_id_list := ();
alert_medication_class_id_list:= ();
alert_medication_is_combo_drug_list := ();
alert_unchecked_allergen_list := ();
alert_unchecked_allergen_message_list := ();
indent:= " ";
long_alert_message:= "";
long_alert_message_unmapped:= "";
details_order_guid_list:= ();
details_additive_guid_list:= ();
details_prescription_id_list:= ();
details_order_name_list:= ();
details_OrderOrAdditive_name_list:= ();
details_prescription_name_list:= ();
details_item_type_list:= ();
details_start_date_list:= ();
details_status_type_list:= ();
details_type_code_list:= ();
is_unmapped_order_found := false;
if is_reverse_checking
then
// pass in medication orders and prescription orders
// depending on the flags set for drug vendor checking
input_parameter_xml := "<ROOT>";
// only check drug vendor data for medication orders if flag is set
if ( DRUG_VENDOR_DATA_ALLERGY_CHECK = true AND med_order_parameter_xml <> "" )
then
input_parameter_xml := input_parameter_xml || med_order_parameter_xml;
endif;
if ( Rx_parameter_xml <> "" )
then
input_parameter_xml := input_parameter_xml || Rx_parameter_xml;
endif;
input_parameter_xml := input_parameter_xml || "</ROOT>";
multum_object_list := call func_drug_vendor_data_allergy_check with
(unmapped_allergen_type_list,
pending_community_allergy_alert_text,
enable_community_data_allergy_alerts,
can_retrieve_pending_imported_allergies,
cat_item_guid,
client_guid,
patient_allergy_names,
allergy_external_drug_code_list,
allergy_external_drug_category_list,
patient_allergy_category_types,
generic_nameID,
Allergen_Classification_Check,
FALSE,
display_alert_types,
alert_if_error,
alert_if_unmapped,
input_parameter_xml,
allergy_decl_xml,
DRUG_VENDOR_DATA_ALLERGY_CHECK,
check_orders,
check_prescriptions,
outpatient_orders_flag
);
// pass in non-medication orders and prescription orders
// depending on the flags set for catalog allergen checking
input_parameter_xml := "<ROOT>";
// only check drug vendor data for medication orders if flag is set
check_med_orders := false;
if ( DRUG_VENDOR_DATA_ALLERGY_CHECK = true
AND Order_Other_Allergen_Check = true)
OR
(DRUG_VENDOR_DATA_ALLERGY_CHECK = false
AND Order_Other_Allergen_Check = true)
then
check_med_orders := true;
endif;
if ( check_med_orders AND med_order_parameter_xml <> "" )
then
input_parameter_xml := input_parameter_xml || med_order_parameter_xml;
endif;
if ( Rx_Other_Allergen_Check = true AND Rx_parameter_xml <> "" )
then
input_parameter_xml := input_parameter_xml || Rx_parameter_xml;
endif;
if (non_med_order_parameter_xml <> "")
then
input_parameter_xml := input_parameter_xml || non_med_order_parameter_xml;
endif;
input_parameter_xml := input_parameter_xml || "</ROOT>";
catalog_object_list := call func_item_catalog_allergy_check with
(
null,
false,
null,
null,
null,
null,
null,
null,
null,
input_parameter_xml,
allergen_guid,
client_guid,
allergy_category_type,
Rx_Other_Allergen_Check,
is_reverse_checking,
check_orders,
check_prescriptions,
check_med_orders,
outpatient_orders_flag
);
complete_obj_list := ();
if exist multum_object_list
then
complete_obj_list := multum_object_list;
endif;
if exist catalog_object_list
then
complete_obj_list := complete_obj_list, catalog_object_list;
endif;
sorted_obj_list := SORT sort_field DATA complete_obj_list;
else
//-----------------------------------------------------------------------------
// Process one order, option component, or additive at a time to check for
// allergies
//-----------------------------------------------------------------------------
index_list:= 1 seqto (count order_name_list);
temp_allergen:= ();
temp_alert_msg:= ();
temp_category_type:= ();
temp_adverse_event_year:= ();
temp_adverse_event_month:= ();
temp_adverse_event_day:= ();
temp_alert_allergen_generic_name := ();
temp_alert_allergen_component := ();
temp_alert_allergen_id := ();
temp_alert_reaction_level := ();
temp_alert_medication_category_name := ();
temp_alert_medication_class_name := ();
temp_alert_allergen_category_type := ();
temp_alert_allergen_component_id := ();
temp_alert_drug_vendor_text_id := ();
temp_alert_medication_category_id := ();
temp_alert_medication_class_id := ();
temp_alert_medication_is_combo_drug := ();
for index_item in index_list do
order_name:= order_name_list[index_item];
cat_item_guid:= cat_item_guid_list[index_item];
generic_nameID := generic_nameID_list[index_item];
order_is_additive := order_is_additive_list[index_item];
If evoked_from_prescriptions = true
OR (DRUG_VENDOR_DATA_ALLERGY_CHECK
and order_type = "Medication")
then
(temp_allergen,
temp_alert_msg,
temp_category_type,
temp_adverse_event_year,
temp_adverse_event_month,
temp_adverse_event_day,
temp_alert_allergen_generic_name,
temp_alert_allergen_component,
temp_alert_allergen_id,
temp_alert_reaction_level,
temp_alert_medication_category_name,
temp_alert_medication_class_name,
temp_alert_allergen_category_type,
temp_alert_allergen_component_id,
temp_alert_drug_vendor_text_id,
temp_alert_medication_category_id,
temp_alert_medication_class_id,
temp_alert_medication_is_combo_drug
):= call func_drug_vendor_data_allergy_check with
(unmapped_allergen_type_list,
pending_community_allergy_alert_text,
enable_community_data_allergy_alerts,
can_retrieve_pending_imported_allergies,
cat_item_guid,
client_guid,
patient_allergy_names,
allergy_external_drug_code_list,
allergy_external_drug_category_list,
patient_allergy_category_types,
generic_nameID,
Allergen_Classification_Check,
evoked_from_prescriptions,
display_alert_types,
alert_if_error,
alert_if_unmapped
);
// If using drug vendor data and the Item Catalog then perform this
// section to use the Item-Catalog to check for other allergies
// not checked in Drug Vendor Data
if (evoked_from_prescriptions = false and Order_Other_Allergen_Check = true)
then
if ((exists order_other_allergen_type_list) and (count order_other_allergen_type_list > 0))
then
patient_drug_nondrug_allergy_names :=
patient_allergy_names
where (allergen_is_not_drug OR (not allergen_is_not_drug AND (patient_allergy_allergenTypes in (order_other_allergen_type_list))) )
and patient_allergy_category_type_descriptions in (display_alert_types)
and patient_allergy_names not in (temp_allergen);
patient_drug_nondrug_category_types :=
patient_allergy_category_type_descriptions
where (allergen_is_not_drug OR (not allergen_is_not_drug AND (patient_allergy_allergenTypes in (order_other_allergen_type_list))) )
and patient_allergy_category_type_descriptions in (display_alert_types)
and patient_allergy_names not in (temp_allergen);
patient_drug_nondrug_allergy_years:=
allergy_onset_year_list
where (allergen_is_not_drug OR (not allergen_is_not_drug AND (patient_allergy_allergenTypes in (order_other_allergen_type_list))) )
and patient_allergy_category_type_descriptions in (display_alert_types)
and patient_allergy_names not in (temp_allergen);
patient_drug_nondrug_allergy_months:=
allergy_onset_month_list
where (allergen_is_not_drug OR (not allergen_is_not_drug AND (patient_allergy_allergenTypes in (order_other_allergen_type_list))) )
and patient_allergy_category_type_descriptions in (display_alert_types)
and patient_allergy_names not in (temp_allergen);
patient_drug_nondrug_allergy_days:=
allergy_onset_day_list
where (allergen_is_not_drug OR (not allergen_is_not_drug AND (patient_allergy_allergenTypes in (order_other_allergen_type_list))) )
and patient_allergy_category_type_descriptions in (display_alert_types)
and patient_allergy_names not in (temp_allergen);
(temp_allergen2,
temp_alert_msg2,
temp_category_type2,
temp_adverse_event_year2,
temp_adverse_event_month2,
temp_adverse_event_day2):= call func_item_catalog_allergy_check with
(
order_name,
order_is_additive,
patient_drug_nondrug_allergy_names,
cat_item_guid,
null,
patient_drug_nondrug_category_types,
patient_drug_nondrug_allergy_years,
patient_drug_nondrug_allergy_months,
patient_drug_nondrug_allergy_days
);
else
patient_nondrug_allergy_names :=
patient_allergy_names
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_category_types :=
patient_allergy_category_type_descriptions
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_years:=
allergy_onset_year_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_months:=
allergy_onset_month_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_days:=
allergy_onset_day_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
(temp_allergen2,
temp_alert_msg2,
temp_category_type2,
temp_adverse_event_year2,
temp_adverse_event_month2,
temp_adverse_event_day2):= call func_item_catalog_allergy_check with
(
order_name,
order_is_additive,
patient_nondrug_allergy_names,
cat_item_guid,
null,
patient_nondrug_category_types,
patient_nondrug_allergy_years,
patient_nondrug_allergy_months,
patient_nondrug_allergy_days
);
endif;
// combine the Drug Vendor Data alerts and the Item Catalog
// alerts
If exists temp_allergen2
then
if exists temp_allergen or exists temp_alert_msg
then
temp_allergen:= temp_allergen, temp_allergen2;
temp_alert_msg:= temp_alert_msg, temp_alert_msg2;
temp_category_type :=
temp_category_type, temp_category_type2;
temp_adverse_event_year :=
temp_adverse_event_year, temp_adverse_event_year2;
temp_adverse_event_month :=
temp_adverse_event_month, temp_adverse_event_month2;
temp_adverse_event_day :=
temp_adverse_event_day, temp_adverse_event_day2;
if (temp_alert_allergen_id[1] <> -2)
then
temp_alert_allergen_generic_name :=
temp_alert_allergen_generic_name, temp_allergen2;
endif;
temp_alert_allergen_component :=
temp_alert_allergen_component, temp_allergen2;
else
temp_allergen:= temp_allergen2;
temp_alert_msg:= temp_alert_msg2;
temp_category_type := temp_category_type2;
temp_adverse_event_year := temp_adverse_event_year2;
temp_adverse_event_month := temp_adverse_event_month2;
temp_adverse_event_day := temp_adverse_event_day2;
temp_alert_allergen_generic_name := temp_allergen2;
temp_alert_allergen_component := temp_allergen2;
endif;
endif;
elseif (evoked_from_prescriptions = true
and Rx_Other_Allergen_Check = true)
then
patient_nondrug_allergy_names :=
patient_allergy_names
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_category_types :=
patient_allergy_category_type_descriptions
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_years:=
allergy_onset_year_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_months:=
allergy_onset_month_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
patient_nondrug_allergy_days:=
allergy_onset_day_list
where allergen_is_not_drug
and patient_allergy_category_type_descriptions
in (display_alert_types);
(temp_allergen2,
temp_alert_msg2,
temp_category_type2,
temp_adverse_event_year2,
temp_adverse_event_month2,
temp_adverse_event_day2):=
call func_item_catalog_allergy_check with
(
order_name,
false, // prescriptions don{{{SINGLE-QUOTE}}}t have additives
patient_nondrug_allergy_names,
null,
generic_nameID,
patient_nondrug_category_types,
patient_nondrug_allergy_years,
patient_nondrug_allergy_months,
patient_nondrug_allergy_days
);
// combine the Drug Vendor Data alerts and the Item Catalog
// alerts
If exists temp_allergen2
then
if exists temp_allergen or exists temp_alert_msg
then
temp_allergen:= temp_allergen, temp_allergen2;
temp_alert_msg:= temp_alert_msg, temp_alert_msg2;
temp_category_type :=
temp_category_type, temp_category_type2;
temp_adverse_event_year := temp_adverse_event_year,
temp_adverse_event_year2;
temp_adverse_event_month :=
temp_adverse_event_month, temp_adverse_event_month2;
temp_adverse_event_day :=
temp_adverse_event_day, temp_adverse_event_day2;
temp_alert_allergen_generic_name :=
temp_alert_allergen_generic_name, temp_allergen2;
temp_alert_allergen_component :=
temp_alert_allergen_component, temp_allergen2;
else
temp_allergen:= temp_allergen2;
temp_alert_msg:= temp_alert_msg2;
temp_category_type := temp_category_type2;
temp_adverse_event_year := temp_adverse_event_year2;
temp_adverse_event_month := temp_adverse_event_month2;
temp_adverse_event_day := temp_adverse_event_day2;
temp_alert_allergen_generic_name := temp_allergen2;
temp_alert_allergen_component := temp_allergen2;
endif;
endif;
endif;
else
// Send data to the Item-Catalog to check for allergies
(temp_allergen,
temp_alert_msg,
temp_category_type,
temp_adverse_event_year,
temp_adverse_event_month,
temp_adverse_event_day ):= call func_item_catalog_allergy_check with
(
order_name,
order_is_additive,
patient_allergy_names
WHERE patient_allergy_category_type_descriptions
IN display_alert_types,
cat_item_guid,
null,
patient_allergy_category_type_descriptions
WHERE patient_allergy_category_type_descriptions
IN display_alert_types,
allergy_onset_year_list
WHERE patient_allergy_category_type_descriptions
IN display_alert_types,
allergy_onset_month_list
WHERE patient_allergy_category_type_descriptions
IN display_alert_types,
allergy_onset_day_list
WHERE patient_allergy_category_type_descriptions
IN display_alert_types
);
temp_alert_allergen_generic_name := temp_allergen2;
temp_alert_allergen_component := temp_allergen2;
endif; // If DRUG_VENDOR_DATA_ALLERGY_CHECK
// Create the lists used for format the alert message
if exist temp_alert_msg
then
allergen_name_list:= allergen_name_list, temp_allergen;
alert_message_list:= alert_message_list, temp_alert_msg;
alert_category_type_list :=
alert_category_type_list, temp_category_type;
adverse_event_year_list :=
adverse_event_year_list, temp_adverse_event_year;
adverse_event_month_list :=
adverse_event_month_list, temp_adverse_event_month;
adverse_event_day_list :=
adverse_event_day_list, temp_adverse_event_day;
unmapped_allergen_generic_names := "";
temp_unmapped_allergen_generic_name_list := ();
if temp_alert_allergen_id[1] = -2
then
temp_unmapped_allergen_generic_name_list := temp_alert_allergen_generic_name[1];
unmapped_allergen_generic_names := temp_alert_allergen_generic_name[1];
if (unmapped_allergen_generic_names is not null and unmapped_allergen_generic_names <> "" )
then
unmapped_allergen_generic_names := call (unmapped_allergen_generic_names as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "@#", "," as string;
endif;
if (
((exists order_other_allergen_type_list) and (count order_other_allergen_type_list > 0)) OR
((exists unmapped_allergen_type_list) and (count unmapped_allergen_type_list > 0))
)
then
unmapped_allergen_generic_name_filtered_names := "";
//unmapped_allergen_generic_name_filtered_list := ();
unmapped_allergen_generic_name_tlb := ();
// Splitting unmapped_allergens by {{{SINGLE-QUOTE}}}@#{{{SINGLE-QUOTE}}} if multiple are selected
temp_unmapped_allergens_string := TRIM(temp_unmapped_allergen_generic_name_list);
unmapped_allergens_length := length of temp_unmapped_allergens_string;
if (unmapped_allergens_length > 0)
then
// get the first string by finding the first separator @#
separator_index := find "@#" in string temp_unmapped_allergens_string;
while (separator_index > 0) do
single_unmapped_allergen :=
TRIM (substring (separator_index - 1)
characters from temp_unmapped_allergens_string);
if (length of single_unmapped_allergen > 0)
then
unmapped_allergen_generic_name_tlb:= unmapped_allergen_generic_name_tlb, single_unmapped_allergen;
endif;
// remove the extracted unmapped allergen from the string
temp_unmapped_allergens_string :=
TRIM(substring (unmapped_allergens_length)
characters starting at (separator_index + 2)
from temp_unmapped_allergens_string);
// find the position marking the next unmapped_allergen in the string
separator_index := find "@#" in string temp_unmapped_allergens_string;
enddo;
// add the last unmapped_allergen to the list
if separator_index = 0
then
single_unmapped_allergen := TRIM(temp_unmapped_allergens_string);
if (length of single_unmapped_allergen > 0)
then
unmapped_allergen_generic_name_tlb:= unmapped_allergen_generic_name_tlb, single_unmapped_allergen;
endif;
endif;
endif;
// Spliting logic ends here
FOR i in 1 seqto count unmapped_allergen_generic_name_tlb DO
unmapped_allergen_generic_name_item := TRIM(unmapped_allergen_generic_name_tlb[i]);
search_pattern := unmapped_allergen_generic_name_item;
search_pattern := call (search_pattern as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with pending_community_allergy_text_with_formatting, "" as string;
//If (NOT temp_allergen MATCHES PATTERN search_pattern)
If(search_pattern not in temp_allergen)
then
if (unmapped_allergen_generic_name_filtered_names <> "") then
unmapped_allergen_generic_name_filtered_names:= unmapped_allergen_generic_name_filtered_names || ", " || unmapped_allergen_generic_name_item;
Else
unmapped_allergen_generic_name_filtered_names:= unmapped_allergen_generic_name_item;
Endif;
Endif;
ENDDO;
unmapped_allergen_generic_names := unmapped_allergen_generic_name_filtered_names;
endif;
if (unmapped_allergen_generic_names is not null and unmapped_allergen_generic_names <> "" )
then
is_unmapped_order_found := true;
endif;
else
allergen_generic_name_list :=
allergen_generic_name_list, temp_alert_allergen_generic_name;
endif;
allergen_component_generic_name_list :=
allergen_component_generic_name_list, temp_alert_allergen_component;
if temp_alert_allergen_id = -2
then
alert_allergen_id_citation_list := temp_alert_allergen_id;
else
alert_allergen_id_citation_list :=
alert_allergen_id_citation_list, temp_alert_allergen_id;
endif;
alert_reaction_level_list :=
alert_reaction_level_list, temp_alert_reaction_level;
alert_medication_category_name_list :=
alert_medication_category_name_list, temp_alert_medication_category_name;
alert_medication_class_name_list :=
alert_medication_class_name_list, temp_alert_medication_class_name;
alert_allergen_category_type_list :=
alert_allergen_category_type_list, temp_alert_allergen_category_type;
alert_allergen_component_id_list :=
alert_allergen_component_id_list, temp_alert_allergen_component_id;
alert_drug_vendor_text_id_list :=
alert_drug_vendor_text_id_list, temp_alert_drug_vendor_text_id;
alert_medication_category_id_list :=
alert_medication_category_id_list, temp_alert_medication_category_id;
alert_medication_class_id_list:=
alert_medication_class_id_list, temp_alert_medication_class_id;
alert_medication_is_combo_drug_list:=
alert_medication_is_combo_drug_list, temp_alert_medication_is_combo_drug;
temp_message_index:= 1 seqto count(temp_alert_msg);
// Keep the length of the list consistent with the number of alert
// messages
for KK in temp_message_index do
reaction_order_list:= reaction_order_list, order_name;
if alert_allergen_id_citation_list <> -2
then
alert_allergen_id_citation_list :=
alert_allergen_id_citation_list, NULL;
endif;
if KK = 1 AND temp_alert_allergen_id[1] = -2
then
alert_allergen_id_list :=
alert_allergen_id_list, temp_alert_allergen_id[1];
alert_unchecked_allergen_message_list :=
alert_unchecked_allergen_message_list, temp_alert_msg[1];
alert_unchecked_allergen_list :=
alert_unchecked_allergen_list, unmapped_allergen_generic_names;
else
alert_allergen_id_list :=
alert_allergen_id_list, NULL;
alert_unchecked_allergen_message_list :=
alert_unchecked_allergen_message_list, NULL;
alert_unchecked_allergen_list :=
alert_unchecked_allergen_list, NULL;
endif;
alert_reaction_level_list :=
alert_reaction_level_list, NULL;
alert_medication_category_name_list :=
alert_medication_category_name_list, NULL;
alert_medication_class_name_list :=
alert_medication_class_name_list, NULL;
alert_allergen_category_type_list :=
alert_allergen_category_type_list, NULL;
alert_allergen_component_id_list :=
alert_allergen_component_id_list, NULL;
alert_drug_vendor_text_id_list :=
alert_drug_vendor_text_id_list, NULL;
alert_medication_category_id_list :=
alert_medication_category_id_list, NULL;
alert_medication_class_id_list:=
alert_medication_class_id_list, NULL;
alert_medication_is_combo_drug_list:=
alert_medication_is_combo_drug_list, NULL;
enddo; // for KK
endif; // if exist temp_alert_msg
enddo; // for index_item
endif; // if is_reverse_checking
/*--------------------------*/
/* Format the alert message */
/*--------------------------*/
if (is_reverse_checking) and exists sorted_obj_list
then
details_messages := "";
components_found := false;
other_orders_found := false;
combo_drug_name := "";
prev_sort_string := "";
prev_msg_type := "";
process_msg_only := false;
unmapped_medications_list := ();
order_additives_names_list := ();
outpatient_rx_names_list := ();
outpatient_hx_names_list := ();
prescription_names_list := ();
home_medications_names_list := ();
order_prescription_list := ();
// Construct the order/prescription detail messages as well as the
// strings displayed at the top of the message (ex: Order/Additive Name(s))
number_list := 1 seqto count(sorted_obj_list);
for JJ in number_list do
// build the strings that will be displayed
one_order_name := sorted_obj_list[JJ].OrderName;
one_OrderOrAdditive_name := sorted_obj_list[JJ].OrderOrAdditiveName;
one_prescription_name := sorted_obj_list[JJ].PrescriptionName;
one_ComponentName := sorted_obj_list[JJ].ComponentName;
one_ComboDrugName := sorted_obj_list[JJ].ComboDrugName;
one_start_date := sorted_obj_list[JJ].StartDate;
one_status_type := sorted_obj_list[JJ].StatusType;
one_type_code := sorted_obj_list[JJ].TypeCode;
one_IsUnmapped := sorted_obj_list[JJ].IsUnmapped;
one_AdditiveGUID := sorted_obj_list[JJ].AdditiveGUID;
one_PrescriptionID := sorted_obj_list[JJ].PrescriptionID;
one_sort_field := sorted_obj_list[JJ].sort_field;
one_msg_type := sorted_obj_list[JJ].msg_type;
one_alert_message := sorted_obj_list[JJ].allergen_msg;
one_is_combo_drug := sorted_obj_list[JJ].IsComboDrug;
one_hx_rx_type_code := sorted_obj_list[JJ].rx_hx_typecode;
one_alternate_order_type := sorted_obj_list[JJ].AlternateOrderType;
one_order_is_script := sorted_obj_list[JJ].IsScript;
one_entered_date := sorted_obj_list[JJ].EnteredDate;
if (one_alternate_order_type = 2)
then
one_order_is_outpatient := true;
else
one_order_is_outpatient := false;
endif;
// determine if this is the first occurrence of the order/prescription that
// we are processing
if prev_sort_string is not null and prev_sort_string <> ""
then
prev_sort_str_len := length of prev_sort_string;
curr_sort_str_len := length of one_sort_field;
curr_isunmapped_string := one_IsUnmapped;
// parse out the sort string
prev_str := substring (prev_sort_str_len - 3)
characters starting at 1 from prev_sort_string;
curr_str := substring (curr_sort_str_len - 3)
characters starting at 1 from one_sort_field;
if (prev_str = curr_str)
then
process_msg_only := true;
if (prev_isunmapped_string <> curr_isunmapped_string)
then
if (one_OrderOrAdditive_name is not in order_additives_names_list)
then
order_additives_names_list :=
order_additives_names_list, one_OrderOrAdditive_name;
endif;
endif;
else
process_msg_only := false;
endif;
endif;
prev_sort_string := one_sort_field;
prev_msg_type := one_msg_type;
prev_isunmapped_string := one_IsUnmapped;
if (process_msg_only
and one_alert_message is not null
and one_alert_message <> "")
then
// Append the message only
details_messages := details_messages || "\n" || one_alert_message;
else
// since we{{{SINGLE-QUOTE}}}re processing a new object, add a space to separate this object
// from the previously processed object.
if JJ > 1
then
details_messages := details_messages || "\n\n";
endif;
if (alert_if_unmapped and one_IsUnmapped)
then
// construct the unmapped medication list.
// the assumption is that prescriptions will always be mapped, so
// we only consider orders in this case.
if (one_OrderOrAdditive_name is not in unmapped_medications_list)
then
unmapped_medications_list :=
unmapped_medications_list, one_OrderOrAdditive_name;
endif;
elseif (one_OrderOrAdditive_name is not null)
and (one_OrderOrAdditive_name <> "")
then
if (one_order_is_outpatient)
then
if (one_order_is_script = 1)
then
if (one_OrderOrAdditive_name is not in outpatient_rx_names_list)
then
outpatient_rx_names_list :=
outpatient_rx_names_list, one_OrderOrAdditive_name;
endif;
else
if (one_OrderOrAdditive_name is not in outpatient_hx_names_list)
then
outpatient_hx_names_list :=
outpatient_hx_names_list, one_OrderOrAdditive_name;
endif;
endif;
// construct the Order/Additive Name(s) list:
else
if (one_OrderOrAdditive_name is not in order_additives_names_list)
then
order_additives_names_list :=
order_additives_names_list, one_OrderOrAdditive_name;
endif;
endif;
else
// construct prescription name list: ( here the type codes 3 & 4 signify home medications )
if(one_hx_rx_type_code = 3 OR one_hx_rx_type_code = 4)
then
if ( one_prescription_name is not in home_medications_names_list)
then
home_medications_names_list :=
home_medications_names_list, one_prescription_name;
endif;
else
if (one_prescription_name is not in prescription_names_list)
then
prescription_names_list :=
prescription_names_list, one_prescription_name;
endif;
endif;
endif;
// construct the details message
temp_name := ""; // holds the string that will be placed
// in the alert abstract
if (one_ComponentName is not null and one_ComponentName <> ""
and one_ComponentName <> one_ComboDrugName
and one_is_combo_drug)
then
// If component is defined, then create a component message.
// Otherwise, create a prescription message.
details_messages := details_messages || "COMPONENT: {{+R}}"
|| one_ComponentName || "{{-R}} in {{+R}}"
|| one_ComboDrugName || "{{-R}} ";
components_found := true;
combo_drug_name := one_ComboDrugName;
temp_name := one_ComponentName || " component of "
|| one_ComboDrugName || " with ";
if (one_type_code = "Prescription")
then
//( here the type codes 3 & 4 signify home medications )
if ( one_hx_rx_type_code = 3 OR one_hx_rx_type_code = 4 )
then
temp_name := temp_name || one_prescription_name
|| " (home medication)";
else
temp_name := temp_name || one_prescription_name
|| " (prescription)";
endif;
else
temp_name := temp_name || one_order_name || " (order)";
endif;
elseif (one_AdditiveGUID is not null or one_AdditiveGUID <> "0")
then
details_messages := details_messages || "ADDITIVE: {{+R}}"
|| one_OrderOrAdditive_name
|| "{{-R}} in {{+R}}"
|| one_order_name || "{{-R}} ";
other_orders_found := true;
temp_name := one_OrderOrAdditive_name || " IV Additive in "
|| one_order_name
|| " (order)";
elseif (one_type_code = "Prescription")
then
details_messages := details_messages || "{{+R}}"
|| one_prescription_name
|| "{{-R}} ";
other_orders_found := true;
//( here the type codes 3 & 4 signify home medications )
if ( one_hx_rx_type_code = 3 OR one_hx_rx_type_code = 4 )
then
temp_name := one_prescription_name || " (home medication)";
else
temp_name := one_prescription_name || " (prescription)";
endif;
else
// display the order name
details_messages := details_messages || "{{+R}}" || one_order_name
|| "{{-R}} ";
other_orders_found := true;
temp_name := one_order_name || " (order)";
endif;
// add temp name to the list that will be used to populate
// the alert abstract string
if (temp_name is not in order_prescription_list)
then
order_prescription_list := order_prescription_list, temp_name;
endif;
if (one_order_is_outpatient)
then
//if start date is empty, use the entered date
if (one_start_date is null) or (one_start_date = "")
then
details_messages := details_messages || "Entered Date: ";
if (one_entered_date is null) or (one_entered_date = "")
then
details_messages := details_messages || "<N/A>";
else
formatted_entered_date := one_entered_date formatted with "%.4t";
details_messages := details_messages || formatted_entered_date;
endif;
else
details_messages := details_messages || "Start Date: ";
formatted_start_date := one_start_date formatted with "%.4t";
details_messages := details_messages || formatted_start_date;
endif;
else
// determine the <DateType> value
if (one_type_code = "Medication")
then
details_messages := details_messages || "Start Date: ";
else
details_messages := details_messages || "Requested Date: ";
endif;
// format the start date
if (one_start_date is null) or (one_start_date = "")
then
details_messages := details_messages || "<N/A>";
elseif (one_prescription_name is null) or (one_prescription_name = "")
then
formatted_start_date := one_start_date formatted with "%.4t";
details_messages := details_messages || formatted_start_date;
else
//it{{{SINGLE-QUOTE}}}s a prescription
formatted_start_date := one_start_date formatted with "%.2t";
details_messages := details_messages || formatted_start_date;
endif;
endif;
// add the status code
details_messages := details_messages || " Status: "
|| one_status_type || " ";
if (one_type_code = "Prescription")
then
//( here the type codes 3 & 4 signify home medications )
if ( one_hx_rx_type_code = 3 OR one_hx_rx_type_code = 4 )
then
details_messages := details_messages || "Home Medication";
else
details_messages := details_messages || one_type_code;
endif;
else
//Alternate order type 2 is outpatient order
if (one_order_is_outpatient)
then
if (one_order_is_script = 1)
then
details_messages := details_messages || "Prescription";
else
details_messages := details_messages || "Home Medication";
endif;
else
details_messages := details_messages || "Order";
endif;
endif;
// Add the allergen message
if (one_alert_message is not null and one_alert_message <> "")
then
details_messages := details_messages || "\n" || one_alert_message;
else
details_messages := null;
endif;
endif;
enddo; // JJ in number_list do
// conclude false if we{{{SINGLE-QUOTE}}}re not alerting on unmapped orders and only
// unmapped orders/prescriptions have been found.
is_unchecked_allergen_alert := false;
if (exist unmapped_medications_list
and not exist order_additives_names_list
and not exist outpatient_rx_names_list
and not exist outpatient_hx_names_list
and not exist prescription_names_list)
then
if (alert_if_unmapped)
then
is_unchecked_allergen_alert := true;
else
conclude false;
endif;
endif;
// Construct the allergy information of the message.
if (EvokingEventType = entered_allergy.type)
then
entered_or_modified_or_received := "entered";
elseif (EvokingEventType = modified_allergy.type)
then
entered_or_modified_or_received := "modified";
elseif (EvokingEventType = imported_allergy.type)
then
entered_or_modified_or_received := "received";
endif;
if (is_unchecked_allergen_alert)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+C}}UNCHECKED ALLERGEN ALERT - "
|| allergy_name_with_status || "{{-C}}{{-B}}\n"
|| "The " || allergy_name
|| " allergen that was just "
|| entered_or_modified_or_received || ".\n\n";
alert_abstract_string := "Unchecked Allergen - " || allergy_name_with_community;
else
if (allergy_category_type = adverse_event_category_type_enum)
then
alert_destination := "adverse_event_alert";
long_alert_message := long_alert_message || "{{+B}}ADVERSE EVENT ALERT - "
|| allergy_name_with_status
|| "{{-C}}{{-B}}";
if (components_found
and not other_orders_found
and combo_drug_name <> ""
and combo_drug_name is not null)
then
long_alert_message := long_alert_message || "{{+B}} component(s) of "
|| combo_drug_name || "{{-B}}";
endif;
long_alert_message :=
long_alert_message || "\nPotential allergic reaction(s) or "
|| "intolerance(s) to the "
|| allergy_name
|| " Adverse Event that was just "
|| entered_or_modified_or_received || ".\n\n";
alert_abstract_string := allergy_name_with_community || " Adverse Event to ";
elseif (allergy_category_type = intolerance_category_type_enum)
then
alert_destination := "intolerance_alert";
long_alert_message := long_alert_message || "{{+B}}INTOLERANCE ALERT - "
|| allergy_name_with_status || "{{-C}}{{-B}}";
if (components_found
and not other_orders_found
and combo_drug_name <> ""
and combo_drug_name is not null)
then
long_alert_message := long_alert_message || "{{+B}} component(s) of "
|| combo_drug_name || "{{-B}}";
endif;
long_alert_message :=
long_alert_message || "\nPotential intolerance to the "
|| allergy_name
|| " Intolerance that was just "
|| entered_or_modified_or_received || ".\n\n";
alert_abstract_string := allergy_name_with_community || " Intolerance to ";
else
alert_destination := "allergy_alert";
long_alert_message :=
long_alert_message || "{{+B}}{{+C}}ALLERGY ALERT - "
|| allergy_name_with_status || "{{-C}}{{-B}}";
if (components_found
and not other_orders_found
and combo_drug_name <> ""
and combo_drug_name is not null)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+C}} component(s) of "
|| combo_drug_name || "{{-C}}{{-B}}";
endif;
long_alert_message :=
long_alert_message || "\nPotential allergic reaction(s) with the "
|| allergy_name || " Allergy that was just "
|| entered_or_modified_or_received || ".\n\n";
alert_abstract_string := allergy_name_with_community || " Allergy to ";
endif;
if exist order_prescription_list
then
// construct the rest of the alert abstract string
number_list := 1 seqto count(order_prescription_list);
for JJ in number_list do
alert_abstract_string := alert_abstract_string
|| order_prescription_list[JJ];
if JJ < count(order_prescription_list)
then
alert_abstract_string := alert_abstract_string || ", ";
else
alert_abstract_string := alert_abstract_string || ". ";
endif;
enddo;
else
// clear out the abstract string if none of the orders or
// prescription were checked against the entered/modified allergy
alert_abstract_string := "";
endif;
if (alert_if_unmapped and exist unmapped_medications_list)
then
alert_abstract_string := alert_abstract_string || "Unmapped - ";
sorted_unmapped_medications_list := SORT data unmapped_medications_list;
// construct the unmapped medication string
number_list := 1 seqto count(sorted_unmapped_medications_list);
for JJ in number_list do
alert_abstract_string :=
alert_abstract_string
|| sorted_unmapped_medications_list[JJ];
if JJ < count(sorted_unmapped_medications_list)
then
alert_abstract_string := alert_abstract_string || ", ";
else
alert_abstract_string := alert_abstract_string || ". ";
endif;
enddo;
endif;
// construct the rest of the message.
if exist order_additives_names_list
then
long_alert_message := long_alert_message || "Order/Additive Name(s): ";
sorted_order_additives_names_list := SORT data order_additives_names_list;
number_list := 1 seqto count(sorted_order_additives_names_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}"
|| sorted_order_additives_names_list[J]
|| "{{-R}}{{-B}}";
else
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}, "
|| sorted_order_additives_names_list[J]
|| "{{-R}}{{-B}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n";
endif;
if exist outpatient_rx_names_list
then
long_alert_message := long_alert_message || "Prescription Name(s): ";
sorted_outpatient_rx_names_list := SORT data outpatient_rx_names_list;
number_list := 1 seqto count(sorted_outpatient_rx_names_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}"
|| sorted_outpatient_rx_names_list[J]
|| "{{-R}}{{-B}}";
else
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}, "
|| sorted_outpatient_rx_names_list[J]
|| "{{-R}}{{-B}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n";
endif;
if exist outpatient_hx_names_list
then
long_alert_message := long_alert_message || "Home Medication Name(s): ";
sorted_outpatient_hx_names_list := SORT data outpatient_hx_names_list;
number_list := 1 seqto count(sorted_outpatient_hx_names_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}"
|| sorted_outpatient_hx_names_list[J]
|| "{{-R}}{{-B}}";
else
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}, "
|| sorted_outpatient_hx_names_list[J]
|| "{{-R}}{{-B}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n";
endif;
if exist home_medications_names_list
then
long_alert_message := long_alert_message || "Home Medication Name(s): ";
sorted_home_medication_list := sort data home_medications_names_list;
number_list := 1 seqto count(sorted_home_medication_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}"
|| home_medications_names_list[J]
|| "{{-R}}{{-B}}";
else
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}, "
|| home_medications_names_list[J]
|| "{{-R}}{{-B}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n";
endif;
if exist prescription_names_list
then
long_alert_message := long_alert_message || "Prescription Name(s): ";
sorted_prescription_names_list := sort data prescription_names_list;
number_list := 1 seqto count(sorted_prescription_names_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}"
|| sorted_prescription_names_list[J]
|| "{{-R}}{{-B}}";
else
long_alert_message :=
long_alert_message || "{{+B}}{{+R}}, "
|| sorted_prescription_names_list[J]
|| "{{-R}}{{-B}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n";
endif;
// construct the Reaction string
long_alert_message := long_alert_message || "Reaction: ";
if (allergy_severity is null or allergy_severity = "")
then
long_alert_message := long_alert_message || "<N/A>\n";
else
// long_alert_message := long_alert_message || allergy_severity
// || " to "
// || allergy_name || "\n";
long_alert_message := long_alert_message || "{{+C}}{{+B}}" || allergy_severity
|| " to "
|| allergy_name || " {{-C}}{{-B}}" || "\n";
endif;
// construct the Description string
if (allergy_text is not null and allergy_text <> "")
then
long_alert_message := long_alert_message || "Description: "
|| allergy_text || "\n";
endif;
long_alert_message := long_alert_message || "Confidence Level: ";
if (allergy_confidence is not null and allergy_confidence <> "")
then
long_alert_message := long_alert_message || allergy_confidence || "\n";
else
long_alert_message := long_alert_message || "not available\n";
endif;
long_alert_message := long_alert_message || "\n";
endif; // if not is_unchecked_allergen_alert
if alert_if_unmapped and exist unmapped_medications_list
then
long_alert_message := long_alert_message
|| "The following Unmapped medication(s) could not be "
|| "checked. Please use an alternative plan to do the "
|| "check.\n";
number_list := 1 seqto count(unmapped_medications_list);
for J in number_list do
if (J = 1)
then
long_alert_message :=
long_alert_message || "{{+R}}{{+B}}"
|| unmapped_medications_list[J]
|| "{{-B}}{{-R}}";
else
long_alert_message :=
long_alert_message || "{{+R}}{{+B}}, "
|| unmapped_medications_list[J]
|| "{{-B}}{{-R}}";
endif;
enddo;
long_alert_message := long_alert_message || "\n\n";
endif;
// construct the details message section
long_alert_message := long_alert_message || "{{+B}}Details are:{{-B}}\n";
// display the adverse event in the Details section if required.
if (allergy_category_type = adverse_event_category_type_enum)
then
if (allergy_onset_day is not null
and allergy_onset_day > 0
and allergy_onset_month is not null
and allergy_onset_month > 0
and allergy_onset_year is not null
and allergy_onset_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
allergy_onset_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
allergy_onset_month as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
allergy_onset_day as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := last(preferred_date_format);
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
elseif (allergy_onset_month is not null
and allergy_onset_month > 0
and allergy_onset_year is not null
and allergy_onset_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
allergy_onset_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
allergy_onset_month as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := last(preferred_partial_date_format);
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
elseif (allergy_onset_year is not null
and allergy_onset_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
allergy_onset_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := "yyyy";
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
else
adverse_event_date := "N/A";
endif;
long_alert_message :=
long_alert_message || "{{+R}}"
|| allergy_name
|| "{{-R}} Adverse Event Date: "
|| adverse_event_date;
// construct the Reaction string
long_alert_message := long_alert_message || "\nReaction: ";
if (allergy_severity is null or allergy_severity = "")
then
long_alert_message := long_alert_message || "<N/A>";
else
// long_alert_message := long_alert_message || allergy_severity
// || " to "
// || allergy_name;
long_alert_message := long_alert_message || "{{+C}}{{+B}}" || allergy_severity
|| " to "
|| allergy_name || "{{-C}}{{-B}}";
endif;
// construct the Description string
if (allergy_text is not null and allergy_text <> "")
then
long_alert_message := long_alert_message || "\nDescription: "
|| allergy_text;
endif;
long_alert_message := long_alert_message || "\nConfidence Level: ";
if (allergy_confidence is not null and allergy_confidence <> "")
then
long_alert_message := long_alert_message || allergy_confidence;
else
long_alert_message := long_alert_message || "not available";
endif;
long_alert_message := long_alert_message || "\nThis patient has an adverse "
|| "event with "
|| allergy_name
|| ".\n\n";
endif;
// append the detail messages to the alert message
if details_messages is null
then
long_alert_message := "";
else
long_alert_message := long_alert_message || details_messages;
endif;
elseif exist alert_message_list
then
alert_adverse_event_message_list := "";
allergy_message_list := "";
intolerance_message_list := "";
allergy_names := "";
abstract_allergy_names := "";
allergy_name_list := "";
adverse_event_names := "";
abstract_adverse_event_names := "";
adverse_event_name_list := "";
intolerance_names := "";
abstract_intolerance_names := "";
intolerance_name_list := "";
temp_allergy_message_list := "";
temp_alert_adverse_event_message_list := "";
temp_intolerance_message_list:= "";
number_list:= 1 seqto count(alert_message_list);
display_alert_for_this_allergy := true;
alert_summary := "";
summary_allergy_name_list := ();
for JJ in number_list do
// Get one order, allergen, and alert message
one_order_name:= reaction_order_list[JJ];
temp_one_allergen_name:= allergen_name_list[JJ];
one_alert_message:= alert_message_list[JJ];
one_category_type:= alert_category_type_list[JJ];
one_adverse_event_year := adverse_event_year_list[JJ];
one_adverse_event_month := adverse_event_month_list[JJ];
one_adverse_event_day := adverse_event_day_list[JJ];
one_generic_name := allergen_generic_name_list[JJ];
previous_generic_name := allergen_generic_name_list[JJ-1];
next_generic_name := allergen_generic_name_list[JJ+1];
one_component_generic_name := allergen_component_generic_name_list[JJ];
one_alert_allergen_id := alert_allergen_id_list[JJ];
one_alert_unchecked_allergen := alert_unchecked_allergen_list[JJ];
one_alert_unchecked_allergen_message := alert_unchecked_allergen_message_list[JJ];
one_alert_reaction_level := alert_reaction_level_list[JJ];
one_alert_medication_category_name := alert_medication_category_name_list[JJ];
one_alert_medication_class_name := alert_medication_class_name_list[JJ];
one_alert_allergen_category_type := alert_allergen_category_type_list[JJ];
one_alert_allergen_component_id := alert_allergen_component_id_list[JJ];
one_alert_drug_vendor_text_id := alert_drug_vendor_text_id_list[JJ];
one_alert_medication_category_id := alert_medication_category_id_list[JJ];
one_alert_medication_class_id := alert_medication_class_id_list[JJ];
one_alert_is_combo_drug := alert_medication_is_combo_drug_list[JJ];
if (one_alert_allergen_id = -2)
then
if not (evoked_from_prescriptions)
then
if evoking_order_is_outpatient
then
if evoking_order_is_script
then
name_label:= "Prescription Name:";
else
name_label := "Home Medication Name:";
endif;
else
name_label := "Order/Additive Name:";
endif;
unmapped_alert_message := "";
if (
((exists order_other_allergen_type_list) and (count order_other_allergen_type_list > 0)) OR
((exists unmapped_allergen_type_list) and (count unmapped_allergen_type_list > 0))
)
then
unmapped_alert_message := one_alert_unchecked_allergen_message
|| "\n" || indent || name_label || " {{+R}}{{+B}}" || one_order_name
|| "{{-B}}{{-R}}";
unmappedbr := "";
if long_alert_message_unmapped is not null and long_alert_message_unmapped <> ""
then
unmappedbr := "\n\n";
endif;
long_alert_message_unmapped :=
long_alert_message_unmapped || unmappedbr || "{{+B}}{{+C}}UNCHECKED ALLERGEN ALERT - "
|| one_alert_unchecked_allergen || "{{-C}}{{-B}}\n\n"
|| unmapped_alert_message;
else
unmapped_alert_message := "\n" || indent || name_label || " {{+R}}{{+B}}" || one_order_name
|| "{{-B}}{{-R}}";
if long_alert_message_unmapped is null or long_alert_message_unmapped = ""
then
long_alert_message_unmapped := "{{+B}}{{+C}}UNCHECKED ALLERGEN ALERT - "
|| one_alert_unchecked_allergen || "{{-C}}{{-B}}\n\n"
|| one_alert_unchecked_allergen_message
|| unmapped_alert_message;
else
long_alert_message_unmapped := long_alert_message_unmapped || unmapped_alert_message;
endif;
endif;
endif; //Not evoked_from_prescriptions
else
// Find the associated severities and confidences
patient_allergy_found:= (temp_one_allergen_name = patient_allergy_names)
and (one_category_type = patient_allergy_category_type_descriptions)
and (one_adverse_event_year = allergy_onset_year_list)
and (one_adverse_event_month = allergy_onset_month_list)
and (one_adverse_event_day = allergy_onset_day_list);
confidence:=
first(patient_allergy_confidences where patient_allergy_found);
severity:=
first(patient_allergy_severities where patient_allergy_found);
description :=
first (patient_allergy_descriptions where patient_allergy_found);
allergy_decl_status :=
first (allergy_decl_statuses where patient_allergy_found);
/* tms reduce alerts to elimniate drug-class reactions */
if one_alert_reaction_level is not null
and (one_alert_reaction_level as number) > 2
then
display_alert_for_this_allergy := false;
else
display_alert_for_this_allergy := true;
endif;
/* tms end reduce alerts to elimniate drug-class reactions */
if display_alert_for_this_allergy = true
then
if one_component_generic_name IS NOT NULL AND
one_component_generic_name <> "" AND
one_component_generic_name <> one_generic_name
AND one_alert_is_combo_drug IS NOT NULL
AND one_alert_is_combo_drug = 1
then
one_allergen_name := temp_one_allergen_name ||
" in " || one_order_name;
else
one_allergen_name := temp_one_allergen_name;
endif;
long_alert_message := "";
if (one_alert_message is not null)
then
if alert_on_demand_source = "Worksheet"
and (EvokingEventType = alert_check_order.type
OR EvokingEventType = alert_check_prescription.type)
then
one_order_name := one_order_name || "(unsubmitted medication)";
endif;
// Create the long alert message
long_alert_message:= "\n\n" || one_alert_message;
if (one_category_type = "Adverse Event")
then
if (one_adverse_event_day is not null
and one_adverse_event_day > 0
and one_adverse_event_month is not null
and one_adverse_event_month > 0
and one_adverse_event_year is not null
and one_adverse_event_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
one_adverse_event_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
one_adverse_event_month as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
one_adverse_event_day as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := last(preferred_date_format);
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
elseif (one_adverse_event_month is not null
and one_adverse_event_month > 0
and one_adverse_event_year is not null
and one_adverse_event_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
one_adverse_event_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
one_adverse_event_month as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := last(preferred_partial_date_format);
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
elseif (one_adverse_event_year is not null
and one_adverse_event_year > 0 )
then
AdverseEventDateObj := new net_object {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}} with (
one_adverse_event_year as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month
1 as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); // Day
DateFormatString := "yyyy";
adverse_event_date := call AdverseEventDateObj.ToString
with DateFormatString;
else
adverse_event_date := "";
endif;
if adverse_event_date is not null
then
long_alert_message := long_alert_message || "\n"
||indent || "Adverse Event Date: " || adverse_event_date;
endif; //adverse_event_date is not null
endif; //one_category_type = "Adverse Event"
if (evoked_from_prescriptions)
then
if (evoking_prescription_description = "Hx" OR evoking_prescription_description = "eHx" )
then
long_alert_message:= long_alert_message
|| "\n" || indent || "Home Medication Name: {{+R}}{{+B}}" || one_order_name
|| "{{-B}}{{-R}}";
else
long_alert_message:= long_alert_message
|| "\n" || indent || "Prescription Name: {{+R}}{{+B}}" || one_order_name
|| "{{-B}}{{-R}}";
endif;
else
if evoking_order_is_outpatient
then
if evoking_order_is_script
then
name_label:= "Prescription Name:";
else
name_label := "Home Medication Name:";
endif;
else
name_label := "Order/Additive Name:";
endif;
long_alert_message:= long_alert_message
|| "\n" || indent || name_label || " {{+R}}{{+B}}" || one_order_name
|| "{{-B}}{{-R}}";
endif; //evoked_from_prescriptions
// construct the Reaction string
long_alert_message := long_alert_message || "\n" || indent || "Reaction: ";
if (exist severity)
then
// long_alert_message := long_alert_message || severity
// || " to "
// || one_allergen_name
// || "\n";
long_alert_message := long_alert_message || " {{+C}}{{+B}}" || severity
|| " to "
|| one_allergen_name || " {{-C}}{{-B}}"
|| "\n";
else
long_alert_message := long_alert_message || "<N/A>";
endif;
// construct the Description string
if (exist description)
then
long_alert_message := long_alert_message || indent
|| "Description: "
|| description
|| "\n";
endif;
long_alert_message := long_alert_message || indent
|| "Confidence Level: ";
if (exist confidence)
then
long_alert_message := long_alert_message || confidence;
else
long_alert_message := long_alert_message || "not available";
endif;
if (one_category_type = "Allergy" or (one_category_type is null and one_allergen_name is not null )
or (one_category_type is null and one_alert_message is not null))
then
//Do not insert duplicate long_alert_message
if(long_alert_message NOT IN temp_allergy_message_list)
then
temp_allergy_message_list := temp_allergy_message_list, long_alert_message;
allergy_message_list := allergy_message_list
|| long_alert_message;
endif;
if (one_allergen_name is not null and one_allergen_name <> ""
and one_allergen_name NOT IN allergy_name_list )
then
if allergy_names <> ""
then
allergy_names := allergy_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
allergy_names := "{{+B}}" || allergy_names || temp_one_allergen_name || pending_community_allergy_text_with_formatting || "{{-B}}";
else
allergy_names := "{{+B}}" || allergy_names || temp_one_allergen_name || "{{-B}}";
endif;
if abstract_allergy_names <> ""
then
abstract_allergy_names := abstract_allergy_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
abstract_allergy_names := abstract_allergy_names || temp_one_allergen_name || pending_community_allergy_abstract_alert_text;
else
abstract_allergy_names := abstract_allergy_names || temp_one_allergen_name;
endif;
allergy_name_list := allergy_name_list, one_allergen_name;
endif;
elseif (one_category_type = "Adverse Event")
then
if (long_alert_message NOT IN temp_alert_adverse_event_message_list)
then
temp_alert_adverse_event_message_list := temp_alert_adverse_event_message_list || long_alert_message;
alert_adverse_event_message_list := alert_adverse_event_message_list
|| long_alert_message;
endif;
if (one_allergen_name is not null and one_allergen_name <> ""
and one_allergen_name NOT IN adverse_event_name_list )
then
if adverse_event_names <> ""
then
adverse_event_names := adverse_event_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
adverse_event_names := "{{+B}}" || adverse_event_names || temp_one_allergen_name || pending_community_allergy_alert_text || "{{-B}}";
else
adverse_event_names := "{{+B}}" || adverse_event_names || temp_one_allergen_name || "{{-B}}";
endif;
if abstract_adverse_event_names <> ""
then
abstract_adverse_event_names := abstract_adverse_event_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
abstract_adverse_event_names := abstract_adverse_event_names || temp_one_allergen_name || pending_community_allergy_abstract_alert_text;
else
abstract_adverse_event_names := abstract_adverse_event_names || temp_one_allergen_name;
endif;
adverse_event_name_list := adverse_event_name_list, one_allergen_name;
endif;
elseif (one_category_type = "Intolerance")
then
if (long_alert_message NOT IN temp_intolerance_message_list)
then
temp_intolerance_message_list := temp_intolerance_message_list || long_alert_message;
intolerance_message_list := intolerance_message_list
|| long_alert_message;
endif;
if (one_allergen_name is not null and one_allergen_name <> ""
and one_allergen_name NOT IN intolerance_name_list )
then
if intolerance_names <>""
then
intolerance_names := intolerance_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
intolerance_names := "{{+B}}" || intolerance_names || temp_one_allergen_name || pending_community_allergy_alert_text || "{{-B}}";
else
intolerance_names := "{{+B}}" || intolerance_names || temp_one_allergen_name || "{{-B}}";
endif;
if abstract_intolerance_names <> ""
then
abstract_intolerance_names := abstract_intolerance_names || ", ";
endif;
if (allergy_decl_status = "Pending")
then
abstract_intolerance_names := abstract_intolerance_names || temp_one_allergen_name || pending_community_allergy_abstract_alert_text;
else
abstract_intolerance_names := abstract_intolerance_names || temp_one_allergen_name;
endif;
intolerance_name_list := intolerance_name_list, one_allergen_name;
endif;
endif;
endif;
endif;
endif;//one_alert_allergen_id
enddo; // for JJ
index_list:= 1 seqto (count temp_alert_allergen_component);
for index_item in index_list do
allergy_item := temp_alert_allergen_component[index_item];
if allergy_item IS NOT NULL
then
if alert_summary = "" then
summary_allergy_name_list := allergy_item;
alert_summary := allergy_item;
else
if allergy_item NOT IN summary_allergy_name_list then
summary_allergy_name_list := summary_allergy_name_list, allergy_item;
alert_summary := alert_summary || ", " || allergy_item;
endif;
endif;
endif;
enddo;
long_alert_message := "";
alert_abstract_string := "";
if allergy_message_list is not null and allergy_message_list <> ""
then
long_alert_message := "{{+C}}{{+B}}ALLERGY ALERT - "
|| allergy_names || "{{-B}}{{-C}}" || allergy_message_list;
alert_destination := "allergy_alert";
alert_abstract_string := alert_abstract_string || abstract_allergy_names
|| " Allergy; ";
endif;
if alert_adverse_event_message_list is not null
and alert_adverse_event_message_list <> ""
then
long_alert_message :=
long_alert_message || "\n\n{{+B}}ADVERSE EVENT ALERT - "
|| adverse_event_names || "{{-B}}{{-C}}"
|| alert_adverse_event_message_list;
alert_abstract_string :=
alert_abstract_string
|| abstract_adverse_event_names
|| " Adverse Event; ";
if (alert_destination = "")
then
alert_destination := "adverse_event_alert";
endif;
endif;
if intolerance_message_list is not null
and intolerance_message_list <> ""
then
long_alert_message :=
long_alert_message || "\n\n{{+B}}INTOLERANCE ALERT - "
|| intolerance_names || "{{-B}}{{-C}}" || intolerance_message_list;
alert_abstract_string :=
alert_abstract_string
|| abstract_intolerance_names
|| " Intolerance; ";
if (alert_destination = "")
then
alert_destination := "intolerance_alert";
endif;
endif;
if ( is_unmapped_order_found = true )
then
unmapped_br := "";
if long_alert_message is not null and long_alert_message <> ""
then
unmapped_br := "\n\n\n";
endif;
long_alert_message_unmapped := unmapped_br || long_alert_message_unmapped;
if (alert_destination = "")
then
alert_destination := "allergy_alert";
alert_abstract_string := alert_abstract_string || abstract_allergy_names || " Allergy; ";
endif;
endif;
endif; // if is_reverse_checking
mdo_reference_list:=();
complet_multum_references:="";
// Display citiations details
multum_citations_string:="{{+B}}Citations{{-B}}:\n {{+I}}Note: The following citations"
|| " are from Cerner Multum, Inc. If your local facility has modified the"
|| " explanation of the conflict in the alert message, the citations below"
|| " may or may not apply.{{-I}}";
// Display none citiations details
citations_string:="{{+B}}Citations{{-B}}: None";
if is_reverse_checking
then
ref_number_list:= 1 seqto count(sorted_obj_list);
for JJ in ref_number_list do
instance := new Med_Data_Object;
instance.Sort_field := sorted_obj_list[JJ].DrugClassName;
instance.ExternalDrugCode := sorted_obj_list[JJ].ExternalDrugCode;
instance.TextTitle:= sorted_obj_list[JJ].DrugClassName;
instance.DrugClassID:= sorted_obj_list[JJ].DrugClassID;
if instance.TextTitle is not null
then
mdo_reference_list := mdo_reference_list, instance;
endif;
enddo;
else
ref_number_list:= 1 seqto count(alert_allergen_id_citation_list);
for JJ in ref_number_list do
instance := new Med_Data_Object;
instance.Sort_field := alert_medication_class_name_list[JJ];
if alert_allergen_component_id_list[JJ] <> alert_allergen_id_citation_list[JJ]
then
instance.ExternalDrugCode := alert_allergen_component_id_list[JJ];
else
instance.ExternalDrugCode := alert_allergen_id_citation_list[JJ];
endif;
instance.TextTitle:= alert_medication_class_name_list[JJ];
instance.DrugClassID:= alert_medication_class_id_list[JJ];
if instance.TextTitle is not null
then
mdo_reference_list := mdo_reference_list, instance;
endif;
enddo;
endif; // if is_reverse_checking
if count(ref_number_list) > 0
then
sorted_obj_list := SORT Sort_field DATA mdo_reference_list;
if exist sorted_obj_list
then
number_list := 1 seqto count(sorted_obj_list);
for JJ in number_list do
one_TextTitle := sorted_obj_list[JJ].TextTitle;
one_ExternalDrugCode := sorted_obj_list[JJ].ExternalDrugCode;
one_DrugClassID := sorted_obj_list[JJ].DrugClassID;
if (JJ > 1)
then
PreviousDrugClassID :=
sorted_obj_list[JJ-1].DrugClassID;
else
PreviousDrugClassID := null;
endif;
if (PreviousDrugClassID IS NULL
OR
PreviousDrugClassID <> one_DrugClassID
OR (PreviousDrugClassID = one_DrugClassID AND multum_references IS NULL ))
then
// build up list of refrences/Citations
(multum_references, multum_date, ref_count):=
call func_multum_references with
"rtf",
"allrgy",
one_TextTitle,
null,
null,
null,
one_ExternalDrugCode,
null;
if multum_references is not null
then
if complet_multum_references is null or complet_multum_references=""
then
complet_multum_references:= multum_references;
citations_string:=multum_citations_string;
else
complet_multum_references:= complet_multum_references
|| multum_references;
endif;
endif;
endif;
enddo;//for JJ in number_list do
endif;//if exist sorted_obj_list
endif;
/*---------------*/
/* Clinical Rule */
/*---------------*/
if long_alert_message is not null and long_alert_message <> ""
then conclude true;
endif;
if (is_unmapped_order_found = true) and long_alert_message_unmapped is not null and long_alert_message_unmapped <> ""
then
conclude true;
endif;
;;
action:
if is_uncoded_allergen and alert_if_new_uncoded_allergen
then
uncoded_allergen_alert.alert_abstract := alert_abstract_string;
uncoded_allergen_alert.references := uncoded_allergen_alert.references
|| revision_date_string || "\n\n" || citations_string;
write uncoded_allergen_msg
at uncoded_allergen_alert;
elseif (missing_severity and alert_if_severity_missing_in_sequence)
OR is_unchecked_allergen_alert
then
unchecked_allergen_alert.alert_abstract := alert_abstract_string;
unchecked_allergen_alert.references := unchecked_allergen_alert.references
|| revision_date_string || "\n\n" || citations_string;
if (is_unchecked_allergen_alert)
then
write long_alert_message
at unchecked_allergen_alert;
else
write unchecked_allergen_msg
at unchecked_allergen_alert;
endif;
elseif alert_destination = "intolerance_alert"
then
intolerance_alert.references := intolerance_alert.references
|| revision_date_string || "\n\n" || citations_string
|| "\n\n" || complet_multum_references;
intolerance_alert.alert_abstract := alert_abstract_string;
write long_alert_message
at intolerance_alert;
if(is_unmapped_order_found = true)
then
write long_alert_message_unmapped
at intolerance_alert;
endif;
elseif alert_destination = "adverse_event_alert"
then
adverse_event_alert.references := adverse_event_alert.references
|| revision_date_string || "\n\n" || citations_string
|| "\n\n" || complet_multum_references;
adverse_event_alert.alert_abstract := alert_abstract_string;
write long_alert_message
at adverse_event_alert;
if(is_unmapped_order_found = true)
then
write long_alert_message_unmapped
at adverse_event_alert;
endif;
elseif alert_destination = "allergy_alert"
then
allergy_alert.references := allergy_alert.references
|| revision_date_string || "\n\n" || citations_string
|| "\n\n" || complet_multum_references;
allergy_alert.alert_abstract := alert_abstract_string;
if( (allergy_names is not null and allergy_names <> "") OR (allergy_name is not null and allergy_name <> "") )
then
write long_alert_message
at allergy_alert;
endif;
if(is_unmapped_order_found = true)
then
write long_alert_message_unmapped
at allergy_alert;
endif;
endif;
;;
Urgency: 90;;
end: