Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions app/components/app_consent_card_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<%= render AppCardComponent.new(colour:) do |card| %>
<% card.with_heading { heading } %>

<% if consent_status.no_response? %>
<% if latest_consent_request %>
<p>No-one responded to our requests for consent.</p>
<p>A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.</p>
<% else %>
<p>No requests have been sent.</p>
<% unless vaccination_status.vaccinated? %>
<% if consent_status.no_response? %>
<% if latest_consent_request %>
<p>No-one responded to our requests for consent.</p>
<p>A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.</p>
<% else %>
<p>No requests have been sent.</p>
<% end %>
<% elsif consent_status.conflicts? %>
<p>You can only vaccinate if all respondents give consent.</p>
<% elsif consent_status.refused? %>
<p><%= who_refused %> refused to give consent.</p>
<% elsif consent_status.given? %>
<p><%= patient.full_name %> is ready for the vaccinator.</p>
<% end %>
<% elsif consent_status.conflicts? %>
<p>You can only vaccinate if all respondents give consent.</p>
<% elsif consent_status.refused? %>
<p><%= who_refused %> refused to give consent.</p>
<% elsif consent_status.given? %>
<p><%= patient.full_name %> is ready for the vaccinator.</p>
<% end %>

<div class="app-button-group nhsuk-u-margin-bottom-4">
<% if can_send_consent_request? %>
<%= govuk_button_to "Send consent request",
send_request_session_patient_programme_consents_path(
<div class="app-button-group nhsuk-u-margin-bottom-4">
<% if can_send_consent_request? %>
<%= govuk_button_to "Send consent request",
send_request_session_patient_programme_consents_path(
session, patient, programme
),
secondary: true %>
<% end %>

<%= govuk_button_to "Get verbal consent",
session_patient_programme_consents_path(
session, patient, programme
),
secondary: true %>
<% end %>
</div>

<%= govuk_button_to "Get verbal consent",
session_patient_programme_consents_path(
session, patient, programme
),
secondary: true %>
</div>

<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
<% end %>

<%= render AppConsentTableComponent.new(patient_session:, programme:) %>
<% end %>
7 changes: 5 additions & 2 deletions app/components/app_consent_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ def latest_consent_request
end

def consent_status
@consent_status ||=
patient.consent_statuses.find_or_initialize_by(programme:)
@consent_status ||= patient.consent_status(programme:)
end

def vaccination_status
@vaccination_status ||= patient.vaccination_status(programme:)
end

def can_send_consent_request?
Expand Down
10 changes: 10 additions & 0 deletions spec/components/app_consent_card_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
end
end

context "when vaccinated" do
before do
create(:patient_vaccination_status, :vaccinated, patient:, programme:)
end

it { should_not have_css("p", text: "No requests have been sent.") }
it { should_not have_css("button", text: "Get verbal consent") }
it { should_not have_css("button", text: "Assess Gillick competence") }
end

context "with refused consent" do
let!(:consent) { create(:consent, :refused, patient:, programme:) }

Expand Down
Loading