Skip to content

Commit

Permalink
Hide GP information for restricted patients
Browse files Browse the repository at this point in the history
If we're looking at the consent form for a restricted patient, the GP
information should not be shown to the user.
  • Loading branch information
thomasleese committed Oct 18, 2024
1 parent f0eff9a commit fb148f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/components/app_consent_patient_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call
row.with_value { patient.date_of_birth.to_fs(:long) }
end

if (consent_form = consent.consent_form)
if !consent.restricted? && (consent_form = consent.consent_form)
summary_list.with_row do |row|
row.with_key { "Home address" }
row.with_value { helpers.format_address_multi_line(consent_form) }
Expand Down
2 changes: 2 additions & 0 deletions app/models/consent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def wizard_steps
].compact
end

delegate :restricted?, to: :patient

def name
via_self_consent? ? patient.full_name : parent.full_name
end
Expand Down
15 changes: 14 additions & 1 deletion spec/components/app_consent_patient_summary_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
session:
)
end

let(:restricted) { false }
let(:patient) do
create(
:patient,
given_name: "John",
family_name: "Doe",
date_of_birth: Date.new(2000, 1, 1),
school:,
team:
team:,
restricted_at: restricted ? Time.current : nil
)
end

Expand All @@ -44,4 +47,14 @@

it { should have_content("School") }
it { should have_content("Waterloo Road") }

context "with a restricted patient" do
let(:restricted) { true }

it { should_not have_content("GP surgery") }
it { should_not have_content("Waterloo GP") }

it { should_not have_content("Home address") }
it { should_not have_content("SW1A 1AA") }
end
end

0 comments on commit fb148f2

Please sign in to comment.