Skip to content

Commit 2423924

Browse files
committed
Add follow_up_outcome and follow_up_resolved_at to consents
When a nurse follows up with a parent who requested a discussion before refusing, the outcome needs to be recorded on the existing consent. These columns track whether the follow-up resulted in the refusal being confirmed or withdrawn, and when that resolution took place - enabling the activity log to reflect the full follow-up history accurately.
1 parent 8732752 commit 2423924

5 files changed

Lines changed: 24 additions & 0 deletions

File tree

app/models/consent.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# id :bigint not null, primary key
88
# academic_year :integer not null
99
# disease_types :enum not null, is an Array
10+
# follow_up_outcome :integer
1011
# follow_up_requested :boolean
12+
# follow_up_resolved_at :datetime
1113
# health_answers :jsonb not null
1214
# invalidated_at :datetime
1315
# notes :text default(""), not null
@@ -95,6 +97,12 @@ class Consent < ApplicationRecord
9597
{ website: 0, phone: 1, paper: 2, in_person: 3, self_consent: 4 },
9698
prefix: "via",
9799
validate: true
100+
enum :follow_up_outcome,
101+
{ confirmed: 0, withdrawn: 1 },
102+
prefix: :follow_up,
103+
validate: {
104+
allow_nil: true
105+
}
98106

99107
validates :parent, presence: true, unless: :via_self_consent?
100108
validates :recorded_by,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
class AddFollowUpOutcomeToConsents < ActiveRecord::Migration[8.1]
4+
def change
5+
change_table :consents, bulk: true do |t|
6+
t.integer :follow_up_outcome
7+
t.datetime :follow_up_resolved_at
8+
end
9+
end
10+
end

db/schema.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@
309309
t.bigint "consent_form_id"
310310
t.datetime "created_at", null: false
311311
t.enum "disease_types", null: false, array: true, enum_type: "disease_type"
312+
t.integer "follow_up_outcome"
312313
t.boolean "follow_up_requested"
314+
t.datetime "follow_up_resolved_at"
313315
t.jsonb "health_answers", default: [], null: false
314316
t.datetime "invalidated_at"
315317
t.text "notes", default: "", null: false

spec/factories/consents.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# id :bigint not null, primary key
88
# academic_year :integer not null
99
# disease_types :enum not null, is an Array
10+
# follow_up_outcome :integer
1011
# follow_up_requested :boolean
12+
# follow_up_resolved_at :datetime
1113
# health_answers :jsonb not null
1214
# invalidated_at :datetime
1315
# notes :text default(""), not null

spec/models/consent_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# id :bigint not null, primary key
88
# academic_year :integer not null
99
# disease_types :enum not null, is an Array
10+
# follow_up_outcome :integer
1011
# follow_up_requested :boolean
12+
# follow_up_resolved_at :datetime
1113
# health_answers :jsonb not null
1214
# invalidated_at :datetime
1315
# notes :text default(""), not null

0 commit comments

Comments
 (0)