Skip to content

Commit

Permalink
Add a view for a single patient
Browse files Browse the repository at this point in the history
This adds a page that allows the user to see an individual child record
based on the designs in the prototype.
  • Loading branch information
thomasleese committed Oct 17, 2024
1 parent 5109eca commit 2b2f5c4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/components/app_patient_table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<% body.with_row do |row| %>
<% row.with_cell do %>
<span class="nhsuk-table-responsive__heading">Full name</span>
<%= patient.full_name %>
<%= link_to patient.full_name, patient_path(patient) %>
<% end %>
<% row.with_cell do %>
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
class PatientsController < ApplicationController
include Pagy::Backend

layout "full"

def index
@pagy, @patients = pagy(policy_scope(Patient).order_by_name)

render layout: "full"
end

def show
@patient = policy_scope(Patient).find(params[:id])
end
end
15 changes: 15 additions & 0 deletions app/views/patients/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% content_for :before_main do %>
<%= render AppBreadcrumbComponent.new(items: [
{ text: "Home", href: programmes_path },
{ text: t("patients.index.title"), href: patients_path },
]) %>
<% end %>
<%= h1 page_title: @patient.initials do %>
<%= @patient.full_name %>
<% end %>
<%= render AppCardComponent.new do |c| %>
<% c.with_heading { "Child record" } %>
<%= render AppPatientSummaryComponent.new(@patient, show_common_name: true, show_address: true, show_parent_or_guardians: true) %>
<% end %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
end
end

resources :patients, only: :index
resources :patients, only: %i[index show]

resources :programmes, only: %i[index show] do
get "sessions", on: :member
Expand Down
15 changes: 14 additions & 1 deletion spec/features/manage_children_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

when_i_click_on_children
then_i_see_the_children

when_i_click_on_a_child
then_i_see_the_child
end

def given_my_team_exists
@team = create(:team, :with_one_nurse)
end

def and_patients_exist
create_list(:patient, 10, team: @team)
create(:patient, team: @team, given_name: "John", family_name: "Smith")
create_list(:patient, 9, team: @team)
end

def when_i_click_on_children
Expand All @@ -27,4 +31,13 @@ def when_i_click_on_children
def then_i_see_the_children
expect(page).to have_content("10 children")
end

def when_i_click_on_a_child
click_on "John Smith"
end

def then_i_see_the_child
expect(page).to have_title("JS")
expect(page).to have_content("John Smith")
end
end

0 comments on commit 2b2f5c4

Please sign in to comment.