Skip to content

Commit bf02150

Browse files
authored
fix(Dr. Rai Reports): Allow ContactOverduePatientsIndicator for regions with data (#5695)
**Story card:** [sc-16738](https://app.shortcut.com/simpledotorg/story/16738) ## Because With regions which do not have dashboard data for `overdue_patients` and / or `contactable_overdue_patients`, the contact overdue patients indicator breaks. Rightly so, because the data is missing. ## This addresses Modifying the indicator to be unavailable when there is on data. ## Test instructions suite tests
1 parent a9eacce commit bf02150

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

app/models/dr_rai/contact_overdue_patients_indicator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def action_active
3737
end
3838

3939
def is_supported?(region)
40-
true
40+
!datasource(region).empty?
4141
end
4242
end
4343
end

spec/models/dr_rai/contact_overdue_patients_indicator_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
require "rails_helper"
22

33
RSpec.describe DrRai::ContactOverduePatientsIndicator, type: :model do
4+
describe "#is_supported?" do
5+
let(:district_with_facilities) { setup_district_with_facilities }
6+
let(:region) { district_with_facilities[:region] }
7+
let(:indicator) { DrRai::ContactOverduePatientsIndicator.new }
8+
9+
context "when region has data" do
10+
before do
11+
allow(indicator).to receive(:datasource).with(region).and_return({"some" => "data"})
12+
end
13+
14+
it "works" do
15+
expect(indicator.is_supported?(region)).to be_truthy
16+
end
17+
end
18+
19+
context "when region has no data" do
20+
before do
21+
allow(indicator).to receive(:datasource).with(region).and_return({})
22+
end
23+
24+
it "is unsupported" do
25+
expect(indicator.is_supported?(region)).to be_falsey
26+
end
27+
end
28+
end
29+
430
describe "indicator_function" do
531
around do |example|
632
Timecop.freeze("June 25 2025 15:12 GMT") { example.run }

0 commit comments

Comments
 (0)