Skip to content

Commit b035a0a

Browse files
Merge pull request #4415 from nhsuk/make-protocol-optional
Make `VaccinationRecord.protocol` optional from imports and API
2 parents 9abdef1 + b7161f8 commit b035a0a

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

app/models/immunisation_import_row.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def to_vaccination_record
106106
performed_by_user:,
107107
performed_ods_code: performed_ods_code&.to_s,
108108
programme:,
109-
protocol: "pgd",
110109
session:
111110
}
112111

@@ -117,7 +116,7 @@ def to_vaccination_record
117116
)
118117
end
119118

120-
attributes.merge!(notify_parents: true) if session
119+
attributes.merge!(notify_parents: true, protocol: "pgd") if session
121120

122121
attributes_to_stage_if_already_exists = {
123122
batch_id: batch&.id,

app/models/vaccination_record.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ class VaccinationRecord < ApplicationRecord
141141

142142
encrypts :notes
143143

144-
with_options if: :administered? do
145-
validates :full_dose, inclusion: [true, false]
146-
validates :protocol, presence: true
147-
end
144+
validates :full_dose, inclusion: [true, false], if: :administered?
145+
validates :protocol,
146+
presence: true,
147+
if: -> { administered? && recorded_in_service? }
148148

149149
validates :notes, length: { maximum: 1000 }
150150

spec/models/vaccination_record_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@
7474
it { should allow_values(true, false).for(:full_dose) }
7575
it { should_not allow_values(nil).for(:full_dose) }
7676

77-
it { should validate_presence_of(:protocol) }
77+
context "when administered in mavis" do
78+
before { vaccination_record.session = create(:session) }
79+
80+
it { should validate_presence_of(:protocol) }
81+
end
7882
end
7983

8084
context "when not administered" do

0 commit comments

Comments
 (0)