maintenance: title: SCH_CREATE_CARDIACMONITOR_FROM_ADMIT;; mlmname: SCH_CREATE_CARDIACMONITOR_FROM_ADMIT;; arden: version 2;; version: 5.00;; institution: St Clair Hospital;; author: Shawn Head;; specialist: Peggy Karish;; date: 2016-05-10;; validation: testing;; library: purpose: Create cardiac monitor order when the admit to inpatient order has the monitored bed selected ;; explanation: 05.10.2016 - STH - CSR#: 34074 - created {Go-Live 5/17/2016} ;; keywords: Objects+, Care Provider Visit Role, Auto create care provider, auto DC care provider ;; knowledge: type: data-driven;; data: /* Set to true if logging is needed.*/ log_execution_info:= FALSE; standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; on_order_enter := event {OrderWorksheetSubmit User } ; from_order_name := ""; CreateMonitorOrder := false; UnSub_CardMonOrd := read last { UNSUBMITTED Order: Name where name in ("Monitor: Cardiac") }; if(UnSub_CardMonOrd is null) then userguid,user_id :=read last {UserInfo: guid,idcode}; (ReadUnSub_AdmitUD, CP_GUID, OrderName, sessiontype) := read { UNSUBMITTED Order: OrderUserData , careproviderguid , name , InitialSessionTypeCode where name in ("Admit to Inpatient","Place in Observation")}; if(count(ReadUnSub_AdmitUD) > 0) then (clientGUID, chartGUID, ClientVisitGUID, LocationGUID) := read last { ClientVisit: ClientGUID, ChartGUID, GUID, CurrentLocationGUID }; (MonitorOrderGUID) := read last { " select guid from cv3order o with (nolock) where o.ClientGUID = " || sql(ClientGUID) || " and o.chartguid = " || sql(chartGUID) || " and o.clientvisitguid = " || sql(ClientVisitGUID) || " and o.name = ({{{SINGLE-QUOTE}}}Monitor: Cardiac{{{SINGLE-QUOTE}}}) and o.orderstatuscode not in ({{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CAND{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CANP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CANT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DISCD{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DISCR{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DISCT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}HISDP{{{SINGLE-QUOTE}}}) " }; if(MonitorOrderGUID is nulL) then for y in (1 seqto(count(ReadUnSub_AdmitUD))) do CurOrder_UserDataFields := ReadUnSub_AdmitUD[y]; (userdatacode, value ) := read last { OrderUserData: UserDataCode, Value REFERENCING CurOrder_UserDataFields where UserDataCode = "NUR_ADTMonitoredBedCBx"} ; if(value = "1") then CreateMonitorOrder := true; from_order_name := OrderName[y]; endif; enddo; endif; endif; endif; /* if called_by_editor then EvokingObject := read last {Order: THIS WHERE Name in ("Admit to Inpatient","Place in Observation")}; endif; */ if(CreateMonitorOrder) then try CV_Obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((ClientVisitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; WSSessionType := trim(sessiontype[1]); if(sessiontype[1] = "Hold") then WSSessionReason := "Hold Orders"; else WSSessionReason := ""; endif; WSRequestedBySource := ""; RequestedBy_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((CP_GUID[1] as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((LocationGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}Common Data:{{-R}}\n" || ex.Message || "\n\n"; if ( CV_Obj is NOT NULL ) then void:= call CV_Obj.Dispose; CV_Obj:= null; endif; if ( RequestedBy_obj is NOT NULL ) then void:= call RequestedBy_obj.Dispose; RequestedBy_obj:= null; endif; if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; endcatch; try Catalog_Item_Name := "Monitor: Cardiac"; order_type := "other"; modifier := ""; modversion := ""; order_Creation_Reason := from_order_name || " ordered with Monitor Bed request."; order_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; GeneralOrder_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with CV_Obj, order_catalog_item, order_Creation_Reason, RequestedBy_obj, WSRequestedBySource, WSSessionType, WSSessionReason, location_obj, "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; if (Order_catalog_item.Name in ("Monitor: Cardiac")) then GeneralOrder_obj.SpecialInstructions := order_Creation_Reason; //GeneralOrder_obj.RequestedTime := "Now"; endif; if( GeneralOrder_obj is NOT NULL ) then void := call GeneralOrder_Obj.Save; void := call GeneralOrder_Obj.Dispose; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New General order:{{-R}}\n" || ex.Message || "\n\n"; endcatch; if ( Order_catalog_item is NOT NULL ) then void:= call Order_catalog_item.Dispose; Order_catalog_item:= null; endif; endif; ;; evoke: on_order_enter; ;; logic: conclude true; ;; action: ;; Urgency: 50;; end: