maintenance: title: FORM_SET_MOVIPREP;; mlmname: FORM_SET_MOVIPREP;; arden: version 2.5;; version: 5.50;; institution: St Clair Hospital;; author: Juliet M. Law, Allscripts ;; specialist: Bryan Berkeybile, Allscripts;; date: 2013-03-18;; validation: testing;; library: purpose: Change date/time on Moviprep orders based on Opening date/time ;; explanation: This MLM is called from the Moviprep OS (bowel prep for Colonoscopy) Change history 13.03.18 JML CSR# 30966 copied from FORM_SET_LIDODERM_PATCH 19.11.27 TMS CSR# 38801 Add scheduling logic for baseline and follow up magnesium and electrolytes. ;; keywords: Called MLMs, Moviprep ;; knowledge: type: data-driven;; data: // Communication object Form object Arden ClientInfo object (this_communication, this_form, client_info_obj) := argument; standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; // Use Generic MLM generic_mlm := mlm {{{SINGLE-QUOTE}}}FORM_Set_Generic_Item_Control{{{SINGLE-QUOTE}}}; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; log_execution_info := FALSE; error_message:=""; // Assigns fields passed in the Form object to the Field object field_list:= this_form.fields; client_guid := this_communication.ClientGUID; visit_guid := this_communication.ClientVisitGUID; chart_guid := this_communication.ChartGuid; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; //Capture Opening Date and Time fields; synchs with first medication date and time OpeningDate := first of (field_list WHERE field_list.DataItemName = "RequestedDate" AND field_list.Control_MultiFieldOccNum = 4); OpeningTime := first of (field_list WHERE field_list.DataItemName = "RequestedTime" AND field_list.Control_MultiFieldOccNum = 5); OpeningTimeValue := OpeningTime.Value; //Capture second medication date and time PolyReqDate2 := first of (field_list WHERE field_list.DataItemName = "RequestedDate" AND field_list.Control_MultiFieldOccNum = 2); PolyReqTime2 := first of (field_list WHERE field_list.DataItemName = "RequestedTime" AND field_list.Control_MultiFieldOccNum = 3); PolyReqTime2Value := PolyReqTime2.Value; //Capture NPO date and time NPOReqDate := first of (field_list WHERE field_list.DataItemName = "RequestedDate" AND field_list.Control_MultiFieldOccNum = 3); NPOReqTime := first of (field_list WHERE field_list.DataItemName = "RequestedTime" AND field_list.Control_MultiFieldOccNum = 4); NPOReqTimeValue := NPOReqTime.Value; // Capture dates and priority of baseline and follow up lab tests BaseLineLab := first of (field_list WHERE field_list.DataItemName = "RequestedDate" AND field_list.Control_MultiFieldOccNum = 5); FollowupLab := first of (field_list WHERE field_list.DataItemName = "RequestedDate" AND field_list.Control_MultiFieldOccNum = 6); BaselinePriority := first of (field_list WHERE field_list.DataItemName = "LAB_Order Priorities" AND field_list.Control_MultiFieldOccNum = 1); EntryTime := (now as time) ; EntryHour := extract hour EntryTime; EntryMonth := extract month EntryTime; EntryDay := extract day EntryTime; EntryYear := extract year EntryTime; EntryDate := EntryMonth || "-" || EntryDay || "-" || EntryYear || " 00:00"; if (CallingEvent = "FormOpen") then //Execute the generic MLM on form open execute_generic_mlm := call generic_mlm with this_communication, this_form, client_info_obj; //Default the Opening Requested time to 6:00PM OpeningTimeValue.ReqTimeCode := "Scheduled/Start Time"; OpeningTimeValue.ReqTimeValue := "18:00"; //Default the second medication date / time to T+1 and 4:00am PolyReqDate2.Value := OpeningDate.Value + 1 day; PolyReqTime2Value.ReqTimeCode := "Scheduled/Start Time"; PolyReqTime2Value.ReqTimeValue := "04:00"; //Default the NPO to one hour past the second medication date/time NPOReqDate.Value := PolyReqDate2.Value; NPOReqTimeValue.ReqTimeCode := "Scheduled Time"; NPOReqTimeValue.ReqTimeValue := "05:00"; //Default Lab Draws, schedule baseline for next even hour if AM rounds has passed. BaselineLab.value := OpeningDate.Value; FollowupLab.value := OpeningDate.Value + 1 day; If (EntryHour as number) < 5 then BaselinePriority.value := "AM Rounds"; else BaselinePriority.value := "ROUTINE (Drawn next even hour)"; endif; elseif (CallingEvent = "FieldChange") then //Event handle if user changes the opening date /time that synchs with first medication date/time if ((CallingField = "RequestedDate|4") OR (CallingField = "RequestedTime|5")) then //Retrieve Opening date StartDate := OpeningDate.Value; // If Date of procedure changed to day other then today adjust collection of baseline // and follow up lab to be day before and day of procedure. If (StartDate as time) > (EntryDate as time) then BaselineLab.value := OpeningDate.Value; FollowupLab.value := OpeningDate.Value + 1 day; BaselinePriority.value := "AM Rounds"; endif; //Retrieve opening hour plus the full time cast as a Time data type OpeningTimeHour := (substring 2 characters from OpeningTimeValue.ReqTimeValue) as number; OpeningTimeFullTime := OpeningTimeValue.ReqTimeValue as Time; //We need to know when we have to flip the date to T+1 on the second med order //Easiest way I could figure to do this is to grab the opening date and time //If the opening time is greater than or equal to 14:00 (i.e. 2:00PM), then flip the second //med date to T+1 if (OpeningTimeHour >= 14) then PolyReqDate2.Value := (OpeningDate.Value + 1 day); else PolyReqDate2.Value := OpeningDate.Value; endif; //Second medication time needs to be 10 hours past the opening (or first med) time NewMedTime := OpeningTimeFullTime + 10 hours; NewMedTimeHour := extract hour NewMedTime; if (length (NewMedTimeHour as string) = 1) then Hr := "0" || NewMedTimeHour; else Hr := NewMedTimeHour; endif; NewMedTimeMinute := extract minute NewMedTime; if (length (newMedTimeMinute as string) = 1) then Mins := "0" || NewMedTimeMinute; else Mins := NewMedTimeMinute; endif; PolyReqTime2Value.ReqTimeValue := Hr || ":" || Mins; //Deal with the NPO NPOReqDate.Value := PolyReqDate2.Value; //Need to add 1 hour to the second med hour for the NPO NPOTimeHour := NewMedTimeHour + 1; if (NPOTimeHour = 24) then NPOTimeHour := "00"; NPOReqDate.Value := PolyReqDate2.Value + 1 day; endif; if (length (NPOTimeHour as string) = 1) then NPOHr := "0" || NPOTimeHour; else NPOHr := NPOTimeHour; endif; NPOReqTimeValue.ReqTimeValue := NPOHr || ":" || Mins; endif; endif; ;; evoke: // No evoke statement ;; logic: conclude true; ;; action: // This MLM returns two parameters, of types communication_type and form_type respectively. return this_communication, this_form; ;; end: