Skip to content

Commit a209cce

Browse files
authored
Merge pull request #3681 from nhsuk/full-dose-half-dose
Add full dose or half dose step
2 parents aa5323f + bfd722c commit a209cce

11 files changed

Lines changed: 81 additions & 5 deletions

File tree

app/components/app_vaccination_record_summary_component.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ def call
139139
summary_list.with_row do |row|
140140
row.with_key { "Dose volume" }
141141
row.with_value { dose_volume_value }
142+
143+
if (href = @change_links[:dose_volume])
144+
row.with_action(
145+
text: "Change",
146+
href:,
147+
visually_hidden_text: "dose volume"
148+
)
149+
end
142150
end
143151
end
144152

app/controllers/draft_vaccination_records_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ def handle_date_and_time
8181
end
8282

8383
def handle_outcome
84-
if @draft_vaccination_record.administered?
85-
@draft_vaccination_record.full_dose = true
86-
elsif @draft_vaccination_record.location_name.present?
84+
if !@draft_vaccination_record.administered? &&
85+
@draft_vaccination_record.location_name.present?
8786
# If not administered and location is set, we can skip to confirm.
8887
# Otherwise, we need to get the location information from the user.
8988
jump_to("confirm")
@@ -147,6 +146,7 @@ def update_params
147146
confirm: @draft_vaccination_record.editing? ? [] : %i[notes],
148147
date_and_time: %i[performed_at],
149148
delivery: %i[delivery_site delivery_method],
149+
dose: %i[full_dose],
150150
location: %i[location_name],
151151
notes: %i[notes],
152152
outcome: %i[outcome]

app/forms/vaccinate_form.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def save(draft_vaccination_record:)
6060

6161
draft_vaccination_record.batch_id = todays_batch&.id
6262
draft_vaccination_record.dose_sequence = dose_sequence
63-
draft_vaccination_record.full_dose = true
6463
draft_vaccination_record.patient_id = patient_session.patient_id
6564
draft_vaccination_record.performed_at = Time.current
6665
draft_vaccination_record.performed_by_user = current_user

app/models/draft_vaccination_record.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def wizard_steps
4141
(:outcome if can_change_outcome?),
4242
(:delivery if administered?),
4343
(:batch if administered?),
44+
(:dose if administered? && can_be_half_dose?),
4445
(:location if location&.generic_clinic?),
4546
:confirm
4647
].compact
@@ -73,6 +74,10 @@ def wizard_steps
7374
validates :batch_id, presence: true
7475
end
7576

77+
on_wizard_step :dose, exact: true do
78+
validates :full_dose, inclusion: [true, false]
79+
end
80+
7681
on_wizard_step :location, exact: true do
7782
validates :location_name, presence: true
7883
end
@@ -175,6 +180,7 @@ def vaccination_record=(value)
175180
end
176181

177182
delegate :vaccine, to: :batch, allow_nil: true
183+
delegate :can_be_half_dose?, to: :vaccine, allow_nil: true
178184

179185
delegate :id, to: :vaccine, prefix: true, allow_nil: true
180186

@@ -187,10 +193,13 @@ def writable_attribute_names
187193
end
188194

189195
def reset_unused_fields
190-
unless administered?
196+
if administered?
197+
self.full_dose = true unless can_be_half_dose?
198+
else
191199
self.batch_id = nil
192200
self.delivery_method = nil
193201
self.delivery_site = nil
202+
self.full_dose = nil
194203
end
195204
end
196205

app/models/vaccine.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def active? = !discontinued
5555

5656
def contains_gelatine? = programme.flu? && nasal?
5757

58+
def can_be_half_dose? = nasal?
59+
5860
AVAILABLE_DELIVERY_SITES = {
5961
"injection" => %w[
6062
left_arm_upper_position

app/views/draft_vaccination_records/confirm.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
batch: wizard_path("batch"),
1919
delivery_method: wizard_path("delivery"),
2020
delivery_site: wizard_path("delivery"),
21+
dose_volume: @draft_vaccination_record.wizard_steps.include?(:dose) ? wizard_path("dose") : nil,
2122
location: @draft_vaccination_record.wizard_steps.include?(:location) ? wizard_path("location") : nil,
2223
notes: wizard_path("notes"),
2324
outcome: @draft_vaccination_record.wizard_steps.include?(:outcome) ? wizard_path("outcome") : nil,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% content_for :before_main do %>
2+
<%= render AppBacklinkComponent.new(@back_link_path) %>
3+
<% end %>
4+
5+
<% legend = "Did they get the full dose?" %>
6+
<% content_for :page_title, legend %>
7+
8+
<%= form_with model: @draft_vaccination_record, url: wizard_path, method: :put do |f| %>
9+
<% content_for(:before_content) { f.govuk_error_summary } %>
10+
11+
<%= f.govuk_collection_radio_buttons :full_dose,
12+
%i[true false],
13+
:itself,
14+
caption: { text: @patient.full_name, size: "l" },
15+
legend: { text: legend, tag: "h1", size: "l" } %>
16+
17+
<%= f.govuk_submit %>
18+
<% end %>

config/locales/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ en:
7272
delivery_site:
7373
blank: Choose a delivery site
7474
inclusion: Choose a delivery site
75+
full_dose:
76+
inclusion: Choose whether they got the full dose
7577
location_name:
7678
blank: Enter where the vaccination was given
7779
notes:
@@ -686,6 +688,7 @@ en:
686688
date_of_birth: date-of-birth
687689
dates: dates
688690
delivery: delivery
691+
dose: dose
689692
education_setting: education-setting
690693
file_format: file-format
691694
gp: gp

config/locales/helpers.en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ en:
1212
keep_both: The new and existing records will both be kept.
1313

1414
label:
15+
draft_vaccination_record:
16+
full_dose_options:
17+
true: Yes, they got the full dose
18+
false: No, they got half a dose
1519
import_duplicate_form:
1620
apply_changes_options:
1721
apply: Use duplicate record

spec/models/draft_vaccination_record_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@
8484
describe "#reset_unused_fields" do
8585
subject(:save!) { draft_vaccination_record.save! }
8686

87+
context "when administered" do
88+
let(:attributes) { valid_administered_attributes.except(:full_dose) }
89+
90+
it "sets full dose to true if half doses cannot be recorded" do
91+
expect { save! }.to change(draft_vaccination_record, :full_dose).to(
92+
true
93+
)
94+
end
95+
end
96+
8797
context "when not administered" do
8898
let(:attributes) do
8999
valid_not_administered_attributes.merge(

0 commit comments

Comments
 (0)