Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
701f58c
Populate select menu with active sites
benjystanton Sep 24, 2026
63af382
Update deactivation warning message
Anna-Sutton Sep 24, 2026
27ee0e9
Changed order of links on so paper form comes first
Anna-Sutton Sep 24, 2026
214a46e
Don't show 'Deactivate site' link if it's the only site.
benjystanton Sep 24, 2026
1784a6e
Add site deactivated error page template
Anna-Sutton Sep 24, 2026
4ad4abe
Add error page for when there is a problem deactivating a site
Anna-Sutton Sep 24, 2026
6060d9e
only show the Active sites and/or Deactivated sites tabs if there is …
benjystanton Sep 24, 2026
90440c2
Merge branch 'update-vaccines-section' of https://github.com/NHSDigit…
benjystanton Sep 24, 2026
141bfdb
Error page for problem deactivating site when 2 users try at the same…
Anna-Sutton Sep 24, 2026
eb4f75b
Update General errors section of the index page, by adding 3 new erro…
Anna-Sutton Sep 24, 2026
69f211c
Fix typo in vaccine access message
Anna-Sutton Sep 24, 2026
d16a16d
Only show the Active and/or Deactivated tabs if there is at least 1 A…
benjystanton Sep 24, 2026
4933c2d
Add site deactivation as possible reason
benjystanton Sep 24, 2026
f77d988
Deactivate batches if parent site is deactivated
benjystanton Sep 24, 2026
eac857f
If no active batches are available and user clicks on vaccine product…
benjystanton Sep 24, 2026
bfed4e8
Filter site list to only show selected one (only possible when 5 or m…
benjystanton Sep 24, 2026
0f4bbd1
Delete app/views/errors/problem-deactivating-site.html
Anna-Sutton Sep 24, 2026
2ef822f
Removed one of the error msg for when deactivating a site doesn't work.
Anna-Sutton Sep 24, 2026
0e58419
Update link text for navigation on deactivated site page
Anna-Sutton Sep 24, 2026
6bd847e
Update error link for site deactivation issue
Anna-Sutton Sep 24, 2026
df8402a
Pointed link at /vaccines
benjystanton Sep 25, 2026
057f462
Add missing p tag and missing link destination
benjystanton Sep 25, 2026
7a32994
Pointed link at page so link works
benjystanton Sep 25, 2026
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
1 change: 1 addition & 0 deletions app/assets/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CheckboxFilter } from './checkbox-filter.js'
import { CheckboxSelectAll } from './checkbox-select-all.js'
import { CheckboxSelectedCount } from './checkbox-selected-count.js'
import { RadiosFilter } from './radios-filter.js'
import './vaccine-site-filter.js'

