maintenance: title: FORM_NPO_Diet_StartStop;; mlmname: FORM_NPO_Diet_StartStop;; arden: version 2;; version: 5.50;; institution: St Clair;; author: Shawn Head, Allscripts;; specialist: ;; date: 2013-11-09;; validation: testing;; library: purpose: Manage Date fields ;; explanation: This MLM is called from the NPO for Bloodwork order form. The end date will be the start date + 1 on form open and close. Also this MLM will create the start time and end time based on location ICU and CVSU will be start 19:00 stop 04:00. All other locations will be start 21:00 stop 06:00. Change history 11.8.13 STH Created - CSR#: 31694 ;; keywords: Called MLMs, Form fields, NPO, Diet ;; 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; /***************************************************************************************/ // Initialize error message error_message:=""; //execute on FormOpen and FormClose. if this_communication.CallingEvent in ("FormOpen","FormClose") then // Assigns fields passed in the Form object to the Field object field_list:= this_form.fields; CallingField :=this_communication.CallingFieldName; ClientGuid := this_communication.ClientGUID; ClientVisitGuid := this_communication.ClientVisitGUID; ChartGuid := this_communication.ChartGuid; requesteddate:= last of (field_list where field_list.DataItemName = "RequestedDate" ); stopdate:= last of (field_list where field_list.DataItemName = "StopDate" ); requestedtime:= last of (field_list where field_list.DataItemName = "RequestedTime" ); stoptime := last of (field_list where field_list.DataItemName = "StopTime" ); rq_time := requestedtime.value; userguid := this_communication.userguid; //Get the selected patients current location. CurrentLocation := read last {"Select CurrentLocation " ||" From cv3Clientvisit with (nolock)" ||" Where ClientGuid = " || SQL(ClientGuid) ||" and chartguid = " || SQL(ChartGuid) ||" and Guid = " || SQL(ClientVisitGuid) ||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; //if location starts with CVSU or ICU set start time to 19:00 and stop time to 04:00. if (currentLocation matches pattern "CVSU%" OR currentLocation matches pattern "ICU%") then stoptime.value := "04:00"; rq_time.ReqTimeCode := "Scheduled Time"; rq_time.ReqTimeValue := "19:00"; //for any other locations set the start time to 21:00 and stop time to 06:00 else stoptime.value := "06:00"; rq_time.ReqTimeCode := "Scheduled Time"; rq_time.ReqTimeValue := "21:00"; endif; //always set the stop date to the start date + 1 day. stopdate.value := (RequestedDate.Value) + 86400 seconds; 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: