maintenance: title: SCH_LAB_PRIORITY_OPTIONS_CALLED;; mlmname: SCH_LAB_PRIORITY_OPTIONS_CALLED;; arden: version 2;; version: 4.50;; institution: St Clair Isolation Set MLM;; author: Eclipsys Corp;; specialist: Shawn Head;; date: 2014-11-24;; validation: testing;; library: purpose: MLM will display either the custom priorities or system priorites and assign the proper schedule to the lab orders. ;; explanation: This MLM is called from several MLM{{{SINGLE-QUOTE}}}s. As of go-live for this MLM the following MLM{{{SINGLE-QUOTE}}}s call this MLM. FORM_LAB_HOLDORDER_REQUESTEDTIME,FORM_GENERIC_EITHER_OR_MANDITORY,FORM_BB_Type_and_Screen,FORM_LAB_GENERIC_MANDITORY Additional MLM{{{SINGLE-QUOTE}}}s may require calling this MLM in the future. Please see the MLM FORM_LAB_PRIORITY_OPTIONS for more details or review the original CSR specs. Change History 2014.11.24 - STH CSR#: 32765 - Created MLM 2015.03.09 - STH CSR#: 32765 - Issues addressed based on users feed back (showing the time field disabled instead of hidding it,adding section for order set calling, and making sure all fields are working from both order entry and being called from Order Sets). 2015.03.19 - STH CSR#: 32765 - Added logic for Order sets to be able to have multiple user friendly lab priority fields and still have the time disabled/enabled approriately. ;; keywords: Called MLMs, Form fields, schedule ;; 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*******************/ /* These variables must containt he same wording as the options in the drop down list */ /***************************************************************************************/ // Initialize error message error_message:=""; field_list:= this_form.fields; clientguid := this_communication.ClientGUID; clientvisitguid := this_communication.ClientVisitGUID; chartguid := this_communication.ChartGUID; // Obtain common fields passed in the Form object to the Field object //commented out ones are just not being used; however left incase you need them. system_lab_priority := last of (field_list where field_list.DataItemName = "RequestedTime" ); user_friendly_lab_priority := last of (field_list where field_list.DataItemName = "LAB_Order Priorities" ); user_friendly_lab_time := last of (field_list where field_list.DataItemName = "LAB_Phleb Draw Sched Time" ); Lab_Priority_to_summary_line := last of (field_list where field_list.DataItemName = "LAB_Order Priority Summ Line" ); Blood_in_lab_checkbox := last of (field_list where field_list.DataItemName = "LAB_CB_BIL"); OrderName := this_communication.PrimaryObj.name; OrderGUID := this_communication.ItemID; comm_obj := this_communication.primaryobj; session_type := comm_obj.internalprocessingtype; // References the LOCAL SESSION object local_session := cds_session.local; standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; if this_communication.FormType = "Order" then DisplayNewScheduled := first of (field_list.Value where field_list.DataItemName = "LAB_CB_Alternate Priorities"); //BEGIN - FORM OPEN SECTION //if (this_communication.CallingEvent = "FormOpen") then Order_Lab_ClassType_Value := read {"SELECT distinct cctv.Value " || " from CV3OrderCatalogMasterItem (NOLOCK) " || " inner join CV3CatalogClassTypeValue cctv (nolock) " || " on CV3OrderCatalogMasterItem.GUID = cctv.CatalogMasterGUID " || " Where cctv.ClassTypeGUID = (SELECT GUID FROM CV3CLASSTYPE WHERE CODE = {{{SINGLE-QUOTE}}}Lab_Specimentype{{{SINGLE-QUOTE}}}) " || " and CV3OrderCatalogMasterItem.Name = " || sql(OrderName)}; if Order_Lab_ClassType_Value[1] is not null then AllBloodInLabOrders := (); for x in 1 seqto(count(Order_Lab_ClassType_Value)) do classtype := Order_Lab_ClassType_Value[x]; BloodInLabOrders := read {"SELECT distinct cv3order.name " || " from CV3Order with (nolock) " || " left JOIN CV3OrderCatalogMasterItem (NOLOCK) " || " on (CV3Order.OrderCatalogMasterItemGUID = CV3OrderCatalogMasterItem.guid) " || " inner join CV3CatalogClassTypeValue cctv (nolock) " || " on CV3OrderCatalogMasterItem.GUID = cctv.CatalogMasterGUID " || " Where cv3order.clientguid = " || sql(ClientGuid) || " and cv3order.chartguid = " || sql(chartguid) || " and cv3order.clientvisitguid = " || sql(ClientVisitGuid) || " and cctv.ClassTypeGUID = (SELECT GUID FROM CV3CLASSTYPE WHERE CODE = {{{SINGLE-QUOTE}}}Lab_Specimentype{{{SINGLE-QUOTE}}}) " || " and cctv.Value = " || sql(classtype) || " and cv3order.OrderStatusLevelNum in (60,80,83,85) " || " and cv3order.SignificantDtm >= dateadd(hh,-2,getdate()) "}; AllBloodInLabOrders := AllBloodInLabOrders, BloodInLabOrders; enddo; endif; endif; //REQUESTEDTIME-END field logic. End of section. ;; evoke: // No evoke statement ;; logic: //BEGIN - ORDER SET LOGIC FOR LAB PRIORITY OPTIONS if this_communication.FormType = "OrderSet" then OS_UserFriendly_LabPriority := (field_list where field_list.DataItemName = "LAB_Order Priorities" ); OS_UserFriendly_LabTimes := (field_list where field_list.DataItemName = "LAB_Phleb Draw Sched Time" ); for x in (1 seqto count(OS_UserFriendly_LabPriority)) do if (this_communication.CallingEvent = "FormOpen") or (this_communication.CallingFieldName = "LAB_Order Priorities|" || x) then if (OS_UserFriendly_LabPriority[x].Value = "Scheduled Time")then OS_UserFriendly_LabTimes[x].Control_Read_Only := false; OS_UserFriendly_LabTimes[x].Control_Visible := true; OS_UserFriendly_LabTimes[x].Control_Mandatory := true; else OS_UserFriendly_LabTimes[x].Control_Read_Only := true; OS_UserFriendly_LabTimes[x].Control_Mandatory := false; OS_UserFriendly_LabTimes[x].Control_Visible := true; OS_UserFriendly_LabTimes[x].value := ""; endif; endif; enddo; endif; //END - ORDER SET LOGIC FOR LAB PRIORITY OPTIONS //BEGIN - ORDER FORM LOGIC if this_communication.FormType = "Order" then if (this_communication.CallingEvent = "FormOpen") then user_friendly_lab_time.Control_Visible := true; user_friendly_lab_time.Control_Read_Only := false; testbilo := BloodInLabOrders[1]; testallbilo := AllBloodInLabOrders[1]; if BloodInLabOrders[1] is not null or AllBloodInLabOrders[1] is not null then Blood_in_lab_checkbox.Control_Visible := true; else Blood_in_lab_checkbox.Control_Visible := false; endif; if (DisplayNewScheduled) then system_lab_priority.Control_Visible := false; user_friendly_lab_priority.Control_Visible := true; user_friendly_lab_priority.Control_Mandatory := true; if (user_friendly_lab_priority.Value = "Scheduled Time")then user_friendly_lab_time.Control_Read_Only := false; user_friendly_lab_time.Control_Visible := true; user_friendly_lab_time.Control_Mandatory := true; else user_friendly_lab_time.Control_Read_Only := true; user_friendly_lab_time.Control_Mandatory := false; user_friendly_lab_time.value := ""; endif; else system_lab_priority.Control_Visible := true; user_friendly_lab_priority.Control_Visible := false; user_friendly_lab_priority.Control_Mandatory := false; user_friendly_lab_time.Control_Visible := false; user_friendly_lab_time.Control_Mandatory := false; endif; if user_friendly_lab_priority.Value is not null and user_friendly_lab_priority.Value <> "" then if (user_friendly_lab_priority.Value = "AM Rounds") then system_lab_priority.Value.ReqTimeCode := "AM Rounds"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "ROUTINE (Drawn next even hour)") then system_lab_priority.Value.ReqTimeCode := "Today"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "STAT") then system_lab_priority.Value.ReqTimeCode := "STAT"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "Scheduled Time") then system_lab_priority.Value.ReqTimeCode := "Scheduled Time"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "Nurse Collect (Add Specimen Required)") then system_lab_priority.Value.ReqTimeCode := "Routine Collected Specimen"; Lab_Priority_to_summary_line.Value := "Nurse Collect"; elseif (user_friendly_lab_priority.Value = "Blood in Lab") then system_lab_priority.Value.ReqTimeCode := "Routine Collected Specimen"; Lab_Priority_to_summary_line.Value := "Blood in Lab"; elseif (user_friendly_lab_priority.Value = "Nurse Collect STAT (Add Specimen Required)") then system_lab_priority.Value.ReqTimeCode := "STAT Collected Specimen"; Lab_Priority_to_summary_line.Value := "Nurse Collect STAT"; else system_lab_priority.Value.ReqTimeCode := ""; user_friendly_lab_priority.Value := ""; Lab_Priority_to_summary_line.Value := ""; endif; endif; endif; //END - FORM OPEN SECTION //BEGIN - USER FRIENDLY PRIORITY CHANGED if (this_communication.CallingFieldName = "LAB_Order Priorities") then if (user_friendly_lab_priority.Value = "Scheduled Time") then //user_friendly_lab_time.Control_Visible := true; user_friendly_lab_time.Control_Read_Only := false; user_friendly_lab_time.Control_Mandatory := true; else //user_friendly_lab_time.Control_Visible := false; user_friendly_lab_time.Control_Read_Only := true; user_friendly_lab_time.Control_Mandatory := false; user_friendly_lab_time.Value := ""; endif; if (user_friendly_lab_priority.Value = "") then system_lab_priority.Value.ReqTimeCode := ""; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "AM Rounds") then system_lab_priority.Value.ReqTimeCode := "AM Rounds"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "ROUTINE (Drawn next even hour)") then system_lab_priority.Value.ReqTimeCode := "Today"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "STAT") then system_lab_priority.Value.ReqTimeCode := "STAT"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "Scheduled Time") then system_lab_priority.Value.ReqTimeCode := "Scheduled Time"; Lab_Priority_to_summary_line.Value := ""; elseif (user_friendly_lab_priority.Value = "Nurse Collect (Add Specimen Required)") then system_lab_priority.Value.ReqTimeCode := "Routine Collected Specimen"; Lab_Priority_to_summary_line.Value := "Nurse Collect"; elseif (user_friendly_lab_priority.Value = "Blood in Lab") then system_lab_priority.Value.ReqTimeCode := "Routine Collected Specimen"; Lab_Priority_to_summary_line.Value := "Blood in Lab"; elseif (user_friendly_lab_priority.Value = "Nurse Collect STAT (Add Specimen Required)") then system_lab_priority.Value.ReqTimeCode := "STAT Collected Specimen"; Lab_Priority_to_summary_line.Value := "Nurse Collect STAT"; else system_lab_priority.Value.ReqTimeCode := ""; user_friendly_lab_priority.Value := ""; Lab_Priority_to_summary_line.Value := ""; endif; endif; //END - USER FRIENDLY PRIORITY CHANGED //BEGIN - BLOOD IN LAB CHECKBOX CHANGE if (this_communication.CallingFieldName = "LAB_CB_BIL") then if Blood_in_lab_checkbox.Value = true then user_friendly_lab_priority.Value := ""; user_friendly_lab_time.value := ""; user_friendly_lab_priority.Control_Mandatory := false; user_friendly_lab_priority.Control_Read_Only := true; user_friendly_lab_time.Control_Mandatory := false; user_friendly_lab_time.Control_Read_Only := true; system_lab_priority.Value.ReqTimeCode := "Routine Collected Specimen"; Lab_Priority_to_summary_line.Value := "Blood in Lab"; else user_friendly_lab_priority.Control_Read_Only := false; user_friendly_lab_priority.Control_Mandatory := true; system_lab_priority.Value.ReqTimeCode := ""; Lab_Priority_to_summary_line.Value := ""; endif; endif; //END - BLOOD IN LAB CHECKBOX CHANGE if (this_communication.CallingFieldName = "Lab_Phleb Draw Sched Time") then if user_friendly_lab_time.Value is not null or user_friendly_lab_time.Value <> "" then system_lab_priority.Value.ReqTimeValue := user_friendly_lab_time.Value; endif; endif; //END - ORDER FORM LOGIC endif; if (session_type = "Hold") then if ((user_friendly_lab_priority.Value = "Scheduled Time") or (system_lab_priority.Value.ReqTimeCode = "Scheduled Time"))then system_lab_priority.Control_Mandatory := false; user_friendly_lab_time.Control_Mandatory := false; endif; endif; conclude true; ;; action: // This MLM returns two parameters, of types communication_type and form_type respectively. return this_communication, this_form; ;; end: