Skip to content

Commit 8271889

Browse files
committed
Add filtering by patient status
This allows nurses to filter patients more easily.
1 parent 7819cfd commit 8271889

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

app/components/app_session_patient_table_component.html.erb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@
3939
<% end %>
4040
<% end %>
4141

42+
<% if @columns.include?(:status) %>
43+
<%= f.govuk_check_boxes_fieldset :status, legend: { text: "Status", size: "s" } do %>
44+
<% status_options.each do |state| %>
45+
<%= f.govuk_check_box :status,
46+
state,
47+
label: { text: t("patient_session_statuses.#{state}.banner_title") },
48+
checked: state.to_s.in?(params[:status] || []),
49+
"data-autosubmit-target": "field",
50+
"data-action": "autosubmit#submit",
51+
"data-turbo-permanent": "true" %>
52+
<% end %>
53+
<% end %>
54+
<% end %>
55+
4256
<%= f.hidden_field :sort, value: params[:sort] %>
4357
<%= f.hidden_field :direction, value: params[:direction] %>
4458
<%= f.govuk_submit "Reset filters", type: "reset",

app/components/app_session_patient_table_component.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,8 @@ def header_attributes(column)
224224
end
225225
{ html_attributes: { aria: { sort: } } }
226226
end
227+
228+
def status_options
229+
PatientSessionStateConcern.available_states
230+
end
227231
end

app/controllers/concerns/patient_sorting_concern.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@ def filter_patients!(patients_or_patient_sessions)
5858
value.to_s.in?(year_groups)
5959
end
6060
end
61+
62+
if (statuses = params[:status]).present?
63+
patients_or_patient_sessions.select! do
64+
value = _1.try(:state) || "not_in_session"
65+
value.to_s.in?(statuses)
66+
end
67+
end
6168
end
6269
end

0 commit comments

Comments
 (0)