// Initiate NHS.UK frontend components on page load
document.addEventListener('DOMContentLoaded', () => {
Expand Down
16 changes: 16 additions & 0 deletions app/assets/javascript/vaccine-site-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Filter vaccine site sections from the site select menu

document.addEventListener('DOMContentLoaded', () => {
const select = document.getElementById('select-1')
const siteSections = document.querySelectorAll('[data-vaccine-site]')

if (!select || siteSections.length === 0) return

select.addEventListener('change', () => {
const selectedSite = select.value

siteSections.forEach((siteSection) => {
siteSection.hidden = selectedSite !== '' && siteSection.dataset.vaccineSite !== selectedSite
})
})
})
30 changes: 29 additions & 1 deletion app/routes/vaccines.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,24 @@ module.exports = (router) => {
// Mark site as closed
router.post('/vaccines/sites/:siteId/deactivated', (req, res) => {
const currentOrganisationSites = res.locals.currentOrganisation.sites || []
const data = req.session.data
const site = currentOrganisationSites.find((item) => item.id === req.params.siteId)
if (!site) { res.redirect('/vaccines'); return }

site.status = 'closed'

const today = new Date().toISOString().substring(0, 10)
data.vaccineStock
.filter((vaccine) => vaccine.organisationId === res.locals.currentOrganisation.id && vaccine.siteId === site.id)
.forEach((vaccine) => {
vaccine.batches.forEach((batch) => {
if (!batch.deactivatedDate && batch.expiryDate >= today) {
batch.deactivatedDate = today
batch.deactivationReason = 'site'
}
})
})

res.redirect(`/vaccines?siteTab=deactivated&deactivatedSite=true&siteName=${encodeURIComponent(site.name)}`)
})

Expand All @@ -246,11 +259,23 @@ module.exports = (router) => {
// Mark site as active
router.post('/vaccines/sites/:siteId/reactivated', (req, res) => {
const currentOrganisationSites = res.locals.currentOrganisation.sites || []
const data = req.session.data
const site = currentOrganisationSites.find((item) => item.id === req.params.siteId)
if (!site) { res.redirect('/vaccines'); return }

delete site.status

data.vaccineStock
.filter((vaccine) => vaccine.organisationId === res.locals.currentOrganisation.id && vaccine.siteId === site.id)
.forEach((vaccine) => {
vaccine.batches.forEach((batch) => {
if (batch.deactivationReason === 'site') {
batch.deactivatedDate = null
delete batch.deactivationReason
}
})
})

res.redirect(`/vaccines?siteTab=active&reactivatedSite=true&siteName=${encodeURIComponent(site.name)}`)
})

Expand Down Expand Up @@ -345,7 +370,9 @@ module.exports = (router) => {

const currentTab = requestedTab === 'inactive' && batchesByStatus.inactive.length === 0
? 'active'
: requestedTab
: requestedTab === 'active' && batchesByStatus.active.length === 0 && batchesByStatus.inactive.length > 0
? 'inactive'
: requestedTab

const filteredBatches = batchesByStatus[currentTab]
const totalBatches = filteredBatches.length
Expand Down Expand Up @@ -496,6 +523,7 @@ module.exports = (router) => {
let deactivatedDate = new Date()

batch.deactivatedDate = deactivatedDate.toISOString().substring(0,10)
batch.deactivationReason = 'manual'

res.redirect(`/vaccines/${vaccine.id}?tab=inactive&deactivated=true&batchNumber=${encodeURIComponent(batch.batchNumber)}`)
})
Expand Down
16 changes: 16 additions & 0 deletions app/views/errors/problem-deactivating-site-2-users-trying.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'layout.html' %}

{% set pageName = "There is a problem deactivating this site" %}
{% set currentSection = "vaccines" %}


{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">

<h1 class="nhsuk-heading-l">{{ pageName }}</h1>
<p>Go back to the <a href="/vaccines">Vaccines</a> section and check the site's status before trying again.</p>

</div>
</div>
{% endblock %}
25 changes: 25 additions & 0 deletions app/views/errors/site-deactivated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends 'layout.html' %}

{% set pageName = "There is a problem saving this vaccination" %}

{% block content %}

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">

<h1 class="nhsuk-heading-l">{{ pageName }}</h1>

<p>You cannot save this vaccination because [site name] has been deactivated.</p>

<p>An administrator can reactivate the site in the Vaccines setion. Once the site is reactivated, you will be able to record this vaccination but you will have to start again.</p>

<p>If no one is available to reactivate the site, record it on paper.</p>

<p><a href="https://guide.ravs.england.nhs.uk/service-unavailable/">Download our paper form (opens in new tab)</a></p>

<p><a href="/record-vaccinations/patient">Go back to Record vaccinations</a></p>

</div>
</div>

{% endblock %}
7 changes: 4 additions & 3 deletions app/views/errors/vaccine-disabled.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
{% set pageName = "There is a problem saving this vaccination" %}

{% block content %}

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">

<h1 class="nhsuk-heading-l">{{ pageName }}</h1>

<p>You cannot save this vaccination because a regional lead has removed your access to [vaccine name] vaccines.</p>

<p>If you have already vaccinated the patient, record it on paper and contact your regional lead.</p>

<p><a href="">Go back to the Check and confirm page</a> to see details of the vaccination.</p>
<p><a href="https://guide.ravs.england.nhs.uk/service-unavailable/">Download our paper form (opens in new tab)</a></p>


<p><a href="/vaccines/check">Go back to the Check and confirm page</a> to see details of the vaccination.</p>

</div>
</div>


{% endblock %}
22 changes: 19 additions & 3 deletions app/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,34 @@ <h2>Error pages</h2>
],
[
{
html: "<a href='/errors/rate-limit'>Rate limited (429 error)</a>"
html: "<a href='/errors/rate-limit'>Sorry, there is a problem with the service (rate limited, 429 error)</a>"
},
{
text: "When too many requests are made in a short time."
}
],
[
{
html: "<a href='/errors/vaccine-disabled'>Problem saving the vaccination (Regional admin has removed vaccines mid-recording)</a>"
html: "<a href='/errors/vaccine-disabled'>There is a problem saving this vaccination</a>"
},
{
text: "When a vaccination programme becomes unavailable during the recording flow."
text: "When a regional user has removed access to a vaccine type mid-recording."
}
],
[
{
html: "<a href='/errors/site-deactivated'>There is a problem saving this vaccination</a>"
},
{
text: "When a site is deactivated during the recording flow."
}
],
[
{
html: "<a href='/errors/problem-deactivating-site-2-users-trying'>There is a problem deactivating this site</a>"
},
{
text: "When there is a problem deactivating a site because 2 users are trying to do this at the same time or because of another issue such as API failure."
}
]
]
Expand Down
2 changes: 1 addition & 1 deletion app/views/vaccines/deactivate-site.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<h1 class="nhsuk-heading-l">{{ pageName }}</h1>

<p>Are you sure you want to deactivate this site?</p>
<p>Are you sure you want to deactivate this site? Once deactivated, the site will have no active batches and you will not be able to record any vaccinations there. You can reactivate it at anytime.</p>

<form action="/vaccines/sites/{{ site.id }}/deactivated" method="post" novalidate="true">
{{ button({
Expand Down
27 changes: 18 additions & 9 deletions app/views/vaccines/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ <h1 class="nhsuk-heading-l">Vaccines</h1>
<div class="nhsuk-u-margin-bottom-4">
{{ appSecondaryNavigation({
visuallyHiddenTitle: "Sites by status",
items: [{
items: [
{
text: "Active sites (" + activeSitesCount + ")",
href: "/vaccines?siteTab=active",
current: (currentSiteTab == "active")
}, {
} if activeSitesCount != "0"
,
{
text: "Deactivated sites (" + deactivatedSitesCount + ")",
href: "/vaccines?siteTab=deactivated",
current: (currentSiteTab == "deactivated")
}]
} if deactivatedSitesCount != "0"
]
}) }}
</div>

Expand All @@ -130,8 +134,9 @@ <h1 class="nhsuk-heading-l">Vaccines</h1>
selected: true
}] %}

{% for site in filteredSites %}
{% set filterItems = (filterItems.push({text: currentOrganisation.sites[site].name, value: site}), filterItems) %}
{% for siteId in filteredSites %}
{% set site = currentOrganisation.sites | findById(siteId) %}
{% set filterItems = (filterItems.push({text: site.name, value: siteId}), filterItems) %}
{% endfor %}


Expand All @@ -158,6 +163,7 @@ <h1 class="nhsuk-heading-l">Vaccines</h1>

{% set site = currentOrganisation.sites | findById(siteId) %}

<div data-vaccine-site="{{ siteId }}">
<table class="nhsuk-table nhsuk-u-margin-bottom-2">
<caption class="nhsuk-table__caption nhsuk-table__caption--m nhsuk-u-margin-bottom-2">{{ site.name }}</caption>
<thead role="rowgroup" class="nhsuk-table__head">
Expand Down Expand Up @@ -229,13 +235,16 @@ <h1 class="nhsuk-heading-l">Vaccines</h1>
</tbody>
</table>

{% if site.status != "closed" %}
{% if site.status != "closed" and (filteredSites | length) <= 1 %}
{# Don't show anything, because we don't want users to close the last site #}
{% elif site.status != "closed" %}
<div style="height: 8px;"></div>
<p class="nhsuk-body nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-7">No longer using this site? <a href="/vaccines/sites/{{ site.id }}/deactivate" class="nhsuk-link">Deactivate {{ site.name }}</a></p>
{% else %}
<div style="height: 8px;"></div>
<p class="nhsuk-body nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-7">Using this site again? <a href="/vaccines/sites/{{ site.id }}/reactivate" class="nhsuk-link">Reactivate {{ site.name }}</a></p>
{% else %}
<div style="height: 8px;"></div>
<p class="nhsuk-body nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-7">Using this site again? <a href="/vaccines/sites/{{ site.id }}/reactivate" class="nhsuk-link">Reactivate {{ site.name }}</a></p>
{% endif %}
</div>
{% endfor %}


Expand Down
18 changes: 12 additions & 6 deletions app/views/vaccines/product-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ <h2 class="nhsuk-heading-m nhsuk-u-margin-top-7 nhsuk-u-margin-bottom-4">Batches
{% set activeCount = activeBatchesCount | default(0) %}
{% set inactiveCount = inactiveBatchesCount | default(0) %}

{% set secondaryNavItems = [{
text: "Active (" + activeCount + ")",
href: "/vaccines/" + vaccine.id + "?tab=active",
current: (currentTab == "active")
}] %}
{% set secondaryNavItems = [] %}

{% if activeCount > 0 %}
{% set secondaryNavItems = (secondaryNavItems.push({
text: "Active (" + activeCount + ")",
href: "/vaccines/" + vaccine.id + "?tab=active",
current: (currentTab == "active")
}), secondaryNavItems) %}
{% endif %}

{% if inactiveCount > 0 %}
{% set secondaryNavItems = (secondaryNavItems.push({
Expand Down Expand Up @@ -212,7 +216,9 @@ <h2 class="nhsuk-heading-m nhsuk-u-margin-top-7 nhsuk-u-margin-bottom-4">Batches
{% endif %}
</td>
<td class="nhsuk-table__cell">
{% if batch.deactivatedDate %}
{% if batch.deactivationReason == "site" %}
Site deactivated
{% elif batch.deactivatedDate %}
Deactivated by user
{% elif (batch.expiryDate | daysAgo) > 0 %}
Expired
Expand Down
Loading