From 69c76503b15d8e2b2f761e66c09c9d66401e902d Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 15:20:33 +0100 Subject: [PATCH 1/9] Move index.html to start.html --- app/prototype_v4_1/views/start.html | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 app/prototype_v4_1/views/start.html diff --git a/app/prototype_v4_1/views/start.html b/app/prototype_v4_1/views/start.html new file mode 100644 index 0000000..4a0b20c --- /dev/null +++ b/app/prototype_v4_1/views/start.html @@ -0,0 +1,56 @@ +{% extends "prototype_v4/views/layouts/main.html" %} + +{% set title = "Help us test a new online service" %} + +{% block content %} +
+
+ + {% include "prototype_v4/views/includes/page-heading.html" %} + +

We are testing a new online questionnaire for lung cancer screening. This service will ask you some questions about your medical history and lifestyle.

+ +

This online service cannot currently recommend if you need a lung scan. Once you have completed the online service you will need to call us to repeat the questionnaire by phone.

+ +

The answers you submit will not be shared with your patient care advisor during your phone appointment, or with your GP.

+ +

As a thank you for testing the online service, we will offer you a £10 voucher once you have completed both the online service and your phone appointment.

+ +

The benefits of lung cancer screening

+ +

Your risk of lung cancer increases as you get older. Screening aims to find lung cancer early, sometimes before you have symptoms. Early diagnosis can make lung cancer more treatable and make treatment more successful.

+ +

You are eligible for lung cancer screening if you are:

+ +
    +
  • aged between 55 and 74
  • +
  • registered with a GP surgery
  • +
  • someone who smokes or used to smoke
  • +
+ +

What to expect in the online service

+ +

We will ask you questions about:

+ +
    +
  • your height and weight
  • +
  • your ethnicity
  • +
  • your education
  • +
  • if you have ever had a cancer diagnosis
  • +
  • if your parents, siblings, or children have ever had a lung cancer diagnosis
  • +
  • your smoking habits
  • +
+ + {{ button({ + text: "Continue", + href: actions.start, + classes: "nhsuk-button--login" + }) }} + +

If you do not want to test the online service

+ +

You should call us on {{ serviceTelephone }} to complete the questionnaire by phone.

+ +
+
+{% endblock %} From 88caaf9d6b9205984f80f5ef8125209e3b329679 Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 15:20:53 +0100 Subject: [PATCH 2/9] Create a page index --- app/prototype_v4_1/routes.js | 119 +++++++++++++++++- app/prototype_v4_1/views/index.html | 181 +++++++++++++++++++++------- 2 files changed, 257 insertions(+), 43 deletions(-) diff --git a/app/prototype_v4_1/routes.js b/app/prototype_v4_1/routes.js index fc35e74..747325c 100644 --- a/app/prototype_v4_1/routes.js +++ b/app/prototype_v4_1/routes.js @@ -19,6 +19,96 @@ const hasView = (template) => { return templatePath.startsWith(viewsDirectory) && fs.existsSync(templatePath) } +const defaultAnswers = { + acceptTerms: ['yes'], + phoneQuestionnaire: 'no', + smoker: 'yes_current', + dateOfBirth: { + day: '15', + month: '3', + year: '1964' + }, + faceToFaceAppointment: 'no', + height: { + metric: '170' + }, + weight: { + metric: '70' + }, + gender: 'female', + sex: 'female', + ethnicity: 'white', + education: 'further_education', + respiratoryConditions: ['no'], + asbestosAtWork: 'no', + asbestosAtHome: 'no', + cancerDiagnosis: 'no', + cancerDiagnosisRelatives: 'yes', + cancerDiagnosisRelativesAge: 'no', + ageStartedSmoking: '18', + periodsStoppedSmoking: 'no', + smokingType: ['cigarettes'], + cigarettes: { + smokingStatus: 'yes', + smokingFrequency: 'daily', + smokingQuantity: '10', + smokingChange: ['greater'], + smokingChangeIncrease: { + frequency: 'weekly', + quantity: '5', + years: '10' + } + } +} + +const getDefaultAnswers = () => JSON.parse(JSON.stringify(defaultAnswers)) + +const getDefaultAnswerProfile = (profile) => { + const answers = getDefaultAnswers() + + if (profile === 'former') { + answers.smoker = 'yes_previous' + answers.ageStoppedSmoking = '55' + answers.cigarettes = { + smokingFrequency: 'daily', + smokingQuantity: '10', + smokingChange: ['greater'], + smokingChangeIncrease: { + frequency: 'weekly', + quantity: '5', + years: '10' + } + } + } + + if (profile === 'shisha') { + answers.smokingType = ['shisha'] + delete answers.cigarettes + answers.shisha = { + smokingStatus: 'yes', + smokingSetting: ['group'], + group: { + smokingFrequency: 'weekly', + smokingQuantity: '30_minutes_to_1_hour' + } + } + } + + return answers +} + +const getIndexRedirect = (returnUrl) => { + if (!returnUrl || typeof returnUrl !== 'string') { + return `/prototype_${version}/check-your-answers` + } + + if (!returnUrl.startsWith(`/prototype_${version}/`) || returnUrl.includes('//')) { + return `/prototype_${version}/page-index` + } + + return returnUrl +} + /// ------------------------------------------------------------------------ /// /// Controller modules - used for routing /// ------------------------------------------------------------------------ /// @@ -37,7 +127,7 @@ router.get(`/prototype_${version}`, (req, res) => { }) router.get(`/prototype_${version}/start-page`, (req, res) => { - res.render(view('index'), { + res.render(view('start'), { actions: { start: `/prototype_${version}/sign-in` } @@ -218,6 +308,33 @@ router.get(`/prototype_${version}/server-error`, errorController.unexpectedError router.get(`/prototype_${version}/503`, errorController.serviceUnavailable) router.get(`/prototype_${version}/service-unavailable`, errorController.serviceUnavailable) +/// ------------------------------------------------------------------------ /// +/// Page index +/// ------------------------------------------------------------------------ /// + +router.get(`/prototype_${version}/set-default-answers`, (req, res) => { + req.session.data = req.session.data || {} + req.session.data.answers = getDefaultAnswerProfile(req.query.profile) + + res.redirect(getIndexRedirect(req.query.returnUrl)) +}) + +router.get(`/prototype_${version}/page-index`, (req, res) => { + res.render(view('index'), { + actions: { + setDefaultAnswers: `/prototype_${version}/set-default-answers` + } + }) +}) + +router.get(`/prototype_${version}/index`, (req, res) => { + res.redirect(`/prototype_${version}/page-index`) +}) + +router.get(`/prototype_${version}/index-allpages`, (req, res) => { + res.redirect(`/prototype_${version}/page-index`) +}) + /// ------------------------------------------------------------------------ /// /// Add your routes above /// ------------------------------------------------------------------------ /// diff --git a/app/prototype_v4_1/views/index.html b/app/prototype_v4_1/views/index.html index 4a0b20c..09c10aa 100644 --- a/app/prototype_v4_1/views/index.html +++ b/app/prototype_v4_1/views/index.html @@ -1,56 +1,153 @@ {% extends "prototype_v4/views/layouts/main.html" %} -{% set title = "Help us test a new online service" %} - -{% block content %} -
-
- - {% include "prototype_v4/views/includes/page-heading.html" %} - -

We are testing a new online questionnaire for lung cancer screening. This service will ask you some questions about your medical history and lifestyle.

- -

This online service cannot currently recommend if you need a lung scan. Once you have completed the online service you will need to call us to repeat the questionnaire by phone.

- -

The answers you submit will not be shared with your patient care advisor during your phone appointment, or with your GP.

- -

As a thank you for testing the online service, we will offer you a £10 voucher once you have completed both the online service and your phone appointment.

- -

The benefits of lung cancer screening

- -

Your risk of lung cancer increases as you get older. Screening aims to find lung cancer early, sometimes before you have symptoms. Early diagnosis can make lung cancer more treatable and make treatment more successful.

+{% set title = "Page index" %} + +{% macro pageLink(href, text) %} +
+
+ {{ text }} +
+
+
+{% endmacro %} -

