diff --git a/app/models/generic_event.rb b/app/models/generic_event.rb index 9bff78c39..0b9730ed3 100644 --- a/app/models/generic_event.rb +++ b/app/models/generic_event.rb @@ -87,6 +87,7 @@ class GenericEvent < ApplicationRecord PerPrisonerWelfare PerPropertyChange PerSelfHarm + PerSuicideAndSelfHarm PerUpdated PerViolentDangerous PerWeapons @@ -110,6 +111,7 @@ class GenericEvent < ApplicationRecord incident: 'incident', medical: 'medical', notification: 'notification', + suicide_and_self_harm: 'suicide_and_self_harm', } belongs_to :eventable, polymorphic: true, touch: true diff --git a/app/models/generic_event/per_suicide_and_self_harm.rb b/app/models/generic_event/per_suicide_and_self_harm.rb new file mode 100644 index 000000000..aead92679 --- /dev/null +++ b/app/models/generic_event/per_suicide_and_self_harm.rb @@ -0,0 +1,24 @@ +class GenericEvent + class PerSuicideAndSelfHarm < GenericEvent + details_attributes :concerns, + :history, + :sash_methods, + :source_type, + :source_summary, + :source_observations, + :safety_actions, + :observation_level, + :observation_level_comment, + :comments, + :reporting_officer, + :reporting_officer_signed_at, + :reception_officer, + :reception_officer_signed_at + + eventable_types 'PersonEscortRecord' + + def event_classification + :suicide_and_self_harm + end + end +end diff --git a/spec/factories/generic_event.rb b/spec/factories/generic_event.rb index 93eed8e4b..d7b4d08c9 100644 --- a/spec/factories/generic_event.rb +++ b/spec/factories/generic_event.rb @@ -669,6 +669,27 @@ factory :event_per_self_harm, parent: :per_incident, class: 'GenericEvent::PerSelfHarm' do end + factory :event_per_suicide_and_self_harm, parent: :per_incident, class: 'GenericEvent::PerSuicideAndSelfHarm' do + eventable { association(:person_escort_record, :confirmed) } + details do + { + concerns: 'They have said they will self-harm', + history: 'Previous incident in 2024', + method: 'Cutting, ligatgure - picked at a scab', + source: 'Third party', + source_summary: 'Police officer stated he would self-harm', + source_observations: 'Something was observed', + safety_actions: 'Referred to a medical professional', + observation_level: 'Every 10 minutes', + comments: 'A comment was recorded', + reporting_officer: 'PCO Roberts', + reporting_officer_signed_at: 1.hour.ago, + reception_officer: 'PCO Smith', + reception_officer_signed_at: 55.minutes.ago, + } + end + end + factory :event_per_violent_dangerous, parent: :per_incident, class: 'GenericEvent::PerViolentDangerous' do end diff --git a/spec/models/generic_event/per_suicide_and_self_harm_spec.rb b/spec/models/generic_event/per_suicide_and_self_harm_spec.rb new file mode 100644 index 000000000..dd6ba2629 --- /dev/null +++ b/spec/models/generic_event/per_suicide_and_self_harm_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +RSpec.describe GenericEvent::PerSuicideAndSelfHarm do + let(:per_suicide_and_self_harm_event) { build(:event_per_suicide_and_self_harm) } + + it_behaves_like 'an event with details', :concerns, :history, :sash_methods, :source_type, :source_summary, :source_observations, + :safety_actions, :observation_level, :observation_level_comment, :comments, :reporting_officer, + :reporting_officer_signed_at, :reception_officer, :reception_officer_signed_at + + it_behaves_like 'an event with eventable types', 'PersonEscortRecord' + + describe '#event_classification' do + subject(:event_classification) { per_suicide_and_self_harm_event.event_classification } + + it { is_expected.to eq(:suicide_and_self_harm) } + end +end