Skip to content

Commit 09dd837

Browse files
sc-14652 modification in LK quick links (#5664)
**Story card:** [sc-14651](https://app.shortcut.com/simpledotorg/story/14652/expand-quick-links-to-ethiopia-srilanka)
1 parent c1ad0bb commit 09dd837

File tree

5 files changed

+65
-102
lines changed

5 files changed

+65
-102
lines changed

.env.ET

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ HELP_SCREEN_SUPPORT_GROUP_ICON="icon_telegram_icon.svg"
44
#State
55
DIVISION_METABASE_TITRATION_URL= "https://simple.moh.gov.et/metabase/question/255-state-wise-monthly-titration-trends-rtsl-facilities-only?months=past9months&state_name="
66
DIVISION_METABASE_BP_FUDGING_URL= "https://simple.moh.gov.et/metabase/question/227-01-district-report?state_name="
7+
DIVISION_DRUG_STOCK_REPORT_URL= "https://simple.moh.gov.et/metabase/question/195-z-archive-drug-stock-simplified-using-expiry-dates?state="
78
#District
8-
DISTRICT_DRUG_STOCK_REPORT_URL= "https://simple.moh.gov.et/metabase/question/195-z-archive-drug-stock-simplified-using-expiry-dates?state="
9+
DISTRICT_DRUG_STOCK_REPORT_URL= "https://simple.moh.gov.et/metabase/question/202-drug-stock-report-simplified?region="
910
DISTRICT_METABASE_TITRATION_URL= "https://simple.moh.gov.et/metabase/question/254-district-wise-monthly-titration-trends-rtsl-facilities-only?months=past9months&district_name="
1011
DISTRICT_METABASE_BP_FUDGING_URL= "https://simple.moh.gov.et/metabase/question/227-01-district-report?"
1112
#facility

.env.LK

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ METABASE_BP_FUDGING_URL= "https://metabase-simple.health.gov.lk/question/264-03-
88
DIVISION_METABASE_TITRATION_URL= "https://metabase-simple.health.gov.lk/question/305-medication-titration-state-wise-monthly-titration-trends?months=past9months&state_name="
99
DIVISION_METABASE_BP_FUDGING_URL= "https://metabase-simple.health.gov.lk/question/262-01-district-report?state_name="
1010
#District
11-
DISTRICT_METABASE_TITRATION_URL= "https://metabase-simple.health.gov.lk/question/304-medication-titration-district-wise-monthly-titration-trends?months=past9months&district_name=Colombo"
11+
DISTRICT_METABASE_TITRATION_URL= "https://metabase-simple.health.gov.lk/question/304-medication-titration-district-wise-monthly-titration-trends?months=past9months&district_name="
1212
DISTRICT_METABASE_BP_FUDGING_URL= "https://metabase-simple.health.gov.lk/question/262-01-district-report?"

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ DISTRICT_METABASE_SYSTOLIC_BP_URL = "https://metabase.example.com/systolic?distr
7474
DIVISION_METABASE_TITRATION_URL = "https://metabase.example.com/titration?state_name="
7575
DIVISION_METABASE_SYSTOLIC_BP_URL = "https://metabase.example.com/systolic?state_name="
7676
DIVISION_METABASE_BP_FUDGING_URL = "https://metabase.example.com/bp_fudging_division?state_name="
77+
DIVISION_DRUG_STOCK_REPORT_URL = "https://metabase.example.com/my_facilities/drug_stocks?state="

app/views/reports/regions/show.html.erb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
<% elsif @region.district_region? %>
4343
<div class="float-right desktop">
4444
<h4 class="mb-0px">Quick links</h4>
45-
<div><a href="<%= ENV.fetch('DISTRICT_FACILITY_TREND_REPORT_URL', '') %><%= @region.source.slug %>&for_end_of_month=" target="_blank">
46-
Facility trends
47-
</a></div>
45+
<% if CountryConfig.current_country?("Bangladesh") %>
46+
<div><a href="<%= ENV.fetch('DISTRICT_FACILITY_TREND_REPORT_URL', '') %><%= @region.source.slug %>&for_end_of_month=" target="_blank">
47+
Facility trends
48+
</a></div>
49+
<% end %>
4850
<% if CountryConfig.current_country?("Ethiopia") %>
4951
<div><a href="<%= ENV.fetch('DISTRICT_DRUG_STOCK_REPORT_URL', '') %><%= @region.source.slug %>" target="_blank">
5052
Metabase: Drug stock report
@@ -60,19 +62,28 @@
6062
<div><a href="<%= ENV.fetch('DISTRICT_METABASE_BP_FUDGING_URL', '') %><%= @region.parent.name %>&district_name=<%= @region.name %>" target="_blank">
6163
Metabase: BP fudging report
6264
</a></div>
63-
<div><a href="<%= ENV.fetch('DISTRICT_METABASE_SYSTOLIC_BP_URL', '') %><%= @region.name %>" target="_blank">
64-
Metabase: Systolic BP reading report
65-
</a></div>
65+
<% if CountryConfig.current_country?("Bangladesh") %>
66+
<div><a href="<%= ENV.fetch('DISTRICT_METABASE_SYSTOLIC_BP_URL', '') %><%= @region.name %>" target="_blank">
67+
Metabase: Systolic BP reading report
68+
</a></div>
69+
<% end %>
6670
</div>
6771
<% elsif @region.state_region? %>
6872
<div class="float-right desktop">
6973
<h4 class="mb-0px">Quick links</h4>
7074
<div><a href="<%= ENV.fetch('DIVISION_METABASE_TITRATION_URL', '') %><%= @region.name %>" target="_blank">
7175
Metabase: Titration report
7276
</a></div>
73-
<div><a href="<%= ENV.fetch('DIVISION_METABASE_SYSTOLIC_BP_URL', '') %><%= @region.name %>" target="_blank">
74-
Metabase: Systolic BP reading report
75-
</a></div>
77+
78+
<% if CountryConfig.current_country?("Ethiopia") %>
79+
<div><a href="<%= ENV.fetch('DIVISION_DRUG_STOCK_REPORT_URL', '') %><%= @region.name %>" target="_blank">
80+
Metabase: Drug stock report
81+
</a></div>
82+
<% elsif CountryConfig.current_country?("Bangladesh")%>
83+
<div><a href="<%= ENV.fetch('DIVISION_METABASE_SYSTOLIC_BP_URL', '') %><%= @region.name %>" target="_blank">
84+
Metabase: Systolic BP reading report
85+
</a></div>
86+
<% end %>
7687
<div><a href="<%= ENV.fetch('DIVISION_METABASE_BP_FUDGING_URL', '') %><%= @region.name %>" target="_blank">
7788
Metabase: BP fudging report
7889
</a></div>

spec/controllers/reports/regions_controller_spec.rb

Lines changed: 41 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,35 @@
4949
allow(region).to receive(:facility_region?).and_return(true)
5050
allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop"))
5151
end
52-
context "and the feature flag is enabled" do
52+
53+
context "and the quick_link_for_metabase feature flag is enabled" do
5354
before { Flipper.enable(:quick_link_for_metabase, cvho) }
54-
it "displays the quick links section with the correct URLs" do
55+
56+
it "displays the generic quick links section" do
5557
sign_in(cvho.email_authentication)
5658
get :show, params: {id: region.slug, report_scope: "facility"}
5759
expect(response.body).to include("Quick links")
58-
expect(response.body).to include("Drug stock report")
5960
expect(response.body).to include("Metabase: Titration report")
6061
expect(response.body).to include("Metabase: BP fudging report")
61-
expect(response.body).to include("https://api.example.com/my_facilities/drug_stocks?facility_group=")
62-
expect(response.body).to include("href=\"https://metabase.example.com/titration?region=#{region.name}\"")
63-
expect(response.body).to include("href=\"https://metabase.example.com/bp_fudging?region=#{region.name}\"")
6462
end
65-
end
66-
context "and the feature flag is disabled" do
67-
it "does not display the quick links section" do
63+
64+
it "shows the Metabase: Drug stock report link for Ethiopia" do
6865
sign_in(cvho.email_authentication)
66+
allow(CountryConfig).to receive(:current_country?).and_return(false)
67+
allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(true)
6968
get :show, params: {id: region.slug, report_scope: "facility"}
70-
expect(response.body).to_not include("Quick links")
71-
expect(response.body).to_not include("Drug stock report")
72-
expect(response.body).to_not include("Metabase: Titration report")
73-
expect(response.body).to_not include("Metabase: BP fudging report")
69+
expect(response.body).to include("Metabase: Drug stock report")
70+
expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", ""))
71+
expect(response.body).to include("&name=#{region.name}")
72+
end
73+
74+
it "does not show any drug stock links for Sri Lanka" do
75+
sign_in(cvho.email_authentication)
76+
allow(CountryConfig).to receive(:current_country?).and_return(false)
77+
allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(true)
78+
get :show, params: {id: region.slug, report_scope: "facility"}
79+
expect(response.body).not_to include("Drug stock report")
80+
expect(response.body).not_to include("Metabase: Drug stock report")
7481
end
7582
end
7683
end
@@ -83,100 +90,43 @@
8390
allow(region).to receive(:district_region?).and_return(true)
8491
allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop"))
8592
end
86-
context "and the feature flag is enabled" do
93+
94+
context "and the quick_link_for_metabase feature flag is enabled" do
8795
before { Flipper.enable(:quick_link_for_metabase, cvho) }
88-
it "displays the quick links section with the correct URLs" do
96+
97+
it "displays the generic quick links section" do
8998
sign_in(cvho.email_authentication)
9099
get :show, params: {id: facility_group.slug, report_scope: "district"}
91-
expect(response.body).to include("Facility trends")
92-
expect(response.body).to include("Drug stock")
100+
expect(response.body).to include("Quick links")
93101
expect(response.body).to include("Metabase: Titration report")
94102
expect(response.body).to include("Metabase: BP fudging report")
95-
expect(response.body).to include("Metabase: Systolic BP reading report")
96-
expect(response.body).to include("https://api.example.com/my_facilities/drug_stocks?facility_group=")
97-
expect(response.body).to include("https://api.example.com/my_facilities/bp_controlled?facility_group=")
98-
expect(response.body).to include("https://metabase.example.com/titration?district_name=")
99-
expect(response.body).to include("https://metabase.example.com/bp_fudging?state_name=")
100-
expect(response.body).to include("https://metabase.example.com/systolic?district_name=")
101103
end
102-
end
103-
context "and the feature flag is disabled" do
104-
it "does not display the quick links section" do
104+
105+
it "displays Facility trends link and Metabase: Systolic BP reading report link for Bangladesh" do
105106
sign_in(cvho.email_authentication)
107+
allow(CountryConfig).to receive(:current_country?).and_return(false)
108+
allow(CountryConfig).to receive(:current_country?).with("Bangladesh").and_return(true)
106109
get :show, params: {id: facility_group.slug, report_scope: "district"}
107-
expect(response.body).to_not include("District facility trend report")
108-
expect(response.body).to_not include("District Drug sto_notck report")
109-
expect(response.body).to_not include("Metabase: Titration report")
110-
expect(response.body).to_not include("Metabase: BP fudging report")
111-
expect(response.body).to_not include("Metabase: Systolic BP reading report")
112-
expect(response.body).to_not include("https://api.example.com/my_facilities/drug_stocks?facility_group=")
113-
expect(response.body).to_not include("https://api.example.com/my_facilities/bp_controlled?facility_group=")
114-
expect(response.body).to_not include("https://metabase.example.com/titration?district_name=")
115-
expect(response.body).to_not include("https://metabase.example.com/bp_fudging?state_name=")
116-
expect(response.body).to_not include("https://metabase.example.com/systolic?district_name=")
110+
expect(response.body).to include("Facility trends")
111+
expect(response.body).to include(ENV.fetch("DISTRICT_FACILITY_TREND_REPORT_URL", ""))
112+
expect(response.body).to include("Metabase: Systolic BP reading report")
113+
expect(response.body).to include(ENV.fetch("DISTRICT_METABASE_SYSTOLIC_BP_URL", ""))
117114
end
118-
end
119-
end
120-
121-
context "drug stock report links by country" do
122-
let(:facility_group) { create(:facility_group, organization: organization) }
123-
let(:facility) { create(:facility, facility_group: facility_group) }
124-
let(:region) { facility.region }
125115

126-
before do
127-
allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop"))
128-
Flipper.enable(:quick_link_for_metabase, cvho)
129-
sign_in(cvho.email_authentication)
130-
end
131-
132-
context "when country is Ethiopia" do
133-
before do
116+
it "displays Metabase: Drug stock report link for Ethiopia" do
117+
sign_in(cvho.email_authentication)
118+
allow(CountryConfig).to receive(:current_country?).and_return(false)
134119
allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(true)
135-
allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(false)
136-
get :show, params: {id: region.slug, report_scope: "facility"}
137-
end
138-
139-
it "shows the facility drug stock report link" do
140-
expect(response.body).to include("Metabase: Drug stock report")
141-
expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", ""))
142-
expect(response.body).to include("&name=#{region.name}")
143-
end
144-
145-
it "shows the district drug stock report link" do
120+
get :show, params: {id: facility_group.slug, report_scope: "district"}
146121
expect(response.body).to include("Metabase: Drug stock report")
147122
expect(response.body).to include(ENV.fetch("DISTRICT_DRUG_STOCK_REPORT_URL", ""))
148-
expect(response.body).to include(region.source.slug)
149-
end
150-
end
151-
152-
context "when country is not Sri Lanka" do
153-
before do
154-
allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(false)
155-
allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(false)
156-
get :show, params: {id: region.slug, report_scope: "facility"}
157123
end
158124

159-
it "shows the facility drug stock report link" do
160-
expect(response.body).to include("Drug stock report")
161-
expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", ""))
162-
expect(response.body).to include(region.name)
163-
end
164-
165-
it "shows the district drug stock report link" do
166-
expect(response.body).to include("Drug stock")
167-
expect(response.body).to include(ENV.fetch("DISTRICT_DRUG_STOCK_REPORT_URL", ""))
168-
expect(response.body).to include(region.source.slug)
169-
end
170-
end
171-
172-
context "when country is Sri Lanka" do
173-
before do
174-
allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(false)
125+
it "does not show any drug stock links for Sri Lanka" do
126+
sign_in(cvho.email_authentication)
127+
allow(CountryConfig).to receive(:current_country?).and_return(false)
175128
allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(true)
176-
get :show, params: {id: region.slug, report_scope: "facility"}
177-
end
178-
179-
it "does not show any drug stock links" do
129+
get :show, params: {id: facility_group.slug, report_scope: "district"}
180130
expect(response.body).not_to include("Drug stock report")
181131
expect(response.body).not_to include("Metabase: Drug stock report")
182132
end

0 commit comments

Comments
 (0)