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

2402 lines
87 KiB
Plaintext

maintenance:
title: Drug and Pregnancy and Lactation conflicts;;
mlmname: STD_PREGNANCY_AND_LACTATION;;
arden: version 2.5;;
version: 18.4;;
institution: Allscripts, Standard MLM;;
author: Allscripts Healthcare Solutions, Inc.;;
specialist: ;;
date: 2018-10-26;;
validation: testing;;
/* P r o p r i e t a r y N o t i c e */
/* Unpublished (c) 2014 - 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:
Generate a warning when medications are entered that conflict with Lactation,
Pregnancy, or the possibility of Pregnancy.
;;
explanation:
This MLM generates Alerts for both pregnancy and lactation drug contraindications.
The site can control how these Alerts are generated by using filters defined in the
MLM and via configuration done with Multum Data Configuration Dictionary.
Pregnancy/Lactation drug conflict checking occurs when the following happens:
1. The evoking-event is
* a MEDICATION ORDER originating from Sunrise Clinical Manager
or Sunrise Medication Manager
* Medication Outpatient orders from Order Reconciliation Manager
* a PRESCRIPTION originating from Sunrise Prescription Writer
* an update to pregnancy or lactation physical notes
2. Drug Conflicts are checked at the following times:
In Clinical Manager:
* 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.
* OrderEnterIVADDITVE - 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.
In Medication Manager:
* OrderInitPharmacy - Checking occurs when the Clinical Manager 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.
In Prescription Writer:
* PrescriptionInit - Checking occurs when the Prescription Writer user
selects an drug. At this point, the prescription object are not fully
populated since the order details have not been completed. The drug name
is known.
* PrescriptionRenew - Checking occurs when the Prescription Writer user
selects an existing prescription and clicks Renew.
In Patient Info Data Entry:
* PhysNoteEnter - Checking occurs when the user clicks OK after entering
Pregnancy/Lactation information at the Data Entry option in Patient Info.
* PhysNoteModify - Checking occurs when the user clicks OK after updating
Pregnancy/Lactation information at the Data Entry option in Patient Info.
In 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.
3. The facility must set the send_alert flag to indicate whether the
alert message should be sent to the ancillary system:
If this field is set to "" or left blank, then CDS Controller will use the
{{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} setting in the AlertTypes dictionary.
(NOTE that the default AlertTypes dictionary 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.)
NOTE this flag only applies to orders.
"DoNotSend" = do not send the alert regardless of the AlertTypes dictionary
setting for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
"Send" = send the alert regardless of the AlertTypes dictionary setting
for the {{{SINGLE-QUOTE}}}Send with order{{{SINGLE-QUOTE}}} flag
4. The facility must set the flag that indicates the order is not mapped to
Multum. Setting this flag to true will cause an Alert to be displayed to the
user warning the user that the order could not be checked as it is not
mapped.
NOTE this flag only applies to orders.
alert_if_unmapped = TRUE;
5. The facility must set the warning level filter for the Lactation Alert in the
Multum Data Configuration Dictionary - Lactation Data. The options are:
* None
* No Lactation Literature Available
* Minor Lactation Warning
* Major Lactation Warning
6. The facility must set the warning level filter for the Pregnancy Alert in the
Multum Data Configuration Dictionary - Pregnancy Data.
NOTE this filter is set separately for Males, Pregnant Females, and
Non-Pregnant Females:
* None
* Minor
* Major
7. The facility must set the FDA Classification level filter for the Pregnancy
Alert in the Multum Data Configuration Dictionary - Pregnancy Data.
Note multiples can be selected:
* Pregnancy Category A - Controlled studies show no risk.
* Pregnancy Category B - No evidence of risk in humans.
* Pregnancy Category C - Risk cannot be ruled out.
* Pregnancy Category D - Positive evidence of risk.
* Pregnancy Category N - FDA has not classified the drug.
* Pregnancy Category X - Contraindicated.
8. The facility can review each drug and determine if that particular drug should
not generate an alert for any of the following combinations using the Multum
Data Configuration Dictionary:
* Exclude Male
* Exclude Pregnant Female
* Exclude Non-Pregnant Female
9. The facility can set the age range to be used for Females and Males within
this MLM:
* lower_limit_female_age_range := 10;
* upper_limit_female_age_range := 55;
* lower_limit_male_age_range := 10;
* upper_limit_male_age_range := 95;
10. The facility can set the number of days after EDD, Pregnancy data entered
or Lactation Data entered that the data is considered to be outdated.
is_pregnant_data_valid_interval := 268;
EDD_data_valid_interval := 2;
is_lactating_data_valid_interval := 360;
NOTE the following flags have all been defaulted to FALSE. This means that no
alert will be generated if the patient{{{SINGLE-QUOTE}}}s age or gender is unknown, if there
is no pregnancy information on patients, or if the pregnancy data is
outdated.
11. The facility can set MLM flags to indicate if the user should be warned about any
missing data.
alert_if_missing_gender_data := FALSE;
alert_if_missing_age_data := FALSE;
alert_if_missing_preg_lact_data := FALSE;
12. The facility can set MLM flags to indicate if the user should be reminded to update
pregnancy and lactation data.
alert_using_outdated_preg_lact_data := FALSE;
13. The facility can set MLM flags to indicate if an Alert should be generated
using outdated pregnancy or lactation data.
alert_if_outdated_preg_lact_data := FALSE;
14. The facility can set MLM flags to indicate if an Alert should be generated
using unknown or missing pregnancy or lactation data.
alert_if_unknown_preg_lact_data := FALSE;
15. The facility can set ambiguous gender codes in this list. When the gender is
ambiguous, that is other or unknown, and the pregnancy or lactation status of
the patient is missing, the MLM logic cannot determine which age range to use.
Therefore it cannot determine whether to issue a Drug conflict Alert.
The MLM will display a missing data Alert letting the user know that the MLM
could not determine whether an alert should be posted. "There is no gender
information on this patient, unable to determine whether a pregnancy drug
contraindication alert should be posted."
The following variable in the MLM allows sites to indicate which Ambiguous
Genders to ignore and not display a missing gender message. The site can
set the types of ambiguous genders that they want a missing data Alert to
be issued for. If the list is empty, no missing data checking will be
performed. The default = ().
ambiguous_gender_list:= ("Other", "Unknown");
16. The facility can set which outpatient order types should be checked when retrieving existing meds.
Add "Outpatient Hx" to include Home Medications ("Outpatient Rx", "Outpatient Hx")
check_outpatient_orders := ("Outpatient Rx");
17. The facility can set MLM flag to allow the site to determine where they want to see
Pregnancy Lactation Drug Conflicts for Community Medications upon acceptance as a
Sunrise medication. Set the flag to True to turn on Community Medication checking.
The default = False;
enable_community_data_medication_alerts := False;
18. The facility can set MLM flag to allow the site to control the "text" that is displayed in
the alert message for Community Medications workflows versus a Sunrise Medication.
The default = " ( Pending ) " . The alert text is configurable.
pending_community_medication_alerts_text := " (Pending) " ;
19. The facility can set MLM flag to exclude alerts about Pregnancy Lactation Drug Conflicts for
Community Medications in the physical note workflows. The default = empty list ()
indicates all triggers are included. The trigger names must be strings.
Use double-quotes around the trigger name.
Use ( "PhysNoteModify" , "PhysNoteEnter" ) to exclude
PhysNoteModify and PhyNoteEnter triggers. Do not include medication triggers
in this list, as this MLM does not retrieve Community Medications, when it is triggered
by a medication.
community_data_excluded_triggers_list := ( "PhysNoteModify", "PhysNoteEnter");
20. The facility can set MLM flag to limit Pregnancy Lactation drug conflict alerts for
Community Medication by record age. The default is 366, which means exclude
any community medication that is older than 366 days. The number is configurable
and can be set to a smaller or larger positive whole number. Set the flag to NULL to
include all pending community medications, regardless of its age.
exclude_pending_community_meds_older_than_days := 366;
Change History:
09.30.2019 TMS Updated alert to require reason when alert presented to user not in physician/physician extender
group. CSR 37977
;;
keywords: Pregnancy and Lactation
;;
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:
/***************Make Changes To Spelling And Flags In This Section*******************/
/* Set the number of days that the data will be considered outdated after Is Patient
Pregnant has been set to Yes. Default = 268. */
is_pregnant_data_valid_interval:= 268;
/* Set the number of days that the data will be considered outdated after the
Expected Delivery Date (EDD) has passed. Default = 2. */
EDD_data_valid_interval:= 2;
/* Set the number of days that the data will be considered outdated after Is Patient
Breastfeeding has been set to Yes. Default = 360. */
is_lactating_data_valid_interval:= 360;
/* Set to True to display a message that data, such as age, is missing.
Default = FALSE for all. */
alert_if_missing_gender_data:= FALSE;
alert_if_missing_age_data:= FALSE;
alert_if_missing_preg_lact_data:= FALSE;
/* Set to true if you want to display a message that pregnancy or lactation data is
outdated. Default = FALSE. */
alert_if_outdated_preg_lact_data:= FALSE;
/* Set to true if an Alert should be generated using outdated pregnancy or lactation
data. Default = FALSE. */
alert_using_outdated_preg_lact_data:= FALSE;
/* Set to true if an Alert should be generated using unknown or missing pregnancy or
lactation data. Default = FALSE. */
alert_if_unknown_preg_lact_data := FALSE;
/* Set the site gender codes that are associated with Other or Unknown that a
missing data Alert should be issued for. If left empty no Alert will be issued
for missing data for these gender definitions. The default = ().*/
// alert_ambigous_gender_list := ("Undetermined","Did Not Ask");
ambiguous_gender_list:= ();
/* Change limits for female child bearing age. Default = 10-55. */
lower_limit_female_age_range:= 10;
upper_limit_female_age_range:= 55;
/* Change limits for male age range. Default = 10-95. */
lower_limit_male_age_range:= 10;
upper_limit_male_age_range:= 95;
/* Set to true if you want to display a message for any unmapped drugs.*/
alert_if_unmapped:= TRUE;
/*Add "Outpatient Hx" to include Home Medications ("Outpatient Rx", "Outpatient Hx")*/
check_outpatient_orders := ("Outpatient Rx");
/* Set the text for this variable to indicate whether to send/print the Alert
message. */
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 it is restricted dictionary or not.
Selections are: TRUE, FALSE*/
// UDDD_is_restricted := FALSE;
// Enter the list of PhysNote triggers that you want to exclude
// from community medication checking.
// The trigger names must be strings.
// Use double-quotes around the trigger name.
// Do not put any medication triggers in the list below
// because this MLM only retrieves community medications
// from Physical Note Triggers.
// Depending on which behavior is wanted, edit as follows:
// *Use () means all triggers are included.
// *Use ("PhysNoteModify", "PhysNoteEnter") to exclude PhysNoteModify and PhysNoteEnter
community_data_excluded_triggers_list:= ();
// The pregnancy and lactation drug conflict alert flags are as follows:
// Set this flag to TRUE to include community medication data.
// Set this flag to FALSE to suppress community medication data (default).
enable_community_data_medication_alerts := false;
//Set flag to exclude pending Community Medications that are older that the days specified by the flag value
exclude_pending_community_meds_older_than_days := 366;
// Enter the text to differentiate community medication in pregnancy lactation alerts:
// Set this flag to " (Pending)" to include pending community medication data for MLM.
pending_community_medication_alert_text := " (Pending)";
fire_on_UserCPOE := ("MD","DO","DDS","DPM","PA","PA-C","CRNP","IT");
fire_on_User := ("RN","RPh");
/* Get the current user{{{SINGLE-QUOTE}}}s occupation*/
(user_id,userguid) :=read last {UserInfo: idcode, guid};
UserCode, OrderRole := read last
{"Select occupationcode, orderroletype "
||" From cv3user with (nolock) "
||" Where Guid = " || SQL(userguid) };
If usercode in fire_on_UserCPOE then
sync_alert_dialog:= "";
UDDD_dictionary_name := "";
UDDD_is_restricted := FALSE;
continue_processing := true;
elseif usercode in fire_on_User then
sync_alert_dialog:= "Must Comment";
UDDD_dictionary_name := "AlertAckComment";
UDDD_is_restricted := TRUE;
continue_processing := true;
else continue_processing := false;
endif;
/* Alert destination. MLM logic will set the other properties later. */
pregnancy_lactation_alert_destination:= DESTINATION {Alert} WITH
[alert_type:= "Warning",
short_message:= "Pregnancy and Lactation Warning",
priority:= "High",
scope:= "Chart",
send_with_order := send_alert,
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
];
/* The following trigger events will evoke this MLM. */
/* Physical Note entry/modification events. */
phys_note_enter_event:= EVENT { PhysNoteEnter Any PhysicalNote :
Where (TypeCode="IS PREGNANT" And (Text = "Yes" Or Text = "No" Or Text = "Unknown")) Or
(TypeCode="IS LACTATING" And (Text = "Yes" Or Text = "No" Or Text = "Unknown")) };
phys_note_modify_event:= EVENT { PhysNoteModify Any PhysicalNote :
Where (TypeCode="IS PREGNANT" And (Text = "Yes" Or Text = "No" Or Text = "Unknown")) Or
(TypeCode="IS LACTATING" And (Text = "Yes" Or Text = "No" Or Text = "Unknown")) };
/* Order entry/modification events. */
order_init_event:= EVENT {OrderInitNoIVAdditives User Order:
Where TypeCode = "Medication" };
patient_group_order_init_event:= EVENT {OrderInitNoIVAdditives Batch Order:
Where TypeCode = "Medication" and IsCreatedFromPatientGroupOrderTemplate = TRUE };
order_enter_event:= EVENT {OrderEnterWithIVAdditives User Order:
Where TypeCode = "Medication" };
patient_group_order_enter_event:= EVENT {OrderEnterWithIVAdditives Batch Order:
Where TypeCode = "Medication" and IsCreatedFromPatientGroupOrderTemplate = TRUE };
order_modify_event:= 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}}}*/
outpatient_order_init_event:= EVENT {OutpatientOrderInitNoIVAdditive User Order:
where TypeCode <> "other"
AND OrderAdditionalInfo.IsScript <> FALSE };
/* Pharmacy Order entry/modification events. */
pharm_order_init_event:= EVENT {OrderInitPharmacy User Order:
Where TypeCode = "Medication" };
pharm_dispense_new_event:= EVENT {OrderDispensePharmacyNew Any Order:
Where TypeCode = "Medication" };
pharm_dispense_exist_event:= EVENT {OrderDispensePharmacyExisting Any Order:
Where TypeCode = "Medication" };
/* Prescription entry and renewal events. */
/* Prescription entry and renewal events. */
// Uncomment the line with {{{SINGLE-QUOTE}}}and SourceApplicationType NOT in (10, 15){{{SINGLE-QUOTE}}} if the alerts
// from this MLM should not occur in the {{{SINGLE-QUOTE}}}Meds from Other Sources{{{SINGLE-QUOTE}}} dialog when the user
// accepts a Surescripts or Community Medication as a Sunrise Home Medication.
// * 10 = Surescripts Medication
// * 15 = Community Medication (from dbMotion)
// Depending which behavior is wanted, edit the {{{SINGLE-QUOTE}}}(10, 15){{{SINGLE-QUOTE}}} as follows:
// * Use (10) to suppress the alert for Surescripts Medications
// * Use (15) to suppress alerts for Community Medications
// * Use (10, 15) to suppress alerts for both Surescripts and Community Medications
prescription_init_event:= EVENT {PrescriptionInit Any ClientPrescription:
Where PrescriptionTypeDescription in ("Rx", "Hx")
//and SourceApplicationType NOT in (10, 15)
};
prescription_renew_event:= EVENT{PrescriptionRenew User ClientPrescription:
Where PrescriptionTypeDescription in ("Rx") };
/* Alert on Demand events. */
alert_check_order_event:= EVENT {AlertCheckingOrder User Order};
alert_check_client_pres_event:= EVENT{AlertCheckingClientPrescription User
ClientPrescription};
/* 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. */
/* Historical Order entry/modification events. */
/*
order_alternate_enter_IV_event:= EVENT {OrderAlternateEnterWithIVAdditive User
Order: Where TypeCode = "Medication"
AND AlternateOrderType = 1 };
order_alternate_enter_NOIV_event:= EVENT {OrderAlternateEnterNoIVAdditive User
Order: Where TypeCode = "Medication"
AND AlternateOrderType = 1 };
order_alternate_modify_event:= EVENT {OrderAlternateModify User
Order: Where TypeCode = "Medication"
AND AlternateOrderType = 1 };
*/
/************************************************************************************/
/* Alert destination variables */
preg_lact_alert_abstract:= null;
preg_lact_short_message:= "";
preg_lact_rule_group:= "";
preg_lact_rule_number:= 0;
/* Missing/outdated data alert variables */
is_missing_gender:= FALSE;
missing_gender_preg_message:= "";
missing_gender_lact_message:= "";
show_missing_gender_without_preg_alert:= FALSE;
show_missing_gender_without_lact_alert:= FALSE;
is_missing_age:= FALSE;
missing_age_preg_data_message:= "";
missing_age_lact_data_message:= "";
missing_age_with_preg_data_message:= "";
missing_age_with_lact_data_message:= "";
show_missing_age_without_preg_alert:= FALSE;
show_missing_age_without_lact_alert:= FALSE;
is_missing_pregnancy_data:= FALSE;
missing_pregnancy_data_message:= "";
show_missing_pregnancy_data_alert:= FALSE;
is_missing_lactation_data:= FALSE;
missing_lactation_data_message:= "";
show_missing_lactation_data_alert:= FALSE;
is_outdated_preg_data:= FALSE;
outdated_preg_data_message:= "";
show_outdated_preg_data_alert:= FALSE;
is_outdated_lact_data:= FALSE;
outdated_lact_data_message:= "";
show_outdated_lact_data_alert:= FALSE;
is_outdated_edd_data:= FALSE;
outdated_edd_data_message:= "";
show_outdated_edd_data_alert:= FALSE;
pregnancy_alert_header:= "";
show_pregnancy_alert:= FALSE;
lactation_alert_header:= "";
show_lactation_alert:= FALSE;
preg_lact_alert:= "";
missing_data_header:= "";
unmapped_orders_alert:= "";
has_some_mapped:= FALSE;
show_unmapped_alert:= FALSE;
/* Evoking event variables */
evoked_from_prescriptions:= FALSE;
evoked_from_physical_note:= FALSE;
/* Indicates whether patient is within age range */
is_patient_in_age_range:= FALSE;
/* Indicates whether to check preg/lact alert */
check_preg_lact_alert:= FALSE;
/* Indicates whether to skip checking preg/lact alert in the stored procedure */
is_skip_check_pregnant:= FALSE;
community_medication_abstract_text := " (Community Data)" ;
// mlm name is passed to STD_FUNC_COMMUNITY_DATA_RETRIEVAL_RULES which is responsible for user right{{{SINGLE-QUOTE}}}s
mlm_Name := "STD_PREGNANCY_AND_LACTATION";
// Enum values for Community Medication defined
enum_rx_type_Community_Med := 5;
// Declare MLMs that can be called from this MLM
func_multum_references := MLM {{{SINGLE-QUOTE}}}STD_FUNC_MULTUM_REFERENCES{{{SINGLE-QUOTE}}};
func_community_data_retrieval_rules:= MLM {{{SINGLE-QUOTE}}}STD_FUNC_COMMUNITY_DATA_RETRIEVAL_RULES{{{SINGLE-QUOTE}}};
/* Executes only when this MLM is called by the editor */
if called_by_editor
then
//Select a CDS Object to test by uncommenting it.
//Comment out the other two choices.
object_choice :=
//"Order";
//"Prescription";
"PhysicalNote";
if object_choice = "Order"
then
order_obj := read last
{ Order: THIS
//WHERE Name = "Warfarin"
};
EvokingEvent:= order_enter_event;
EvokingObject := order_obj;
EvokingEventType := order_enter_event.Type;
elseif object_choice = "Prescription"
then
prescription_obj := read last
{ ClientPrescription: THIS
//WHERE DrugName = "leuprolide-norethindrone"
};
EvokingEvent:= prescription_init_event;
EvokingObject := prescription_obj;
EvokingEventType := prescription_init_event.Type;
elseif object_choice = "PhysicalNote"
then
phys_note_obj := read last
{ PhysicalNote: THIS
WHERE TypeCode = "IS PREGNANT" };
EvokingEvent:= phys_note_enter_event;
EvokingObject := phys_note_obj;
EvokingEventType := phys_note_enter_event.Type;
endif;
endif;
/* Get the user guid for rights checking */
( user_guid ):= read last { StateInfo: UserGUID };
// Retrieve clientvisit guid from State object
(visit_guid) := read last { StateInfo: visitGuid};
/* Get the patient{{{SINGLE-QUOTE}}}s gender and age */
( client_gender_intl_code,
client_gender,
client_birthdatetime,
client_guid
):= read last { ClientInfo: GenderTypeIntlCode,
GenderCode,
Birthdatetime,
GUID};
if( client_gender_intl_code = "M" )
then
client_gender:= "Male";
endif;
if( client_gender_intl_code = "F" )
then
client_gender:= "Female";
endif;
/* Get the patient{{{SINGLE-QUOTE}}}s chart*/
( chart_guid ):= read last { ChartInfo: GUID };
client_age_in_seconds:= Now - client_birthdatetime;
client_age:= truncate( client_age_in_seconds / (1 year) );
client_is_pregnant:= 0;
client_pregnancy_status:= null;
client_is_pregnant_touched_when:= null;
client_is_lactating:= 0;
client_lactation_status:= null;
client_is_lactating_touched_when:= null;
client_edd:= null;
continue_processing:= TRUE;
/* Set the master and child order types */
complex_child_order_types:= ( 2, 4, 6 );
complex_master_order_types:= ( 1, 3, 5);
/* IV-Additive TYPES are used to store additives in CV3OrderComponent.Type
If more than two IV-additive types are used, add them to this list
Note: Type 3 was used for calculated IV-dosage in CV3.1.2,
but is not used in SCM 3.0 or SCM 3.01 */
iv_additive_types:= ( 0, 3 );
/* Initialize input XML parameter */
evoking_order_parameter_xml:= "";
evoking_Rx_parameter_xml:= "";
unsubmitted_order_parameter_xml:= "";
unsub_Rx_parameter_xml:= "";
community_medication_parameter_xml := "";
evoking_physical_note_type_code:= null;
is_pregnant_physical_note:= FALSE;
// When the flag is set to TRUE, the alert generated for all users does include dbMotion medication data
// that conflicts with current medication that triggered the call to the Interaction MLM.
//To make sure that the below SUB MLM is called only when the flag is true.
if(enable_community_data_medication_alerts = true)
then
(can_perform,can_retrieve_data_obj) := call func_community_data_retrieval_rules with
(
EvokingObject,
EvokingEventType,
mlm_Name,
community_data_excluded_triggers_list
);
else
can_perform := true;
endif;
if (can_perform)
then
/* 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";
evoking_order_is_outpatient := false;
/* Get evoking Order, Physical Note, or Prescription */
/* Evoking object is a prescription */
if ( EvokingObject is ClientPrescription )
then
evoked_from_prescriptions:= TRUE;
( evoking_object_name,
evoking_generic_name_id,
evoking_rx_start_dtm,
evoking_rx_renewal_dtm,
evoking_Rx_status,
evoking_Rx_type,
chart_guid,
evoking_rx_source,
evoking_dispensed_detail_id
) := read last { ClientPrescription: DrugName,
GenericNameID,
StartDate,
RenewalDate,
StatusType,
PrescriptionType,
ChartGUID,
AlertOnDemandSource,
DispensedDetailID
REFERENCING EvokingObject };
evoking_object_start_date := evoking_rx_start_dtm;
/* Evoking object is a physical note - need to get unsubmitted */
elseif( EvokingObject is PhysicalNote )
then
evoked_from_physical_note:= TRUE;
( evoking_physical_note_type_code,
evoking_physical_note_text,
evoking_physical_note_touched_when,
chart_guid
) := read last { PhysicalNote: TypeCode,
Text,
TouchedWhen,
ChartGUID
REFERENCING EvokingObject };
/* Get the unsubmitted orders that should be checked for pregnancy/lactation
interactions. These are New or Modified orders */
( unsub_intended_action_list,
unsub_order_name_list,
unsub_catalog_item_guid_list,
unsub_order_additiveobj_list,
unsub_order_start_date_list,
unsub_order_status_list,
unsub_alternate_order_type_list,
unsub_order_additional_info_obj_list,
unsub_order_entered_date_list
) := read{ UnsubmittedOrders: IntendedAction,
Name,
OrderCatalogMasterItemGUID,
OrderComponent,
SignificantDtm,
OrderStatusCode,
AlternateOrderType,
OrderAdditionalInfo,
Entered
WHERE TypeCode = "Medication"
AND ComplexOrderType IS NOT IN complex_child_order_types
AND ( IntendedAction IS NULL
OR IntendedAction IS IN
("Add New","Modify","Modified","Suspend"))
};
unsub_order_is_script_list := ();
index_list := 1 seqto count (unsub_order_additional_info_obj_list);
for JJ in index_list do
OrderAdditionalInfoObj := unsub_order_additional_info_obj_list[jj];
(unsub_order_additional_info_is_script) := read { OrderAdditionalInfo: IsScript
REFERENCING OrderAdditionalInfoObj};
unsub_order_is_script_list := unsub_order_is_script_list, unsub_order_additional_info_is_script;
enddo;
/* For each unsubmitted order, add the order-name and additive info (if any),
to the list of unsubmitted order names to be processed. */
unsubmitted_order_parameter_xml := "";
index_list := 1 seqto count (unsub_order_name_list);
for JJ in index_list do
unsub_cat_guid := last (first JJ from unsub_catalog_item_guid_list);
unsub_additiveObj := last (first JJ from unsub_order_additiveobj_list);
unsub_order_name := last (first JJ from unsub_order_name_list);
unsub_order_start_date := last (first JJ from unsub_order_start_date_list);
unsub_order_status := last (first JJ from unsub_order_status_list);
if ( unsub_order_start_date is null )
then
unsub_order_start_date:= "";
endif;
unsub_alternate_order_type := unsub_alternate_order_type_list[jj];
unsub_order_is_script := unsub_order_is_script_list[jj];
unsub_order_entered_date := unsub_order_entered_date_list[jj];
if ( unsub_order_entered_date is null )
then
unsub_order_entered_date := "";
endif;
unsubmitted_order_parameter_xml := unsubmitted_order_parameter_xml ||
" <Order " ||
" IsEvoking={{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_name) || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || unsub_cat_guid || "{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_name) || "{{{SINGLE-QUOTE}}}" ||
" ItemType={{{SINGLE-QUOTE}}}Regular{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_start_date) || "{{{SINGLE-QUOTE}}}" ||
" Status={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_status) || "{{{SINGLE-QUOTE}}}" ||
" AlternateOrderType={{{SINGLE-QUOTE}}}" || XMLEX(unsub_alternate_order_type) || "{{{SINGLE-QUOTE}}}" ||
" IsScript={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_is_script) || "{{{SINGLE-QUOTE}}}" ||
" EnteredDate={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_entered_date) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
/* If there are additives obtain the info */
if exist unsub_additiveObj
then
( temp_additive_name_list,
temp_item_guid_list
):= read{ OrderComponent: Name,
OrderCatalogMasterItemGUID
REFERENCING unsub_additiveObj
WHERE (Dosage AS Number) > 0 };
additive_index_list := 1 seqto count(temp_additive_name_list);
for additive_ind in additive_index_list do
unsubmitted_additive_cat_GUID := last (first additive_ind
from temp_item_guid_list);
unsubmitted_additive_name := last (first additive_ind
from temp_additive_name_list);
if (unsub_order_start_date is null)
then
unsub_order_start_date:= "";
endif;
unsubmitted_additive_xml :=
" <Order " ||
" IsEvoking={{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX( unsub_order_name ) || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || unsubmitted_additive_cat_GUID ||
"{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || XMLEX(unsubmitted_additive_name) ||
"{{{SINGLE-QUOTE}}}" ||
" ItemType={{{SINGLE-QUOTE}}}Additive{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_start_date) || "{{{SINGLE-QUOTE}}}" ||
" Status={{{SINGLE-QUOTE}}}" || XMLEX(unsub_order_status) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
unsubmitted_order_parameter_xml := unsubmitted_order_parameter_xml ||
unsubmitted_additive_xml;
enddo; //for additive_index_list
endif; //if exist unsub_additiveObj
enddo; //for for JJ
/* Get the unsubmitted prescription - New or Modified orders */
( unsub_Rx_name_list,
unsub_Rx_cds_unique_guid_list,
unsub_Rx_generic_name_id_list,
unsub_Rx_start_date_list,
unsub_Rx_renewal_date_list,
unsub_Rx_status_list,
unsub_Rx_type_list
) := read { Unsubmitted ClientPrescription: DrugName,
CDSUniqueIDGUID,
GenericNameID,
StartDate,
RenewalDate,
StatusType,
PrescriptionType
WHERE PrescriptionTypeDescription in ("Rx", "Hx") };
unsub_Rx_parameter_xml := "";
unsub_Rx_index_list := 1 seqto count(unsub_Rx_name_list);
for unsub_Rx_ind in unsub_Rx_index_list
do
unsub_Rx_name :=
last (first unsub_Rx_ind from unsub_Rx_name_list);
unsub_Rx_generic_name_id :=
last (first unsub_Rx_ind from unsub_Rx_generic_name_id_list);
unsub_Rx_start_date:=
last (first unsub_Rx_ind from unsub_Rx_start_date_list);
unsub_Rx_status:=
last (first unsub_Rx_ind from unsub_Rx_status_list);
unsub_Rx_renewal_date:=
last (first unsub_Rx_ind from unsub_Rx_renewal_date_list);
unsub_Rx_type:=
last (first unsub_Rx_ind from unsub_Rx_type_list);
rx_start_date:= unsub_Rx_start_date;
if( rx_start_date is null )
then
rx_start_date:= "";
endif;
unsub_Rx_parameter_xml := unsub_Rx_parameter_xml ||
" <Prescription " ||
" IsEvoking = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || unsub_Rx_name || "{{{SINGLE-QUOTE}}} " ||
" GenericNameID={{{SINGLE-QUOTE}}}" || unsub_Rx_generic_name_id || "{{{SINGLE-QUOTE}}} " ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(rx_start_date) || "{{{SINGLE-QUOTE}}}" ||
" RxStatus={{{SINGLE-QUOTE}}}" || unsub_Rx_status || "{{{SINGLE-QUOTE}}}" ||
" PrescriptionType={{{SINGLE-QUOTE}}}" || unsub_Rx_type || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
enddo; // END for unsub_Rx_ind
// Community medication parameter
orig_pending_community_med_str := "";
include_community_medication :=false;
if (evoking_dispensed_detail_id is not null)
then
orig_pending_community_med_str := " OriginalCommunityMedicationId={{{SINGLE-QUOTE}}}" ||
XMLEX(evoking_dispensed_detail_id) || "{{{SINGLE-QUOTE}}}";
endif;
// exclude pending community medication parameter
exclude_older_than_days_str := "";
if (exclude_pending_community_meds_older_than_days is not null)
then
exclude_older_than_days_str := " ExcludeOlderThanDays={{{SINGLE-QUOTE}}}"|| XMLEX(exclude_pending_community_meds_older_than_days) || "{{{SINGLE-QUOTE}}}";
endif;
if(can_retrieve_data_obj.PendingImportedMedications is Not null)
then
include_community_medication :=can_retrieve_data_obj.PendingImportedMedications ;
endif;
community_medication_parameter_xml := community_medication_parameter_xml ||
" <CommunityMedication " ||
" IsIncluded={{{SINGLE-QUOTE}}}"|| XMLEX(include_community_medication) || "{{{SINGLE-QUOTE}}}" ||
orig_pending_community_med_str ||
exclude_older_than_days_str ||
" ExistingHomeMedClientVisitGUID={{{SINGLE-QUOTE}}}"|| visit_guid || "{{{SINGLE-QUOTE}}}" ||
" />\n";
/* Evoking object is an order */
elseif( EvokingObject is Order )
then
( evoking_object_name,
evoking_cat_item_guid,
evoking_object_start_date,
evoking_order_status,
evoking_order_component_obj,
evoking_pharm_order_obj,
evoking_complex_order_type,
evoking_order_var_comp_obj,
evoking_backup_obj,
chart_guid,
evoking_med_source,
evoking_alternate_order_type,
evoking_order_entered_date,
AdditionalInfoObj
) := read last { Order: Name,
OrderCatalogMasterItemGUID,
SignificantDtm,
OrderStatusCode,
OrderComponent,
PharmacyOrder,
ComplexOrderType,
OrderVariableComponent,
Backup,
ChartGUID,
AlertOnDemandSource,
AlternateOrderType,
Entered,
OrderAdditionalInfo
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;
/* When present, add additive names to this list current orders */
if exist evoking_order_component_obj
then
( evoking_additive_name_list,
evoking_additive_GUID_list,
evoking_component_GUID_list ) := read
{ OrderComponent: Name,
OrderCatalogMasterItemGUID,
GUID
REFERENCING evoking_order_component_obj
where (Dosage AS Number) > 0 };
endif;
endif;
/* for modify, only continue if IV additives have been added */
if ( EvokingEventType = order_modify_event.type
/* 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. */
/* EvokingEventType = order_alternate_modify_event.type */ )
then
evoking_order_component_backup_obj:= evoking_backup_obj.OrderComponent;
( backup_component_GUID_list ):= read
{ OrderComponent: GUID
REFERENCING evoking_order_component_backup_obj
where (Dosage AS Number) > 0 };
if evoking_component_GUID_list IS NULL then
continue_processing:= FALSE;
else
new_components:= ();
num_components:= count (evoking_component_GUID_list);
for J in (1 seqto num_components ) do
one_new_component:= evoking_component_GUID_list[J];
if NOT one_new_component IN backup_component_GUID_list
then
new_components:= new_components, one_new_component;
endif;
enddo;
if count (new_components) = 0 then
continue_processing := FALSE;
endif;
endif; //if evoking_component_GUID_list is NULL
endif; // if EvokingEvent = order_modify_event
/* Get pharmacy order objects, don{{{SINGLE-QUOTE}}}t show duplicate alerts for pharmacy items */
if continue_processing
then
if exist evoking_pharm_order_obj
then
is_pharmacy_order := true;
pharmacy_order_option_obj := read last
{ PharmacyOrder : PharmacyOrderOption
REFERENCING evoking_pharm_order_obj };
if exist pharmacy_order_option_obj
then
( pharm_ord_opt_comp_obj,
pharm_ord_opt_comp_ovc_guid) := read first
{ PharmacyOrderOption : PharmacyOrderOptionComponent,
OrderVariableComponentGUID
REFERENCING pharmacy_order_option_obj };
endif; // if exists pharmacy_order_option_obj
endif; // if exists evoking_pharm_order_obj
/* Get all pharmacy order option component data */
if ( is_pharmacy_order and
exist pharm_ord_opt_comp_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_ord_opt_comp_obj };
/* Check to see if this is a complex order */
if ( evoking_complex_order_type IS IN complex_master_order_types and
exist evoking_order_var_comp_obj )
then
is_complex_order:= TRUE;
first_order_variable_component_guid := read first
{ OrderVariableComponent: GUID
REFERENCING evoking_order_var_comp_obj };
if ( pharm_ord_opt_comp_ovc_guid = first_order_variable_component_guid )
then
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
/* Do not process if this is a complex order and not 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:= ();
rest_of_ocmi_guid_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 exist current_ocmi_guid_list
then
/* Reset list to clear evoking order in order to add pharmacy */
/* components */
pharm_order_name_list := ();
pharm_cat_item_guid_list := ();
/* 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_event.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 in rest_of_drug_key_list)
then
no_alert_this_one:= true;
else
/* Add this one to the list to check */
pharm_order_name_list :=
pharm_order_name_list, this_item_name;
pharm_cat_item_guid_list :=
pharm_cat_item_guid_list, this_guid;
endif; // if (this_key is in rest_of_drug_key_list)
endif; // if (this_guid is in rest_of_ocmi_guid_list)
endif; // if this_guid = evoking_cat_item_guid and
// pharm_dispense_new_event
i := i +1;
enddo; // for this_guid in current_list
endif; // if exists current_ocmi_guid_list
endif; // if continue_processing
endif; // is_pharmacy_order and
// exists pharm_ord_opt_comp_obj )
endif; // if continue_processing
if continue_processing
then
/* Add evoking object information in the input XML parameter */
if (EvokingObject is Order)
then
/* order has pharmacy components */
if( pharm_cat_item_guid_list is not null and
count ( pharm_cat_item_guid_list ) > 0 )
then
pharm_cat_item_guid_count:= 1 seqto count( pharm_cat_item_guid_list );
for pharm_ind in pharm_cat_item_guid_count do
evoking_pharm_cat_GUID:= last( first pharm_ind
from pharm_cat_item_guid_list );
evoking_pharm_name:= last( first pharm_ind
from pharm_order_name_list );
if (evoking_pharm_cat_GUID is not null)
then
if(evoking_object_start_date is null)
then
evoking_object_start_date:= "";
endif;
evoking_pharm_parameter_xml :=
" <Order " ||
" IsEvoking = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX(evoking_pharm_name) || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || evoking_pharm_cat_GUID || "{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || XMLEX(evoking_pharm_name) || "{{{SINGLE-QUOTE}}}" ||
" ItemType={{{SINGLE-QUOTE}}}Regular{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_start_date) || "{{{SINGLE-QUOTE}}}" ||
" Status={{{SINGLE-QUOTE}}}" || XMLEX(evoking_order_status) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
evoking_order_parameter_xml := evoking_order_parameter_xml ||
evoking_pharm_parameter_xml;
endif; // if (evoking_additive_cat_GUID is not null)
enddo;
/* regular evoking order */
else
if evoking_object_start_date is null
then
evoking_object_start_date:= "";
endif;
if evoking_order_entered_date is null
then
evoking_order_entered_date := "";
endif;
evoking_order_parameter_xml :=
" <Order " ||
" IsEvoking = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_name) || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || evoking_cat_item_guid || "{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_name) || "{{{SINGLE-QUOTE}}}" ||
" ItemType={{{SINGLE-QUOTE}}}Regular{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_start_date) || "{{{SINGLE-QUOTE}}}" ||
" Status={{{SINGLE-QUOTE}}}" || XMLEX(evoking_order_status) || "{{{SINGLE-QUOTE}}}" ||
" AlternateOrderType={{{SINGLE-QUOTE}}}" || XMLEX(evoking_alternate_order_type) || "{{{SINGLE-QUOTE}}}" ||
" IsScript={{{SINGLE-QUOTE}}}" || XMLEX(evoking_order_is_script) || "{{{SINGLE-QUOTE}}}" ||
" EnteredDate={{{SINGLE-QUOTE}}}" || XMLEX(evoking_order_entered_date) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
endif;
additive_index_list := 1 seqto count (evoking_additive_GUID_list);
for additive_ind in additive_index_list do
evoking_additive_cat_GUID := last (first additive_ind
from evoking_additive_GUID_list);
evoking_additive_name := last (first additive_ind
from evoking_additive_name_list);
if (evoking_additive_cat_GUID is not null)
then
if(evoking_object_start_date is null)
then
evoking_object_start_date:= "";
endif;
evoking_additive_xml :=
" <Order " ||
" IsEvoking = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_name) || "{{{SINGLE-QUOTE}}} " ||
" CatalogGUID={{{SINGLE-QUOTE}}}" || evoking_additive_cat_GUID ||
"{{{SINGLE-QUOTE}}}" ||
" OrderOrAdditiveName={{{SINGLE-QUOTE}}}" || XMLEX(evoking_additive_name) ||
"{{{SINGLE-QUOTE}}}" ||
" ItemType={{{SINGLE-QUOTE}}}Additive{{{SINGLE-QUOTE}}}" ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_start_date) || "{{{SINGLE-QUOTE}}}" ||
" Status={{{SINGLE-QUOTE}}}" || XMLEX(evoking_order_status) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
evoking_order_parameter_xml := evoking_order_parameter_xml ||
evoking_additive_xml;
endif;
enddo;
elseif (EvokingObject is ClientPrescription)
then
if(evoking_object_start_date is null)
then
evoking_object_start_date:= "";
endif;
evoking_Rx_parameter_xml :=
" <Prescription " ||
" IsEvoking = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} " ||
" Name={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_name) || "{{{SINGLE-QUOTE}}} " ||
" GenericNameID={{{SINGLE-QUOTE}}}" || evoking_generic_name_id || "{{{SINGLE-QUOTE}}} " ||
" StartDate={{{SINGLE-QUOTE}}}" || XMLEX(evoking_object_start_date) || "{{{SINGLE-QUOTE}}}" ||
" RxStatus={{{SINGLE-QUOTE}}}" || XMLEX(evoking_Rx_status) || "{{{SINGLE-QUOTE}}}" ||
" PrescriptionType={{{SINGLE-QUOTE}}}" || XMLEX(evoking_Rx_type) || "{{{SINGLE-QUOTE}}}" ||
"/>\n";
endif; // END if EvokingObject - for adding evoking object info
/* Combine the evoking order, evoking Rx, unsubmitted order, unsubmitted Rx */
input_parameter_xml := "\n<ROOT>\n" ||
evoking_order_parameter_xml ||
evoking_Rx_parameter_xml ||
unsubmitted_order_parameter_xml ||
unsub_Rx_parameter_xml ||
community_medication_parameter_xml ||
"</ROOT>\n";
/* If evoking object is physical note, get the pregnancy/lactation info */
/* from the evoking object. */
if( evoked_from_physical_note )
then
if( evoking_physical_note_type_code = "IS PREGNANT" )
then
client_pregnancy_status:= evoking_physical_note_text;
client_is_pregnant_touched_when:= evoking_physical_note_touched_when;
is_pregnant_physical_note:= TRUE;
elseif( evoking_physical_note_type_code = "IS LACTATING" )
then
client_lactation_status:= evoking_physical_note_text;
client_is_lactating_touched_when:= evoking_physical_note_touched_when;
endif;
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;
/* If not, get the pregnancy/lactation info from database */
else
physical_note_type_codes:= ();
physical_note_texts:= ();
physical_note_touched_whens:= ();
( physical_note_type_codes,
physical_note_texts,
physical_note_touched_whens
) := read { "EXEC SCMFindPregnancyLactationDataSelPr "
|| SQL(client_guid) };
physical_notes_count:= count( physical_note_type_codes );
for row_index in (1 seqto physical_notes_count ) do
type_code:= physical_note_type_codes[row_index];
if( type_code is not null )
then
if( type_code = "IS PREGNANT" )
then
client_pregnancy_status:= physical_note_texts[row_index];
client_is_pregnant_touched_when:=
physical_note_touched_whens[row_index];
elseif ( type_code = "IS LACTATING" )
then
client_lactation_status:= physical_note_texts[row_index];
client_is_lactating_touched_when:=
physical_note_touched_whens[row_index];
elseif ( type_code = "EDD" )
then
client_edd:= physical_note_texts[row_index];
endif;
endif;
enddo;
/* Check whether pregnancy data is outdated */
if( client_pregnancy_status = "Yes" )
then
preg_touched_when_diff_in_seconds:=
Now - client_is_pregnant_touched_when;
preg_touched_when_diff:= truncate( preg_touched_when_diff_in_seconds /
(1 day) );
if( preg_touched_when_diff > is_pregnant_data_valid_interval )
then
is_outdated_preg_data:= TRUE;
if( alert_using_outdated_preg_lact_data = FALSE )
then
client_pregnancy_status:= "Not Applicable";
endif;
if( alert_if_outdated_preg_lact_data )
then
show_outdated_preg_data_alert:= TRUE;
endif;
endif;
endif;
/* Check whether lactation data is outdated */
if( client_lactation_status = "Yes" )
then
lact_touched_when_diff_in_seconds:=
Now - client_is_lactating_touched_when;
lact_touched_when_diff:= truncate( lact_touched_when_diff_in_seconds
/ (1 day) );
if( lact_touched_when_diff > is_lactating_data_valid_interval )
then
is_outdated_lact_data:= TRUE;
if( alert_using_outdated_preg_lact_data = FALSE )
then
client_lactation_status:= "Not Applicable";
endif;
if( alert_if_outdated_preg_lact_data )
then
show_outdated_lact_data_alert:= TRUE;
endif;
endif;
endif; //if( client_lactation_status = "Yes" )
endif; // if( evoked_from_physical_note )
/* If is pregnant is no OR
(is pregnant is unknown and alert for unknown data = TRUE) OR
(is lactating is unknown and alert for unknown data = TRUE),
check for gender and age range. */
if( client_pregnancy_status = "No"
or ( client_pregnancy_status is null or client_pregnancy_status = "Unknown" )
or ( client_lactation_status is null or client_lactation_status = "Unknown" )
)
then
/* Check whether missing pregnancy info */
if( ( client_pregnancy_status is null or
client_pregnancy_status = "Unknown" ) and
client_gender = "Female")
then
/* only show missing pregnancy data when evoking is not physical note
or evoking physical note is pregnant */
if( evoking_physical_note_type_code is null or
evoking_physical_note_type_code = "IS PREGNANT")
then
is_missing_pregnancy_data:= TRUE;
if( alert_if_missing_preg_lact_data )
then
show_missing_pregnancy_data_alert:= TRUE;
endif;
endif;
endif;
/* Check whether missing lactation info */
if( ( client_lactation_status is null or
client_lactation_status = "Unknown" ) and
client_gender = "Female" )
then
/* only show missing lactation data when evoking is not physical note
or evoking physical note is lactating */
if( evoking_physical_note_type_code is null or
evoking_physical_note_type_code = "IS LACTATING")
then
is_missing_lactation_data:= TRUE;
if( alert_if_missing_preg_lact_data )
then
show_missing_lactation_data_alert:= TRUE;
endif;
endif;
endif;
/* Check whether gender is missing */
if ( ( count(ambiguous_gender_list) > 0 and
client_gender is in ambiguous_gender_list )
or client_gender is null )
then
is_missing_gender:= TRUE;
if ( alert_if_missing_gender_data )
then
if( ( client_pregnancy_status <> "Yes" or
client_pregnancy_status is null )
and ( ( evoked_from_physical_note = FALSE )
or ( evoked_from_physical_note and
is_pregnant_physical_note ) ) )
then
show_missing_gender_without_preg_alert:= TRUE;
endif;
if( ( client_lactation_status is null or
client_lactation_status <> "Yes")
and ( ( evoked_from_physical_note = FALSE )
or ( evoked_from_physical_note and
is_pregnant_physical_note = FALSE) ) )
then
show_missing_gender_without_lact_alert:= TRUE;
endif;
endif;
endif;
/* Check whether age is missing */
if ( client_age is null or client_age < 0 or client_birthdatetime is null )
then
is_missing_age:= TRUE;
if ( alert_if_missing_age_data )
then
if( ( client_pregnancy_status <> "Yes" or
client_pregnancy_status is null )
and ( ( evoked_from_physical_note = FALSE )
or ( evoked_from_physical_note and
is_pregnant_physical_note ) ) )
then
show_missing_age_without_preg_alert:= TRUE;
endif;
if( ( client_lactation_status is null or
client_lactation_status <> "Yes")
and ( ( evoked_from_physical_note = FALSE )
or ( evoked_from_physical_note and
is_pregnant_physical_note = FALSE) ) )
then
show_missing_age_without_lact_alert:= TRUE;
endif;
endif;
/* Check whether age is within range */
elseif ( ( client_gender = "Male" and
( client_age >= lower_limit_male_age_range and
client_age <= upper_limit_male_age_range ) )
or
( client_gender = "Female" and
( client_age >= lower_limit_female_age_range and
client_age <= upper_limit_female_age_range ) )
)
then
is_patient_in_age_range:= TRUE;
endif;
if( client_pregnancy_status = "No" )
then
if(is_patient_in_age_range = TRUE)
then
check_preg_lact_alert := TRUE;
else
// we want to skip checking for pregnant when not in age range,
// not pregnant but lactation is null and missing age so has to check
// lactation.
is_skip_check_pregnant:= TRUE;
endif;
// lactation is unknown or pregnancy is unknown
elseif ( client_pregnancy_status is null or
client_pregnancy_status = "Unknown" or
client_lactation_status is null or
client_lactation_status = "Unknown" )
then
// if checking for unknown, either within age range or no age (CR 166476)
// and female will check for alerts.
if ((is_patient_in_age_range or is_missing_age) and
client_gender = "Female" and
alert_if_unknown_preg_lact_data = TRUE)
then
check_preg_lact_alert := TRUE;
elseif(client_gender = "Male" and is_patient_in_age_range)
then
check_preg_lact_alert := TRUE;
endif;
endif;
endif;
/* Check whether EDD is outdated */
client_edd_time:= client_edd as time;
edd_difference_in_seconds:= Now - client_edd_time;
edd_difference:= truncate( edd_difference_in_seconds / (1 day) );
if( client_edd is not null AND
edd_difference > edd_data_valid_interval )
then
is_outdated_edd_data:= TRUE;
if( alert_if_outdated_preg_lact_data )
then
show_outdated_edd_data_alert:= TRUE;
endif;
endif;
/* Convert to boolean for stored procedure */
if( client_pregnancy_status = "Yes" )
then
/* pregnant female */
client_is_pregnant:= 1;
elseif( client_pregnancy_status = "Not Applicable" )
then
/* not applicable */
client_is_pregnant:= -1;
else
/* male and non-pregnant female */
client_is_pregnant:= 0;
endif;
if(client_lactation_status = "Yes" or
((client_lactation_status = "Unknown" or client_lactation_status is null) and
(alert_if_unknown_preg_lact_data and (is_patient_in_age_range or is_missing_age)) and
client_gender = "Female" ))
then
client_is_lactating:= 1;
else
client_is_lactating:= 0;
endif;
/* Check for pregnancy/lactation drug alerts */
if( client_pregnancy_status = "Yes" or
client_lactation_status = "Yes" or
check_preg_lact_alert = TRUE )
then
is_pregnancy_alert_list:=();
drug_id_list:=();
alert_title_list:=();
drug_name_list:=();
order_name_list:=();
component_name_list:=();
additive_name_list:=();
start_date_list:=();
last_fill_date_list:=();
status_list:=();
clinical_text_list:=();
has_level_two_list:=();
is_additive_list:=();
is_component_list:=();
is_mapped_list:=();
is_order_list:= ();
preg_lact_alert_abstract_list:= ();
severity_list := ();
alternate_order_type_list := ();
is_script_list := ();
entered_date_list :=();
( is_pregnancy_alert_list,
drug_id_list,
alert_title_list,
drug_name_list,
order_name_list,
component_name_list,
additive_name_list,
start_date_list,
last_fill_date_list,
status_list,
clinical_text_list,
has_level_two_list,
is_additive_list,
is_component_list,
is_mapped_list,
is_order_list,
severity_list,
alternate_order_type_list,
is_script_list,
entered_date_list ,
PrescriptionType_list) := read
{ "EXEC SCMGetPregnancyLactationDrugConflictInfoSelPr "
|| SQL(input_parameter_xml)
|| ","
|| SQL(client_gender)
|| " , "
|| SQL(client_is_pregnant)
|| " , "
|| SQL(client_is_lactating)
|| " , "
|| SQL(client_guid)
|| " , "
|| SQL(user_guid)
|| " , "
|| SQL(evoked_from_physical_note)
|| " , "
|| SQL(is_pregnant_physical_note)
|| " , "
|| SQL(is_skip_check_pregnant)
|| " , "
|| SQL(outpatient_orders_flag)
};
//Declare the Med_Data_Object
Med_Data_Object := OBJECT [
Sort_field,
Drug_ID,
Function_ID,
Is_pregnancy_alert,
TextTitle
];
// list that holds all of the objects that will be returned
mdo_reference_list := ();
level_two_reference:= "\n\nTo see additional reference information, "
|| "use Drug Info/Expert Advice to look up this drug, ";
alert_count:= count( drug_id_list );
for row_index in (1 seqto alert_count ) do
instance := new Med_Data_Object;
is_pregnancy_alert:= is_pregnancy_alert_list[row_index];
alert_title:= alert_title_list[row_index];
drug_name:= drug_name_list[row_index];
order_name:= order_name_list[row_index];
additive_name:= additive_name_list[row_index];
component_name:= component_name_list[row_index];
start_date:= start_date_list[row_index];
last_fill_date:=last_fill_date_list[row_index];
status:= status_list[row_index];
clinical_text:= clinical_text_list[row_index];
has_level_two:= has_level_two_list[row_index];
is_additive:= is_additive_list[row_index];
is_component:= is_component_list[row_index];
is_mapped:= is_mapped_list[row_index];
is_order:= is_order_list[row_index];
severity:= severity_list[row_index];
drug_id:= drug_id_list[row_index];
alternate_order_type := alternate_order_type_list[row_index];
is_script := is_script_list[row_index];
entered_date := entered_date_list[row_index];
prescriptionType := PrescriptionType_list[row_index];
is_outpatient_order := false;
if alternate_order_type = 2
then
is_outpatient_order := true;
endif;
if is_pregnancy_alert=TRUE
then
instance.Function_ID:=5;
if alert_title = "Family Planning - Drug Conflict"
then
instance.Sort_field:=drug_name || " conflict with family planning";
instance.TextTitle:=drug_name || " conflict with family planning";
else
instance.Sort_field:=drug_name || " conflict with pregnancy";
instance.TextTitle:=drug_name || " conflict with pregnancy";
endif;
endif;
if is_pregnancy_alert=FALSE
then
instance.Function_ID:=6;
if alert_title = "Family Planning - Drug Conflict"
then
instance.Sort_field:=drug_name || " conflict with family planning";
instance.TextTitle:=drug_name || " conflict with family planning";
else
instance.Sort_field:=drug_name || " conflict with lactation";
instance.TextTitle:=drug_name || " conflict with lactation";
endif;
endif;
instance.Is_pregnancy_alert:=is_pregnancy_alert_list[row_index];
instance.Drug_ID:=drug_id_list[row_index];
if( alert_if_unmapped and is_mapped <> TRUE)
then
if( show_unmapped_alert = FALSE )
then
unmapped_orders_alert:=
"\n\nThe order(s) listed below could not be checked for"
|| " pregnancy/lactation contraindications."
|| " Please use an alternate plan to do the check."
|| " Notify your system administrator for Sunrise"
|| " Clinical Manager that the Multum"
|| " Pregnancy/Lactation Checking could not be"
|| " performed for the unmapped drug(s).";
endif;
show_unmapped_alert:= TRUE;
temp_order_name:= "";
if (is_additive)
then
temp_order_name:= additive_name;
else
temp_order_name:= order_name;
endif;
unmapped_orders_alert:= unmapped_orders_alert
|| "\n " || "{{+B}}{{+R}}" || temp_order_name
|| "{{-B}}{{-R}}" ;
preg_lact_alert_abstract:= "Unmapped - " || temp_order_name;
elseif(is_mapped = TRUE)
then
has_some_mapped:= TRUE;
formatted_drug_name:= "{{+B}}{{+C}}" || order_name
|| "{{-C}}{{-B}}";
formatted_component:= "";
formatted_additive:= "";
// construct additive, component, or additive & component drugs
if( is_additive = TRUE or is_component = TRUE )
then
if( is_additive = TRUE and is_component = TRUE )
then
formatted_additive:= "{{+B}}{{+C}}" || drug_name
|| "{{-C}}{{-B}}" || " component of "
|| additive_name
|| " additive in "
|| order_name;
formatted_drug_name:= "";
elseif( is_additive = TRUE and is_component = FALSE )
then
formatted_additive:= "{{+B}}{{+C}}" || drug_name
|| "{{-C}}{{-B}}" || " additive in "
|| order_name;
formatted_drug_name:= "";
elseif ( is_component = TRUE and is_additive = FALSE )
then
formatted_component:= "{{+B}}{{+C}}" || drug_name
|| "{{-C}}{{-B}}" || " component of "
|| order_name;
formatted_drug_name:= "";
endif;
endif;
// construct alert abstract, no duplicates for same components
if(is_component = TRUE or count (order_name_list) > 1 )
then
if( order_name is not in preg_lact_alert_abstract_list)
then
preg_lact_alert_abstract_list:=
preg_lact_alert_abstract_list, order_name;
if( preg_lact_alert_abstract is null )
then
// Add the phrase "(Community Data)" next to the Medication, when it is a Community Medication
if(enable_community_data_medication_alerts = true AND PrescriptionType = enum_rx_type_Community_Med)
then
preg_lact_alert_abstract:= order_name || community_medication_abstract_text ;
else
preg_lact_alert_abstract:= order_name;
endif;
else
// Add the phrase "(Community Data)" next to the Medication, when it is a Community Medication
if(enable_community_data_medication_alerts = true AND PrescriptionType = enum_rx_type_Community_Med)
then
preg_lact_alert_abstract:= preg_lact_alert_abstract || ", " || order_name || community_medication_abstract_text ;
else
preg_lact_alert_abstract:= preg_lact_alert_abstract || ", " || order_name;
endif;
endif;
endif;
else
// Add the phrase "(Community Data)" next to the Medication, when it is a Community Medication
if(enable_community_data_medication_alerts = true AND PrescriptionType = enum_rx_type_Community_Med)
then
preg_lact_alert_abstract:= order_name || community_medication_abstract_text ;
else
preg_lact_alert_abstract:= order_name;
endif;
endif;
alert_title:= "{{+B}}" || alert_title || "{{-B}}" ;
if( is_pregnancy_alert )
then
show_pregnancy_alert:= TRUE;
if( pregnancy_alert_header = "" )
then
pregnancy_alert_header:= "\n\nThere is a "
|| alert_title || " with the following: \n"
|| " "
|| formatted_drug_name || formatted_additive
|| formatted_component;
else
pregnancy_alert_header:= pregnancy_alert_header || "\n"
|| " "
|| formatted_drug_name || formatted_additive
|| formatted_component;
endif;
pregnancy_alert_header:= pregnancy_alert_header ||
" (" || severity || ")";
if(enable_community_data_medication_alerts = true AND PrescriptionType = enum_rx_type_Community_Med)
then
pregnancy_alert_header:= pregnancy_alert_header || "{{+B}} "|| pending_community_medication_alert_text||"{{-B}}";
endif;
else
show_lactation_alert:= TRUE;
if( lactation_alert_header = "" )
then
lactation_alert_header:= "\n\nThere is a "
|| alert_title || " with the following: \n "
|| " "
|| formatted_drug_name || formatted_additive
|| formatted_component;
else
lactation_alert_header:= lactation_alert_header
|| "\n"
|| " "
|| formatted_drug_name || formatted_additive
|| formatted_component;
endif;
lactation_alert_header:= lactation_alert_header ||
" (" || severity || ")";
if(enable_community_data_medication_alerts = true AND PrescriptionType = enum_rx_type_Community_Med)
then
lactation_alert_header:= lactation_alert_header ||"{{+B}} "|| pending_community_medication_alert_text||"{{-B}}";
endif;
endif;
if (is_outpatient_order)
then
if (is_script)
then
order_rx_indicator := " Prescription";
else
order_rx_indicator := " Home Medication";
endif;
else
if( is_order )
then
order_rx_indicator:= " Order";
else
if(PrescriptionType = 1)
then
order_rx_indicator := " Prescription";
elseif(prescriptionType = 3)
then
order_rx_indicator := " Home Medication";
elseif(PrescriptionType = 5)
then
order_rx_indicator := " Community Medication";
endif;
endif;
endif;
preg_lact_alert:= preg_lact_alert || "\n\n{{+B}}Details for "
|| alert_title
|| ":{{-B}}" || "\n" || formatted_drug_name
|| formatted_additive
|| formatted_component || ". ";
if (is_outpatient_order)
then
if (start_date is null)
then
if (entered_date is null)
then
entered_date := "<N/A>";
else
entered_date := (entered_date formatted with "%.4t");
endif;
else
start_date := (start_date formatted with "%.4t");
endif;
else
if( start_date is null )
then
start_date:= "<N/A>";
else
if not is_order then
start_date:= start_date formatted with "%.2t";
else
start_date:= start_date formatted with "%.4t";
endif;
endif;
if( last_fill_date is null )
then
last_fill_date:= "<N/A>";
else
if not is_order then
last_fill_date:= last_fill_date formatted with "%.2t";
else
last_fill_date:= last_fill_date formatted with "%.4t";
endif;
endif;
endif;
if( status is null )
then
status:= "Current";
endif;
if( EvokingEventType = alert_check_client_pres_event.type or
EvokingEventType = alert_check_order_event.type )
then
if(evoking_rx_source = "EvokingCatalog" or
evoking_med_source = "EvokingCatalog")
then
status:= "Selected";
elseif (evoking_rx_source = "Worksheet" or
evoking_med_source = "Worksheet")
then
status:= "Unsubmitted";
endif;
endif;
if (is_outpatient_order) and (start_date is null)
then
preg_lact_alert:= preg_lact_alert || "Entered Date: "
|| entered_date || " Status: " || status
|| order_rx_indicator;
else
preg_lact_alert:= preg_lact_alert || "Start Date: "
|| start_date || " Last Fill Date: " || last_fill_date || " Status: " || "{{+C}}"|| status
|| order_rx_indicator||"{{-C}}";
endif;
preg_lact_alert:= preg_lact_alert || "\n\n" || clinical_text;
if( has_level_two = true )
then
preg_lact_alert:= preg_lact_alert || level_two_reference
|| formatted_drug_name || formatted_additive
|| formatted_component || ".";
endif;
endif; //if( alert_if_unmapped and is_mapped <> TRUE)
mdo_reference_list := mdo_reference_list, instance;
enddo;
endif; //if pregnancy = Y or lactation = Y or within age range
endif; //if continue_processing 1
if( continue_processing )
then
/* Alert Header */
if( show_pregnancy_alert = TRUE )
then
pregnancy_alert_header:= pregnancy_alert_header;
endif;
if( show_lactation_alert = TRUE )
then
lactation_alert_header:= lactation_alert_header;
endif;
/* Missing or outdated alert */
if( ( show_unmapped_alert and has_some_mapped ) or
( show_unmapped_alert <> TRUE )
)
then
if ( show_missing_gender_without_preg_alert )
then
missing_gender_preg_message:= "\n\nThere is no gender information on"
|| " this patient,"
|| " unable to determine whether a pregnancy drug"
|| " contraindication alert should be posted.";
endif;
if ( show_missing_gender_without_lact_alert )
then
missing_gender_lact_message:= "\n\nThere is no gender information on"
|| " this patient,"
|| " unable to determine whether a lactation drug"
|| " contraindication alert should be posted.";
endif;
if ( show_missing_age_without_preg_alert )
then
if ( show_missing_pregnancy_data_alert )
then
missing_age_preg_data_message:= "\n\nThere is no age or pregnancy"
|| " information on this patient, unable to determine whether a"
|| " pregnancy drug contraindication alert should be posted.";
else
missing_age_with_preg_data_message:= "\n\nThere is no age on this"
|| " patient, unable to determine whether a pregnancy drug"
|| " contraindication alert should be posted.";
endif;
else
if ( show_missing_pregnancy_data_alert )
then
missing_pregnancy_data_message:= "\n\nThere is no pregnancy"
|| " information available for this patient, age and gender"
|| " will be used to determine whether to display a pregnancy"
|| " drug conflict.";
endif;
endif;
if ( show_missing_age_without_lact_alert )
then
if ( show_missing_lactation_data_alert )
then
missing_age_lact_data_message:= "\n\nThere is no age or lactation"
|| " information on this patient, unable to determine whether a"
|| " lactation drug contraindication alert should be posted.";
else
missing_age_with_lact_data_message:= "\n\nThere is no age on this"
|| " patient, unable to determine whether a lactation drug"
|| " contraindication alert should be posted.";
endif;
else
if ( show_missing_lactation_data_alert )
then
missing_lactation_data_message:= "\n\nThere is no lactation"
|| " information available for this patient, age and gender"
|| " will be used to determine whether to display a lactation"
|| " drug conflict.";
endif;
endif;
if ( show_outdated_preg_data_alert )
then
outdated_preg_data_message:= "\n\nNote the pregnancy information is out"
|| " of date, please update as soon as possible.";
endif;
if ( show_outdated_lact_data_alert )
then
outdated_lact_data_message:= "\n\nNote the lactation information is out"
|| " of date, please update as soon as possible.";
endif;
if ( show_outdated_edd_data_alert )
then
outdated_edd_data_message:= "\n\nNote the Estimated Delivery Date is out"
|| " of date, please update as soon as possible.";
endif;
if( show_missing_gender_without_preg_alert
or show_missing_gender_without_lact_alert
or show_missing_age_without_preg_alert
or show_missing_age_without_lact_alert
or show_missing_pregnancy_data_alert
or show_missing_lactation_data_alert
or show_outdated_preg_data_alert
or show_outdated_lact_data_alert
or show_outdated_edd_data_alert )
then
missing_data_header:= "\n\n{{+B}}{{+R}}Alert information may be affected"
|| " by missing data or outdated information{{-R}}{{-B}}";
endif;
endif; //if(show_unmapped_alert and has_some_mapped) or (!show_unmapped_alert)
/* Alert Title */
if ( show_pregnancy_alert or
show_missing_pregnancy_data_alert or
show_outdated_preg_data_alert or
show_outdated_edd_data_alert or
show_missing_gender_without_preg_alert or
show_missing_age_without_preg_alert or
show_unmapped_alert )
then
if( show_lactation_alert or
show_missing_lactation_data_alert or
show_outdated_lact_data_alert or
show_missing_gender_without_lact_alert or
show_missing_age_without_lact_alert or
show_unmapped_alert )
then
preg_lact_short_message:= "Pregnancy and Lactation Warning";
preg_lact_rule_group:= "Pregnancy and Lactation Conflict";
preg_lact_rule_number:= 2020;
else
preg_lact_short_message:= "Pregnancy Warning";
preg_lact_rule_group:= "Pregnancy Conflict";
preg_lact_rule_number:= 2010;
endif;
elseif ( show_lactation_alert or
show_missing_lactation_data_alert or
show_outdated_lact_data_alert or
show_missing_gender_without_lact_alert or
show_missing_age_without_lact_alert )
then
preg_lact_short_message:= "Lactation Warning";
preg_lact_rule_group:= "Lactation Conflict";
preg_lact_rule_number:= 2015;
endif;
endif; //if continue_processing 2
// 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;
complet_multum_references:="";
if( show_missing_gender_without_preg_alert
or show_missing_age_without_preg_alert
or show_missing_gender_without_lact_alert
or show_missing_age_without_lact_alert
or show_missing_pregnancy_data_alert
or show_missing_lactation_data_alert
or show_outdated_preg_data_alert
or show_outdated_lact_data_alert
or show_outdated_edd_data_alert
or show_unmapped_alert )
then
citations_string:="{{+B}}Citations{{-B}}:None";
else
sorted_obj_list := SORT Sort_field DATA mdo_reference_list;
if exist sorted_obj_list
then
// Display citiations details
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}}";
number_list := 1 seqto count(sorted_obj_list);
for JJ in number_list do
textTitle := sorted_obj_list[JJ].TextTitle;
drugID := sorted_obj_list[JJ].Drug_ID;
functionID := sorted_obj_list[JJ].Function_ID;
isPregnancyAlert := sorted_obj_list[JJ].Is_pregnancy_alert;
if (JJ > 1)
then
PreviousdrugID :=
sorted_obj_list[JJ-1].Drug_ID;
PreviousisPregnancyAlert :=
sorted_obj_list[JJ-1].Is_pregnancy_alert;
else
PreviousdrugID := null;
PreviousisPregnancyAlert := null;
endif;
can_reclaim_citation_details:=false;
if (PreviousdrugID=drugID)
then
if (PreviousisPregnancyAlert=isPregnancyAlert)
then
can_reclaim_citation_details:=false;
else
can_reclaim_citation_details:=true;
endif;
else
can_reclaim_citation_details:=true;
endif;
if can_reclaim_citation_details = true
then
// build up list of refrences/Citations
(multum_references, revisionDate, referenceCount):=
call func_multum_references with
"rtf",
"preglact",
textTitle,
drugID,
null,
null,
null,
functionID;
if multum_references is not null
then
if complet_multum_references is null or complet_multum_references=""
then
complet_multum_references:= multum_references;
else
complet_multum_references:= complet_multum_references
|| multum_references;
endif;
endif;
endif;
enddo;//for JJ in number_list do
endif;
endif;
endif;
;;
priority: 50
;;
evoke:
phys_note_enter_event
or phys_note_modify_event
or order_init_event
or patient_group_order_init_event
or order_enter_event
or patient_group_order_enter_event
or order_modify_event
or outpatient_order_init_event
or pharm_order_init_event
or pharm_dispense_new_event
or pharm_dispense_exist_event
or prescription_init_event
or prescription_renew_event
or alert_check_order_event
or alert_check_client_pres_event
/* 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. */
/*
or order_alternate_enter_IV_event
or order_alternate_enter_NOIV_event
or order_alternate_modify_event
*/
;
;;
logic:
if not continue_processing
then
conclude false;
endif;
if( show_pregnancy_alert
or show_lactation_alert
or show_missing_gender_without_preg_alert
or show_missing_age_without_preg_alert
or show_missing_gender_without_lact_alert
or show_missing_age_without_lact_alert
or show_missing_pregnancy_data_alert
or show_missing_lactation_data_alert
or show_outdated_preg_data_alert
or show_outdated_lact_data_alert
or show_outdated_edd_data_alert
or show_unmapped_alert )
then
conclude true;
endif;
conclude false;
;;
action:
pregnancy_lactation_alert_destination.short_message:= preg_lact_short_message;
pregnancy_lactation_alert_destination.rule_group:= preg_lact_rule_group;
pregnancy_lactation_alert_destination.rule_number:= preg_lact_rule_number;
pregnancy_lactation_alert_destination.alert_abstract:= preg_lact_alert_abstract;
pregnancy_lactation_alert_destination.references :=
pregnancy_lactation_alert_destination.references || revision_date_string || "\n\n" ||
citations_string || "\n\n" || complet_multum_references;
alert_message := pregnancy_alert_header
|| lactation_alert_header
|| missing_data_header
|| missing_gender_preg_message
|| missing_gender_lact_message
|| missing_age_preg_data_message
|| missing_age_lact_data_message
|| missing_age_with_preg_data_message
|| missing_age_with_lact_data_message
|| missing_pregnancy_data_message
|| missing_lactation_data_message
|| outdated_preg_data_message
|| outdated_lact_data_message
|| outdated_edd_data_message
|| preg_lact_alert
|| unmapped_orders_alert;
write alert_message at pregnancy_lactation_alert_destination;
;;
urgency: 50
;;
end: