Skip to content

Commit 6064b58

Browse files
committed
Set identifier for national reporting
Vaccination records uploaded through national reporting have a slightly different identifier when uploaded to the NHS Imms API. Jira-Issue: MAV-2733
1 parent 80cb3e4 commit 6064b58

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

app/lib/fhir_mapper/vaccination_record.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class VaccinationRecord
66

77
MAVIS_SYSTEM_NAME =
88
"http://manage-vaccinations-in-schools.nhs.uk/vaccination_records"
9+
MAVIS_NATIONAL_REPORTING_SYSTEM_NAME =
10+
"http://manage-vaccinations-in-schools.nhs.uk/national-reporting/vaccination-records"
911

1012
MILLILITER_SUB_STRINGS = %w[ml millilitre milliliter].freeze
1113

@@ -123,7 +125,15 @@ def self.from_fhir_record(fhir_record, patient:)
123125
private
124126

125127
def fhir_identifier
126-
FHIR::Identifier.new(system: MAVIS_SYSTEM_NAME, value: uuid)
128+
case source
129+
when "bulk_upload"
130+
FHIR::Identifier.new(
131+
system: MAVIS_NATIONAL_REPORTING_SYSTEM_NAME,
132+
value: uuid
133+
)
134+
else
135+
FHIR::Identifier.new(system: MAVIS_SYSTEM_NAME, value: uuid)
136+
end
127137
end
128138

129139
def fhir_vaccination_procedure_extension

spec/lib/fhir_mapper/vaccination_record_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@
8888

8989
its(:value) { should eq vaccination_record.uuid }
9090
its(:system) { should eq mavis_system }
91+
92+
context "when the vaccination record is from national reporting" do
93+
let(:national_reporting_test_ods_code) { "NR121" }
94+
let(:vaccination_record) do
95+
create(
96+
:vaccination_record,
97+
:sourced_from_bulk_upload,
98+
uploaded_by: User.first,
99+
performed_ods_code: :national_reporting_test_ods_code,
100+
patient:,
101+
programme:,
102+
vaccine: programme.vaccines.first,
103+
outcome: "administered"
104+
)
105+
end
106+
107+
let(:national_reporting_system) do
108+
"http://manage-vaccinations-in-schools.nhs.uk/national-reporting/vaccination-records"
109+
end
110+
111+
its(:system) { should eq national_reporting_system }
112+
end
91113
end
92114

93115
describe "vaccine code" do

0 commit comments

Comments
 (0)