You are eligible for lung cancer screening if you are:

+{% macro seededPageLink(returnUrl, text) %} + {{ pageLink(actions.setDefaultAnswers + "?returnUrl=" + returnUrl, text) }} +{% endmacro %} -
    -
  • aged between 55 and 74
  • -
  • registered with a GP surgery
  • -
  • someone who smokes or used to smoke
  • -
+{% macro seededProfilePageLink(returnUrl, profile, text) %} + {{ pageLink(actions.setDefaultAnswers + "?returnUrl=" + returnUrl + "&profile=" + profile, text) }} +{% endmacro %} -

What to expect in the online service

+{% block beforeContent %} + {{ backLink({ + href: "javascript:history.back();", + text: "Go back" + }) }} +{% endblock %} -

We will ask you questions about:

+{% block content %} + -

You should call us on {{ serviceTelephone }} to complete the questionnaire by phone.

+
+
+

{{ title }}

+

Quick navigation to all pages in prototype v4.1.

+

Some links set default answers before opening the page, so conditional pages and check your answers have enough data to render.

+
+
+
+
+

Start and sign in

+
+ {{ pageLink("/prototype_v4_1/start-page", "Help us test a new online service") }} + {{ pageLink("/prototype_v4_1/sign-in", "Log in to your NHS account") }} + {{ pageLink("/prototype_v4_1/security-code", "Enter the security code") }} + {{ pageLink("/prototype_v4_1/sign-in-agreement", "Agree to share NHS login information") }} + {{ pageLink("/prototype_v4_1/sign-in-agreement-declined", "You cannot use this service") }} + {{ pageLink("/prototype_v4_1/accept-terms", "Terms of use") }} + {{ pageLink("/prototype_v4_1/phone-questionnaire", "Confirm if you have completed a lung cancer risk questionnaire by phone") }} + {{ pageLink("/prototype_v4_1/phone-questionnaire-exit", "You do not need to test the online service") }} +
+ +

Eligibility

+
+ {{ pageLink("/prototype_v4_1/smoker", "Tobacco smoking") }} + {{ pageLink("/prototype_v4_1/date-of-birth", "What is your date of birth?") }} + {{ pageLink("/prototype_v4_1/face-to-face-appointment", "Check if you need a face-to-face appointment") }} + {{ pageLink("/prototype_v4_1/not-eligible-for-screening", "You are not eligible for lung cancer screening") }} + {{ pageLink("/prototype_v4_1/not-eligible-for-scan", "You are not eligible for an NHS lung scan") }} + {{ pageLink("/prototype_v4_1/book-appointment", "Call us to book an appointment") }} +
+ +

About you

+
+ {{ pageLink("/prototype_v4_1/height-metric", "Your height - metric") }} + {{ pageLink("/prototype_v4_1/height-imperial", "Your height - imperial") }} + {{ pageLink("/prototype_v4_1/weight-metric", "Your weight - metric") }} + {{ pageLink("/prototype_v4_1/weight-imperial", "Your weight - imperial") }} + {{ pageLink("/prototype_v4_1/gender", "Your gender identity") }} + {{ pageLink("/prototype_v4_1/sex", "Your sex at birth") }} + {{ pageLink("/prototype_v4_1/ethnicity", "Your ethnic background") }} + {{ pageLink("/prototype_v4_1/education", "Your education") }} +
+ +

Your health

+
+ {{ pageLink("/prototype_v4_1/respiratory-conditions", "Respiratory conditions") }} + {{ pageLink("/prototype_v4_1/asbestos-at-work", "Asbestos at work") }} + {{ pageLink("/prototype_v4_1/asbestos-at-home", "Asbestos at home") }} + {{ pageLink("/prototype_v4_1/cancer-diagnosis", "Cancer diagnosis") }} +
+ +

Family history

+
+ {{ pageLink("/prototype_v4_1/cancer-diagnosis-relatives", "Relatives with lung cancer") }} + {{ seededPageLink("/prototype_v4_1/cancer-diagnosis-relatives-age", "Relatives under 60 when diagnosed") }} +
+ +

Smoking habits

+
+ {{ pageLink("/prototype_v4_1/age-started-smoking", "Age you started smoking") }} + {{ seededProfilePageLink("/prototype_v4_1/age-stopped-smoking", "former", "Former smoker - age you stopped smoking") }} + {{ pageLink("/prototype_v4_1/periods-stopped-smoking", "Periods when you stopped smoking") }} + {{ pageLink("/prototype_v4_1/smoking-type", "The type of tobacco you smoke or used to smoke") }} + {{ pageLink("/prototype_v4_1/smoking-type-exit", "You cannot test the online service") }} +
+ +

Tobacco questions

+
+ {{ seededPageLink("/prototype_v4_1/smoking-status?type=cigarettes", "Cigarettes - currently smoke") }} + {{ seededPageLink("/prototype_v4_1/smoking-frequency?type=cigarettes", "Cigarettes - frequency") }} + {{ seededPageLink("/prototype_v4_1/smoking-quantity?type=cigarettes", "Cigarettes - quantity") }} + {{ seededPageLink("/prototype_v4_1/smoking-change?type=cigarettes", "Cigarettes - has quantity changed") }} + {{ seededPageLink("/prototype_v4_1/smoking-frequency-change?type=cigarettes%26change=greater", "Cigarettes - more frequency") }} + {{ seededPageLink("/prototype_v4_1/smoking-quantity-change?type=cigarettes%26change=greater", "Cigarettes - more quantity") }} + {{ seededPageLink("/prototype_v4_1/smoking-years-change?type=cigarettes%26change=greater", "Cigarettes - more duration") }} + {{ seededProfilePageLink("/prototype_v4_1/smoking-setting?type=shisha", "shisha", "Shisha - smoking setting") }} + {{ seededProfilePageLink("/prototype_v4_1/smoking-frequency?type=shisha%26setting=group", "shisha", "Shisha in a group - frequency") }} + {{ seededProfilePageLink("/prototype_v4_1/smoking-quantity?type=shisha%26setting=group", "shisha", "Shisha in a group - quantity") }} +
+ +

Check and confirmation

+
+ {{ seededPageLink("/prototype_v4_1/check-your-answers", "Check your answers - with default answers") }} + {{ pageLink("/prototype_v4_1/confirmation", "Confirmation") }} +
+ +

Static pages

+
+ {{ pageLink("/prototype_v4_1/accessibility-statement", "Accessibility statement") }} + {{ pageLink("/prototype_v4_1/contact-us", "Contact us") }} + {{ pageLink("/prototype_v4_1/cookies", "Cookies") }} + {{ pageLink("/prototype_v4_1/privacy-policy", "Privacy policy") }} + {{ pageLink("/prototype_v4_1/terms-of-use", "Terms of use") }} +
+ +

Error pages

