Skip to content

Commit 1905afa

Browse files
Imms API records should have Batch.team = nil
This is because we expect most vaccinatination records from this source to have been administered in GP practices, meaning that they should not be associated with team in Mavis.
1 parent a97d4cf commit 1905afa

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

app/lib/fhir_mapper/vaccination_record.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def fhir_record
5050
immunisation
5151
end
5252

53-
def self.from_fhir_record(fhir_record, patient:, team:)
53+
def self.from_fhir_record(fhir_record, patient:)
5454
attrs = {}
5555

5656
attrs[:source] = "nhs_immunisations_api"
@@ -98,12 +98,8 @@ def self.from_fhir_record(fhir_record, patient:, team:)
9898

9999
attrs[:vaccine] = Vaccine.from_fhir_record(fhir_record)
100100

101-
if attrs[:vaccine] && team
102-
attrs[:batch] = batch_from_fhir(
103-
fhir_record,
104-
vaccine: attrs[:vaccine],
105-
team:
106-
)
101+
if attrs[:vaccine]
102+
attrs[:batch] = batch_from_fhir(fhir_record, vaccine: attrs[:vaccine])
107103
attrs[:full_dose] = full_dose_from_fhir(
108104
fhir_record,
109105
vaccine: attrs[:vaccine]
@@ -322,11 +318,10 @@ def fhir_protocol_applied
322318
)
323319
end
324320

325-
private_class_method def self.batch_from_fhir(fhir_record, vaccine:, team:)
321+
private_class_method def self.batch_from_fhir(fhir_record, vaccine:)
326322
::Batch.create_with(archived_at: Time.current).find_or_create_by!(
327323
expiry: fhir_record.expirationDate&.to_date,
328324
name: fhir_record.lotNumber.to_s,
329-
team:,
330325
vaccine:
331326
)
332327
end

spec/lib/fhir_mapper/vaccination_record_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295

296296
describe "#from_fhir_record" do
297297
subject(:record) do
298-
VaccinationRecord.from_fhir_record(fhir_immunization, patient:, team:)
298+
VaccinationRecord.from_fhir_record(fhir_immunization, patient:)
299299
end
300300

301301
around { |example| travel_to(Date.new(2025, 11, 20)) { example.run } }
@@ -312,6 +312,10 @@
312312
its(:source) { should eq "nhs_immunisations_api" }
313313
its(:nhs_immunisations_api_synced_at) { should eq Time.current }
314314

315+
it "batch.team is nil" do
316+
expect(record.batch&.team).to be_nil
317+
end
318+
315319
context "when the record is saved to the database" do
316320
before { record.save! }
317321

0 commit comments

Comments
 (0)