Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/concerns/patient_session_state_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def consent_conflicts?
end

def no_consent?
consents.empty? || consents.all?(&:invalidated?)
consents.empty? || consents.all?(&:response_not_provided?) ||
consents.all?(&:invalidated?)
end

def triage_needed?
Expand Down
3 changes: 1 addition & 2 deletions app/models/consent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class Consent < ApplicationRecord
scope :withdrawn, -> { where.not(withdrawn_at: nil) }
scope :not_withdrawn, -> { where(withdrawn_at: nil) }

enum :response, %w[given refused], prefix: true

enum :response, %w[given refused not_provided], prefix: true
enum :reason_for_refusal,
%w[
contains_gelatine
Expand Down
1 change: 1 addition & 0 deletions app/models/patient_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def latest_consents
@latest_consents ||=
consents
.select(&:not_invalidated?)
.select { _1.response_given? || _1.response_refused? }
.group_by(&:name)
.map { |_, consents| consents.max_by(&:recorded_at) }
end
Expand Down
5 changes: 5 additions & 0 deletions app/views/consents/edit/agree.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
label: { text: "Yes, they agree" }, link_errors: true %>
<%= f.govuk_radio_button :response, "refused",
label: { text: "No, they do not agree" } %>
<% unless @consent.via_self_consent? %>
<%= f.govuk_radio_divider %>
<%= f.govuk_radio_button :response, "not_provided",
label: { text: "No response" } %>
<% end %>
<% end %>

<div class="nhsuk-u-margin-top-6">
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ en:
will_be_vaccinated_elsewhere: Vaccine will be given elsewhere
responses:
given: consent given
not_provided: not provided
refused: consent refused
routes:
in_person: In person
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/concerns/triage_mailer_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ def initialize(current_user:)
end
end

context "when the patient didn't response" do
let(:patient_session) { create(:patient_session, :consent_not_provided) }

it "doesn't send an email" do
expect { send_triage_confirmation }.not_to have_enqueued_email
end

it "doesn't send a text message" do
expect { send_triage_confirmation }.not_to have_enqueued_text
end
end

context "when the parents have verbally refused consent" do
let(:patient_session) { create(:patient_session, :consent_refused) }

Expand Down
11 changes: 11 additions & 0 deletions spec/factories/patient_sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
end
end

trait :consent_not_provided do
patient do
association :patient,
:consent_not_provided,
performed_by: user,
programme:,
organisation:,
school: session.location
end
end

trait :consent_conflicting do
patient do
association :patient,
Expand Down
16 changes: 16 additions & 0 deletions spec/factories/patients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@
end
end

trait :consent_not_provided do
consents do
[
association(
:consent,
:recorded,
:not_provided,
:from_mum,
patient: instance,
organisation:,
programme:
)
]
end
end

trait :triage_ready_to_vaccinate do
triages do
[
Expand Down
Loading