Skip to content

Commit c54ccca

Browse files
committed
Fix MMRV health questions appearing in MMR consent forms
This addresses a bug where MMRV health questions got mixed in with MMR health questions. This was because `programme.vaccines` wasn't filtering the vaccines for MMR only.
1 parent 7983070 commit c54ccca

6 files changed

Lines changed: 17 additions & 11 deletions

File tree

app/models/concerns/belongs_to_programme.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ module BelongsToProgramme
1515

1616
if disease_types.present?
1717
enum_values = disease_types.map { |dt| Vaccine.disease_types[dt] }
18-
query.where("disease_types && ARRAY[?]::integer[]", enum_values)
18+
query.where(
19+
"array_sort(disease_types) = ARRAY[?]::integer[]",
20+
enum_values.sort
21+
)
1922
else
2023
query
2124
end

app/models/programme.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ class Programme
88
TYPES_SUPPORTING_DELEGATION = %w[flu].freeze
99
MIN_MMRV_ELIGIBILITY_DATE = Date.new(2020, 1, 1).freeze
1010

11+
DISEASE_TYPES = {
12+
"flu" => %w[influenza],
13+
"hpv" => %w[human_papillomavirus],
14+
"mmr" => %w[measles mumps rubella],
15+
"td_ipv" => %w[tetanus diphtheria polio],
16+
"menacwy" => %w[meningitis_a meningitis_c meningitis_w meningitis_y]
17+
}.freeze
18+
1119
attr_accessor :type
1220

1321
def initialize(type:)
@@ -118,7 +126,7 @@ def is_catch_up?(year_group:)
118126
end
119127

120128
def vaccines
121-
@vaccines ||= Vaccine.where_programme(self)
129+
@vaccines ||= Vaccine.where_programme(self, DISEASE_TYPES[type])
122130
end
123131

124132
def vaccine_methods

app/models/programme_variant.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
class ProgrammeVariant < SimpleDelegator
44
attr_reader :variant_type
55

6-
DISTINGUISHING_DISEASE_TYPES = {
7-
"mmrv" => ["varicella"] # MMR + Varicella = MMRV
8-
}.freeze
6+
DISEASE_TYPES = { "mmrv" => %w[measles mumps rubella varicella] }.freeze
97

108
SNOMED_PROCEDURE_TERMS = { "mmrv" => "TBC" }.freeze
119

@@ -25,8 +23,7 @@ def name_in_sentence
2523
end
2624

2725
def vaccines
28-
@vaccines ||=
29-
Vaccine.where_programme(self, DISTINGUISHING_DISEASE_TYPES[variant_type])
26+
@vaccines ||= Vaccine.where_programme(self, DISEASE_TYPES[variant_type])
3027
end
3128

3229
def snomed_procedure_term

config/vaccines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ vaxpro:
186186

187187
# MMRV
188188

189-
pro_quad :
189+
pro_quad:
190190
type: mmr
191191
brand: ProQuad
192192
method: injection

lib/tasks/vaccines.rake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,6 @@ def create_menacwy_health_questions(vaccine)
349349
end
350350

351351
def create_mmr_health_questions(vaccine)
352-
Flipper.enable(:mmrv)
353-
354352
bleeding =
355353
vaccine.health_questions.create!(
356354
title: "Does your child have a bleeding disorder?"

spec/factories/vaccines.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
transient { programme { nil } }
3535

3636
programme_type { programme&.type || Programme::TYPES.sample }
37-
37+
disease_types { Programme::DISEASE_TYPES[programme_type] }
3838
brand { Faker::Commerce.product_name }
3939
manufacturer { Faker::Company.name }
4040
sequence(:nivs_name) { |n| "#{brand.parameterize}-#{n}" }

0 commit comments

Comments
 (0)