Skip to content

Commit bea1841

Browse files
committed
Use AppConsentCardComponent
This updates the `AppPatientSessionConsentComponent` to use the new `AppConsentCardComponent`, matching the latest designs in the prototype. This also allows us to remove the `AppConsentTableComponent` as its no longer in use. Jira-Issue: MAV-1474
1 parent db25554 commit bea1841

7 files changed

Lines changed: 27 additions & 120 deletions

app/components/app_consent_table_component.html.erb

Lines changed: 0 additions & 30 deletions
This file was deleted.

app/components/app_consent_table_component.rb

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/components/app_patient_session_consent_component.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@
3838
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
3939
<% end %>
4040

41-
<%= render AppConsentTableComponent.new(patient_session:, programme:) %>
41+
<% if consents.any? %>
42+
<h3 class="nhsuk-heading-s">Consent responses</h3>
43+
44+
<% consents.each do |consent| %>
45+
<%= render AppConsentCardComponent.new(consent, session:) %>
46+
<% end %>
47+
<% end %>
4248

4349
<% if show_health_answers? %>
4450
<hr class="nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--l">
4551

4652
<h3 class="nhsuk-heading-s">All answers to health questions</h3>
4753

48-
<%= render AppHealthAnswersSummaryComponent.new(consents) %>
54+
<%= render AppHealthAnswersSummaryComponent.new(grouped_consents) %>
4955
<% end %>
5056
<% end %>

app/components/app_patient_session_consent_component.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def latest_consent_request
3232
.first
3333
end
3434

35+
def consents
36+
@consents ||=
37+
patient
38+
.consents
39+
.where(programme:)
40+
.includes(:consent_form, :parent, :programme)
41+
.order(created_at: :desc)
42+
end
43+
3544
def consent_status
3645
@consent_status ||= patient.consent_status(programme:)
3746
end
@@ -45,16 +54,16 @@ def can_send_consent_request?
4554
session.open_for_consent? && patient.parents.any?
4655
end
4756

48-
def who_refused
49-
consents.find(&:response_refused?)&.who_responded
57+
def grouped_consents
58+
@grouped_consents ||= ConsentGrouper.call(consents, programme:)
5059
end
5160

52-
def consents
53-
@consents ||= ConsentGrouper.call(patient.consents, programme:)
61+
def who_refused
62+
grouped_consents.find(&:response_refused?)&.who_responded
5463
end
5564

5665
def show_health_answers?
57-
consents.any?(&:response_given?)
66+
grouped_consents.any?(&:response_given?)
5867
end
5968

6069
delegate :status, to: :consent_status

spec/components/app_consent_table_component_spec.rb

Lines changed: 0 additions & 47 deletions
This file was deleted.

spec/components/app_patient_session_consent_component_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
before { create(:patient_consent_status, :refused, patient:, programme:) }
4646

4747
it { should have_css(".app-card--red", text: "Consent refused") }
48-
it { should have_css("tr", text: /#{consent.parent.full_name}/) }
49-
it { should have_css("tr", text: /#{consent.parent_relationship.label}/) }
50-
it { should have_css("table tr", text: /Consent refused/) }
48+
it { should have_content(consent.parent.full_name) }
49+
it { should have_content(consent.parent_relationship.label) }
50+
it { should have_content("Consent refused") }
5151
it { should_not have_css("details", text: "Responses to health questions") }
5252
end
5353

spec/features/self_consent_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,12 @@ def when_the_nurse_views_the_childs_record
268268

269269
def then_they_see_that_the_child_has_consent_from_themselves
270270
expect(page).to have_content("Consent given")
271-
expect(page).to have_content(
272-
"#{@patient.full_name} Child (Gillick competent)"
273-
)
271+
expect(page).to have_content("Child (Gillick competent)")
274272
end
275273

276274
def then_they_see_that_the_child_has_consent_from_the_parent
277275
expect(page).to have_content("Consent given")
278-
expect(page).to have_content("Decision #{@parent.full_name}")
276+
expect(page).to have_content(@parent.full_name)
279277
end
280278

281279
def and_the_child_should_be_safe_to_vaccinate

0 commit comments

Comments
 (0)