Skip to content

Commit 30a1973

Browse files
committed
Add columns for Imms API SNOMED procedure code and term to VaccinationRecord
* Fills these with the SNOMED procedure code and term from Imms API record * These values are NOT used anywhere. We are storing these to use later (as part of vaccs history alpha) Jira-Issue: MAV-5718
1 parent 55a52e2 commit 30a1973

7 files changed

Lines changed: 300 additions & 135 deletions

File tree

app/lib/fhir_mapper/vaccination_record.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class VaccinationRecord
1414
BATCH_EXPIRY_MIN = Date.new(Date.current.year - 100, 1, 1)
1515
BATCH_EXPIRY_MAX = Date.new(Date.current.year + 100, 1, 1)
1616

17+
VACCINATION_PROCEDURE_EXTENSION_URL =
18+
"https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationProcedure"
19+
1720
def initialize(vaccination_record)
1821
@vaccination_record = vaccination_record
1922
end
@@ -84,6 +87,14 @@ def self.from_fhir_record(fhir_record, patient:)
8487
.value
8588
attrs[:nhs_immunisations_api_primary_source] = fhir_record.primarySource
8689

90+
procedure_coding = vaccination_procedure_coding_from_fhir(fhir_record)
91+
attrs[
92+
:nhs_immunisations_api_snomed_procedure_code
93+
] = procedure_coding&.code
94+
attrs[
95+
:nhs_immunisations_api_snomed_procedure_term
96+
] = procedure_coding&.display
97+
8798
attrs[:programme] = Programme.from_fhir_record(fhir_record)
8899

89100
attrs[:performed_at] = Time.zone.parse(fhir_record.occurrenceDateTime)
@@ -180,8 +191,7 @@ def fhir_identifier
180191

181192
def fhir_vaccination_procedure_extension
182193
FHIR::Extension.new(
183-
url:
184-
"https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationProcedure",
194+
url: VACCINATION_PROCEDURE_EXTENSION_URL,
185195
valueCodeableConcept: vaccine.fhir_procedure_coding(dose_sequence:)
186196
)
187197
end
@@ -341,6 +351,17 @@ def fhir_org_performer
341351
fhir_record.performer.find { it.actor&.type == "Organization" }&.actor
342352
end
343353

