Skip to content

Commit ef1b470

Browse files
committed
Remove health_answers_require_follow_up column
This removes the column from the `Patient::ConsentStatus` model as it's no longer being used. Instead, the triage status is calculated using the values from the consent directly meaning the consent status and triage status can be updated independently.
1 parent 498601f commit ef1b470

File tree

7 files changed

+27
-59
lines changed

7 files changed

+27
-59
lines changed

app/lib/status_updater.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def update_consent_statuses!
4040
batch,
4141
on_duplicate_key_update: {
4242
conflict_target: [:id],
43-
columns: %i[health_answers_require_follow_up status]
43+
columns: %i[status]
4444
}
4545
)
4646
end

app/models/patient/consent_status.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
#
55
# Table name: patient_consent_statuses
66
#
7-
# id :bigint not null, primary key
8-
# health_answers_require_follow_up :boolean default(FALSE), not null
9-
# status :integer default("no_response"), not null
10-
# patient_id :bigint not null
11-
# programme_id :bigint not null
7+
# id :bigint not null, primary key
8+
# status :integer default("no_response"), not null
9+
# patient_id :bigint not null
10+
# programme_id :bigint not null
1211
#
1312
# Indexes
1413
#
@@ -41,9 +40,6 @@ class Patient::ConsentStatus < ApplicationRecord
4140
-> { where("patient_id = patient_sessions.patient_id") }
4241

4342
def assign_status
44-
self.health_answers_require_follow_up =
45-
latest_consents.any?(&:health_answers_require_follow_up?)
46-
4743
self.status =
4844
if status_should_be_given?
4945
:given
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveHealthAnswersRequireFollowUpFromPatientConsentStatus < ActiveRecord::Migration[
4+
8.0
5+
]
6+
def change
7+
remove_column :patient_consent_statuses,
8+
:health_answers_require_follow_up,
9+
:boolean,
10+
default: false,
11+
null: false
12+
end
13+
end

db/schema.rb

Lines changed: 1 addition & 2 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_03_24_063136) do
13+
ActiveRecord::Schema[8.0].define(version: 2025_03_24_191759) 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"
@@ -551,7 +551,6 @@
551551
t.bigint "patient_id", null: false
552552
t.bigint "programme_id", null: false
553553
t.integer "status", default: 0, null: false
554-
t.boolean "health_answers_require_follow_up", default: false, null: false
555554
t.index ["patient_id", "programme_id"], name: "index_patient_consent_statuses_on_patient_id_and_programme_id", unique: true
556555
t.index ["patient_id"], name: "index_patient_consent_statuses_on_patient_id"
557556
t.index ["programme_id"], name: "index_patient_consent_statuses_on_programme_id"

spec/factories/patient_consent_statuses.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
#
55
# Table name: patient_consent_statuses
66
#
7-
# id :bigint not null, primary key
8-
# health_answers_require_follow_up :boolean default(FALSE), not null
9-
# status :integer default("no_response"), not null
10-
# patient_id :bigint not null
11-
# programme_id :bigint not null
7+
# id :bigint not null, primary key
8+
# status :integer default("no_response"), not null
9+
# patient_id :bigint not null
10+
# programme_id :bigint not null
1211
#
1312
# Indexes
1413
#
@@ -28,9 +27,5 @@
2827
programme
2928

3029
traits_for_enum :status
31-
32-
trait :health_answers_require_follow_up do
33-
health_answers_require_follow_up { true }
34-
end
3530
end
3631
end

spec/factories/patients.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@
276276
association(
277277
:patient_consent_status,
278278
:given,
279-
:health_answers_require_follow_up,
280279
patient: instance,
281280
programme:
282281
)

spec/models/patient/consent_status_spec.rb

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
#
55
# Table name: patient_consent_statuses
66
#
7-
# id :bigint not null, primary key
8-
# health_answers_require_follow_up :boolean default(FALSE), not null
9-
# status :integer default("no_response"), not null
10-
# patient_id :bigint not null
11-
# programme_id :bigint not null
7+
# id :bigint not null, primary key
8+
# status :integer default("no_response"), not null
9+
# patient_id :bigint not null
10+
# programme_id :bigint not null
1211
#
1312
# Indexes
1413
#
@@ -132,37 +131,4 @@
132131
end
133132
end
134133
end
135-
136-
describe "#health_answers_require_follow_up" do
137-
subject do
138-
patient_consent_status.assign_status
139-
patient_consent_status.health_answers_require_follow_up
140-
end
141-
142-
before { patient.strict_loading!(false) }
143-
144-
context "with no consent" do
145-
it { should be(false) }
146-
end
147-
148-
context "with an invalidated consent with health answers" do
149-
before do
150-
create(
151-
:consent,
152-
:invalidated,
153-
:health_question_notes,
154-
patient:,
155-
programme:
156-
)
157-
end
158-
159-
it { should be(false) }
160-
end
161-
162-
context "with a consent with health answers" do
163-
before { create(:consent, :health_question_notes, patient:, programme:) }
164-
165-
it { should be(true) }
166-
end
167-
end
168134
end

0 commit comments

Comments
 (0)