maintenance: title: St.Clair: Non Routine Diet Trays;; mlmname: FORM_Diet_Overdue_NonRoutine_Tray;; arden: version 2;; version: 4.50;; institution: St Clair;; author: Don Warnick, Eclipsys Corp;; specialist: ;; date: 2007-03-22;; validation: testing;; library: purpose: Determine if it is too late to send a routine meal tray and force the entry of a non routine tray is needed. ;; explanation: This MLM is called from the Form_DietAllOptions form. Change history 07.11.2008 RS Changed Today time from string to Arden time format ;; keywords: Called MLMs, Form fields, Non Routine Diet Tray ;; 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; visit_guid := this_communication.ClientVisitGUID; /*******************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; requesteddate:= last of (field_list where field_list.DataItemName = "RequestedDate" ); requestedtime:= last of (field_list where field_list.DataItemName = "RequestedTime" ); nonroutinetray:= last of (field_list where field_list.DataItemName = "DIET_Non Routine Trays" ); // determine if the requested time is scheduled or coded. if exists requestedtime.value.reqtimevalue then time_type := "scheduled"; time_value := requestedtime.value.reqtimevalue; else time_type := "coded"; time_value := requestedtime.value.reqtimecode; endif; // if coded get the timelimit of the coded time..if scheduled get the inputted time w/o the : if time_type = "coded" then (timelimit) := read last {" select endtime " ||" from cv3codedtime " ||" where name = " || sql(time_value) ||" and active = 1 " }; elseif time_type = "scheduled" then (timelimit) := read last {" select stuff(" || sql (time_value) || ", patindex({{{SINGLE-QUOTE}}}%:%{{{SINGLE-QUOTE}}}," || sql (time_value) || " ),1,null) "}; endif; // extract components of current time and create fields which can be compared with requested time hr := extract hour now; if hr < 10 then hr := "0" || hr; endif; mi := extract minute now; if mi < 10 then mi := "0" || mi; endif; currtime := hr || mi; yr := extract year now; mn := extract month now; if mn < 10 then mn := "0" || mn; endif; dd := extract day now; if dd < 10 then dd := "0" || dd; endif; // today:= mn || "-" || dd || "-" || yr || " 00:00:00"; // 07-11-2008 RS Changed today string to equal Arden Time String today:= yr || "-" || mn || "-" || dd || "T00:00:00"; // determine if meal is overdue based upon requested time and current date and time if requesteddate.value > (today as time) then overdue:= False; elseif requesteddate.value < (today as time) then overdue:= True; elseif requesteddate.value = (today as time) and (currtime as number) > (timelimit as number) then overdue:= True; else overdue:= False; endif; if overdue = True then nonroutinetray.Control_mandatory:= True; else nonroutinetray.Control_mandatory:= False; endif; // Use visit_guids to fire alerts so we can test on MACS TEST PATIENT ONLY IN PROD // JUST CHANGE THE GUID FOR THE NEW ACCOUNT AND UNCOMMENT BATCH OF CODE /* If (visit_guid ="9000221334600270") or (visit_guid = "9000001559200270") then this_communication.Message := "\nschedule type = " || time_type || "\nschedulte time value= " || time_value || "\n " || "\ncurrent date / time = " || now || "\n " || "\ncurrent date = " || (today as time) || "\nrequested date = " || requesteddate.value || "\n " || "\ncurrent time = " || currtime || "\ntime limit = " || timelimit || "\n " || "\noverdue = " || overdue || "\n\nyear =" || yr || "\nMonth = " || mn || "\nDay = " || dd || "\n\nMessage From Robert Spence, HIS 7461"; this_communication.MessageType := "Informational"; 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: