Skip to content

Commit 1ace9a1

Browse files
Merge pull request #6467 from NHSDigital/mike/mmr-systmone-codes
Add Read codes for MMR and MMRV to SystmOne exporter
2 parents 280d3fe + 3a8ac27 commit 1ace9a1

2 files changed

Lines changed: 60 additions & 13 deletions

File tree

app/lib/reports/systm_one_exporter.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Reports::SystmOneExporter
1010

1111
# We think these are CVT3 Read codes still used within SystmOne
1212
# They have been looked up from the SystmOne Code Browser
13-
# They are also available online here: https://biobank.ndph.ox.ac.uk/ukb/coding.cgi?id=8708&nl=1
14-
VACCINE_DOSE_MAPPINGS = {
13+
# Some of them are also available online here: https://biobank.ndph.ox.ac.uk/ukb/coding.cgi?id=8708&nl=1
14+
PRODUCT_DOSE_MAPPINGS = {
1515
"Cell-based Trivalent Influenza Vaccine Seqirus" => {
1616
1 => "YcjYj"
1717
},
@@ -31,16 +31,10 @@ class Reports::SystmOneExporter
3131
1 => "Y0da5",
3232
nil => "Y0da5"
3333
},
34-
"MMR VaxPro" => {
35-
nil => "Yb9ZN"
36-
},
3734
"Nimenrix" => {
3835
1 => "YOfcf",
3936
nil => "YOfcf"
4037
},
41-
"Priorix" => {
42-
nil => "Yav8l"
43-
},
4438
"Revaxis" => {
4539
1 => "Y3417",
4640
2 => "Y3418",
@@ -58,6 +52,17 @@ class Reports::SystmOneExporter
5852
}
5953
}.freeze
6054

55+
PROCEDURE_DOSE_MAPPINGS = {
56+
"mmr" => {
57+
1 => "65M1.",
58+
2 => "65MA."
59+
},
60+
"mmrv" => {
61+
1 => "Y3fec",
62+
2 => "Y3fed"
63+
}
64+
}.freeze
65+
6166
DELIVERY_SITE_MAPPINGS = {
6267
left_arm_upper_position: "Left deltoid",
6368
left_arm_lower_position: "Left deltoid",
@@ -222,10 +227,16 @@ def gender_code(code)
222227
def vaccination(vaccination_record)
223228
return if vaccination_record.not_administered?
224229

230+
programme = vaccination_record.programme
225231
vaccine_brand = vaccination_record.vaccine.brand
226232
dose_sequence = vaccination_record.dose_sequence
227233

228-
mapping = VACCINE_DOSE_MAPPINGS.dig(vaccine_brand, dose_sequence)
234+
mapping =
235+
if programme.mmr?
236+
PROCEDURE_DOSE_MAPPINGS.dig(programme.variant_type, dose_sequence)
237+
else
238+
PRODUCT_DOSE_MAPPINGS.dig(vaccine_brand, dose_sequence)
239+
end
229240

230241
return mapping if mapping.present?
231242

spec/lib/reports/systm_one_exporter_spec.rb

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,52 @@
295295
let(:programme) { Programme.mmr }
296296
let(:dose_sequence) { nil }
297297

298-
context "Priorix" do
298+
context "Priorix with unknown dose sequence" do
299299
let(:vaccine) { Vaccine.find_by!(brand: "Priorix") }
300300

301-
it { should eq("Yav8l") }
301+
it { should eq("Priorix") }
302302
end
303303

304-
context "MMR VaxPro" do
304+
context "MMR VaxPro with unknown dose sequence" do
305305
let(:vaccine) { Vaccine.find_by!(brand: "MMR VaxPro") }
306306

307-
it { should eq("Yb9ZN") }
307+
it { should eq("MMR VaxPro") }
308+
end
309+
310+
context "Priorix with dose sequence 1" do
311+
let(:vaccine) { Vaccine.find_by!(brand: "Priorix") }
312+
let(:dose_sequence) { 1 }
313+
314+
it { should eq("65M1.") }
315+
end
316+
317+
context "MMR VaxPro with dose sequence 2" do
318+
let(:vaccine) { Vaccine.find_by!(brand: "MMR VaxPro") }
319+
let(:dose_sequence) { 2 }
320+
321+
it { should eq("65MA.") }
322+
end
323+
324+
context "MMRV vaccinations" do
325+
context "ProQuad with unknown dose sequence" do
326+
let(:vaccine) { Vaccine.find_by!(brand: "ProQuad") }
327+
328+
it { should eq("ProQuad") }
329+
end
330+
331+
context "ProQuad with dose sequence 1" do
332+
let(:vaccine) { Vaccine.find_by!(brand: "ProQuad") }
333+
let(:dose_sequence) { 1 }
334+
335+
it { should eq("Y3fec") }
336+
end
337+
338+
context "Priorix Tetra with dose sequence 2" do
339+
let(:vaccine) { Vaccine.find_by!(brand: "Priorix-Tetra") }
340+
let(:dose_sequence) { 2 }
341+
342+
it { should eq("Y3fed") }
343+
end
308344
end
309345
end
310346

0 commit comments

Comments
 (0)