maintenance: title: Alcohol Withdrawal Protocol Orders;; mlmname: FORM_Set_AWP_Sched_Protocol;; arden: version 2.5;; version: 16.3;; institution: St Clair Hospital;; author: Teresa Spicuzza, Allscripts ;; specialist: Teresa Spicuzza, Allscripts;; date: 2017-03-17;; validation: testing;; library: purpose: Used for autoscheduling start times for Scheduled Alcohol Withdrawal Protocol ;; explanation: This MLM is called from Alcohol Withdrawal Scheduled Lorazepam (Ativan) Orders Change history 09.21.2017 TMS CSR 35319 Created to auto-schedule scheduled lorazepam protocol of Alcohol withdrawal orders, based upon last administration time of PRN protocol. ;; keywords: Called MLMs, Lab Grids on Order Sets, Alcohol Withdrawal Protocol ;; knowledge: type: data-driven;; data: // Use String parse str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; // 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; /***************************************************************************************/ // Initialize error message error_message:=""; // Assigns fields passed in the Form object to the Field object field_list:= this_form.fields; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; RequestedTime_obj := OBJECT [ReqTimeCode, RegTimeValue, ReqTimeUOM, ReqTimeEventModifier, ReqTimeEventCode]; //Get the multi order grid check box value Checkbox_fld := last of (field_list where field_list.DataItemName = "PRX_Checkbox1"); Ativan_grid := last of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 64); Ativan_list :=Ativan_grid.Value; Ativan_SelList := Ativan_List.IsSelected; Day1reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 1); Day2reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 2); Day3reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 3); Day4reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 4); Day5reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 5); Day6reqdate:= last of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 6); Day1reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 1); Day2reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 2); Day3reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 3); Day4reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 4); Day5reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 5); Day6reqtime:= last of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 6); if (CallingEvent = "FormOpen") THEN Checkbox_fld.value := true; clientGUID := this_communication.ClientGUID; ChartGUID := this_communication.ChartGUID; VisitGUID := this_communication.ClientVisitGUID; MedGuids := read {" select guid from cv3ordercatalogmasteritem where description like {{{SINGLE-QUOTE}}}%(awp)%{{{SINGLE-QUOTE}}} and expirydate is null"}; //find last administration time of lorazepam from alcohol withdrawal prn orders Last_given, Frequency := read first {" select oto.significantdtm, ot.orderfrequency from cv3ordertask ot join CV3OrderTaskOccurrence oto on oto.ordertaskguid = ot.guid where OrderCatalogMasterItemGUID in (" || sql(medguids) || ") and ot.clientguid = " ||sql(clientguid)|| "and oto.TaskStatusCode = {{{SINGLE-QUOTE}}}performed{{{SINGLE-QUOTE}}} order by oto.SignificantDtm desc" }; DefType, IntervalTime, IntervalUOM := read last {" select definitiontype, timefromvalue, timeuom from CV3Frequency where code = " || SQL(Frequency)}; If DefType = 2 and IntervalUOM = "hr(s)" then TimeSpan := IntervalTime; else TimeSpan := 2; endif; CurrentMinute:= extract minute NOW; CurrentHour := extract hour NOW; newtime := last_given as time; duetime := newtime + (TimeSpan as number) hours; If (duetime < now or duetime is null) then duetime := now as time; endif; DueMinute:= extract minute duetime; if dueminute > 10 then duetime := duetime + 1 hours; endif; DueYear := extract year duetime; DueDay := extract day duetime; DueMon := extract month duetime; DueHour := extract hour duetime; If CurrentHour > DueHour then DueHour := CurrentHour; endif; DueYear := extract year duetime; DueDay := extract day duetime; DueMon := extract month duetime; newstarttime := duehour formatted with "%2.2d" || ":00"; newstartdate := duemon ||"-" ||dueday ||"-" ||dueyear ; Day1reqtimeValue := Day1reqtime.Value; Day1reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; day1reqtimevalue.reqtimevalue := newstarttime ; day1reqdate.value := newstartdate as time; ENDIF; If exists Day1reqtime then ReqTimeValue := Day1reqtime.Value; // Found_DeSelect:= First of (Grid_list where Grid_list.Name = DeSelect ); If CallingEvent = "FieldChange" Then If Callingfield = "PRX_Checkbox1|1" then If Checkbox_fld.Value = False then ListMembs:= count Ativan_SelList; FalseList := (); for k in (1 seqto ListMembs) do FalseList := FalseList,False; enddo; Ativan_List.IsSelected:= FalseList; ReqTimeValue.ReqTimeCode := NULL; Day6reqtimeValue.ReqTimeCode := NULL; endif; // If Checkbox_fld.Value = False then InstMembs:= count Nurse_Inst_List; schedlist:= (True, False, False); p:=4; for p in (4 seqto InstMembs) do schedlist := schedlist, Nurse_Inst_List.isselected [p]; enddo; Nurse_Inst_List.IsSelected := schedlist; endif; // If Checkbox_fld.Value = True then ListMembs:= count Ativan_SelList; TrueList := (); for k in (1 seqto ListMembs) do TrueList := TrueList,True; enddo; Ativan_List.IsSelected:= TrueList; endif; // If Checkbox_fld.Value = True then InstMembs:= count Nurse_Inst_List; schedlist:= (True, True, True); p:=4; for p in (4 seqto InstMembs) do schedlist := schedlist, Nurse_Inst_List.isselected [p]; enddo; Nurse_Inst_List.IsSelected := schedlist; endif; // If Checkbox_fld.Value = True then ReqTimeValue.ReqTimeCode := "Scheduled/Start Time"; endif; endif; // endif; endif; If ((CallingEvent = "FieldChange") and (CallingField = "RequestedTime|1" or CallingField = "RequestedDate|1")) or CallingEvent = "FormOpen" then StartDate := day1reqdate.value; StartTime := Day1reqtime.value; StartTime_code := starttime.reqtimecode; StartTime_value := starttime.reqtimevalue; ParseTime_list := call str_parse with StartTime_value, ":"; hourvalue := first(ParseTime_list); minvalue := last(ParseTime_list); q6hour := StartTime_Value; q8hour := (hourvalue as number) + 2; if q8hour >= 24 then q8hour := q8hour - 24; endif; if q8hour < 10 then q8hour := "0" || q8hour; endif; q8hour := q8hour || ":" || minvalue; q12hour := (hourvalue as number) + 6; if q12hour >= 24 then q12hour := q12hour - 24; endif; if q12hour < 10 then q12hour := "0" || q12hour; endif; q12hour := q12hour || ":" || minvalue; If starttime_value >= "18:00" then If starttime_value < "22:00" then day2reqdate.value := startdate + 1 day; day3reqdate.value := startdate + 2 day; day4reqdate.value := startdate + 3 day; day5reqdate.value := startdate + 4 day; day6reqdate.value := startdate + 6 day; else day2reqdate.value := startdate + 1 day; day3reqdate.value := startdate + 2 day; day4reqdate.value := startdate + 3 day; day5reqdate.value := startdate + 5 day; day6reqdate.value := startdate + 6 day; endif; else day2reqdate.value := startdate + 1 day; day3reqdate.value := startdate + 2 day; day4reqdate.value := startdate + 3 day; day5reqdate.value := startdate + 4 day; day6reqdate.value := startdate + 5 day; endif; Day2reqtimeValue := Day2reqtime.Value; Day2reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; Day2reqtimeValue.ReqTimeValue := q6hour; Day3reqtimeValue := Day3reqtime.Value; Day3reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; Day3reqtimeValue.ReqTimeValue := q6hour; Day4reqtimeValue := Day4reqtime.Value; Day4reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; Day4reqtimeValue.ReqTimeValue := q6hour; Day5reqtimeValue := Day5reqtime.Value; Day5reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; Day5reqtimeValue.ReqTimeValue := q8hour; Day6reqtimeValue := Day6reqtime.Value; Day6reqtimeValue.ReqTimeCode := "Scheduled/Start Time"; Day6reqtimeValue.ReqTimeValue := q12hour; 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: