-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a model which will track when consent emails/texts are sent (either the first consent request, or the subsequent reminders). This is necessary to support sending multiple reminders, and tracking these notifications across different teams with the same programme.
- Loading branch information
1 parent
07bce41
commit aeeb0fe
Showing
8 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: consent_notifications | ||
# | ||
# id :bigint not null, primary key | ||
# reminder :boolean not null | ||
# sent_at :datetime not null | ||
# patient_id :bigint not null | ||
# programme_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_consent_notifications_on_patient_id (patient_id) | ||
# index_consent_notifications_on_patient_id_and_programme_id (patient_id,programme_id) | ||
# index_consent_notifications_on_programme_id (programme_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (patient_id => patients.id) | ||
# fk_rails_... (programme_id => programmes.id) | ||
# | ||
class ConsentNotification < ApplicationRecord | ||
belongs_to :patient | ||
belongs_to :programme | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateConsentNotifications < ActiveRecord::Migration[7.2] | ||
def change | ||
# rubocop:disable Rails/CreateTableWithTimestamps | ||
create_table :consent_notifications do |t| | ||
t.references :patient, null: false, foreign_key: true | ||
t.references :programme, null: false, foreign_key: true | ||
t.boolean :reminder, null: false | ||
t.datetime :sent_at, null: false, default: -> { "CURRENT_TIMESTAMP" } | ||
|
||
t.index %i[patient_id programme_id] | ||
end | ||
# rubocop:enable Rails/CreateTableWithTimestamps | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: consent_notifications | ||
# | ||
# id :bigint not null, primary key | ||
# reminder :boolean not null | ||
# sent_at :datetime not null | ||
# patient_id :bigint not null | ||
# programme_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_consent_notifications_on_patient_id (patient_id) | ||
# index_consent_notifications_on_patient_id_and_programme_id (patient_id,programme_id) | ||
# index_consent_notifications_on_programme_id (programme_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (patient_id => patients.id) | ||
# fk_rails_... (programme_id => programmes.id) | ||
# | ||
FactoryBot.define do | ||
factory :consent_notification do | ||
patient | ||
programme | ||
|
||
reminder { [true, false].sample } | ||
|
||
trait :request do | ||
reminder { false } | ||
end | ||
|
||
trait :reminder do | ||
reminder { false } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: consent_notifications | ||
# | ||
# id :bigint not null, primary key | ||
# reminder :boolean not null | ||
# sent_at :datetime not null | ||
# patient_id :bigint not null | ||
# programme_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_consent_notifications_on_patient_id (patient_id) | ||
# index_consent_notifications_on_patient_id_and_programme_id (patient_id,programme_id) | ||
# index_consent_notifications_on_programme_id (programme_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (patient_id => patients.id) | ||
# fk_rails_... (programme_id => programmes.id) | ||
# | ||
describe ConsentNotification do | ||
subject(:consent_notification) { build(:consent_notification) } | ||
|
||
it { should be_valid } | ||
end |