diff --git a/app/controllers/analytics/districts_controller.rb b/app/controllers/analytics/districts_controller.rb index 7ad0501de7..5aa87610e5 100644 --- a/app/controllers/analytics/districts_controller.rb +++ b/app/controllers/analytics/districts_controller.rb @@ -95,6 +95,9 @@ def analytics_cache_key end def download_filename - "district-cohort-report_#{@organization_district.district_name}_#{Time.current.to_s(:number)}.csv" + period = @period == :quarter ? "quarterly" : "monthly" + district = @organization_district.district_name + time = Time.current.to_s(:number) + "district-#{period}-cohort-report_#{district}_#{time}.csv" end end diff --git a/app/controllers/analytics/facilities_controller.rb b/app/controllers/analytics/facilities_controller.rb index 39c39c907a..48160a8372 100644 --- a/app/controllers/analytics/facilities_controller.rb +++ b/app/controllers/analytics/facilities_controller.rb @@ -88,6 +88,9 @@ def analytics_cache_key end def download_filename - "facility-cohort-report_#{@facility.name}_#{Time.current.to_s(:number)}.csv" + period = @period == :quarter ? "quarterly" : "monthly" + facility = @facility.name + time = Time.current.to_s(:number) + "facility-#{period}-cohort-report_#{facility}_#{time}.csv" end end diff --git a/app/views/analytics/districts/show.csv.erb b/app/views/analytics/districts/show.csv.erb index 488869d477..825fda2a78 100644 --- a/app/views/analytics/districts/show.csv.erb +++ b/app/views/analytics/districts/show.csv.erb @@ -1,17 +1,18 @@ <%= [ - "Report generated at:", + 'Report generated at:', Time.current ].to_csv -%> -<%= ["#{@organization_district.district_name} Cohort Report"].to_csv -%> +<% period = @period == :quarter ? 'Quarterly' : 'Monthly' %> +<%= ["#{@organization_district.district_name} #{period} Cohort Report"].to_csv -%> <%= ['Facility'].concat(@cohort_analytics.each_with_index.flat_map do |(report_dates, analytics), index| [ 'Cohort period', 'Follow up period', - 'Patients registered', + 'Patients in cohort', 'Patients followed up', 'Patients controlled', 'Patients uncontrolled', - 'Patients defaulted', + "Patients didn't attend", 'Control rate', 'Uncontrolled rate', 'Default rate', diff --git a/app/views/analytics/districts/show.html.erb b/app/views/analytics/districts/show.html.erb index cd3f35be2d..5711c8e617 100644 --- a/app/views/analytics/districts/show.html.erb +++ b/app/views/analytics/districts/show.html.erb @@ -23,9 +23,15 @@

Downloads

- <%= link_to(period: params[:period], format: :csv) do %> - - Cohort report + <%= link_to(period: :quarter, format: :csv) do %> + + Quarterly cohort report + <% end %> +

+

+ <%= link_to(period: :month, format: :csv) do %> + + Monthly cohort report <% end %>

diff --git a/app/views/analytics/facilities/show.csv.erb b/app/views/analytics/facilities/show.csv.erb index ef163e7b46..f29c84f138 100644 --- a/app/views/analytics/facilities/show.csv.erb +++ b/app/views/analytics/facilities/show.csv.erb @@ -1,19 +1,20 @@ <%= [ - "Report generated at:", + 'Report generated at:', Time.current ].to_csv -%> -<%= ["#{@facility.name} Cohort Report"].to_csv -%> +<% period = @period == :quarter ? 'Quarterly' : 'Monthly' %> +<%= ["#{@facility.name} #{period} Cohort Report"].to_csv -%> <%= [ - "Cohort period", - "Follow up period", - "Patients registered", - "Patients followed up", - "Patients controlled", - "Patients uncontrolled", - "Patients defaulted", - "Control rate", - "Uncontrolled rate", - "Default rate" + 'Cohort period', + 'Follow up period', + 'Patients in cohort', + 'Patients followed up', + 'Patients controlled', + 'Patients uncontrolled', + "Patients didn't attend", + 'Control rate', + 'Uncontrolled rate', + 'Default rate' ].to_csv -%> <% @cohort_analytics.each_with_index do |(report_dates, analytics), index| %> <% diff --git a/app/views/analytics/facilities/show.html.erb b/app/views/analytics/facilities/show.html.erb index 02e93fd667..48e67b8f33 100644 --- a/app/views/analytics/facilities/show.html.erb +++ b/app/views/analytics/facilities/show.html.erb @@ -34,9 +34,15 @@

Downloads

- <%= link_to(period: params[:period], format: :csv) do %> - - Cohort report + <%= link_to(period: :quarter, format: :csv) do %> + + Quarterly cohort report + <% end %> +

+

+ <%= link_to(period: :month, format: :csv) do %> + + Monthly cohort report <% end %>