Skip to content

Commit 1da7bf5

Browse files
Don't require VACCINATED column (#3411)
If the file which has been uploaded has a `VACCINE_GIVEN` or `Vaccination type` column, we can assume that the record has been administered. This was already the case, but only the vaccine that the user provided is valid. If the vaccine was invalid, this lead to a confusing scenario where the user would see a validation error about the vaccine being invalid and a validation error about missing `VACCINATED`. This is wrong, once the vaccine has been fixed, the second validation error about the `VACCINATED` column would go away, so there's no need to show it to the user in the first place.
2 parents 7122d22 + c229ca0 commit 1da7bf5

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

app/models/immunisation_import_row.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ def administered
377377
elsif "no".start_with?(vaccinated.to_s.downcase)
378378
false
379379
end
380-
elsif vaccine.present?
380+
elsif vaccine_name.present? ||
381+
combined_vaccination_and_dose_sequence.present?
381382
true
382383
end
383384
end

spec/models/immunisation_import_row_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,40 @@
102102
end
103103
end
104104

105+
context "when missing VACCINATED but a vaccine has been given" do
106+
let(:data) { { "VACCINE_GIVEN" => "A vaccine" } }
107+
108+
it "doesn't require a VACCINATED column" do
109+
expect(immunisation_import_row).to be_invalid
110+
expect(immunisation_import_row.errors[:base]).not_to include(
111+
"<code>VACCINATED</code> is required"
112+
)
113+
end
114+
end
115+
116+
context "when missing VACCINATED but a vaccination type has been given" do
117+
let(:data) { { "Vaccination type" => "HPV 1" } }
118+
119+
it "requires a VACCINATED column" do
120+
expect(immunisation_import_row).to be_invalid
121+
expect(immunisation_import_row.errors[:base]).to include(
122+
"<code>VACCINATED</code> is required"
123+
)
124+
end
125+
126+
context "when SystmOne is enabled" do
127+
before { Flipper.enable(:systm_one_import) }
128+
after { Flipper.disable(:systm_one_import) }
129+
130+
it "doesn't require a VACCINATED column" do
131+
expect(immunisation_import_row).to be_invalid
132+
expect(immunisation_import_row.errors[:base]).not_to include(
133+
"<code>VACCINATED</code> is required"
134+
)
135+
end
136+
end
137+
end
138+
105139
context "when missing fields" do
106140
let(:data) { { "VACCINATED" => "Y" } }
107141

0 commit comments

Comments
 (0)