From 7e7d23d4cdfd735c4e8d9da3a12b8927595bece5 Mon Sep 17 00:00:00 2001 From: Nisanth Yaganti Date: Fri, 21 Jun 2024 11:31:26 -0400 Subject: [PATCH 1/3] removing term check to fix month end nightly events --- .../external_events/enrollment_event_notification.rb | 11 +---------- .../enrollment_event_notification_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/models/external_events/enrollment_event_notification.rb b/app/models/external_events/enrollment_event_notification.rb index 95b08083f..605201237 100644 --- a/app/models/external_events/enrollment_event_notification.rb +++ b/app/models/external_events/enrollment_event_notification.rb @@ -65,7 +65,7 @@ def drop_if_already_processed! :enrollment_action_uri => enrollment_action ) if found_event.any? - if is_eligible_term? + if is_reterm_with_earlier_date? false else response_with_publisher do |result_publisher| @@ -295,15 +295,6 @@ def is_reterm_with_earlier_date? # terminating policy again with earlier termina (existing_policy.present? && existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber)) end - def is_eligible_term? - return false unless is_termination? - return false unless extract_enrollee_end(subscriber).present? - return false if existing_policy.blank? - return true unless existing_policy.terminated? - - existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber) - end - def enrollment_action @enrollment_action ||= extract_enrollment_action(enrollment_event_xml) end diff --git a/spec/models/external_events/enrollment_event_notification_spec.rb b/spec/models/external_events/enrollment_event_notification_spec.rb index 839060ee1..386c3db57 100644 --- a/spec/models/external_events/enrollment_event_notification_spec.rb +++ b/spec/models/external_events/enrollment_event_notification_spec.rb @@ -728,7 +728,7 @@ allow(subject).to receive(:is_termination?).and_return(true) allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id) allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment") - allow(subject).to receive(:is_eligible_term?).and_return(true) + allow(subject).to receive(:is_reterm_with_earlier_date?).and_return(true) end it "returns false" do @@ -744,7 +744,7 @@ allow(subject).to receive('response_with_publisher').and_yield(result_publisher) allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id) allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment") - allow(subject).to receive(:is_eligible_term?).and_return(false) + allow(subject).to receive(:is_reterm_with_earlier_date?).and_return(false) end it "returns notify event already processed" do From 420b3362c04e37e92e582759b999dae1faee9062 Mon Sep 17 00:00:00 2001 From: Nisanth Yaganti Date: Wed, 26 Jun 2024 13:16:17 -0400 Subject: [PATCH 2/3] Revert "removing term check to fix month end nightly events" This reverts commit 7e7d23d4cdfd735c4e8d9da3a12b8927595bece5. --- .../external_events/enrollment_event_notification.rb | 11 ++++++++++- .../enrollment_event_notification_spec.rb | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/external_events/enrollment_event_notification.rb b/app/models/external_events/enrollment_event_notification.rb index 605201237..95b08083f 100644 --- a/app/models/external_events/enrollment_event_notification.rb +++ b/app/models/external_events/enrollment_event_notification.rb @@ -65,7 +65,7 @@ def drop_if_already_processed! :enrollment_action_uri => enrollment_action ) if found_event.any? - if is_reterm_with_earlier_date? + if is_eligible_term? false else response_with_publisher do |result_publisher| @@ -295,6 +295,15 @@ def is_reterm_with_earlier_date? # terminating policy again with earlier termina (existing_policy.present? && existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber)) end + def is_eligible_term? + return false unless is_termination? + return false unless extract_enrollee_end(subscriber).present? + return false if existing_policy.blank? + return true unless existing_policy.terminated? + + existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber) + end + def enrollment_action @enrollment_action ||= extract_enrollment_action(enrollment_event_xml) end diff --git a/spec/models/external_events/enrollment_event_notification_spec.rb b/spec/models/external_events/enrollment_event_notification_spec.rb index 386c3db57..839060ee1 100644 --- a/spec/models/external_events/enrollment_event_notification_spec.rb +++ b/spec/models/external_events/enrollment_event_notification_spec.rb @@ -728,7 +728,7 @@ allow(subject).to receive(:is_termination?).and_return(true) allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id) allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment") - allow(subject).to receive(:is_reterm_with_earlier_date?).and_return(true) + allow(subject).to receive(:is_eligible_term?).and_return(true) end it "returns false" do @@ -744,7 +744,7 @@ allow(subject).to receive('response_with_publisher').and_yield(result_publisher) allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id) allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment") - allow(subject).to receive(:is_reterm_with_earlier_date?).and_return(false) + allow(subject).to receive(:is_eligible_term?).and_return(false) end it "returns notify event already processed" do From 16bbcede163b97255427d99da241c7693d0dec54 Mon Sep 17 00:00:00 2001 From: Nisanth Yaganti Date: Wed, 26 Jun 2024 13:21:39 -0400 Subject: [PATCH 3/3] handling reterm retro canceled --- .../enrollment_event_notification.rb | 7 +++-- .../enrollment_event_notification_spec.rb | 30 ++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/models/external_events/enrollment_event_notification.rb b/app/models/external_events/enrollment_event_notification.rb index 95b08083f..1ed4fb7d9 100644 --- a/app/models/external_events/enrollment_event_notification.rb +++ b/app/models/external_events/enrollment_event_notification.rb @@ -299,9 +299,12 @@ def is_eligible_term? return false unless is_termination? return false unless extract_enrollee_end(subscriber).present? return false if existing_policy.blank? - return true unless existing_policy.terminated? - existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber) + is_reterm_retro_canceled? || (existing_policy.terminated? && existing_policy.policy_end > extract_enrollee_end(subscriber)) + end + + def is_reterm_retro_canceled? + extract_enrollee_end(subscriber) == existing_policy.policy_start end def enrollment_action diff --git a/spec/models/external_events/enrollment_event_notification_spec.rb b/spec/models/external_events/enrollment_event_notification_spec.rb index 839060ee1..3d32be909 100644 --- a/spec/models/external_events/enrollment_event_notification_spec.rb +++ b/spec/models/external_events/enrollment_event_notification_spec.rb @@ -728,7 +728,7 @@ allow(subject).to receive(:is_termination?).and_return(true) allow(subject).to receive(:hbx_enrollment_id).and_return(hbx_enrollment_id) allow(subject).to receive(:enrollment_action).and_return("urn:openhbx:terms:v1:enrollment#terminate_enrollment") - allow(subject).to receive(:is_eligible_term?).and_return(true) + allow(subject).to receive(:is_eligible_term?).and_return(true) end it "returns false" do @@ -752,4 +752,32 @@ subject.drop_if_already_processed! end end + + context '#is_reterm_retro_canceled' do + let(:enrollee) { double } + let(:existing_policy) { double(policy_start: start_date)} + let(:start_date) { Date.today.beginning_of_month } + + before do + allow(subject).to receive(:subscriber).and_return(enrollee) + allow(subject).to receive(:extract_enrollee_end).with(enrollee).and_return(end_date) + allow(subject).to receive(:existing_policy).and_return(existing_policy) + end + + context 'when existing policy start date matches with xml end date' do + let(:end_date) { start_date } + + it 'returns true' do + expect(subject.is_reterm_retro_canceled?).to eq true + end + end + + context 'when existing policy start date does matches with xml end date' do + let(:end_date) { start_date + 5.days } + + it 'returns true' do + expect(subject.is_reterm_retro_canceled?).to eq false + end + end + end end