diff --git a/app/components/app_consent_card_component.html.erb b/app/components/app_consent_card_component.html.erb index b930857045..f1c3b61604 100644 --- a/app/components/app_consent_card_component.html.erb +++ b/app/components/app_consent_card_component.html.erb @@ -1,38 +1,40 @@ <%= render AppCardComponent.new(colour:) do |card| %> <% card.with_heading { heading } %> - <% if consent_status.no_response? %> - <% if latest_consent_request %> -

No-one responded to our requests for consent.

-

A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.

- <% else %> -

No requests have been sent.

+ <% unless vaccination_status.vaccinated? %> + <% if consent_status.no_response? %> + <% if latest_consent_request %> +

No-one responded to our requests for consent.

+

A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.

+ <% else %> +

No requests have been sent.

+ <% end %> + <% elsif consent_status.conflicts? %> +

You can only vaccinate if all respondents give consent.

+ <% elsif consent_status.refused? %> +

<%= who_refused %> refused to give consent.

+ <% elsif consent_status.given? %> +

<%= patient.full_name %> is ready for the vaccinator.

<% end %> - <% elsif consent_status.conflicts? %> -

You can only vaccinate if all respondents give consent.

- <% elsif consent_status.refused? %> -

<%= who_refused %> refused to give consent.

- <% elsif consent_status.given? %> -

<%= patient.full_name %> is ready for the vaccinator.

- <% end %> -
- <% if can_send_consent_request? %> - <%= govuk_button_to "Send consent request", - send_request_session_patient_programme_consents_path( +
+ <% 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 %> +
- <%= govuk_button_to "Get verbal consent", - session_patient_programme_consents_path( - session, patient, programme - ), - secondary: true %> -
- - <%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %> + <%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %> + <% end %> <%= render AppConsentTableComponent.new(patient_session:, programme:) %> <% end %> diff --git a/app/components/app_consent_card_component.rb b/app/components/app_consent_card_component.rb index 6974cf2e14..f994f13152 100644 --- a/app/components/app_consent_card_component.rb +++ b/app/components/app_consent_card_component.rb @@ -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? diff --git a/spec/components/app_consent_card_component_spec.rb b/spec/components/app_consent_card_component_spec.rb index c8f24efc1c..327b267a0b 100644 --- a/spec/components/app_consent_card_component_spec.rb +++ b/spec/components/app_consent_card_component_spec.rb @@ -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:) }