Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the CarePlus exporter to redact patient address_line_1 if patient is restricted #3136

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion app/lib/reports/careplus_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def existing_row(patient:, patient_session:, vaccination_records:)
patient.family_name,
patient.given_name,
patient.date_of_birth.strftime("%d/%m/%Y"),
patient.address_line_1,
patient.restricted? ? "" : patient.address_line_1,
patient_session.latest_consents(programme:).first&.name || "",
99, # Ethnicity, 99 is "Not known"
first_vaccination.performed_at.strftime("%d/%m/%Y"),
Expand Down
28 changes: 28 additions & 0 deletions spec/lib/reports/careplus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,32 @@
expect(data_rows.first).to be_nil
end
end

context "with a restricted patient" do
it "doesn't include the address line 1" do
patient_session =
create(
:patient_session,
:consent_given_triage_not_needed,
programmes:,
session:
)
create(
:vaccination_record,
programme: programmes.first,
patient: patient_session.patient,
session: patient_session.session,
performed_at: 2.weeks.ago
)

patient_session.patient.update!(restricted_at: Time.current)

address_index = headers.index("Address Line 1")
row = data_rows.first

expect(row[0]).to eq(patient_session.patient.nhs_number)
expect(row).not_to be_nil
expect(row[address_index]).to be_blank
end
end
end
21 changes: 21 additions & 0 deletions spec/lib/reports/programme_vaccinations_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,27 @@
end
end

context "with a restricted patient" do
let(:session) { create(:session, programmes:, organisation:) }
let(:patient) { create(:patient, :restricted, session:) }

before do
create(
:vaccination_record,
patient:,
session:,
programme: programmes.first,
performed_by: user
)
end

it "doesn't include the address or postcode" do
expect(rows.count).to eq(1)
expect(rows.first["PERSON_ADDRESS_LINE_1"]).to be_blank
expect(rows.first["PERSON_POSTCODE"]).to be_blank
end
end

context "with a traced NHS number" do
let(:session) { create(:session, programmes:, organisation:) }

Expand Down
Loading