354+
private_class_method def self.vaccination_procedure_coding_from_fhir(
355+
fhir_record
356+
)
357+
fhir_record
358+
.extension
359+
&.find { it.url == VACCINATION_PROCEDURE_EXTENSION_URL }
360+
&.valueCodeableConcept
361+
&.coding
362+
&.find { it.system == "http://snomed.info/sct" }
363+
end
364+
344365
def fhir_reason_code
345366
FHIR::CodeableConcept.new(
346367
coding: [

app/models/vaccination_record.rb

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,52 @@
44
#
55
# Table name: vaccination_records
66
#
7-
# id :bigint not null, primary key
8-
# batch_expiry :date
9-
# batch_number :string
10-
# confirmation_sent_at :datetime
11-
# delivery_method :integer
12-
# delivery_site :integer
13-
# discarded_at :datetime
14-
# disease_types :enum not null, is an Array
15-
# dose_sequence :integer
16-
# full_dose :boolean
17-
# local_patient_id_uri :string
18-
# location_name :string
19-
# nhs_immunisations_api_etag :string
20-
# nhs_immunisations_api_identifier_system :string
21-
# nhs_immunisations_api_identifier_value :string
22-
# nhs_immunisations_api_primary_source :boolean
23-
# nhs_immunisations_api_sync_pending_at :datetime
24-
# nhs_immunisations_api_synced_at :datetime
25-
# notes :text
26-
# notify_parents :boolean
27-
# outcome :integer not null
28-
# pending_changes :jsonb not null
29-
# performed_at_date :date not null
30-
# performed_at_time :time
31-
# performed_by_family_name :string
32-
# performed_by_given_name :string
33-
# performed_ods_code :string
34-
# programme_type :enum not null
35-
# protocol :integer
36-
# source :integer not null
37-
# uuid :uuid not null
38-
# created_at :datetime not null
39-
# updated_at :datetime not null
40-
# duplicate_of_vaccination_record_id :bigint
41-
# local_patient_id :string
42-
# location_id :bigint
43-
# next_dose_delay_triage_id :bigint
44-
# nhs_immunisations_api_id :string
45-
# patient_id :bigint not null
46-
# performed_by_user_id :bigint
47-
# reported_by_id :bigint
48-
# session_id :bigint
49-
# supplied_by_user_id :bigint
50-
# vaccine_id :bigint
7+
# id :bigint not null, primary key
8+
# batch_expiry :date
9+
# batch_number :string
10+
# confirmation_sent_at :datetime
11+
# delivery_method :integer
12+
# delivery_site :integer
13+
# discarded_at :datetime
14+
# disease_types :enum not null, is an Array
15+
# dose_sequence :integer
16+
# full_dose :boolean
17+
# local_patient_id_uri :string
18+
# location_name :string
19+
# nhs_immunisations_api_etag :string
20+
# nhs_immunisations_api_identifier_system :string
21+
# nhs_immunisations_api_identifier_value :string
22+
# nhs_immunisations_api_primary_source :boolean
23+
# nhs_immunisations_api_snomed_procedure_code :string
24+
# nhs_immunisations_api_snomed_procedure_term :string
25+
# nhs_immunisations_api_sync_pending_at :datetime
26+
# nhs_immunisations_api_synced_at :datetime
27+
# notes :text
28+
# notify_parents :boolean
29+
# outcome :integer not null
30+
# pending_changes :jsonb not null
31+
# performed_at_date :date not null
32+
# performed_at_time :time
33+
# performed_by_family_name :string
34+
# performed_by_given_name :string
35+
# performed_ods_code :string
36+
# programme_type :enum not null
37+
# protocol :integer
38+
# source :integer not null
39+
# uuid :uuid not null
40+
# created_at :datetime not null
41+
# updated_at :datetime not null
42+
# duplicate_of_vaccination_record_id :bigint
43+
# local_patient_id :string
44+
# location_id :bigint
45+
# next_dose_delay_triage_id :bigint
46+
# nhs_immunisations_api_id :string
47+
# patient_id :bigint not null
48+
# performed_by_user_id :bigint
49+
# reported_by_id :bigint
50+
# session_id :bigint
51+
# supplied_by_user_id :bigint
52+
# vaccine_id :bigint
5153
#
5254
# Indexes
5355
#
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
class AddNHSImmunisationsAPISnomedProcedureToVaccinationRecords < ActiveRecord::Migration[
4+
8.1
5+
]
6+
def change
7+
change_table :vaccination_records, bulk: true do |t|
8+
t.string :nhs_immunisations_api_snomed_procedure_code
9+
t.string :nhs_immunisations_api_snomed_procedure_term
10+
end
11+
end
12+
end

db/schema.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.1].define(version: 2026_03_30_095301) do
13+
14+
ActiveRecord::Schema[8.1].define(version: 2026_03_30_130232) do
1415
# These are extensions that must be enabled in order to support this database
1516
enable_extension "pg_catalog.plpgsql"
1617
enable_extension "pg_trgm"
@@ -1004,6 +1005,8 @@
10041005
t.string "nhs_immunisations_api_identifier_system"
10051006
t.string "nhs_immunisations_api_identifier_value"
10061007
t.boolean "nhs_immunisations_api_primary_source"
1008+
t.string "nhs_immunisations_api_snomed_procedure_code"
1009+
t.string "nhs_immunisations_api_snomed_procedure_term"
10071010
t.datetime "nhs_immunisations_api_sync_pending_at"
10081011
t.datetime "nhs_immunisations_api_synced_at"
10091012
t.text "notes"

spec/factories/vaccination_records.rb

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,52 @@
44
#
55
# Table name: vaccination_records
66
#
7-
# id :bigint not null, primary key
8-
# batch_expiry :date
9-
# batch_number :string
10-
# confirmation_sent_at :datetime
11-
# delivery_method :integer
12-
# delivery_site :integer
13-
# discarded_at :datetime
14-
# disease_types :enum not null, is an Array
15-
# dose_sequence :integer
16-
# full_dose :boolean
17-
# local_patient_id_uri :string
18-
# location_name :string
19-
# nhs_immunisations_api_etag :string
20-
# nhs_immunisations_api_identifier_system :string
21-
# nhs_immunisations_api_identifier_value :string
22-
# nhs_immunisations_api_primary_source :boolean
23-
# nhs_immunisations_api_sync_pending_at :datetime
24-
# nhs_immunisations_api_synced_at :datetime
25-
# notes :text
26-
# notify_parents :boolean
27-
# outcome :integer not null
28-
# pending_changes :jsonb not null
29-
# performed_at_date :date not null
30-
# performed_at_time :time
31-
# performed_by_family_name :string
32-
# performed_by_given_name :string
33-
# performed_ods_code :string
34-
# programme_type :enum not null
35-
# protocol :integer
36-
# source :integer not null
37-
# uuid :uuid not null
38-
# created_at :datetime not null
39-
# updated_at :datetime not null
40-
# duplicate_of_vaccination_record_id :bigint
41-
# local_patient_id :string
42-
# location_id :bigint
43-
# next_dose_delay_triage_id :bigint
44-
# nhs_immunisations_api_id :string
45-
# patient_id :bigint not null
46-
# performed_by_user_id :bigint
47-
# reported_by_id :bigint
48-
# session_id :bigint
49-
# supplied_by_user_id :bigint
50-
# vaccine_id :bigint
7+
# id :bigint not null, primary key
8+
# batch_expiry :date
9+
# batch_number :string
10+
# confirmation_sent_at :datetime
11+
# delivery_method :integer
12+
# delivery_site :integer
13+
# discarded_at :datetime
14+
# disease_types :enum not null, is an Array
15+
# dose_sequence :integer
16+
# full_dose :boolean
17+
# local_patient_id_uri :string
18+
# location_name :string
19+
# nhs_immunisations_api_etag :string
20+
# nhs_immunisations_api_identifier_system :string
21+
# nhs_immunisations_api_identifier_value :string
22+
# nhs_immunisations_api_primary_source :boolean
23+
# nhs_immunisations_api_snomed_procedure_code :string
24+
# nhs_immunisations_api_snomed_procedure_term :string
25+
# nhs_immunisations_api_sync_pending_at :datetime
26+
# nhs_immunisations_api_synced_at :datetime
27+
# notes :text
28+
# notify_parents :boolean
29+
# outcome :integer not null
30+
# pending_changes :jsonb not null
31+
# performed_at_date :date not null
32+
# performed_at_time :time
33+
# performed_by_family_name :string
34+
# performed_by_given_name :string
35+
# performed_ods_code :string
36+
# programme_type :enum not null
37+
# protocol :integer
38+
# source :integer not null
39+
# uuid :uuid not null
40+
# created_at :datetime not null
41+
# updated_at :datetime not null
42+
# duplicate_of_vaccination_record_id :bigint
43+
# local_patient_id :string
44+
# location_id :bigint
45+
# next_dose_delay_triage_id :bigint
46+
# nhs_immunisations_api_id :string
47+
# patient_id :bigint not null
48+
# performed_by_user_id :bigint
49+
# reported_by_id :bigint
50+
# session_id :bigint
51+
# supplied_by_user_id :bigint
52+
# vaccine_id :bigint
5153
#
5254
# Indexes
5355
#

0 commit comments

Comments
 (0)