+
+ {{ pageLink("/prototype_v4_1/404", "Page not found") }} + {{ pageLink("/prototype_v4_1/500", "Unexpected error") }} + {{ pageLink("/prototype_v4_1/503", "Service unavailable") }} +
{% endblock %} From 42d0681483a0717fa1ba7b2e42e4192fc6afa154 Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 15:29:11 +0100 Subject: [PATCH 3/9] Update page index --- app/prototype_v4_1/views/index.html | 207 ++++++++++++---------------- 1 file changed, 90 insertions(+), 117 deletions(-) diff --git a/app/prototype_v4_1/views/index.html b/app/prototype_v4_1/views/index.html index 09c10aa..62272fe 100644 --- a/app/prototype_v4_1/views/index.html +++ b/app/prototype_v4_1/views/index.html @@ -1,153 +1,126 @@ {% extends "prototype_v4/views/layouts/main.html" %} {% set title = "Page index" %} +{% set prototypePath = "/prototype_v4_1" %} {% macro pageLink(href, text) %} -
-
- {{ text }} -
-
-
+
  • + {{ text }} +
  • {% endmacro %} {% macro seededPageLink(returnUrl, text) %} - {{ pageLink(actions.setDefaultAnswers + "?returnUrl=" + returnUrl, text) }} +
  • + {{ text }} +
  • {% endmacro %} {% macro seededProfilePageLink(returnUrl, profile, text) %} - {{ pageLink(actions.setDefaultAnswers + "?returnUrl=" + returnUrl + "&profile=" + profile, text) }} +
  • + {{ text }} +
  • {% endmacro %} -{% block beforeContent %} - {{ backLink({ - href: "javascript:history.back();", - text: "Go back" - }) }} -{% endblock %} - {% block content %} - -

    {{ title }}

    Quick navigation to all pages in prototype v4.1.

    Some links set default answers before opening the page, so conditional pages and check your answers have enough data to render.

    -
    -
    -
    -

    Start and sign in

    -
    - {{ pageLink("/prototype_v4_1/start-page", "Help us test a new online service") }} - {{ pageLink("/prototype_v4_1/sign-in", "Log in to your NHS account") }} - {{ pageLink("/prototype_v4_1/security-code", "Enter the security code") }} - {{ pageLink("/prototype_v4_1/sign-in-agreement", "Agree to share NHS login information") }} - {{ pageLink("/prototype_v4_1/sign-in-agreement-declined", "You cannot use this service") }} - {{ pageLink("/prototype_v4_1/accept-terms", "Terms of use") }} - {{ pageLink("/prototype_v4_1/phone-questionnaire", "Confirm if you have completed a lung cancer risk questionnaire by phone") }} - {{ pageLink("/prototype_v4_1/phone-questionnaire-exit", "You do not need to test the online service") }} -
    +
      + {{ pageLink("/start-page", "Help us test a new online service") }} + {{ pageLink("/sign-in", "Log in to your NHS account") }} + {{ pageLink("/security-code", "Enter the security code") }} + {{ pageLink("/sign-in-agreement", "Agree to share NHS login information") }} + {{ pageLink("/sign-in-agreement-declined", "You cannot use this service") }} + {{ pageLink("/accept-terms", "Terms of use") }} + {{ pageLink("/phone-questionnaire", "Confirm if you have completed a lung cancer risk questionnaire by phone") }} + {{ pageLink("/phone-questionnaire-exit", "You do not need to test the online service") }} +

    Eligibility

    -
    - {{ pageLink("/prototype_v4_1/smoker", "Tobacco smoking") }} - {{ pageLink("/prototype_v4_1/date-of-birth", "What is your date of birth?") }} - {{ pageLink("/prototype_v4_1/face-to-face-appointment", "Check if you need a face-to-face appointment") }} - {{ pageLink("/prototype_v4_1/not-eligible-for-screening", "You are not eligible for lung cancer screening") }} - {{ pageLink("/prototype_v4_1/not-eligible-for-scan", "You are not eligible for an NHS lung scan") }} - {{ pageLink("/prototype_v4_1/book-appointment", "Call us to book an appointment") }} -
    +
      + {{ pageLink("/smoker", "Tobacco smoking") }} + {{ pageLink("/date-of-birth", "What is your date of birth?") }} + {{ pageLink("/face-to-face-appointment", "Check if you need a face-to-face appointment") }} + {{ pageLink("/not-eligible-for-screening", "You are not eligible for lung cancer screening") }} + {{ pageLink("/not-eligible-for-scan", "You are not eligible for an NHS lung scan") }} + {{ pageLink("/book-appointment", "Call us to book an appointment") }} +

    About you

    -
    - {{ pageLink("/prototype_v4_1/height-metric", "Your height - metric") }} - {{ pageLink("/prototype_v4_1/height-imperial", "Your height - imperial") }} - {{ pageLink("/prototype_v4_1/weight-metric", "Your weight - metric") }} - {{ pageLink("/prototype_v4_1/weight-imperial", "Your weight - imperial") }} - {{ pageLink("/prototype_v4_1/gender", "Your gender identity") }} - {{ pageLink("/prototype_v4_1/sex", "Your sex at birth") }} - {{ pageLink("/prototype_v4_1/ethnicity", "Your ethnic background") }} - {{ pageLink("/prototype_v4_1/education", "Your education") }} -
    +
      + {{ pageLink("/height-metric", "Your height - metric") }} + {{ pageLink("/height-imperial", "Your height - imperial") }} + {{ pageLink("/weight-metric", "Your weight - metric") }} + {{ pageLink("/weight-imperial", "Your weight - imperial") }} + {{ pageLink("/gender", "Your gender identity") }} + {{ pageLink("/sex", "Your sex at birth") }} + {{ pageLink("/ethnicity", "Your ethnic background") }} + {{ pageLink("/education", "Your education") }} +

    Your health

    -
    - {{ pageLink("/prototype_v4_1/respiratory-conditions", "Respiratory conditions") }} - {{ pageLink("/prototype_v4_1/asbestos-at-work", "Asbestos at work") }} - {{ pageLink("/prototype_v4_1/asbestos-at-home", "Asbestos at home") }} - {{ pageLink("/prototype_v4_1/cancer-diagnosis", "Cancer diagnosis") }} -
    - -

    Family history

    -
    - {{ pageLink("/prototype_v4_1/cancer-diagnosis-relatives", "Relatives with lung cancer") }} - {{ seededPageLink("/prototype_v4_1/cancer-diagnosis-relatives-age", "Relatives under 60 when diagnosed") }} -
    - -

    Smoking habits

    -
    - {{ pageLink("/prototype_v4_1/age-started-smoking", "Age you started smoking") }} - {{ seededProfilePageLink("/prototype_v4_1/age-stopped-smoking", "former", "Former smoker - age you stopped smoking") }} - {{ pageLink("/prototype_v4_1/periods-stopped-smoking", "Periods when you stopped smoking") }} - {{ pageLink("/prototype_v4_1/smoking-type", "The type of tobacco you smoke or used to smoke") }} - {{ pageLink("/prototype_v4_1/smoking-type-exit", "You cannot test the online service") }} -
    - -

    Tobacco questions

    -
    - {{ seededPageLink("/prototype_v4_1/smoking-status?type=cigarettes", "Cigarettes - currently smoke") }} - {{ seededPageLink("/prototype_v4_1/smoking-frequency?type=cigarettes", "Cigarettes - frequency") }} - {{ seededPageLink("/prototype_v4_1/smoking-quantity?type=cigarettes", "Cigarettes - quantity") }} - {{ seededPageLink("/prototype_v4_1/smoking-change?type=cigarettes", "Cigarettes - has quantity changed") }} - {{ seededPageLink("/prototype_v4_1/smoking-frequency-change?type=cigarettes%26change=greater", "Cigarettes - more frequency") }} - {{ seededPageLink("/prototype_v4_1/smoking-quantity-change?type=cigarettes%26change=greater", "Cigarettes - more quantity") }} - {{ seededPageLink("/prototype_v4_1/smoking-years-change?type=cigarettes%26change=greater", "Cigarettes - more duration") }} - {{ seededProfilePageLink("/prototype_v4_1/smoking-setting?type=shisha", "shisha", "Shisha - smoking setting") }} - {{ seededProfilePageLink("/prototype_v4_1/smoking-frequency?type=shisha%26setting=group", "shisha", "Shisha in a group - frequency") }} - {{ seededProfilePageLink("/prototype_v4_1/smoking-quantity?type=shisha%26setting=group", "shisha", "Shisha in a group - quantity") }} -
    +
      + {{ pageLink("/respiratory-conditions", "Respiratory conditions") }} + {{ pageLink("/asbestos-at-work", "Asbestos at work") }} + {{ pageLink("/asbestos-at-home", "Asbestos at home") }} + {{ pageLink("/cancer-diagnosis", "Cancer diagnosis") }} +
    + +

    Your family history

    +
      + {{ pageLink("/cancer-diagnosis-relatives", "Relatives with lung cancer") }} + {{ seededPageLink("/cancer-diagnosis-relatives-age", "Relatives under 60 when diagnosed") }} +
    + +

    Your smoking habits

    +
      + {{ pageLink("/age-started-smoking", "Age you started smoking") }} + {{ seededProfilePageLink("/age-stopped-smoking", "former", "Former smoker - age you stopped smoking") }} + {{ pageLink("/periods-stopped-smoking", "Periods when you stopped smoking") }} + {{ pageLink("/smoking-type", "The type of tobacco you smoke or used to smoke") }} + {{ pageLink("/smoking-type-exit", "You cannot test the online service") }} +
    + +

    Tobacco smoking

    +
      + {{ seededPageLink("/smoking-status?type=cigarettes", "Cigarettes - currently smoke") }} + {{ seededPageLink("/smoking-frequency?type=cigarettes", "Cigarettes - frequency") }} + {{ seededPageLink("/smoking-quantity?type=cigarettes", "Cigarettes - quantity") }} + {{ seededPageLink("/smoking-change?type=cigarettes", "Cigarettes - has quantity changed") }} + {{ seededPageLink("/smoking-frequency-change?type=cigarettes%26change=greater", "Cigarettes - more frequency") }} + {{ seededPageLink("/smoking-quantity-change?type=cigarettes%26change=greater", "Cigarettes - more quantity") }} + {{ seededPageLink("/smoking-years-change?type=cigarettes%26change=greater", "Cigarettes - more duration") }} + {{ seededProfilePageLink("/smoking-setting?type=shisha", "shisha", "Shisha - smoking setting") }} + {{ seededProfilePageLink("/smoking-frequency?type=shisha%26setting=group", "shisha", "Shisha in a group - frequency") }} + {{ seededProfilePageLink("/smoking-quantity?type=shisha%26setting=group", "shisha", "Shisha in a group - quantity") }} +

    Check and confirmation

    -
    - {{ seededPageLink("/prototype_v4_1/check-your-answers", "Check your answers - with default answers") }} - {{ pageLink("/prototype_v4_1/confirmation", "Confirmation") }} -
    +
      + {{ seededPageLink("/check-your-answers", "Check your answers - with default answers") }} + {{ pageLink("/confirmation", "Confirmation") }} + {{ pageLink("/confirmation?risk=high", "Confirmation - High risk") }} +

    Static pages

    -
    - {{ pageLink("/prototype_v4_1/accessibility-statement", "Accessibility statement") }} - {{ pageLink("/prototype_v4_1/contact-us", "Contact us") }} - {{ pageLink("/prototype_v4_1/cookies", "Cookies") }} - {{ pageLink("/prototype_v4_1/privacy-policy", "Privacy policy") }} - {{ pageLink("/prototype_v4_1/terms-of-use", "Terms of use") }} -
    +
      + {{ pageLink("/accessibility-statement", "Accessibility statement") }} + {{ pageLink("/contact-us", "Contact us") }} + {{ pageLink("/cookies", "Cookies") }} + {{ pageLink("/privacy-policy", "Privacy policy") }} + {{ pageLink("/terms-of-use", "Terms of use") }} +

    Error pages

    -
    - {{ pageLink("/prototype_v4_1/404", "Page not found") }} - {{ pageLink("/prototype_v4_1/500", "Unexpected error") }} - {{ pageLink("/prototype_v4_1/503", "Service unavailable") }} -
    +
      + {{ pageLink("/404", "Page not found") }} + {{ pageLink("/500", "Unexpected error") }} + {{ pageLink("/503", "Service unavailable") }} +
    {% endblock %} From 721a8d2b55296fff4eb4f36e69a84dae97ac8eed Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 15:31:41 +0100 Subject: [PATCH 4/9] Move default answers and helpers into a lib file --- app/prototype_v4_1/lib/page-index.js | 94 ++++++++++++++++++++++++ app/prototype_v4_1/routes.js | 102 ++------------------------- 2 files changed, 101 insertions(+), 95 deletions(-) create mode 100644 app/prototype_v4_1/lib/page-index.js diff --git a/app/prototype_v4_1/lib/page-index.js b/app/prototype_v4_1/lib/page-index.js new file mode 100644 index 0000000..c37a28c --- /dev/null +++ b/app/prototype_v4_1/lib/page-index.js @@ -0,0 +1,94 @@ +const defaultAnswers = { + acceptTerms: ['yes'], + phoneQuestionnaire: 'no', + smoker: 'yes_current', + dateOfBirth: { + day: '15', + month: '3', + year: '1964' + }, + faceToFaceAppointment: 'no', + height: { + metric: '170' + }, + weight: { + metric: '70' + }, + gender: 'female', + sex: 'female', + ethnicity: 'white', + education: 'further_education', + respiratoryConditions: ['no'], + asbestosAtWork: 'no', + asbestosAtHome: 'no', + cancerDiagnosis: 'no', + cancerDiagnosisRelatives: 'yes', + cancerDiagnosisRelativesAge: 'no', + ageStartedSmoking: '18', + periodsStoppedSmoking: 'no', + smokingType: ['cigarettes'], + cigarettes: { + smokingStatus: 'yes', + smokingFrequency: 'daily', + smokingQuantity: '10', + smokingChange: ['greater'], + smokingChangeIncrease: { + frequency: 'weekly', + quantity: '5', + years: '10' + } + } +} + +const cloneAnswers = () => JSON.parse(JSON.stringify(defaultAnswers)) + +const getDefaultAnswerProfile = (profile) => { + const answers = cloneAnswers() + + if (profile === 'former') { + answers.smoker = 'yes_previous' + answers.ageStoppedSmoking = '55' + answers.cigarettes = { + smokingFrequency: 'daily', + smokingQuantity: '10', + smokingChange: ['greater'], + smokingChangeIncrease: { + frequency: 'weekly', + quantity: '5', + years: '10' + } + } + } + + if (profile === 'shisha') { + answers.smokingType = ['shisha'] + delete answers.cigarettes + answers.shisha = { + smokingStatus: 'yes', + smokingSetting: ['group'], + group: { + smokingFrequency: 'weekly', + smokingQuantity: '30_minutes_to_1_hour' + } + } + } + + return answers +} + +const getIndexRedirect = (returnUrl, prototypePath) => { + if (!returnUrl || typeof returnUrl !== 'string') { + return `${prototypePath}/check-your-answers` + } + + if (!returnUrl.startsWith(`${prototypePath}/`) || returnUrl.includes('//')) { + return `${prototypePath}/page-index` + } + + return returnUrl +} + +module.exports = { + getDefaultAnswerProfile, + getIndexRedirect +} diff --git a/app/prototype_v4_1/routes.js b/app/prototype_v4_1/routes.js index 747325c..7c2ac6b 100644 --- a/app/prototype_v4_1/routes.js +++ b/app/prototype_v4_1/routes.js @@ -4,6 +4,7 @@ const path = require('path') const router = express.Router() const version = 'v4_1' +const prototypePath = `/prototype_${version}` const viewsDirectory = path.join(__dirname, 'views') const view = (template) => { @@ -19,96 +20,6 @@ const hasView = (template) => { return templatePath.startsWith(viewsDirectory) && fs.existsSync(templatePath) } -const defaultAnswers = { - acceptTerms: ['yes'], - phoneQuestionnaire: 'no', - smoker: 'yes_current', - dateOfBirth: { - day: '15', - month: '3', - year: '1964' - }, - faceToFaceAppointment: 'no', - height: { - metric: '170' - }, - weight: { - metric: '70' - }, - gender: 'female', - sex: 'female', - ethnicity: 'white', - education: 'further_education', - respiratoryConditions: ['no'], - asbestosAtWork: 'no', - asbestosAtHome: 'no', - cancerDiagnosis: 'no', - cancerDiagnosisRelatives: 'yes', - cancerDiagnosisRelativesAge: 'no', - ageStartedSmoking: '18', - periodsStoppedSmoking: 'no', - smokingType: ['cigarettes'], - cigarettes: { - smokingStatus: 'yes', - smokingFrequency: 'daily', - smokingQuantity: '10', - smokingChange: ['greater'], - smokingChangeIncrease: { - frequency: 'weekly', - quantity: '5', - years: '10' - } - } -} - -const getDefaultAnswers = () => JSON.parse(JSON.stringify(defaultAnswers)) - -const getDefaultAnswerProfile = (profile) => { - const answers = getDefaultAnswers() - - if (profile === 'former') { - answers.smoker = 'yes_previous' - answers.ageStoppedSmoking = '55' - answers.cigarettes = { - smokingFrequency: 'daily', - smokingQuantity: '10', - smokingChange: ['greater'], - smokingChangeIncrease: { - frequency: 'weekly', - quantity: '5', - years: '10' - } - } - } - - if (profile === 'shisha') { - answers.smokingType = ['shisha'] - delete answers.cigarettes - answers.shisha = { - smokingStatus: 'yes', - smokingSetting: ['group'], - group: { - smokingFrequency: 'weekly', - smokingQuantity: '30_minutes_to_1_hour' - } - } - } - - return answers -} - -const getIndexRedirect = (returnUrl) => { - if (!returnUrl || typeof returnUrl !== 'string') { - return `/prototype_${version}/check-your-answers` - } - - if (!returnUrl.startsWith(`/prototype_${version}/`) || returnUrl.includes('//')) { - return `/prototype_${version}/page-index` - } - - return returnUrl -} - /// ------------------------------------------------------------------------ /// /// Controller modules - used for routing /// ------------------------------------------------------------------------ /// @@ -116,20 +27,21 @@ const getIndexRedirect = (returnUrl) => { const authenticationController = require('./controllers/authentication') const contentController = require('./controllers/content') const errorController = require('./controllers/error') +const { getDefaultAnswerProfile, getIndexRedirect } = require('./lib/page-index') const questionController = require('./controllers/question') /// ------------------------------------------------------------------------ /// /// Start page /// ------------------------------------------------------------------------ /// -router.get(`/prototype_${version}`, (req, res) => { - res.redirect(`/prototype_${version}/start-page`) +router.get(prototypePath, (req, res) => { + res.redirect(`${prototypePath}/start-page`) }) -router.get(`/prototype_${version}/start-page`, (req, res) => { +router.get(`${prototypePath}/start-page`, (req, res) => { res.render(view('start'), { actions: { - start: `/prototype_${version}/sign-in` + start: `${prototypePath}/sign-in` } }) }) @@ -316,7 +228,7 @@ router.get(`/prototype_${version}/set-default-answers`, (req, res) => { req.session.data = req.session.data || {} req.session.data.answers = getDefaultAnswerProfile(req.query.profile) - res.redirect(getIndexRedirect(req.query.returnUrl)) + res.redirect(getIndexRedirect(req.query.returnUrl, prototypePath)) }) router.get(`/prototype_${version}/page-index`, (req, res) => { From 9ee667c5ac0ae592539e20366c28043ed0083c6d Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 15:37:41 +0100 Subject: [PATCH 5/9] Update layout template reference --- .../views/authentication/security-code.html | 2 +- .../sign-in-agreement-declined.html | 2 +- .../authentication/sign-in-agreement.html | 2 +- .../views/authentication/sign-in.html | 2 +- .../views/check-your-answers.html | 2 +- app/prototype_v4_1/views/confirmation.html | 2 +- app/prototype_v4_1/views/content/show.html | 2 +- app/prototype_v4_1/views/errors/404.html | 2 +- app/prototype_v4_1/views/errors/500.html | 2 +- app/prototype_v4_1/views/errors/503.html | 2 +- app/prototype_v4_1/views/index.html | 2 +- app/prototype_v4_1/views/layouts/main.html | 26 +++++++++---------- .../views/questions/book-appointment.html | 2 +- .../questions/not-eligible-for-scan.html | 2 +- .../questions/not-eligible-for-screening.html | 2 +- .../questions/phone-questionnaire-exit.html | 2 +- .../views/questions/smoking-type-exit.html | 2 +- app/prototype_v4_1/views/start.html | 2 +- 18 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/prototype_v4_1/views/authentication/security-code.html b/app/prototype_v4_1/views/authentication/security-code.html index 5f77bc5..2c35934 100644 --- a/app/prototype_v4_1/views/authentication/security-code.html +++ b/app/prototype_v4_1/views/authentication/security-code.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Enter the security code" %} diff --git a/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html b/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html index aacf829..6982391 100644 --- a/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html +++ b/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Sorry, you cannot test the online service" %} diff --git a/app/prototype_v4_1/views/authentication/sign-in-agreement.html b/app/prototype_v4_1/views/authentication/sign-in-agreement.html index 5612273..be641b7 100644 --- a/app/prototype_v4_1/views/authentication/sign-in-agreement.html +++ b/app/prototype_v4_1/views/authentication/sign-in-agreement.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Agree to share your NHS login information" %} diff --git a/app/prototype_v4_1/views/authentication/sign-in.html b/app/prototype_v4_1/views/authentication/sign-in.html index e00b7b3..816714f 100644 --- a/app/prototype_v4_1/views/authentication/sign-in.html +++ b/app/prototype_v4_1/views/authentication/sign-in.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Log in to your NHS account" %} diff --git a/app/prototype_v4_1/views/check-your-answers.html b/app/prototype_v4_1/views/check-your-answers.html index a3ae17c..43f7200 100644 --- a/app/prototype_v4_1/views/check-your-answers.html +++ b/app/prototype_v4_1/views/check-your-answers.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Check your answers" %} diff --git a/app/prototype_v4_1/views/confirmation.html b/app/prototype_v4_1/views/confirmation.html index baf8385..e41dada 100644 --- a/app/prototype_v4_1/views/confirmation.html +++ b/app/prototype_v4_1/views/confirmation.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Thank you for testing the online service" %} diff --git a/app/prototype_v4_1/views/content/show.html b/app/prototype_v4_1/views/content/show.html index 1ad529b..99d4018 100644 --- a/app/prototype_v4_1/views/content/show.html +++ b/app/prototype_v4_1/views/content/show.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = contentData.title %} diff --git a/app/prototype_v4_1/views/errors/404.html b/app/prototype_v4_1/views/errors/404.html index e4e20d8..c500078 100644 --- a/app/prototype_v4_1/views/errors/404.html +++ b/app/prototype_v4_1/views/errors/404.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Page not found" %} diff --git a/app/prototype_v4_1/views/errors/500.html b/app/prototype_v4_1/views/errors/500.html index 1ea9afe..229bf3c 100644 --- a/app/prototype_v4_1/views/errors/500.html +++ b/app/prototype_v4_1/views/errors/500.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set hidePhaseBanner = true %} {% set hideFooterLinks = true %} diff --git a/app/prototype_v4_1/views/errors/503.html b/app/prototype_v4_1/views/errors/503.html index b7c78da..7707742 100644 --- a/app/prototype_v4_1/views/errors/503.html +++ b/app/prototype_v4_1/views/errors/503.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set hidePhaseBanner = true %} {% set hideFooterLinks = true %} diff --git a/app/prototype_v4_1/views/index.html b/app/prototype_v4_1/views/index.html index 62272fe..1bb0b7a 100644 --- a/app/prototype_v4_1/views/index.html +++ b/app/prototype_v4_1/views/index.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Page index" %} {% set prototypePath = "/prototype_v4_1" %} diff --git a/app/prototype_v4_1/views/layouts/main.html b/app/prototype_v4_1/views/layouts/main.html index 8e4853a..1a69c70 100755 --- a/app/prototype_v4_1/views/layouts/main.html +++ b/app/prototype_v4_1/views/layouts/main.html @@ -37,7 +37,7 @@ }, { text: "Log out", - href: "/prototype_v4/" + href: "/prototype_v4_1/" } ] } if data['logged-in'] @@ -68,45 +68,45 @@ meta: { items: [ { - href: "/prototype_v4/accessibility-statement", + href: "/prototype_v4_1/accessibility-statement", text: "Accessibility statement" }, { - href: "/prototype_v4/contact-us", + href: "/prototype_v4_1/contact-us", text: "Contact us" }, { - href: "/prototype_v4/cookies", + href: "/prototype_v4_1/cookies", text: "Cookies" }, { - href: "/prototype_v4/privacy-policy", + href: "/prototype_v4_1/privacy-policy", text: "Privacy policy" }, { - href: "/prototype_v4/terms-of-use", + href: "/prototype_v4_1/terms-of-use", text: "Terms of use" } ] } }) if not hideFooterLinks }} -{# {% endblock %} {% block bodyEnd %} diff --git a/app/prototype_v4_1/views/questions/book-appointment.html b/app/prototype_v4_1/views/questions/book-appointment.html index ddbaedf..1307b39 100644 --- a/app/prototype_v4_1/views/questions/book-appointment.html +++ b/app/prototype_v4_1/views/questions/book-appointment.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Call us to book an appointment" %} diff --git a/app/prototype_v4_1/views/questions/not-eligible-for-scan.html b/app/prototype_v4_1/views/questions/not-eligible-for-scan.html index b4b24b1..30bc3f1 100644 --- a/app/prototype_v4_1/views/questions/not-eligible-for-scan.html +++ b/app/prototype_v4_1/views/questions/not-eligible-for-scan.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "You are not eligible for an NHS lung scan" %} diff --git a/app/prototype_v4_1/views/questions/not-eligible-for-screening.html b/app/prototype_v4_1/views/questions/not-eligible-for-screening.html index 35b4a85..5eded05 100644 --- a/app/prototype_v4_1/views/questions/not-eligible-for-screening.html +++ b/app/prototype_v4_1/views/questions/not-eligible-for-screening.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "You are not eligible for lung cancer screening" %} diff --git a/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html b/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html index 05bcc09..c6001fc 100644 --- a/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html +++ b/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "You do not need to test the online service" %} diff --git a/app/prototype_v4_1/views/questions/smoking-type-exit.html b/app/prototype_v4_1/views/questions/smoking-type-exit.html index 9630dbf..e03b599 100644 --- a/app/prototype_v4_1/views/questions/smoking-type-exit.html +++ b/app/prototype_v4_1/views/questions/smoking-type-exit.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "You are not eligible for lung cancer screening" %} diff --git a/app/prototype_v4_1/views/start.html b/app/prototype_v4_1/views/start.html index 4a0b20c..5f9c396 100644 --- a/app/prototype_v4_1/views/start.html +++ b/app/prototype_v4_1/views/start.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4/views/layouts/main.html" %} +{% extends "prototype_v4_1/views/layouts/main.html" %} {% set title = "Help us test a new online service" %} From ab943a64fb2dc587234a0516ca9d8cfdea83001e Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 16:03:54 +0100 Subject: [PATCH 6/9] Update page index --- app/prototype_v4_1/views/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/prototype_v4_1/views/index.html b/app/prototype_v4_1/views/index.html index 1bb0b7a..4d5a08f 100644 --- a/app/prototype_v4_1/views/index.html +++ b/app/prototype_v4_1/views/index.html @@ -82,10 +82,10 @@

    Your smoking habits

    {{ seededProfilePageLink("/age-stopped-smoking", "former", "Former smoker - age you stopped smoking") }} {{ pageLink("/periods-stopped-smoking", "Periods when you stopped smoking") }} {{ pageLink("/smoking-type", "The type of tobacco you smoke or used to smoke") }} - {{ pageLink("/smoking-type-exit", "You cannot test the online service") }} + {{ pageLink("/smoking-type-exit", "You are not eligible for lung cancer screening") }} -

    Tobacco smoking

    +

    Tobacco smoking

      {{ seededPageLink("/smoking-status?type=cigarettes", "Cigarettes - currently smoke") }} {{ seededPageLink("/smoking-frequency?type=cigarettes", "Cigarettes - frequency") }} From 26fb9411b718fe8772f5ec9280858fe0e4c9d145 Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 16:17:41 +0100 Subject: [PATCH 7/9] Create a prototype settings file --- app/prototype_v4_1/lib/settings.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/prototype_v4_1/lib/settings.js diff --git a/app/prototype_v4_1/lib/settings.js b/app/prototype_v4_1/lib/settings.js new file mode 100644 index 0000000..6648aa7 --- /dev/null +++ b/app/prototype_v4_1/lib/settings.js @@ -0,0 +1,24 @@ +const version = 'v4_1' +const name = `prototype_${version}` +const path = `/${name}` +const viewPath = `${name}/views` + +const view = (template) => { + return `${viewPath}/${template}` +} + +const locals = { + version, + name, + path, + viewPath +} + +module.exports = { + locals, + name, + path, + version, + view, + viewPath +} From 95b7d94e4230dc38361cb5c539656b4bc3bbe079 Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 16:18:13 +0100 Subject: [PATCH 8/9] Use prototype settings --- .../controllers/authentication.js | 41 +++++++++---------- app/prototype_v4_1/controllers/content.js | 5 +-- app/prototype_v4_1/controllers/error.js | 8 ++-- app/prototype_v4_1/data/questions.yaml | 2 +- app/prototype_v4_1/lib/question-renderer.js | 13 +----- app/prototype_v4_1/routes.js | 13 +++--- .../views/authentication/security-code.html | 6 +-- .../sign-in-agreement-declined.html | 4 +- .../authentication/sign-in-agreement.html | 4 +- .../views/authentication/sign-in.html | 6 +-- .../views/check-your-answers.html | 6 +-- app/prototype_v4_1/views/confirmation.html | 18 ++++---- app/prototype_v4_1/views/content/show.html | 2 +- app/prototype_v4_1/views/errors/404.html | 2 +- app/prototype_v4_1/views/errors/500.html | 2 +- app/prototype_v4_1/views/errors/503.html | 2 +- app/prototype_v4_1/views/index.html | 4 +- app/prototype_v4_1/views/layouts/main.html | 18 ++++---- .../views/questions/_question.html | 8 ++-- .../views/questions/book-appointment.html | 6 +-- .../questions/not-eligible-for-scan.html | 6 +-- .../questions/not-eligible-for-screening.html | 6 +-- .../questions/phone-questionnaire-exit.html | 8 ++-- .../views/questions/smoking-type-exit.html | 6 +-- app/prototype_v4_1/views/start.html | 4 +- 25 files changed, 94 insertions(+), 106 deletions(-) diff --git a/app/prototype_v4_1/controllers/authentication.js b/app/prototype_v4_1/controllers/authentication.js index 7aa43b8..1ec3f2c 100644 --- a/app/prototype_v4_1/controllers/authentication.js +++ b/app/prototype_v4_1/controllers/authentication.js @@ -1,15 +1,12 @@ -const version = 'v4_1' -const view = (template) => { - return `prototype_${version}/views/${template}` -} +const { path: prototypePath, view } = require('../lib/settings') exports.signIn_get = (req, res) => { delete req.session.data res.render(view('authentication/sign-in'), { actions: { - back: `/prototype_${version}`, - next: `/prototype_${version}/sign-in` + back: prototypePath, + next: `${prototypePath}/sign-in` } }) } @@ -21,20 +18,20 @@ exports.signIn_post = (req, res) => { res.render(view('authentication/sign-in'), { errors, actions: { - back: `/prototype_${version}`, - next: `/prototype_${version}/sign-in` + back: prototypePath, + next: `${prototypePath}/sign-in` } }) } else { - res.redirect(`/prototype_${version}/security-code`) + res.redirect(`${prototypePath}/security-code`) } } exports.securityCode_get = (req, res) => { res.render(view('authentication/security-code'), { actions: { - back: `/prototype_${version}/sign-in`, - next: `/prototype_${version}/security-code` + back: `${prototypePath}/sign-in`, + next: `${prototypePath}/security-code` } }) } @@ -46,21 +43,21 @@ exports.securityCode_post = (req, res) => { res.render(view('authentication/security-code'), { errors, actions: { - back: `/prototype_${version}/sign-in`, - next: `/prototype_${version}/security-code` + back: `${prototypePath}/sign-in`, + next: `${prototypePath}/security-code` } }) } else { - res.redirect(`/prototype_${version}/sign-in-agreement`) + res.redirect(`${prototypePath}/sign-in-agreement`) } } exports.signInAgreement_get = (req, res) => { res.render(view('authentication/sign-in-agreement'), { actions: { - back: `/prototype_${version}/security-code`, - accept: `/prototype_${version}/sign-in-agreement`, - decline: `/prototype_${version}/sign-in-agreement-declined` + back: `${prototypePath}/security-code`, + accept: `${prototypePath}/sign-in-agreement`, + decline: `${prototypePath}/sign-in-agreement-declined` } }) } @@ -72,20 +69,20 @@ exports.signInAgreement_post = (req, res) => { res.render(view('authentication/sign-in-agreement'), { errors, actions: { - back: `/prototype_${version}/security-code`, - accept: `/prototype_${version}/sign-in-agreement`, - decline: `/prototype_${version}/sign-in-agreement-declined` + back: `${prototypePath}/security-code`, + accept: `${prototypePath}/sign-in-agreement`, + decline: `${prototypePath}/sign-in-agreement-declined` } }) } else { - res.redirect(`/prototype_${version}/accept-terms`) + res.redirect(`${prototypePath}/accept-terms`) } } exports.signInAgreementDeclined_get = (req, res) => { res.render(view('authentication/sign-in-agreement-declined'), { actions: { - back: `/prototype_${version}` + back: prototypePath } }) } diff --git a/app/prototype_v4_1/controllers/content.js b/app/prototype_v4_1/controllers/content.js index a2f2067..2e0212d 100644 --- a/app/prototype_v4_1/controllers/content.js +++ b/app/prototype_v4_1/controllers/content.js @@ -1,8 +1,7 @@ const fs = require('fs') const path = require('path') const matter = require('gray-matter') - -const version = 'v4_1' +const { view } = require('../lib/settings') const contentDirectory = path.join(__dirname, '..', 'content') @@ -60,7 +59,7 @@ const renderContent = (fileName) => (req, res, next) => { return next(error) } - res.render(`prototype_${version}/views/content/show`, { + res.render(view('content/show'), { content: renderedMarkdown, contentData }) diff --git a/app/prototype_v4_1/controllers/error.js b/app/prototype_v4_1/controllers/error.js index 81f4bda..f8dd496 100644 --- a/app/prototype_v4_1/controllers/error.js +++ b/app/prototype_v4_1/controllers/error.js @@ -1,13 +1,13 @@ -const version = 'v4_1' +const { view } = require('../lib/settings') exports.pageNotFound = (req, res) => { - res.status(404).render(`prototype_${version}/views/errors/404`) + res.status(404).render(view('errors/404')) } exports.unexpectedError = (req, res) => { - res.status(500).render(`prototype_${version}/views/errors/500`) + res.status(500).render(view('errors/500')) } exports.serviceUnavailable = (req, res) => { - res.status(503).render(`prototype_${version}/views/errors/503`) + res.status(503).render(view('errors/503')) } diff --git a/app/prototype_v4_1/data/questions.yaml b/app/prototype_v4_1/data/questions.yaml index 97e33ee..40fcc0c 100644 --- a/app/prototype_v4_1/data/questions.yaml +++ b/app/prototype_v4_1/data/questions.yaml @@ -6,7 +6,7 @@ questions: heading: title: Terms of use description: | - To continue, confirm that you have read and agree to the [NHS Check if you need a lung scan terms of use](/prototype_v4_1/terms-of-use). + To continue, confirm that you have read and agree to the [NHS Check if you need a lung scan terms of use](terms-of-use). input: label: Confirm you agree to the terms of use options: diff --git a/app/prototype_v4_1/lib/question-renderer.js b/app/prototype_v4_1/lib/question-renderer.js index 7098012..6f079a7 100644 --- a/app/prototype_v4_1/lib/question-renderer.js +++ b/app/prototype_v4_1/lib/question-renderer.js @@ -1,16 +1,7 @@ const { getQuestion } = require('./questions') +const settings = require('./settings') -const version = 'v4_1' - -/** - * Build a prototype v4_1 view path. - * - * @param {string} template - Template path below the prototype views folder. - * @returns {string} Nunjucks template path. - */ -const view = (template) => { - return `prototype_${version}/views/${template}` -} +const { version, view } = settings /** * Render a YAML-backed question using optional runtime overrides. diff --git a/app/prototype_v4_1/routes.js b/app/prototype_v4_1/routes.js index 7c2ac6b..7a74075 100644 --- a/app/prototype_v4_1/routes.js +++ b/app/prototype_v4_1/routes.js @@ -2,15 +2,11 @@ const express = require('express') const fs = require('fs') const path = require('path') const router = express.Router() +const settings = require('./lib/settings') -const version = 'v4_1' -const prototypePath = `/prototype_${version}` +const { path: prototypePath, version, view } = settings const viewsDirectory = path.join(__dirname, 'views') -const view = (template) => { - return `prototype_${version}/views/${template}` -} - const hasView = (template) => { if (!template || template.includes('..')) { return false @@ -30,6 +26,11 @@ const errorController = require('./controllers/error') const { getDefaultAnswerProfile, getIndexRedirect } = require('./lib/page-index') const questionController = require('./controllers/question') +router.use((req, res, next) => { + res.locals.prototype = settings.locals + next() +}) + /// ------------------------------------------------------------------------ /// /// Start page /// ------------------------------------------------------------------------ /// diff --git a/app/prototype_v4_1/views/authentication/security-code.html b/app/prototype_v4_1/views/authentication/security-code.html index 2c35934..bc6062e 100644 --- a/app/prototype_v4_1/views/authentication/security-code.html +++ b/app/prototype_v4_1/views/authentication/security-code.html @@ -1,14 +1,14 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Enter the security code" %} {% block content %} - {% include "prototype_v4/views/includes/error-summary.html" %} + {% include prototype.viewPath + "/includes/error-summary.html" %}
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %}

      We have sent a 6-digit security code to your phone number ending in 0887. diff --git a/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html b/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html index 6982391..2ab24b7 100644 --- a/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html +++ b/app/prototype_v4_1/views/authentication/sign-in-agreement-declined.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Sorry, you cannot test the online service" %} @@ -18,7 +18,7 @@

      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} diff --git a/app/prototype_v4_1/views/authentication/sign-in-agreement.html b/app/prototype_v4_1/views/authentication/sign-in-agreement.html index be641b7..ce92baa 100644 --- a/app/prototype_v4_1/views/authentication/sign-in-agreement.html +++ b/app/prototype_v4_1/views/authentication/sign-in-agreement.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Agree to share your NHS login information" %} @@ -22,7 +22,7 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %}
      diff --git a/app/prototype_v4_1/views/authentication/sign-in.html b/app/prototype_v4_1/views/authentication/sign-in.html index 816714f..dfc5d48 100644 --- a/app/prototype_v4_1/views/authentication/sign-in.html +++ b/app/prototype_v4_1/views/authentication/sign-in.html @@ -1,14 +1,14 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Log in to your NHS account" %} {% block content %} - {% include "prototype_v4/views/includes/error-summary.html" %} + {% include prototype.viewPath + "/includes/error-summary.html" %}
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} diff --git a/app/prototype_v4_1/views/check-your-answers.html b/app/prototype_v4_1/views/check-your-answers.html index 43f7200..f541116 100644 --- a/app/prototype_v4_1/views/check-your-answers.html +++ b/app/prototype_v4_1/views/check-your-answers.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Check your answers" %} @@ -10,12 +10,12 @@ {% endblock %} {% block content %} - {% include "prototype_v4/views/includes/error-summary.html" %} + {% include prototype.viewPath + "/includes/error-summary.html" %}
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %}

      Check the information you have given us. If any of the details are wrong, you can change them. diff --git a/app/prototype_v4_1/views/confirmation.html b/app/prototype_v4_1/views/confirmation.html index e41dada..8daeff5 100644 --- a/app/prototype_v4_1/views/confirmation.html +++ b/app/prototype_v4_1/views/confirmation.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Thank you for testing the online service" %} @@ -66,23 +66,23 @@ {% endif %} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %} - {% include "prototype_v4/views/includes/find-your-local-stop-smoking-service.html" %} + {% include prototype.viewPath + "/includes/find-your-local-stop-smoking-service.html" %} - {% include "prototype_v4/views/includes/benefits-of-stopping-smoking.html" %} + {% include prototype.viewPath + "/includes/benefits-of-stopping-smoking.html" %} - {% include "prototype_v4/views/includes/help-stop-smoking.html" %} + {% include prototype.viewPath + "/includes/help-stop-smoking.html" %} {% if query.risk and query.risk == "high" %} - {% include "prototype_v4/views/includes/vaping-to-quit-smoking.html" %} + {% include prototype.viewPath + "/includes/vaping-to-quit-smoking.html" %} {% endif %} - {% include "prototype_v4/views/includes/smoking-anxiety-and-mood.html" %} + {% include prototype.viewPath + "/includes/smoking-anxiety-and-mood.html" %} - {% include "prototype_v4/views/includes/help-and-support.html" %} + {% include prototype.viewPath + "/includes/help-and-support.html" %} - {% include "prototype_v4/views/includes/give-feedback.html" %} + {% include prototype.viewPath + "/includes/give-feedback.html" %}

      diff --git a/app/prototype_v4_1/views/content/show.html b/app/prototype_v4_1/views/content/show.html index 99d4018..7adb370 100644 --- a/app/prototype_v4_1/views/content/show.html +++ b/app/prototype_v4_1/views/content/show.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = contentData.title %} diff --git a/app/prototype_v4_1/views/errors/404.html b/app/prototype_v4_1/views/errors/404.html index c500078..749dffa 100644 --- a/app/prototype_v4_1/views/errors/404.html +++ b/app/prototype_v4_1/views/errors/404.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Page not found" %} diff --git a/app/prototype_v4_1/views/errors/500.html b/app/prototype_v4_1/views/errors/500.html index 229bf3c..324cc38 100644 --- a/app/prototype_v4_1/views/errors/500.html +++ b/app/prototype_v4_1/views/errors/500.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set hidePhaseBanner = true %} {% set hideFooterLinks = true %} diff --git a/app/prototype_v4_1/views/errors/503.html b/app/prototype_v4_1/views/errors/503.html index 7707742..6f8b22d 100644 --- a/app/prototype_v4_1/views/errors/503.html +++ b/app/prototype_v4_1/views/errors/503.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set hidePhaseBanner = true %} {% set hideFooterLinks = true %} diff --git a/app/prototype_v4_1/views/index.html b/app/prototype_v4_1/views/index.html index 4d5a08f..fbac5e9 100644 --- a/app/prototype_v4_1/views/index.html +++ b/app/prototype_v4_1/views/index.html @@ -1,7 +1,7 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Page index" %} -{% set prototypePath = "/prototype_v4_1" %} +{% set prototypePath = prototype.path %} {% macro pageLink(href, text) %}
    • diff --git a/app/prototype_v4_1/views/layouts/main.html b/app/prototype_v4_1/views/layouts/main.html index 1a69c70..541a908 100755 --- a/app/prototype_v4_1/views/layouts/main.html +++ b/app/prototype_v4_1/views/layouts/main.html @@ -37,7 +37,7 @@ }, { text: "Log out", - href: "/prototype_v4_1/" + href: prototype.path + "/" } ] } if data['logged-in'] @@ -68,23 +68,23 @@ meta: { items: [ { - href: "/prototype_v4_1/accessibility-statement", + href: prototype.path + "/accessibility-statement", text: "Accessibility statement" }, { - href: "/prototype_v4_1/contact-us", + href: prototype.path + "/contact-us", text: "Contact us" }, { - href: "/prototype_v4_1/cookies", + href: prototype.path + "/cookies", text: "Cookies" }, { - href: "/prototype_v4_1/privacy-policy", + href: prototype.path + "/privacy-policy", text: "Privacy policy" }, { - href: "/prototype_v4_1/terms-of-use", + href: prototype.path + "/terms-of-use", text: "Terms of use" } ] @@ -96,13 +96,13 @@

      For testing

    • diff --git a/app/prototype_v4_1/views/questions/_question.html b/app/prototype_v4_1/views/questions/_question.html index c4364e8..51674f4 100644 --- a/app/prototype_v4_1/views/questions/_question.html +++ b/app/prototype_v4_1/views/questions/_question.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = question.heading.title %} {% set caption = question.heading.caption %} @@ -11,13 +11,13 @@ {% endblock %} {% block content %} - {% include "prototype_v4_1/views/includes/error-summary.html" %} + {% include prototype.viewPath + "/includes/error-summary.html" %}
      {% if not question.input.isPageHeading %} - {% include "prototype_v4_1/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {% endif %} {% if question.description %} @@ -35,7 +35,7 @@ {% if question.input.isPageHeading %} {% set headingHtml %} - {% include "prototype_v4_1/views/includes/page-heading-legend.html" %} + {% include prototype.viewPath + "/includes/page-heading-legend.html" %} {% endset %} {% set legend = { html: headingHtml, diff --git a/app/prototype_v4_1/views/questions/book-appointment.html b/app/prototype_v4_1/views/questions/book-appointment.html index 1307b39..3ee553c 100644 --- a/app/prototype_v4_1/views/questions/book-appointment.html +++ b/app/prototype_v4_1/views/questions/book-appointment.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Call us to book an appointment" %} @@ -23,11 +23,11 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %}
      diff --git a/app/prototype_v4_1/views/questions/not-eligible-for-scan.html b/app/prototype_v4_1/views/questions/not-eligible-for-scan.html index 30bc3f1..699fb2a 100644 --- a/app/prototype_v4_1/views/questions/not-eligible-for-scan.html +++ b/app/prototype_v4_1/views/questions/not-eligible-for-scan.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "You are not eligible for an NHS lung scan" %} @@ -19,11 +19,11 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %}
      diff --git a/app/prototype_v4_1/views/questions/not-eligible-for-screening.html b/app/prototype_v4_1/views/questions/not-eligible-for-screening.html index 5eded05..ad4947b 100644 --- a/app/prototype_v4_1/views/questions/not-eligible-for-screening.html +++ b/app/prototype_v4_1/views/questions/not-eligible-for-screening.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "You are not eligible for lung cancer screening" %} @@ -17,11 +17,11 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %}
      diff --git a/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html b/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html index c6001fc..5c3a77a 100644 --- a/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html +++ b/app/prototype_v4_1/views/questions/phone-questionnaire-exit.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "You do not need to test the online service" %} @@ -16,16 +16,16 @@ {% endblock %} {% block content %} - {% include "prototype_v4/views/includes/error-summary.html" %} + {% include prototype.viewPath + "/includes/error-summary.html" %}
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %}
      diff --git a/app/prototype_v4_1/views/questions/smoking-type-exit.html b/app/prototype_v4_1/views/questions/smoking-type-exit.html index e03b599..924cbcf 100644 --- a/app/prototype_v4_1/views/questions/smoking-type-exit.html +++ b/app/prototype_v4_1/views/questions/smoking-type-exit.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "You are not eligible for lung cancer screening" %} @@ -17,11 +17,11 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %} {{ bodyTextMarkdown | markdownToHtml | safe }} - {% include "prototype_v4/views/includes/speak-to-a-gp.html" %} + {% include prototype.viewPath + "/includes/speak-to-a-gp.html" %}
      diff --git a/app/prototype_v4_1/views/start.html b/app/prototype_v4_1/views/start.html index 5f9c396..95b3248 100644 --- a/app/prototype_v4_1/views/start.html +++ b/app/prototype_v4_1/views/start.html @@ -1,4 +1,4 @@ -{% extends "prototype_v4_1/views/layouts/main.html" %} +{% extends prototype.viewPath + "/layouts/main.html" %} {% set title = "Help us test a new online service" %} @@ -6,7 +6,7 @@
      - {% include "prototype_v4/views/includes/page-heading.html" %} + {% include prototype.viewPath + "/includes/page-heading.html" %}

      We are testing a new online questionnaire for lung cancer screening. This service will ask you some questions about your medical history and lifestyle.

      From 627f5f01199411cad04cb385c70759832a8fbe1e Mon Sep 17 00:00:00 2001 From: Simon Whatley Date: Tue, 19 May 2026 16:27:50 +0100 Subject: [PATCH 9/9] Update footer link --- app/prototype_v4_1/views/layouts/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/prototype_v4_1/views/layouts/main.html b/app/prototype_v4_1/views/layouts/main.html index 541a908..37d40ff 100755 --- a/app/prototype_v4_1/views/layouts/main.html +++ b/app/prototype_v4_1/views/layouts/main.html @@ -96,7 +96,7 @@

      For testing