maintenance: title: SCH_AVL_HIGHMARK_GATEWAY;; mlmname: SCH_AVL_HIGHMARK_GATEWAY;; 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 12.10.2018 DW CSR# 37677 - Create and AVL of Highmark and Gateway paients for Care Director users 01.08.2019 DW CSR# 37677 - User requested us to exclude insurance 119B post activation 01.16.2019 DW HD#3582632 - Needed to add insurance 786B ;; keywords: ObjectsPlus, Advanced Visit List Data ;; 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 := "Insurance Plans"; AVL_External_ID := "010"; AVL_1 := "InsuranceTypes"; AVL_2 := "InsurancePlans"; continue_processing:= true; error_occurred := false; error_message := ""; log_execution_info := false; // Trigger clientvisit_enter_event := event {ClientVisitEnter ANY ClientVisit: where typecode in ("Inpatient", "Observation", "Emergency") }; insurance_enter_event := event{InsuranceEnter ANY ClientVisit}; insurance_modify_event:= event{InsuranceModify ANY ClientVisit}; if EvokingEventType = "ClientVisitEnter" then (clientguid, visitguid, visittype) := read last {ClientVisit: clientguid, guid, typecode REFERENCING EvokingObject}; else (ClientGuid, visitguid) := read last {Insurance: ClientGuid, ClientVisitGUID REFERENCING EvokingObject}; EvokingInsuranceType:= EVOKINGOBJECT.FRPName; visittype := read last { " select typecode from cv3clientvisit with (nolock) where clientguid = " || clientguid || " and guid = " || visitguid || " " }; endif; // 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: Informational, "Diagnostic", low, chart, "Diagnostic", 15042, send_alert, "No Override Allowed" }; // 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 or EvokingInsuranceType not in ("BLUE CROSS","GATEWAY" ) or visittype not in ("Inpatient", "Observation", "Emergency") then // Stop processing if the patient is already on the list of if the insurance type is not one of interest continue_processing := false; else // Gather Visit Insurance plan information InsuranceType, InsurancePlan := read first {" select f.Name, 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}}} and ic.CarrierCode in ({{{SINGLE-QUOTE}}}709B{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}753B{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}141B{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}786B{{{SINGLE-QUOTE}}}) order by fc.SequenceNum "}; // Stop processing if the insurance plan is not one of interest if not exists InsuranceType then continue_processing := false; 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: 4 seconds after time of insurance_enter_event; 4 seconds after time of insurance_modify_event; ;; logic: if continue_processing = false then conclude false; else try // 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 , InsuranceType ; void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with AVL_2 , InsurancePlan ; objects_plus_destination.ObjectsPlus := advanced_visit_list_data_obj; 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_HIGHMARK_GATEWAY {{-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; // Write Diagnostic Alert Message in PatientIfo/Alerts (remove prior to Production deployment) /* write " Messages " || " List Name.: " || AVL_Name || " Evoking Event: " || EvokingEventType || " Evoking Insurance Type: " || EvokingInsuranceType || " InsuranceType: " || InsuranceType || " InsurancePlan: " || InsurancePlan || " ExistingRecord: " || ExistingRecord || " continue_processing : " || continue_processing at alert_dest; */ ;; urgency: 50;; end: