Skip to content

Commit 0128030

Browse files
committed
Remove unused pre-screening columns
This removes a number of columns from the pre-screening model which are no longer used and therefore can be safely removed.
1 parent b218d59 commit 0128030

12 files changed

+94
-150
lines changed

]

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Simplify pre-screening checks
2+
3+
This updates the designs of the pre-screening checks to match the latest
4+
designs in the prototype where the process has been simplified to have
5+
only a single checkbox rather than a checkbox for each question. The
6+
content has also been refreshed to match the medical guidance.
7+
8+
# Conflicts:
9+
# spec/features/e2e_journey_spec.rb
10+
# spec/features/hpv_vaccination_administered_spec.rb
11+
# spec/features/hpv_vaccination_already_had_spec.rb
12+
# spec/features/hpv_vaccination_clinic_spec.rb
13+
# spec/features/hpv_vaccination_delayed_spec.rb
14+
# spec/features/vaccination_todays_batch_spec.rb
15+
16+
# Please enter the commit message for your changes. Lines starting
17+
# with '#' will be ignored, and an empty message aborts the commit.
18+
#
19+
# interactive rebase in progress; onto 8bf4bba60
20+
# Last commands done (2 commands done):
21+
# pick 8ef13d8e8 Refactor pre-screening feature specs
22+
# pick 766d04241 Simplify pre-screening checks
23+
# Next command to do (1 remaining command):
24+
# pick ce12b90dc Remove unused pre-screening columns
25+
# You are currently rebasing branch 'redesign-pre-screening-single-question' on '8bf4bba60'.
26+
#
27+
# Changes to be committed:
28+
# modified: app/components/app_patient_page_component.rb
29+
# modified: app/components/app_vaccinate_form_component.html.erb
30+
# modified: app/controllers/vaccinations_controller.rb
31+
# modified: app/forms/vaccinate_form.rb
32+
# modified: app/models/pre_screening.rb
33+
# modified: config/locales/en.yml
34+
# modified: config/locales/helpers.en.yml
35+
# modified: spec/components/app_patient_page_component_spec.rb
36+
# modified: spec/features/doubles_vaccination_administered_spec.rb
37+
# modified: spec/features/e2e_journey_spec.rb
38+
# modified: spec/features/hpv_vaccination_administered_spec.rb
39+
# modified: spec/features/hpv_vaccination_already_had_spec.rb
40+
# modified: spec/features/hpv_vaccination_clinic_spec.rb
41+
# modified: spec/features/hpv_vaccination_delayed_spec.rb
42+
# modified: spec/features/menacwy_vaccination_administered_spec.rb
43+
# modified: spec/features/pre_screening_spec.rb
44+
# modified: spec/features/td_ipv_vaccination_administered_spec.rb
45+
# modified: spec/features/vaccination_todays_batch_spec.rb
46+
# modified: spec/models/pre_screening_spec.rb
47+
#

app/forms/vaccinate_form.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,9 @@ def ask_not_pregnant? = programme.td_ipv?
6262
def pre_screening
6363
@pre_screening ||=
6464
patient_session.pre_screenings.build(
65-
feeling_well: true,
66-
knows_vaccination: true,
67-
no_allergies: true,
68-
not_already_had: true,
69-
not_pregnant: true,
70-
not_taking_medication: true,
7165
notes: pre_screening_notes,
7266
performed_by: current_user,
73-
programme:,
74-
session_date_id:
67+
programme:
7568
)
7669
end
77-
78-
def session_date_id
79-
patient_session.session.session_dates.today.first&.id
80-
end
8170
end

app/models/pre_screening.rb

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,30 @@
44
#
55
# Table name: pre_screenings
66
#
7-
# id :bigint not null, primary key
8-
# feeling_well :boolean not null
9-
# knows_vaccination :boolean not null
10-
# no_allergies :boolean not null
11-
# not_already_had :boolean not null
12-
# not_pregnant :boolean not null
13-
# not_taking_medication :boolean not null
14-
# notes :text default(""), not null
15-
# created_at :datetime not null
16-
# updated_at :datetime not null
17-
# patient_session_id :bigint not null
18-
# performed_by_user_id :bigint not null
19-
# programme_id :bigint not null
20-
# session_date_id :bigint not null
7+
# id :bigint not null, primary key
8+
# notes :text default(""), not null
9+
# created_at :datetime not null
10+
# updated_at :datetime not null
11+
# patient_session_id :bigint not null
12+
# performed_by_user_id :bigint not null
13+
# programme_id :bigint not null
2114
#
2215
# Indexes
2316
#
2417
# index_pre_screenings_on_patient_session_id (patient_session_id)
2518
# index_pre_screenings_on_performed_by_user_id (performed_by_user_id)
2619
# index_pre_screenings_on_programme_id (programme_id)
27-
# index_pre_screenings_on_session_date_id (session_date_id)
2820
#
2921
# Foreign Keys
3022
#
3123
# fk_rails_... (patient_session_id => patient_sessions.id)
3224
# fk_rails_... (performed_by_user_id => users.id)
3325
# fk_rails_... (programme_id => programmes.id)
34-
# fk_rails_... (session_date_id => session_dates.id)
3526
#
3627
class PreScreening < ApplicationRecord
3728
audited associated_with: :patient_session
3829

3930
belongs_to :patient_session
40-
belongs_to :session_date
4131
belongs_to :programme
4232
belongs_to :performed_by,
4333
class_name: "User",

app/models/session_date.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class SessionDate < ApplicationRecord
2222
belongs_to :session
2323

2424
has_many :session_attendances, dependent: :restrict_with_error
25-
has_many :pre_screenings, dependent: :restrict_with_error
2625

2726
scope :for_session, -> { where("session_id = sessions.id") }
2827

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveFromPreScreenings < ActiveRecord::Migration[8.0]
4+
def up
5+
change_table :pre_screenings, bulk: true do |t|
6+
t.remove :feeling_well,
7+
:knows_vaccination,
8+
:no_allergies,
9+
:not_already_had,
10+
:not_pregnant,
11+
:not_taking_medication
12+
t.remove_references :session_date
13+
end
14+
end
15+
end

db/schema.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.0].define(version: 2025_04_29_140846) do
13+
ActiveRecord::Schema[8.0].define(version: 2025_05_05_193919) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_catalog.plpgsql"
1616
enable_extension "pg_trgm"
@@ -631,21 +631,13 @@
631631
create_table "pre_screenings", force: :cascade do |t|
632632
t.bigint "patient_session_id", null: false
633633
t.bigint "performed_by_user_id", null: false
634-
t.boolean "knows_vaccination", null: false
635-
t.boolean "not_already_had", null: false
636-
t.boolean "feeling_well", null: false
637-
t.boolean "no_allergies", null: false
638634
t.text "notes", default: "", null: false
639635
t.datetime "created_at", null: false
640636
t.datetime "updated_at", null: false
641637
t.bigint "programme_id", null: false
642-
t.boolean "not_taking_medication", null: false
643-
t.boolean "not_pregnant", null: false
644-
t.bigint "session_date_id", null: false
645638
t.index ["patient_session_id"], name: "index_pre_screenings_on_patient_session_id"
646639
t.index ["performed_by_user_id"], name: "index_pre_screenings_on_performed_by_user_id"
647640
t.index ["programme_id"], name: "index_pre_screenings_on_programme_id"
648-
t.index ["session_date_id"], name: "index_pre_screenings_on_session_date_id"
649641
end
650642

651643
create_table "programmes", force: :cascade do |t|
@@ -910,7 +902,6 @@
910902
add_foreign_key "patients", "organisations"
911903
add_foreign_key "pre_screenings", "patient_sessions"
912904
add_foreign_key "pre_screenings", "programmes"
913-
add_foreign_key "pre_screenings", "session_dates"
914905
add_foreign_key "pre_screenings", "users", column: "performed_by_user_id"
915906
add_foreign_key "school_move_log_entries", "locations", column: "school_id"
916907
add_foreign_key "school_move_log_entries", "patients"

spec/components/app_activity_log_component_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@
394394
before do
395395
create(
396396
:pre_screening,
397-
:allows_vaccination,
398397
performed_by: user,
399398
patient_session:,
400399
notes: "Some notes",

spec/components/app_patient_page_component_spec.rb

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,14 @@
129129
describe "#default_vaccinate_form" do
130130
subject(:vaccinate_form) { component.default_vaccinate_form }
131131

132-
context "when a pre-screening from today's session and programme exists" do
133-
let(:today) { Date.current }
134-
let(:patient_session) do
135-
create(:patient_session, :session_in_progress, programmes:)
136-
end
137-
let(:session_date_today) { SessionDate.find_or_create_by(value: today) }
132+
let(:patient_session) { create(:patient_session, programmes:) }
138133

134+
context "when a pre-screening from today's session and programme exists" do
139135
before do
140136
create(
141137
:pre_screening,
142138
patient_session:,
143139
programme: programmes.first,
144-
session_date: session_date_today,
145-
feeling_well: true,
146-
knows_vaccination: true,
147-
no_allergies: true,
148-
not_already_had: true,
149-
not_pregnant: true,
150-
not_taking_medication: true,
151140
notes: "Today's prescreening"
152141
)
153142
end
@@ -162,24 +151,11 @@
162151
end
163152

164153
context "when a pre-screening from today's session and different programme exists" do
165-
let(:today) { Date.current }
166-
let(:patient_session) do
167-
create(:patient_session, :session_in_progress, programmes:)
168-
end
169-
let(:session_date_today) { SessionDate.find_or_create_by(value: today) }
170-
171154
before do
172155
create(
173156
:pre_screening,
174157
patient_session:,
175158
programme: programmes.second,
176-
session_date: session_date_today,
177-
feeling_well: true,
178-
knows_vaccination: true,
179-
no_allergies: true,
180-
not_already_had: true,
181-
not_pregnant: true,
182-
not_taking_medication: true,
183159
notes: "Today's prescreening"
184160
)
185161
end
@@ -194,24 +170,12 @@
194170
end
195171

196172
context "when a pre-screening from yesterday's session and programme exists" do
197-
subject(:vaccinate_form) { component.default_vaccinate_form }
198-
199-
let(:today) { Date.current }
200-
let(:patient_session) do
201-
create(:patient_session, :session_in_progress, programmes:)
202-
end
203-
let(:session_date_yesterday) { create(:session_date, value: today - 1) }
204-
let(:pre_screening_yesterday) do
173+
before do
205174
create(
206175
:pre_screening,
207176
patient_session:,
208-
session_date: session_date_yesterday,
209-
feeling_well: true,
210-
knows_vaccination: true,
211-
no_allergies: true,
212-
not_already_had: true,
213-
not_pregnant: true,
214-
not_taking_medication: true,
177+
programme: programmes.first,
178+
created_at: 1.day.ago,
215179
notes: "Yesterday's prescreening"
216180
)
217181
end

spec/components/app_triage_notes_component_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
before do
7070
create(
7171
:pre_screening,
72-
:allows_vaccination,
7372
patient_session:,
7473
notes: "Some notes",
7574
performed_by:,

spec/factories/pre_screenings.rb

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,31 @@
44
#
55
# Table name: pre_screenings
66
#
7-
# id :bigint not null, primary key
8-
# feeling_well :boolean not null
9-
# knows_vaccination :boolean not null
10-
# no_allergies :boolean not null
11-
# not_already_had :boolean not null
12-
# not_pregnant :boolean not null
13-
# not_taking_medication :boolean not null
14-
# notes :text default(""), not null
15-
# created_at :datetime not null
16-
# updated_at :datetime not null
17-
# patient_session_id :bigint not null
18-
# performed_by_user_id :bigint not null
19-
# programme_id :bigint not null
20-
# session_date_id :bigint not null
7+
# id :bigint not null, primary key
8+
# notes :text default(""), not null
9+
# created_at :datetime not null
10+
# updated_at :datetime not null
11+
# patient_session_id :bigint not null
12+
# performed_by_user_id :bigint not null
13+
# programme_id :bigint not null
2114
#
2215
# Indexes
2316
#
2417
# index_pre_screenings_on_patient_session_id (patient_session_id)
2518
# index_pre_screenings_on_performed_by_user_id (performed_by_user_id)
2619
# index_pre_screenings_on_programme_id (programme_id)
27-
# index_pre_screenings_on_session_date_id (session_date_id)
2820
#
2921
# Foreign Keys
3022
#
3123
# fk_rails_... (patient_session_id => patient_sessions.id)
3224
# fk_rails_... (performed_by_user_id => users.id)
3325
# fk_rails_... (programme_id => programmes.id)
34-
# fk_rails_... (session_date_id => session_dates.id)
3526
#
3627
FactoryBot.define do
3728
factory :pre_screening do
3829
patient_session
3930
programme { patient_session.programmes.first }
40-
session_date { patient_session.session.session_dates.first }
4131
performed_by
42-
43-
trait :allows_vaccination do
44-
knows_vaccination { true }
45-
not_already_had { true }
46-
feeling_well { true }
47-
no_allergies { true }
48-
not_taking_medication { true }
49-
not_pregnant { true }
50-
notes { "Fine to vaccinate" }
51-
end
52-
53-
trait :prevents_vaccination do
54-
knows_vaccination { false }
55-
not_already_had { false }
56-
feeling_well { false }
57-
no_allergies { false }
58-
not_taking_medication { false }
59-
not_pregnant { false }
60-
notes { "Not safe to vaccinate" }
61-
end
32+
notes { "Fine to vaccinate" }
6233
end
6334
end

0 commit comments

Comments
 (0)