Skip to content

Commit 0ca7f2a

Browse files
Merge pull request #6706 from NHSDigital/mike/fix-withdrawn-consent-reporting
Include withdrawn consents in consent reporting breakdowns
2 parents 78b5add + d8e8888 commit 0ca7f2a

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

app/controllers/api/reporting/totals_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def latest_scoped_consents
178178
.where(team_id: @team&.id || current_user.team_ids)
179179
.where(academic_year: params[:academic_year])
180180
.not_invalidated
181-
.not_withdrawn
182181
.response_provided
183182

184183
if params[:programme].present?

spec/controllers/api/reporting/totals_controller_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
expect(routes["self_consent"]).to eq(1)
565565
end
566566

567-
it "excludes invalidated and withdrawn consents" do
567+
it "excludes invalidated consents but includes withdrawn consents" do
568568
patient = create(:patient, session:)
569569
parent_one = create(:parent)
570570
parent_two = create(:parent)
@@ -578,17 +578,18 @@
578578
programme:,
579579
team:,
580580
parent: parent_one,
581-
reason_for_refusal: "medical_reasons"
581+
reason_for_refusal: "medical_reasons",
582+
route: "website"
582583
)
583584
create(
584585
:consent,
585-
:refused,
586586
:withdrawn,
587587
patient:,
588588
programme:,
589589
team:,
590590
parent: parent_two,
591-
reason_for_refusal: "personal_choice"
591+
reason_for_refusal: "personal_choice",
592+
route: "self_consent"
592593
)
593594
PatientStatusUpdater.call(patient:)
594595

@@ -598,7 +599,11 @@
598599

599600
reasons = parsed_response["consent_refusal_reasons"]
600601
expect(reasons["medical_reasons"]).to eq(0)
601-
expect(reasons["personal_choice"]).to eq(0)
602+
expect(reasons["personal_choice"]).to eq(1)
603+
604+
routes = parsed_response["consent_routes"]
605+
expect(routes["website"]).to eq(0)
606+
expect(routes["self_consent"]).to eq(1)
602607
end
603608
end
604609
end

0 commit comments

Comments
 (0)