Skip to content
Open
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
6 changes: 3 additions & 3 deletions app/assets/javascript/expandable-sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Initialize progress
updateProgress(sections, completedSections)

// Handle "Complete all and continue" button
// Handle "Authorise" button
const completeAllButtons = document.querySelectorAll(
'.js-complete-all-sections'
)
Expand Down Expand Up @@ -322,15 +322,15 @@ function openNextIncompleteSection(currentIndex, sections, completedSections) {
// Function to highlight the completion button when all sections are done
function highlightCompletionButton() {
const completeButton = document.querySelector(
'button:contains("Complete all and continue")'
'button:contains("Authorise")'
)

if (!completeButton) {
// Try a more specific selector if the above doesn't work
const buttons = document.querySelectorAll('button')

buttons.forEach((btn) => {
if (btn.textContent.includes('Complete all and continue')) {
if (btn.textContent.includes('Authorise')) {
btn.classList.add('nhsuk-button--green') // Highlight in green
btn.style.animation = 'pulse 2s infinite' // Add a subtle animation
}
Expand Down
3 changes: 3 additions & 0 deletions app/routes/clinics.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ module.exports = (router) => {
}

const clinicData = getClinicData(req.session.data, req.params.id)
if (!clinicData) {
return res.redirect('/clinics')
}
let remainingCount = filterAppointmentsByStatus(
clinicData.appointments,
'remaining'
Expand Down
149 changes: 139 additions & 10 deletions app/views/appointments/review-medical-information.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
{# Display format for medical information sections #}
{% set displayFormat = "expander" %}

{# Check if participant has active (non-removed) breast implants #}
{% set hasActiveImplants = false %}
{% set implantRecords = appointment.medicalInformation.medicalHistory.breastImplantsAugmentation %}
{% if implantRecords | length %}
{% for implant in implantRecords %}
{% if not implant.hasBeenRemoved %}
{% set hasActiveImplants = true %}
{% endif %}
{% endfor %}
{% endif %}

{% block pageContent %}

<h1 class="nhsuk-heading-l">
Expand All @@ -29,26 +40,144 @@ <h1 class="nhsuk-heading-l">
value: appointment.workflowStatus['review-breast-features-after-imaging']
}) }}

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
{% if hasActiveImplants and appointment.workflowStatus['review-medical-information'] != 'completed' %}
{{ insetText({
html: "<p>You do not have permission to authorise some views.</p>"
}) }}
<div class="nhsuk-button-group">
{{ button({
text: "Complete all and continue" if appointment.workflowStatus['review-medical-information'] != 'completed' else "Next section",
classes: "nhsuk-u-margin-bottom-0 nhsuk-button js-complete-all-sections"
text: "Choose an authoriser",
classes: "nhsuk-u-margin-bottom-0 js-irmer-authorise-button js-choose-authoriser-link",
attributes: { type: "button" }
}) }}
<a href="#" class="js-choose-authoriser-link js-alternative-authoriser-link" style="display:none">Choose alternative authoriser</a>
</div>
</div>
{% else %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
{{ button({
text: "Authorise and continue" if appointment.workflowStatus['review-medical-information'] != 'completed' else "Next section",
classes: "nhsuk-u-margin-bottom-0 nhsuk-button js-complete-all-sections"
}) }}
<p class="nhsuk-body-s nhsuk-u-secondary-text-color nhsuk-u-margin-top-2">This will authorise imaging by {{ data.currentUser.firstName }} {{ data.currentUser.lastName }}</p>
</div>
</div>
{% endif %}

<hr class="nhsuk-section-break nhsuk-section-break--m nhsuk-section-break--visible">

{% include "_includes/medical-information/index.njk" %}

<div class="nhsuk-form-group">
{{ button({
text: "Complete all and continue",
classes: "js-complete-all-sections"
}) }}
{% if hasActiveImplants and appointment.workflowStatus['review-medical-information'] != 'completed' %}
{{ insetText({
html: "<p>You do not have permission to authorise some views.</p>"
}) }}
<div class="nhsuk-button-group">
{{ button({
text: "Choose an authoriser",
classes: "nhsuk-u-margin-bottom-0 js-irmer-authorise-button js-choose-authoriser-link",
attributes: { type: "button" }
}) }}
<a href="#" class="js-choose-authoriser-link js-alternative-authoriser-link" style="display:none">Choose alternative authoriser</a>
</div>
{% else %}
{{ button({
text: "Authorise and continue",
classes: "js-complete-all-sections nhsuk-u-margin-bottom-0"
}) }}
<p class="nhsuk-body-s nhsuk-u-secondary-text-color nhsuk-u-margin-top-2 nhsuk-u-margin-bottom-5">This will authorise imaging by {{ data.currentUser.firstName }} {{ data.currentUser.lastName }}</p>
{% endif %}

{% include "screening-cannot-proceed-link.njk" %}
<div class="nhsuk-u-margin-top-6">
{% include "screening-cannot-proceed-link.njk" %}
</div>
</div>

{# Alternative authoriser modal #}
{% if hasActiveImplants %}
{% set authoriserModalContent %}
{{ radios({
name: "irmerAuthoriser",
fieldset: {
legend: {
text: "Select an authoriser"
}
},
items: [
{ value: "S. Patel", text: "S. Patel" },
{ value: "R. Thompson", text: "R. Thompson" },
{ value: "L. Okonkwo", text: "L. Okonkwo" },
{ value: "H. Chambers", text: "H. Chambers" },
{ value: "F. Kaur", text: "F. Kaur" }
]
}) }}
{% endset %}

{{ appModal({
id: "choose-authoriser-modal",
title: "Choose an authoriser",
showCloseButton: true,
content: authoriserModalContent,
actions: [
{
text: "Save",
action: "close",
classes: "js-select-authoriser"
},
{
text: "Cancel",
element: "link",
action: "close"
},
{
text: "Appointment cannot proceed",
element: "link",
href: "/clinics/" + clinicId + "/appointments/" + appointmentId + "/attended-not-screened-reason",
action: "close"
}
]
}) }}
{% endif %}

{% endblock %}

{% if hasActiveImplants %}
{% block pageScripts %}
<script>
// IRMER alternative authoriser selection
document.addEventListener("DOMContentLoaded", () => {
const modal = document.getElementById("choose-authoriser-modal")
if (!modal) return

// Open modal when authoriser button is clicked
document.querySelectorAll(".js-choose-authoriser-link").forEach((link) => {
link.addEventListener("click", (event) => {
event.preventDefault()
window.openModal("choose-authoriser-modal")
})
})

// Update buttons and enable form submission when an authoriser is selected
const selectButton = modal.querySelector(".js-select-authoriser")
if (selectButton) {
selectButton.addEventListener("click", () => {
const selected = modal.querySelector("input[name='irmerAuthoriser']:checked")
if (selected) {
document.querySelectorAll(".js-irmer-authorise-button").forEach((btn) => {
btn.textContent = "Authorise with " + selected.value + " and continue"
btn.removeAttribute("type")
btn.classList.add("js-complete-all-sections")
btn.classList.remove("js-choose-authoriser-link")
})
// Show the alternative authoriser links
document.querySelectorAll(".js-alternative-authoriser-link").forEach((link) => {
link.style.display = ""
})
}
})
}
})
</script>
{% endblock %}
{% endif %}
4 changes: 2 additions & 2 deletions tests/e2e/appointment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test.describe('Screening appointment', () => {
await expect(page.getByText('Lump').first()).toBeVisible()

await page
.getByRole('button', { name: 'Complete all and continue' })
.getByRole('button', { name: 'Authorise' })
.first()
.click()

Expand Down Expand Up @@ -162,7 +162,7 @@ test.describe('Screening appointment', () => {
page.getByRole('heading', { name: 'Review medical information' })
).toBeVisible()
await page
.getByRole('button', { name: 'Complete all and continue' })
.getByRole('button', { name: 'Authorise' })
.first()
.click()

Expand Down