-
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.
Show restricted patients in important notices
This adds restricted patients to the important notices page shown next to deceased patients.
- Loading branch information
1 parent
7478042
commit bb855e1
Showing
5 changed files
with
44 additions
and
9 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
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 |
---|---|---|
@@ -1,17 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
class AppNoticesTableComponent < ViewComponent::Base | ||
def initialize(deceased_patients:) | ||
def initialize(deceased_patients:, restricted_patients:) | ||
super | ||
|
||
@deceased_patients = deceased_patients | ||
@restricted_patients = restricted_patients | ||
end | ||
|
||
def render? | ||
deceased_patients.present? | ||
@deceased_patients.present? || @restricted_patients.present? | ||
end | ||
|
||
private | ||
|
||
attr_reader :deceased_patients | ||
def notices | ||
(deceased_notices + restricted_notices).sort_by { _1[:date] }.reverse | ||
end | ||
|
||
def deceased_notices | ||
@deceased_patients.map do |patient| | ||
{ | ||
patient:, | ||
date_time: patient.date_of_death_recorded_at, | ||
message: "Record updated with child’s date of death" | ||
} | ||
end | ||
end | ||
|
||
def restricted_notices | ||
@restricted_patients.map do |patient| | ||
{ | ||
patient:, | ||
date_time: patient.restricted_at, | ||
message: "Record flagged as sensitive" | ||
} | ||
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<%= h1 t("notices.index.title"), size: "xl" %> | ||
<% if @deceased_patients.any? %> | ||
<%= render AppNoticesTableComponent.new(deceased_patients: @deceased_patients) %> | ||
<%= render AppNoticesTableComponent.new(deceased_patients: @deceased_patients, restricted_patients: @restricted_patients) %> | ||
<% else %> | ||
<p class="nhsuk-body"><%= t("notices.index.no_results") %></p> | ||
<% 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