@@ -6,7 +6,7 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
66 academic_year : :academic_year ,
77 programme : :programme_type ,
88 organisation_id : :organisation_id ,
9- gender : :patient_gender_code ,
9+ gender : :patient_gender ,
1010 year_group : :patient_year_group ,
1111 school_local_authority : :patient_school_local_authority_code ,
1212 local_authority : :patient_local_authority_code
@@ -16,14 +16,14 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
1616 local_authority : :patient_local_authority_code ,
1717 school : :patient_school_name ,
1818 year_group : :patient_year_group ,
19- gender : :patient_gender_code
19+ gender : :patient_gender
2020 } . freeze
2121
2222 GROUP_HEADERS = {
2323 patient_local_authority_code : "Local Authority" ,
2424 patient_school_name : "School" ,
2525 patient_year_group : "Year Group" ,
26- patient_gender_code : "Gender"
26+ patient_gender : "Gender"
2727 } . freeze
2828
2929 METRIC_HEADERS = {
@@ -33,7 +33,12 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
3333 vaccinated_by_sais : "Vaccinated by SAIS" ,
3434 vaccinated_elsewhere_declared : "Vaccinated Elsewhere (Declared)" ,
3535 vaccinated_elsewhere_recorded : "Vaccinated Elsewhere (Recorded)" ,
36- vaccinated_previously : "Vaccinated Previously"
36+ vaccinated_previously : "Vaccinated Previously" ,
37+ consent_given : "Consent Given" ,
38+ consent_no_response : "No Consent Response" ,
39+ consent_conflicts : "Conflicting Consent" ,
40+ parent_refused_consent : "Parent Refused Consent" ,
41+ child_refused_vaccination : "Child Refused Vaccination"
3742 } . freeze
3843
3944 before_action :set_default_filters , :set_filters , :set_scope
@@ -119,7 +124,14 @@ def render_format_json
119124 @scope . vaccinated_elsewhere_recorded_count ,
120125 vaccinated_previously : @scope . vaccinated_previously_count ,
121126 vaccinations_given : @scope . vaccinations_given_count ,
122- monthly_vaccinations_given : @scope . monthly_vaccinations_given
127+ monthly_vaccinations_given : @scope . monthly_vaccinations_given ,
128+ consent_given : @scope . consent_given_count ,
129+ consent_no_response : @scope . consent_no_response_count ,
130+ consent_conflicts : @scope . consent_conflicts_count ,
131+ parent_refused_consent : @scope . parent_refused_consent_count ,
132+ child_refused_vaccination : @scope . child_refused_vaccination_count ,
133+ refusal_reasons : consent_refusal_reasons ,
134+ consent_routes : consent_routes_breakdown
123135 }
124136 end
125137
@@ -155,4 +167,34 @@ def apply_default_year_group_filter
155167
156168 @scope = @scope . where ( Arel ::Nodes ::Exists . new ( subquery ) )
157169 end
170+
171+ def consent_refusal_reasons
172+ Consent
173+ . joins ( :patient )
174+ . where (
175+ patient_id : @scope . select ( :patient_id ) ,
176+ programme_id : @scope . select ( :programme_id ) . distinct ,
177+ academic_year : @scope . select ( :academic_year ) . distinct ,
178+ response : :refused
179+ )
180+ . not_invalidated
181+ . not_withdrawn
182+ . group ( :reason_for_refusal )
183+ . count
184+ end
185+
186+ def consent_routes_breakdown
187+ Consent
188+ . joins ( :patient )
189+ . where (
190+ patient_id : @scope . select ( :patient_id ) ,
191+ programme_id : @scope . select ( :programme_id ) . distinct ,
192+ academic_year : @scope . select ( :academic_year ) . distinct
193+ )
194+ . not_invalidated
195+ . not_withdrawn
196+ . response_provided
197+ . group ( :route )
198+ . count
199+ end
158200end
0 commit comments