diff --git a/app/routes/record-vaccinations.js b/app/routes/record-vaccinations.js index 1e20ad7f..e793a5f0 100644 --- a/app/routes/record-vaccinations.js +++ b/app/routes/record-vaccinations.js @@ -87,6 +87,72 @@ module.exports = router => { res.redirect('/record-vaccinations/delivery-team') }) + router.get('/record-vaccinations/patient-history-deceased', (req, res) => { + const data = req.session.data + data.firstName = 'Jodie' + data.lastName = 'Brown' + data.dateOfBirth = { day: '15', month: '3', year: '1984' } + data.nhsNumber = '9123456789' + res.render('record-vaccinations/patient-history-deceased') + }) + + router.get('/record-vaccinations/vaccination-date-deceased', (req, res) => { + const data = req.session.data + const vaccinationDate = data.vaccinationDate || {} + const vaccinationDateAsDate = dateFromYearMonthDay(vaccinationDate.year, vaccinationDate.month, vaccinationDate.day) + let vaccinationDateError + const dateOfDeath = new Date(2024, 3, 20, 12) // 20 April 2024 + + if (req.query.showError === 'yes') { + if (!vaccinationDateAsDate) { + vaccinationDateError = 'Enter the vaccination date' + } else { + const today = new Date() + today.setHours(0, 0, 0, 0) + vaccinationDateAsDate.setHours(0, 0, 0, 0) + dateOfDeath.setHours(0, 0, 0, 0) + + if (vaccinationDateAsDate >= today) { + vaccinationDateError = 'Enter a date in the past' + } else if (vaccinationDateAsDate > dateOfDeath) { + vaccinationDateError = 'The date of vaccination must be the same as or before the date the patient died (20 April 2024)' + } + } + } + + res.render('record-vaccinations/vaccination-date-deceased', { + vaccinationDateError + }) + }) + + router.post('/record-vaccinations/answer-date-deceased', (req, res) => { + const data = req.session.data + const vaccinationDate = data.vaccinationDate || {} + const vaccinationDateAsDate = dateFromYearMonthDay(vaccinationDate.year, vaccinationDate.month, vaccinationDate.day) + const dateOfDeath = new Date(2024, 3, 20, 12) // 20 April 2024 + + if (!vaccinationDateAsDate) { + return res.redirect('/record-vaccinations/vaccination-date-deceased?showError=yes') + } + + const today = new Date() + today.setHours(0, 0, 0, 0) + vaccinationDateAsDate.setHours(0, 0, 0, 0) + dateOfDeath.setHours(0, 0, 0, 0) + + if (vaccinationDateAsDate >= today) { + return res.redirect('/record-vaccinations/vaccination-date-deceased?showError=yes') + } + + if (vaccinationDateAsDate > dateOfDeath) { + return res.redirect('/record-vaccinations/vaccination-date-deceased?showError=yes') + } + + data.vaccinationToday = 'no' + data.patientIsDeceased = true + res.redirect('/record-vaccinations/delivery-team') + }) + router.get('/record-vaccinations/delivery-team', (req, res) => { let errors = [] const data = req.session.data diff --git a/app/views/index.html b/app/views/index.html index fa25b97b..887fe367 100755 --- a/app/views/index.html +++ b/app/views/index.html @@ -105,6 +105,12 @@

Main interface

  • Profile page
  • +

    Special circumstances

    + + +

    Regions interface