Skip to content

Commit 50d3f45

Browse files
committed
Add ID to FHIR vaccination record
This will be used for updates. Jira-Issue: MAV-1012
1 parent a0b9c52 commit 50d3f45

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

app/lib/fhir_mapper/vaccination_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def initialize(vaccination_record)
99
end
1010

1111
def fhir_record
12-
immunisation = FHIR::Immunization.new
12+
immunisation = FHIR::Immunization.new(id: nhs_immunisations_api_id)
1313

1414
if performed_by_user.present?
1515
immunisation.contained << performed_by_user.fhir_practitioner(

spec/lib/fhir_mapper/vaccination_record_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
let(:session) { patient_session.session }
1414
let(:vaccination_outcome) { :administered }
1515
let(:vaccine) { vaccination_record.vaccine }
16+
let(:nhs_immunisations_api_id) { nil }
1617
let(:vaccination_record) do
1718
create(
1819
:vaccination_record,
@@ -21,7 +22,8 @@
2122
programme:,
2223
session:,
2324
vaccine: programme.active_vaccines.first,
24-
outcome: vaccination_outcome
25+
outcome: vaccination_outcome,
26+
nhs_immunisations_api_id:
2527
)
2628
end
2729
let(:user) { vaccination_record.performed_by_user }
@@ -33,6 +35,20 @@
3335
# expect(immunisation_fhir.to_hash).to eq fhir_immunisation_json(patient:)
3436
# end
3537

38+
describe "id" do
39+
subject { immunisation_fhir.id }
40+
41+
context "when the vaccination record no UUID" do
42+
it { should be_nil }
43+
end
44+
45+
context "when the vaccination record has a UUID" do
46+
let(:nhs_immunisations_api_id) { "1212-1212-1212-121212121212" }
47+
48+
it { should eq "1212-1212-1212-121212121212" }
49+
end
50+
end
51+
3652
describe "contained patient" do
3753
subject { immunisation_fhir.contained.find { it.id == "Patient1" } }
3854

0 commit comments

Comments
 (0)