maintenance: title: SCH_AVL_ACO;; mlmname: SCH_AVL_ACO;; arden: version 2.5;; version: 5.50;; institution: St. Cair Hospital;; author: Janet Nordin;; specialist: Don Warnick;; date: 2018-08-03;; validation: Testing;; library: purpose: Maintains ACO patients Advanced Visit List data ;; explanation: This MLM maintains the ACO Advanced Visit List Change history 08.15.2018 DW CSR# 37090 - Create and AVL of ACO patients for Care Director staff and Navicare representative 02.04.2018 DW HD#3609427 - The large batch ACO updates affect currently admitted patients more than expected. To better update these patients, I added a new trigger for "A&I flowsheet update" which occurs once per shift. ;; keywords: ObjectsPlus, Advanced Visit List Data, ACO ;; knowledge: type: data-driven;; data: standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; // Advanced Visit List Item Names AVL_Name := "ACO Patients"; AVL_External_ID := "009"; AVL_1 := "ACOProgram"; AVL_2 := "ACOInsurances"; AVL_3 := "ACODischargeDispositions"; AVL_4 := "ACODischargeLocations"; continue_processing:= true; record_remove := false; error_occurred := false; error_message := ""; log_execution_info := false; // Triggers trig_event_enter := event {ClientDocumentEnter User ClientDocument: where (documentname matches pattern "%Profile%") or (documentname = "ED Triage Note") or documentname in ("2. Adult Assessment/Intervention" )}; trig_event_modify:= event {ClientDocumentModify User ClientDocument: where (documentname matches pattern "%Profile%") or (documentname = "ED Triage Note") or documentname in ("2. Adult Assessment/Intervention" )}; (VisitGUID, ChartGUID, ClientGUID, docguid) := read last {ClientDocument: ClientVisitGuid, ChartGUID, ClientGUID, guid REFERENCING EvokingObject}; // Destinations objects_plus_destination := destination {ObjectsPlus} with [ alert_type:= "Warning",short_message:= "Object created by MLM",priority := "low",scope:= "chart",rule_group:= "Advanced Visit List Data Object",rule_number:= 2010]; send_alert := "DoNotSend"; alert_dest := destination { Alert: warning, "Order Session Type", high, chart, "Order Session Type", 15042, send_alert, "No Override Allowed" }; // Gather ACO information ACOFlag := read first {"select text from CV3CommentDeclaration with (nolock) where typecode = {{{SINGLE-QUOTE}}}ACO Flags{{{SINGLE-QUOTE}}} and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and ClientGUID = " || ClientGUID || " " }; if not exists ACOFlag then // Check for Existing Record to Remove ExistingRecord := read last {" select avld.AdvancedVisitListDataGUID from CV3AdvancedVisitListData avld with (nolock) where avld.ClientVisitGUID = " || VisitGUID || " and avld.ExternalID = " || AVL_External_ID || " " }; if exists ExistingRecord then record_remove := true; else continue_processing := false; // No processing necessary endif; else // Gather Prior Discharge information (ACODischLoc, ACODischDisp) := read last {" select isnull (dischargelocation, {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}), isnull (DischargeDisposition, {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) from cv3clientvisit with (nolock) where ClientGUID = " || ClientGUID || " and visitstatus = {{{SINGLE-QUOTE}}}dsc{{{SINGLE-QUOTE}}} order by DischargeDtm desc "}; if not exists ACODischLoc then ACODischLoc:= " "; endif; if not exists ACODischDisp then ACODischDisp:= " "; endif; // Gather Visit Insurance plan information InsurancePlan := read {" select ic.name from CV3FRPContract fc with (nolock) join CV3FRP f with (nolock) on f.GUID = fc.FRPGUID join SXAAMInsuranceCarrier ic with (nolock) on ic.InsuranceCarrierID = f.InsuranceCarrierID where fc.ClientGUID = " || ClientGUID || " and fc.ClientVisitGUID = " || VisitGUID || " and fc.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} order by fc.SequenceNum "}; If exists InsurancePlan then for i in 1 seqto count InsurancePlan do if i = 1 then InsurancePlanList := InsurancePlan[i]; else InsurancePlanList := InsurancePlanList || " / " || InsurancePlan[i]; endif; enddo; else InsurancePlanList := " "; endif; endif; if continue_processing then // Create Objecs for Add, Update, or Removal of a record try client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((VisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; advanced_visit_list_data_obj := call {{{SINGLE-QUOTE}}}AdvancedVisitListData{{{SINGLE-QUOTE}}}.CreateAdvancedVisitListData with (client_visit_obj, AVL_Name, AVL_External_ID) ; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}Error Message:{{-R}}\n" || ex.Message || "\n\n"; if ( advanced_visit_list_data_obj is NOT NULL ) then void:= call advanced_visit_list_data_obj.Dispose; advanced_visit_list_data_obj:= null; endif; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; endcatch; endif; ;; priority: 50 ;; evoke: trig_event_enter; trig_event_modify; ;; logic: if continue_processing = false then conclude false; else try if record_remove = true then // Remove - Update the Advance Visit List Object for purge void := call advanced_visit_list_data_obj.Deactivate; void := call advanced_visit_list_data_obj.Purge; objects_plus_destination.ObjectsPlus := advanced_visit_list_data_obj; else // Add or Update - Update the Advance Visit List Object with data void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with AVL_1 , ACOFlag ; void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with AVL_2 , InsurancePlanList ; void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with AVL_3 , ACODischDisp ; void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with AVL_4 , ACODischLoc ; objects_plus_destination.ObjectsPlus := advanced_visit_list_data_obj; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}Error Message:{{-R}}\n" || ex.Message || "\n\n"; if ( advanced_visit_list_data_obj is NOT NULL ) then void:= call advanced_visit_list_data_obj.Dispose; advanced_visit_list_data_obj:= null; endif; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; endcatch; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; conclude true; endif; ;; action: if error_occurred then write "An error has occured in the MLM {{+B}}MLM SCH_AVL_ACO {{-B}} Please notify your System Administrators that an error message has occurred for this patient. They will review the following error message: \n" at alert_dest; write error_message at alert_dest; endif; if exists objects_plus_destination then write true at objects_plus_destination; endif; ;; urgency: 50;; end: