maintenance: maintenance: title: Order Retrieval for Pharmacy Obj Plus Discontinue Function;; filename: FORM_Rx_Medication_Retrieval;; arden: version 2.5;; version: 15.10;; institution: Eclipsys, System MLM;; author: Teresa Spicuzza;; specialist: Teresa Spicuzza;; date: 2015-10-05;; validation: testing;; library: purpose: This MLM retrieves medication by therapeutic class for deletion from within the order form. ;; explanation: This MLM retrieves medication by therapeutic class for deletion from within the order form. History: 04.27.2016 TMS CSR 33465 Created to present duplicate therapeutic medication alerts in an interactive window allowing users to discontinue existing orders or abandon the order they are trying to enter in a user friendly presentation. This MLM uses the duplicate checking stored procedures that are used by the STD_Duplicate_Medication_Therapy MLM and the Multum Data Configuration in Decision Support. This MLM is called from order forms on Form Open. Medications on an order set are checked using FORM_SET_Rx_Medication_Order_Mgt on Form Open. 12.05.2016 TMS Change name of stored procedure used to gather duplicate order guids from SCMTherapeuticDuplicateMedsCheckingPR to SCHTherapeuticDuplicateMedsCheckingPR. This is a copy of the 15.1 version of the stored procedure. This will be used instead of the 16.3 version of SCMTherapeuticDuplicateMedsCheckingPR to eliminate modifying MLM to send additional fields for community medication orders - a new feature not needed for this MLM CSR 35130 04.11.2017 TMS Modified format of order guids in hidden field to save without encasing values in single quotes for use by SCH_ALERT_ON_DUPLICATE_ORDERS. CSR 33465 05.09.2017 TMS Modified to supress duplicate alerts from between Vancomycin PO and Vancomycin IV. CSR 34904 ;; keywords: Called MLMs, Form fields, Therapeutic Duplication ;; 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}}Citations{{-B}}: None supplied by Cerner Multum, Inc. {{+B}}Release{{-B}}: VantageRx Multum Database ;; knowledge: type: data-driven;; data: // This MLM is passed three arguments, of types // communication_type, form_type and client info object respectively. (this_communication, // Communication object this_form, // Form object client_info_obj //Arden ClientInfo object ) := argument; /*******************Make Changes To Spelling And Flags In This Section*******************/ /* Set to true if a decision.log is needed.*/ // log_execution_info := FALSE; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; comm_obj := this_communication.primaryobj; /***************************************************************************************/ // Initialize error message error_message:=""; error_occurred := false; info_message := ""; continue_checking_meds := TRUE; // Assigns fields passed in the Form object to the Field object field_list:= this_form.fields; OrderSource := comm_obj.SourceCode; ProviderGuid := this_communication.CareProviderGUID; MedOrderBox := last of (field_list where field_list.DataItemName = "OBJ_Plus_Med" ); DupFlag := last of (field_list where field_list.DataItemName = "PRX_Dup_Action_Flag"); // InfoBox := last of (field_list where field_list.DataItemName = "PRX_Notecomment0"); IV_additive := last of (field_list where field_list.DataItemName = "IVAdditive" ); Obj_Plus_Launch := last of (field_list where field_list.DataItemName = "PRX_Alert_from_Order_Form"); session_type := comm_obj.internalprocessingtype; client_guid := this_communication.ClientGUID; visit_guid := this_communication.ClientVisitGUID; User_GUID := this_communication.UserGUID; Order_Mgt_MLM := mlm {{{SINGLE-QUOTE}}}SCH_LAUNCH_ORDER_MANAGEMENT{{{SINGLE-QUOTE}}}; Dup_Order_Guids := last of (field_list where field_list.DataItemName = "PRX_Order_Guids" ); OrderSetName := comm_obj.OrderSetName; CalledfromSet := last of (field_list where field_list.DataItemName = "MLM_From Order Set"); // PreSelectedonSet := last of (field_list where field_list.DataItemName = "PRX_PreSelectedOrder"); Addl_Order := last of (field_list where field_list.DataItemName = "PRX_Dosing Addl Dose"); FrequencyField:= last of (field_list where field_list.DataItemName = "FrequencyCode"); FrequencyCode := FrequencyField.value; Frequency := FrequencyCode.FrequencySummary; Dup_Order_Action := last of (field_list where field_list.DataItemName = "PRX_Duplicate_Order_Action_Text"); // Specify which .NET assemblies need to be loaded for ObjectsPlus standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; // Using assembly and namespace using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; /*******************Make Changes To Spelling And Flags In This Section*******************/ /* Set to true if a decision.log is needed.*/ log_execution_info := false; /* Set to false if not need to display Order Form dialog. If it{{{SINGLE-QUOTE}}}s set to true, order form will be displayed and the order will be saved to order entry worksheet when OK is clicked from the order form. */ display_order_form := true; /* Set to false if not to cancel the current order */ cancel_current_order := true; /***************************************************************************************/ // Set to a different Order Status Level // if fewer order statuses should be included lowest_status_level_for_meds:= 0; // Normally orders with a StopDTM will have 3 times their half-life added to // their stopDTM when figuring what drugs are still active in the patient{{{SINGLE-QUOTE}}}s system. // This value indicates that if a completed drug has a half // life less than this then not to bother adding on the 3 x the half-life Past_HalfLife_Grace_Period := 10000; // value in hours // Normally if the drug being ordered has a StopDTM then we add 3 times the // half-life to the StopDTM when figuring what drugs in the database with // start times in the future to include in the checking. // This value indicates that if the drug being ordered has a half // life less than this then not to bother adding on the 3 x the half-life Future_HalfLife_Grace_Period := 10000; //value in hours // Set the variable to indicate timeframe in minutes between the stopdtm // and startdtm of identical orders that would make them be considered // a reorder and thus not included in the duplicate checking. Reorder_Grace_Period := 0; // value in minutes at_in_house_session_list:= ("Inhouse"); // setting for "Suppress Duplicate Checking for Items in This Set" use_catalog_setting_to_suppress_duplicate_checking_in_sets:= TRUE; main_order_name := comm_obj.Name; evoking_order_object_guid := comm_obj.GUID; order_status_code := comm_obj.itemstatus; Order_summary_line := "Summary Line Info"; main_item_catalog_guid := this_communication.ItemID; chart_guid := this_communication.chartguid; client_guid := this_communication.clientguid; client_visit_guid := this_communication.clientvisitguid; significant_date := comm_obj.significantdtm; stop_date := comm_obj.stopdtm; order_is_conditional := comm_obj.isconditional; order_exists := false; parent_conditional_order_guid := null; order_component_obj := null; complex_order := comm_obj.complexordertype; order_is_for_discharge := comm_obj.isformdischarge; order_alternate_order_type := null; evoking_med_source := null; order_session_type_bit_flags := 1; unsubmitted_session_type_bit_flags := 1; db_session_type_bit_flags := 1; back_up_obj := null; // Executes only when this MLM is called by the editor if called_by_editor then main_order_name := "Codeine 30mg Tab"; evoking_order_object_guid := comm_obj.GUID; order_status_code := comm_obj.itemstatus; Order_summary_line := "Summary Line Info"; main_item_catalog_guid := 8000001351073001; chart_guid := this_communication.chartguid; client_guid := this_communication.clientguid; client_visit_guid := this_communication.clientvisitguid; significant_date := comm_obj.significantdtm; stop_date := "25-Feb-2016 0:00:00.000"; order_is_conditional := comm_obj.isconditional; order_exists := false; parent_conditional_order_guid := null; order_component_obj := null; complex_order := comm_obj.complexordertype; order_is_for_discharge := comm_obj.isformdischarge; order_alternate_order_type := null; evoking_med_source := null; client_guid := 9000002166800200; client_visit_guid := 9000003935500270; user_guid := 4000001117119000; db_session_type_bit_flags := 1; avoid_parent_orderset_guid := ""; evoking_order_object_guid := 9001132042600680; back_up_obj := null; endif; func_dup_suppress_checking := MLM {{{SINGLE-QUOTE}}}STD_FUNC_Dup_Suppress_Checking{{{SINGLE-QUOTE}}}; // Initialize input XML parameter evoking_order_parameter_xml := ""; // evoking_rx_parameter_xml := ""; unsubmitted_order_parameter_xml := ""; SP := " "; CR := 13 formatted with "%c"; LF := 10 formatted with "%c"; CRLF:= CR||LF; TAB := 9 formatted with "%c"; OrderSetName := comm_obj.OrderSetName; If Addl_Order.value = True and (Frequency = "Stat" or Frequency = "Now") then Stat_Now_Then_Order := "True"; else Stat_Now_Then_Order := "False"; endif; If (CallingEvent = "FormOpen" and CalledFromSet.value = false and Stat_Now_Then_Order = "False") or (CallingEvent = "FieldChange" and CallingField = "IVAdditive") or (CallingEvent = "FormOpen" and CalledfromSet is null and Stat_Now_Then_Order = "False") then // ****** Check for IV additives if exists IV_additive then additives_list := (); evoking_additive_cat_GUID_List := (); evoking_additive_name_List := (); additives_list := IV_additive.value; evoking_additive_cat_GUID_List := additives_list.OrderCatalogMasterItemGUID; evoking_additive_name_List := additives_list.Name; start_date := significant_date; if (start_date is NULL) then start_date := (day floor of now); endif; IF count evoking_additive_cat_GUID > 0 then listedname := ""; separator := ""; for p in 1 seqto (count evoking_additive_cat_GUID_List ) do evoking_additive_cat_GUID := evoking_additive_cat_guid_list [p]; evoking_additive_name := evoking_additive_name_list[p]; IsAdditive := "1"; evoking_is_selected := 1; if (evoking_additive_cat_GUID is not null) then evoking_additive_xml := " \n"; evoking_order_parameter_xml := evoking_order_parameter_xml || evoking_additive_xml; listedname := listedname || separator || evoking_additive_name; separator := ", "; endif; enddo; listedname := listedname || " in " || main_order_name; endif; endif; // If exists IV_additive then /* Initialize variable to empty string */ avoid_parent_orderset_guid := ""; avoid_child_orderset_guid := ""; cont1 := continue_checking_meds; //marker RS mainorder := main_order_name; //marker RS evoking_item_name := main_order_name; continue_checking_meds := TRUE; start_date := (day floor of now); db_session_type_bit_flags := order_session_type_bit_flags; unsubmitted_session_type_bit_flags := order_session_type_bit_flags; // Check medications from significant date for non-alert checking triggers start_date := significant_date; if (start_date is NULL) then start_date := (day floor of now); endif; evoking_is_selected := 1; if continue_checking_meds then // Add evoking object information in the input XML parameter If IsAdditive <> "1" or IsAdditive is Null then listedname := main_order_name; evoking_order_parameter_xml := " \n"; endif; input_parameter_xml := "\n\n" || evoking_order_parameter_xml || "\n"; // Convert the boolean values to binary flag ignore_discontinued_prescriptons_flag := ignore_discontinued_prescriptons as number; display_lowest_category_exceeded_flag := display_lowest_category_exceeded as number; check_parent_conditionarl_order := 0; // Call stored proc to check duplicate medication therapy (ComponentDrugKey_list, ParentDrugKey_list, EnteredDrugComponent_list, EnteredDrugName_list, EnteredIsAdditive_list, DuplicateOrderName_list, DuplicateAdditiveName_list, DupIngredientName_list, DupIsAdditive_list, DupOrderGUID_list, OrderCatlogMasterItem_list, DupCategoryName_list, MaxDupThreshold_list, DupSummaryLine_list, DupStartDTM_list, DupStopDTM_list, DupOrderStatusNum_list, DupOrderStatus_list, CategoryLevel_list, IsMapped_list, DupIsOrder_list):= read{" SCHTherapeuticDuplicateMedsCheckingPR " || SQL(input_parameter_xml) || ", " || client_guid || ", " || user_guid || ", " || SQL(Past_HalfLife_Grace_Period) || ", " || SQL(Future_HalfLife_Grace_Period) || ", " || SQL(Reorder_Grace_Period) || ", " || SQL(lowest_status_level_for_meds) || ", " || db_session_type_bit_flags || "," || SQL(avoid_parent_orderset_guid) || "," || SQL(avoid_child_orderset_guid) || ", " || SQL(ignore_discontinued_prescriptons_flag) || ", " || SQL(display_lowest_category_exceeded_flag) || ", " || SQL(check_parent_conditionarl_order) || ", " || SQL(parent_conditional_order_guid) }; sqlextract := ""; countnosub := 0; Dup_Order_Guids.value := ""; if exist EnteredDrugName_list then if main_order_name = "Vancomycin:" then noalertname := "Vancomycin Soln"; elseif main_order_name = "Vancomycin Soln" then noalertname := "Vancomycin:"; else noalertname := " "; endif; spool_list := 1 seqto count (EnteredDrugName_list); for countorder in spool_list do singorder := DupOrderGUID_list[countorder]; singstat := DupOrderStatus_list[countorder]; singsum := DupSummaryLine_list[countorder]; singname := DuplicateOrderName_list[countorder]; if (singstat <> "Unapproved" and (singname is not null) and (singname <> noalertname)) // no need to check different accoutn if = unsubmitted then cvguid := read last {" select o.ClientVisitGUID from cv3order o " || " where o.guid = " || singorder }; if cvguid = visit_guid then countnosub := countnosub + 1; if countnosub = 1 then sqlextract := "{{{SINGLE-QUOTE}}}" || singorder || "{{{SINGLE-QUOTE}}}"; Dup_Order_Guids.value := singorder ; else sqlextract := sqlextract || ",{{{SINGLE-QUOTE}}}" || singorder || "{{{SINGLE-QUOTE}}}"; Dup_Order_Guids.value := Dup_Order_Guids.value || "," || singorder ; endif; endif; endif; enddo; endif; endif; // if continue checking meds objplusmsg := ""; If (countnosub > 0) then If OrderSource is null then OrderSource := " "; endif; If this_communication.DisplayForm = "No" and this_communication.OrderSet = "No" then objplusmsg := listedname|| "|Q|" || sqlextract || "|" || OrderSource || "|" || ProviderGuid || "|" || "Pharmacy|"; alerttype := "Q"; alerttype2 := "Q"; continuecheck := "y"; elseif this_communication.DisplayForm = "Yes" and this_communication.OrderSet = "No" then objplusmsg := listedname|| "|Q|" || sqlextract|| "|" || OrderSource || "|" || ProviderGuid || "|" || "Pharmacy|"; alerttype := "Q"; alerttype2 := "F"; continuecheck := "y"; else continuecheck := "n"; endif; If continuecheck = "y" then Dupflag := call Order_Mgt_MLM with (objplusmsg); // If exists Dupflag and dupflag is not null then If exists Dupflag then If exist Dup_Order_Action then If dupflag matches pattern "N%" then Dup_Order_Action.value := "Possible Duplicate Orders Reviewed - No Changes Indicated"; elseif dupflag matches pattern "Y%" then Dup_Order_Action.value := "Possible Duplicate Orders Reviewed - Actions Taken"; else Dup_Order_Action.value := "Possible Duplicate Orders Not Addressed"; endif; endif; endif; endif; //continuecheck = "y" endif; //If (countnosub > 0) endif; // If CallingEvent... // 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; if error_occurred = true then this_communication.MessageType := "Error"; // Informational, Error, Banner this_communication.Message := info_message || "\n" || "Error: " || error_message; endif; ;; evoke: // No evoke statement ;; logic: if alerttype = "Q" and this_communication.DisplayForm = "No" and OrdersetName is null and (dupflag = "NY" or dupflag = "YY") then try //----------------------------------------------------------- // Retrieve current order entry batch. // The new order can be added only if the parent order // belongs to the order entry batch // object owned by the OrderEntryWorksheet. //----------------------------------------------------------- worksheetInfo := call {{{SINGLE-QUOTE}}}OrderEntryBatch{{{SINGLE-QUOTE}}}.GetCurrent; if worksheetInfo is NULL OR "OrderEntryWorksheet" <> (worksheetInfo.OrderBatchOwner as String) then // If current order entry batch is not OrderEntryWorksheet, // do not continue with the order replacement. // Still conclude true to return communication and form objects. conclude true; endif; this_communication.PrimaryObj.CancelOrder := cancel_current_order; if cancel_current_order = true then info_message := "The order is canceled by MLM."; endif; endtry; catch Exception ex error_occurred := true; error_message := ex.Message; endcatch; endif; if alerttype = "Q" and this_communication.DisplayForm = "Yes" and OrdersetName is null and (dupflag = "NY" or dupflag = "YY") then this_communication.DisplayForm := "No" ; try //----------------------------------------------------------- // Retrieve current order entry batch. // The new order can be added only if the parent order // belongs to the order entry batch // object owned by the OrderEntryWorksheet. //----------------------------------------------------------- worksheetInfo := call {{{SINGLE-QUOTE}}}OrderEntryBatch{{{SINGLE-QUOTE}}}.GetCurrent; if worksheetInfo is NULL OR "OrderEntryWorksheet" <> (worksheetInfo.OrderBatchOwner as String) then // If current order entry batch is not OrderEntryWorksheet, // do not continue with the order replacement. // Still conclude true to return communication and form objects. conclude true; endif; this_communication.PrimaryObj.CancelOrder := cancel_current_order; if cancel_current_order = true then info_message := "The order is canceled by MLM."; endif; endtry; catch Exception ex error_occurred := true; error_message := ex.Message; endcatch; endif; if error_occurred = true then this_communication.MessageType := "Error"; // Informational, Error, Banner this_communication.Message := info_message || "\n" || "Error: " || error_message; endif; conclude true; ;; action: // This MLM returns two parameters, of types communication_type and form_type respectively. return this_communication, this_form; ;; end: