diff --git a/app/prototype_v4/views/questions/education.html b/app/prototype_v4/views/questions/education.html
index 4b473e4..d04c4ae 100644
--- a/app/prototype_v4/views/questions/education.html
+++ b/app/prototype_v4/views/questions/education.html
@@ -31,7 +31,7 @@
name: "answers[education]",
fieldset: {
legend: {
- text: "What is the highest level of education have you completed?",
+ text: "What is the highest level of education you have completed?",
isPageHeading: false,
classes: "nhsuk-fieldset__legend--m"
}
diff --git a/app/prototype_v4_1/data/questions.yaml b/app/prototype_v4_1/data/questions.yaml
index e94fbbe..981d7db 100644
--- a/app/prototype_v4_1/data/questions.yaml
+++ b/app/prototype_v4_1/data/questions.yaml
@@ -462,7 +462,7 @@ questions:
If your qualification is not shown choose the closest level.
input:
- label: What is the highest level of education have you completed?
+ label: What is the highest level of education you have completed?
options:
- label: I finished school before the age of 15
value: before_15
diff --git a/app/prototype_v4_1/docs/question-schema.md b/app/prototype_v4_1/docs/question-schema.md
index 84e1c03..85db6b4 100644
--- a/app/prototype_v4_1/docs/question-schema.md
+++ b/app/prototype_v4_1/docs/question-schema.md
@@ -19,7 +19,7 @@ questions:
description: |
We ask this question because education is linked to other factors that may impact your chances of developing lung cancer.
input:
- label: What is the highest level of education have you completed?
+ label: What is the highest level of education you have completed?
options:
- label: GCSEs
hint: Previously O-levels
diff --git a/app/prototype_v4_2/controllers/question.js b/app/prototype_v4_2/controllers/question.js
index f1cd34c..b8504a9 100644
--- a/app/prototype_v4_2/controllers/question.js
+++ b/app/prototype_v4_2/controllers/question.js
@@ -25,6 +25,19 @@ const getQuestionPageIds = (id, answers = {}) => {
return getQuestionPage(id, answers).questions.map((question) => question.id)
}
+const getLastSmokingTypeStepBack = (answers = {}) => {
+ const smokingSteps = getSmokingTypeSteps(answers)
+ const lastSmokingStep = smokingSteps[smokingSteps.length - 1]
+
+ return lastSmokingStep ? getSmokingTypeStepUrl(lastSmokingStep) : `/prototype_${version}/smoking-type`
+}
+
+const getFamilyHistoryBack = (answers = {}) => {
+ return answers.cancerDiagnosisRelatives === 'yes'
+ ? `/prototype_${version}/cancer-diagnosis-relatives-age`
+ : `/prototype_${version}/cancer-diagnosis-relatives`
+}
+
/// ------------------------------------------------------------------------ ///
///
/// ------------------------------------------------------------------------ ///
@@ -281,7 +294,7 @@ exports.weightMetric_post = (req, res) => {
}, errors)
} else {
delete answers.weight?.imperial
- res.redirect(`/prototype_${version}/about-you`)
+ res.redirect(`/prototype_${version}/gender`)
}
}
@@ -310,152 +323,129 @@ exports.weightImperial_post = (req, res) => {
}, errors)
} else {
delete answers.weight?.metric
- res.redirect(`/prototype_${version}/about-you`)
+ res.redirect(`/prototype_${version}/gender`)
}
}
-exports.aboutYou_get = (req, res) => {
+exports.gender_get = (req, res) => {
const back = getWeightBack(req)
- const { answers } = req.session.data
- renderQuestionPage(res, 'about-you', {
- next: `/prototype_${version}/about-you`,
+ renderQuestion(res, 'gender', {
+ next: `/prototype_${version}/gender`,
back,
cancel: `/prototype_${version}/`
- }, [], answers)
+ })
}
-exports.aboutYou_post = (req, res) => {
+exports.gender_post = (req, res) => {
const { answers } = req.session.data
const back = getWeightBack(req)
- const errors = validateQuestions(answers, getQuestionPageIds('about-you', answers))
+ const errors = validateQuestion(answers, 'gender')
if (errors.length) {
- renderQuestionPage(res, 'about-you', {
- next: `/prototype_${version}/about-you`,
+ renderQuestion(res, 'gender', {
+ next: `/prototype_${version}/gender`,
back,
cancel: `/prototype_${version}/`
- }, errors, answers)
+ }, errors)
} else {
- res.redirect(`/prototype_${version}/respiratory-conditions`)
+ res.redirect(`/prototype_${version}/sex`)
}
}
-// exports.gender_get = (req, res) => {
-// const back = getWeightBack(req)
-
-// renderQuestion(res, 'gender', {
-// next: `/prototype_${version}/gender`,
-// back,
-// cancel: `/prototype_${version}/`
-// })
-// }
-
-// exports.gender_post = (req, res) => {
-// const { answers } = req.session.data
-// const back = getWeightBack(req)
-// const errors = validateQuestion(answers, 'gender')
-
-// if (errors.length) {
-// renderQuestion(res, 'gender', {
-// next: `/prototype_${version}/gender`,
-// back,
-// cancel: `/prototype_${version}/`
-// }, errors)
-// } else {
-// res.redirect(`/prototype_${version}/sex`)
-// }
-// }
-
-// exports.sex_get = (req, res) => {
-// renderQuestion(res, 'sex', {
-// next: `/prototype_${version}/sex`,
-// back: `/prototype_${version}/gender`,
-// cancel: `/prototype_${version}/`
-// })
-// }
-
-// exports.sex_post = (req, res) => {
-// const { answers } = req.session.data
-// const errors = validateQuestion(answers, 'sex')
-
-// if (errors.length) {
-// renderQuestion(res, 'sex', {
-// next: `/prototype_${version}/sex`,
-// back: `/prototype_${version}/gender`,
-// cancel: `/prototype_${version}/`
-// }, errors)
-// } else {
-// res.redirect(`/prototype_${version}/ethnicity`)
-// }
-// }
-
-// exports.ethnicity_get = (req, res) => {
-// renderQuestion(res, 'ethnicity', {
-// next: `/prototype_${version}/ethnicity`,
-// back: `/prototype_${version}/sex`,
-// cancel: `/prototype_${version}/`
-// })
-// }
-
-// exports.ethnicity_post = (req, res) => {
-// const { answers } = req.session.data
-// const errors = validateQuestion(answers, 'ethnicity')
-
-// if (errors.length) {
-// renderQuestion(res, 'ethnicity', {
-// next: `/prototype_${version}/ethnicity`,
-// back: `/prototype_${version}/sex`,
-// cancel: `/prototype_${version}/`
-// }, errors)
-// } else {
-// res.redirect(`/prototype_${version}/education`)
-// }
-// }
-
-// exports.education_get = (req, res) => {
-// renderQuestion(res, 'education', {
-// next: `/prototype_${version}/education`,
-// back: `/prototype_${version}/ethnicity`,
-// cancel: `/prototype_${version}/`
-// })
-// }
-
-// exports.education_post = (req, res) => {
-// const { answers } = req.session.data
-// const errors = validateQuestion(answers, 'education')
-
-// if (errors.length) {
-// renderQuestion(res, 'education', {
-// next: `/prototype_${version}/education`,
-// back: `/prototype_${version}/ethnicity`,
-// cancel: `/prototype_${version}/`
-// }, errors)
-// } else {
-// res.redirect(`/prototype_${version}/respiratory-conditions`)
-// }
-// }
+exports.sex_get = (req, res) => {
+ renderQuestion(res, 'sex', {
+ next: `/prototype_${version}/sex`,
+ back: `/prototype_${version}/gender`,
+ cancel: `/prototype_${version}/`
+ })
+}
+
+exports.sex_post = (req, res) => {
+ const { answers } = req.session.data
+ const errors = validateQuestion(answers, 'sex')
+
+ if (errors.length) {
+ renderQuestion(res, 'sex', {
+ next: `/prototype_${version}/sex`,
+ back: `/prototype_${version}/gender`,
+ cancel: `/prototype_${version}/`
+ }, errors)
+ } else {
+ res.redirect(`/prototype_${version}/ethnicity`)
+ }
+}
+
+exports.ethnicity_get = (req, res) => {
+ renderQuestion(res, 'ethnicity', {
+ next: `/prototype_${version}/ethnicity`,
+ back: `/prototype_${version}/sex`,
+ cancel: `/prototype_${version}/`
+ })
+}
+
+exports.ethnicity_post = (req, res) => {
+ const { answers } = req.session.data
+ const errors = validateQuestion(answers, 'ethnicity')
+
+ if (errors.length) {
+ renderQuestion(res, 'ethnicity', {
+ next: `/prototype_${version}/ethnicity`,
+ back: `/prototype_${version}/sex`,
+ cancel: `/prototype_${version}/`
+ }, errors)
+ } else {
+ res.redirect(`/prototype_${version}/education`)
+ }
+}
+
+exports.education_get = (req, res) => {
+ renderQuestion(res, 'education', {
+ next: `/prototype_${version}/education`,
+ back: `/prototype_${version}/ethnicity`,
+ cancel: `/prototype_${version}/`
+ })
+}
+
+exports.education_post = (req, res) => {
+ const { answers } = req.session.data
+ const errors = validateQuestion(answers, 'education')
+
+ if (errors.length) {
+ renderQuestion(res, 'education', {
+ next: `/prototype_${version}/education`,
+ back: `/prototype_${version}/ethnicity`,
+ cancel: `/prototype_${version}/`
+ }, errors)
+ } else {
+ res.redirect(`/prototype_${version}/smoking-duration`)
+ }
+}
/// ------------------------------------------------------------------------ ///
/// Your health
/// ------------------------------------------------------------------------ ///
exports.respiratoryConditions_get = (req, res) => {
+ const answers = req.session.data.answers || {}
+ const back = getLastSmokingTypeStepBack(answers)
+
renderQuestion(res, 'respiratory-conditions', {
next: `/prototype_${version}/respiratory-conditions`,
- back: `/prototype_${version}/about-you`,
+ back,
cancel: `/prototype_${version}/`
})
}
exports.respiratoryConditions_post = (req, res) => {
const { answers } = req.session.data
+ const back = getLastSmokingTypeStepBack(answers)
const errors = validateQuestion(answers, 'respiratory-conditions')
if (errors.length) {
renderQuestion(res, 'respiratory-conditions', {
next: `/prototype_${version}/respiratory-conditions`,
- back: `/prototype_${version}/about-you`,
+ back,
cancel: `/prototype_${version}/`
}, errors)
} else {
@@ -538,7 +528,7 @@ exports.cancerDiagnosisRelatives_post = (req, res) => {
res.redirect(`/prototype_${version}/cancer-diagnosis-relatives-age`)
} else {
delete answers.cancerDiagnosisRelativesAge
- res.redirect(`/prototype_${version}/smoking-duration`)
+ res.redirect(`/prototype_${version}/check-your-answers`)
}
}
}
@@ -562,7 +552,7 @@ exports.cancerDiagnosisRelativesAge_post = (req, res) => {
cancel: `/prototype_${version}/`
}, errors)
} else {
- res.redirect(`/prototype_${version}/smoking-duration`)
+ res.redirect(`/prototype_${version}/check-your-answers`)
}
}
@@ -572,24 +562,22 @@ exports.cancerDiagnosisRelativesAge_post = (req, res) => {
exports.smokingDuration_get = (req, res) => {
const answers = req.session.data.answers || {}
- const back = answers?.cancerDiagnosisRelativesAge ? `/prototype_${version}/cancer-diagnosis-relatives-age` : `/prototype_${version}/cancer-diagnosis-relatives`
renderQuestionPage(res, 'smoking-duration', {
next: `/prototype_${version}/smoking-duration`,
- back,
+ back: `/prototype_${version}/education`,
cancel: `/prototype_${version}/`
}, [], answers)
}
exports.smokingDuration_post = (req, res) => {
const answers = req.session.data.answers || {}
- const back = answers?.cancerDiagnosisRelativesAge ? `/prototype_${version}/cancer-diagnosis-relatives-age` : `/prototype_${version}/cancer-diagnosis-relatives`
const errors = validateQuestions(answers, getQuestionPageIds('smoking-duration', answers))
if (errors.length) {
renderQuestionPage(res, 'smoking-duration', {
next: `/prototype_${version}/smoking-duration`,
- back,
+ back: `/prototype_${version}/education`,
cancel: `/prototype_${version}/`
}, errors, answers)
} else {
@@ -761,14 +749,13 @@ exports.tobaccoSmokingChange_post = (req, res) => {
exports.checkYourAnswers_get = (req, res) => {
const { answers } = req.session.data
- const smokingSteps = getSmokingTypeSteps(answers)
- const lastSmokingStep = smokingSteps[smokingSteps.length - 1]
+ const back = getFamilyHistoryBack(answers)
res.render(view('check-your-answers'), {
checkYourAnswers: getCheckYourAnswers(answers),
actions: {
next: `/prototype_${version}/check-your-answers`,
- back: lastSmokingStep ? getSmokingTypeStepUrl(lastSmokingStep) : `/prototype_${version}/smoking-type`,
+ back,
cancel: `/prototype_${version}/`
}
})
diff --git a/app/prototype_v4_2/data/pages.yaml b/app/prototype_v4_2/data/pages.yaml
index 6e020da..91effdf 100644
--- a/app/prototype_v4_2/data/pages.yaml
+++ b/app/prototype_v4_2/data/pages.yaml
@@ -22,14 +22,14 @@ pages:
- 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
+ - Your smoking history
- id: smoker
questions:
- smoker
heading:
title: Tobacco smoking
description: |
- We will ask you questions about your smoking habits. This includes different types of tobacco smoking such as:
+ We will ask you questions about Your smoking history. This includes different types of tobacco smoking such as:
- cigarettes from a packet
- rolling tobacco, or roll ups
@@ -40,6 +40,8 @@ pages:
It does not currently include vaping or e-cigarettes.
- id: date-of-birth
+ heading:
+ caption: Eligibilty
questions:
- date-of-birth
- id: face-to-face-appointment
@@ -47,6 +49,7 @@ pages:
- face-to-face-appointment
heading:
title: Check if you need a face-to-face appointment
+ caption: Eligibilty
description: |
This online service uses automatic calculations based on your height and weight. This means it is not suitable for everyone.
@@ -96,15 +99,6 @@ pages:
An accurate measurement is important.
If you have digital scales, use these to check your weight. Some pharmacies and gyms have scales where you can check for free.
- - id: about-you
- heading:
- title: About you
- questions:
- - gender
- - sex
- - ethnicity
- - education
- description: The answers you submit will not be shared with your patient care advisor during your phone appointment, or with your GP.
- id: gender
questions:
- gender
@@ -148,8 +142,31 @@ pages:
- respiratory-conditions
- id: asbestos
heading:
- title: Exposure to asbestos
+ title: If you have been exposed to asbestos
caption: Your health
+ description: |
+ You may have been exposed to asbestos if you worked in an industry such as building or construction, particularly from the 1950s to the 1990s.
+
+ You might also have been exposed if you lived with someone who worked with asbestos.
+
+ Asbestos was used in a number of building materials and products. For example: If you or someone you lived with worked in an industry such as building or construction you are more likely to have come into contact with damaged asbestos materials and products.
+
+ What is asbestos?
+
+
+
+
+
Gender, sex, ethnicity and education"]
- weightImperial --> aboutYou
+ weightMetric --> gender["Gender identity"]
+ weightImperial --> gender
+ gender --> sex["Sex at birth"]
+ sex --> ethnicity["Ethnic background"]
+ ethnicity --> education["Education"]
- aboutYou --> respiratory["Respiratory conditions"]
+ education --> smokingDuration["When you smoked tobacco
Age started, age stopped if applicable,
periods stopped"]
+ smokingDuration --> smokingType{"Smoking type"}
+
+ smokingType -- None selected --> smokingTypeExit["Smoking type exit
End"]
+ smokingType -- One or more tobacco types --> tobaccoLoop["Repeat tobacco questions
for each selected type"]
+
+ tobaccoLoop --> respiratory["Respiratory conditions"]
respiratory --> asbestos["Asbestos
At work, at home"]
asbestos --> cancerDiagnosis["Cancer diagnosis"]
cancerDiagnosis --> relatives{"Close relative had
lung cancer?"}
relatives -- Yes --> relativesAge["Relative diagnosed before 60?"]
- relatives -- No --> smokingDuration["Smoking duration
Age started, age stopped if applicable,
periods stopped"]
- relativesAge --> smokingDuration
-
- smokingDuration --> smokingType{"Smoking type"}
-
- smokingType -- None selected --> smokingTypeExit["Smoking type exit
End"]
- smokingType -- One or more tobacco types --> tobaccoLoop["Repeat tobacco questions
for each selected type"]
+ relatives -- No --> cya["Check your answers"]
+ relativesAge --> cya
- tobaccoLoop --> cya["Check your answers"]
cya --> confirmation["Confirmation
End"]
```
@@ -91,8 +94,8 @@ flowchart TD
## Notes
- Height and weight unit pages can be switched manually using the unit-switch links.
-- `Smoking duration` combines age started smoking, age stopped smoking and periods stopped smoking.
-- `Age stopped smoking` is shown on `Smoking duration` when the `smoker` answer is `yes_previous`. It can also be shown again from check your answers if a tobacco-specific `Smoking status` answer is `no`.
+- `When you smoked tobacco` combines age started smoking, age stopped smoking and periods stopped smoking.
+- `Age stopped smoking` is shown on `When you smoked tobacco` when the `smoker` answer is `yes_previous`. It can also be shown again from check your answers if a tobacco-specific `Smoking status` answer is `no`.
- `Tobacco smoking` combines smoking frequency and smoking quantity.
- `Tobacco smoking change` combines changed-smoking frequency, quantity and years.
- The tobacco subflow uses query strings such as `/prototype_v4_2/smoking-status?type=cigarettes` and `/prototype_v4_2/tobacco-smoking-change?type=cigarettes&change=greater`.
diff --git a/app/prototype_v4_2/docs/question-schema.md b/app/prototype_v4_2/docs/question-schema.md
index 5e4cc0e..ac82bc7 100644
--- a/app/prototype_v4_2/docs/question-schema.md
+++ b/app/prototype_v4_2/docs/question-schema.md
@@ -16,7 +16,7 @@ questions:
type: single
answerKey: education
input:
- label: What is the highest level of education have you completed?
+ label: What is the highest level of education you have completed?
options:
- label: GCSEs
hint: Previously O-levels
@@ -53,15 +53,13 @@ Define each individual form control in `questions.yaml`, then compose one or mor
```yaml
pages:
- - id: about-you
+ - id: asbestos
heading:
- title: About you
- description: The answers you submit will not be shared with your patient care advisor during your phone appointment, or with your GP.
+ title: Exposure to asbestos
+ caption: Your health
questions:
- - gender
- - sex
- - ethnicity
- - education
+ - asbestos-at-work
+ - asbestos-at-home
```
Grouped pages use the same question definitions, answer keys and validation rules as single-question pages. This means check-your-answers and later flow logic can keep reading answers from the same session keys, regardless of whether the answers came from one page or several pages.
diff --git a/app/prototype_v4_2/docs/tobacco-schema.md b/app/prototype_v4_2/docs/tobacco-schema.md
index c2532a5..a375e93 100644
--- a/app/prototype_v4_2/docs/tobacco-schema.md
+++ b/app/prototype_v4_2/docs/tobacco-schema.md
@@ -26,7 +26,7 @@ tobaccoTypes:
current:
status: Do you currently smoke cigarettes?
frequency: How often do you smoke cigarettes?
- quantity: How many cigarettes do you currently smoke in a normal day?
+ quantity: How many cigarettes do you currently smoke?
change: Has the number of cigarettes you normally smoke changed over time?
past:
frequency: How often did you smoke cigarettes?
diff --git a/app/prototype_v4_2/lib/page-index.js b/app/prototype_v4_2/lib/page-index.js
index 83568f9..6b2d03f 100644
--- a/app/prototype_v4_2/lib/page-index.js
+++ b/app/prototype_v4_2/lib/page-index.js
@@ -18,12 +18,6 @@ const defaultAnswers = {
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'],
@@ -37,7 +31,13 @@ const defaultAnswers = {
quantity: '5',
years: '10'
}
- }
+ },
+ respiratoryConditions: ['no'],
+ asbestosAtWork: 'no',
+ asbestosAtHome: 'no',
+ cancerDiagnosis: 'no',
+ cancerDiagnosisRelatives: 'yes',
+ cancerDiagnosisRelativesAge: 'no'
}
const cloneAnswers = () => JSON.parse(JSON.stringify(defaultAnswers))
diff --git a/app/prototype_v4_2/lib/summary.js b/app/prototype_v4_2/lib/summary.js
index 61caa87..dd5e70b 100644
--- a/app/prototype_v4_2/lib/summary.js
+++ b/app/prototype_v4_2/lib/summary.js
@@ -315,22 +315,22 @@ const getCheckYourAnswers = (answers = {}) => {
makeSummaryRow({
key: 'Gender identity',
value: formatValue(answers.gender, valueLabels.gender),
- href: `/prototype_${version}/about-you`
+ href: `/prototype_${version}/gender`
}),
makeSummaryRow({
key: 'Sex at birth',
value: formatValue(answers.sex, valueLabels.sex),
- href: `/prototype_${version}/about-you`
+ href: `/prototype_${version}/sex`
}),
makeSummaryRow({
key: 'Ethnic background',
value: formatValue(answers.ethnicity, valueLabels.ethnicity),
- href: `/prototype_${version}/about-you`
+ href: `/prototype_${version}/ethnicity`
}),
makeSummaryRow({
key: 'Education',
value: formatValue(answers.education, valueLabels.education),
- href: `/prototype_${version}/about-you`
+ href: `/prototype_${version}/education`
})
]),
health: makeSummaryRows([
diff --git a/app/prototype_v4_2/lib/tobacco-flow.js b/app/prototype_v4_2/lib/tobacco-flow.js
index 8d98a48..e96f1a9 100644
--- a/app/prototype_v4_2/lib/tobacco-flow.js
+++ b/app/prototype_v4_2/lib/tobacco-flow.js
@@ -9,7 +9,7 @@ const { getQuestionPage } = require('./question-pages')
const { renderQuestion, renderQuestionPage, version } = require('./question-renderer')
const { validateQuestion } = require('./question-validator')
-const nextStepAfterSmokingTypes = `/prototype_${version}/check-your-answers`
+const nextStepAfterSmokingTypes = `/prototype_${version}/respiratory-conditions`
const getValueLabels = () => {
return {
@@ -93,6 +93,16 @@ const getQuestionVariantValueLabels = (id, type) => {
}, {})
}
+/**
+ * Get the display label for a tobacco type.
+ *
+ * @param {string} type - Tobacco type key.
+ * @returns {string} Tobacco type label.
+ */
+const getSmokingTypeLabel = (type) => {
+ return (getValueLabels().smokingType[type] || '').replace(', or ', ' or ')
+}
+
/**
* Get selected tobacco types in tobacco.yaml order.
*
@@ -371,6 +381,7 @@ const getSmokingTypeHeadings = (type, isPast = false) => {
return {
...smokingType,
+ pageHeading: getSmokingTypeLabel(type),
statusHeading: currentHeadings.status,
frequencyHeading: tenseHeadings.frequency,
quantityHeading: tenseHeadings.quantity,
@@ -474,6 +485,20 @@ const getSmokingChangeComparisonText = (type, change, answer = {}) => {
return `when you smoked ${changeLabel} than ${amount}`
}
+/**
+ * Build the heading for a changed-smoking grouped page.
+ *
+ * @param {string} type - Tobacco type key.
+ * @param {string} change - Smoking change key.
+ * @param {Object} answer - Answer object for one tobacco type.
+ * @returns {string} Contextual page heading.
+ */
+const getSmokingChangePageHeading = (type, change, answer = {}) => {
+ const comparisonText = getSmokingChangeComparisonText(type, change, answer)
+
+ return comparisonText ? upperFirst(comparisonText) : ''
+}
+
/**
* Build the heading for changed-smoking frequency, quantity and years pages.
*
@@ -482,9 +507,10 @@ const getSmokingChangeComparisonText = (type, change, answer = {}) => {
* @param {string} change - Smoking change key.
* @param {Object} changeAnswer - Change-specific answer object.
* @param {Object} answer - Answer object for one tobacco type.
+ * @param {boolean} includeComparison - Whether to include the more/fewer comparison text.
* @returns {string} Contextual page heading.
*/
-const getSmokingChangeHeading = (page, type, change, changeAnswer = {}, answer = {}) => {
+const getSmokingChangeHeading = (page, type, change, changeAnswer = {}, answer = {}, includeComparison = true) => {
const smokingType = smokingTypes[type]
const smokingChange = smokingChangeTypes[change]
@@ -494,11 +520,20 @@ const getSmokingChangeHeading = (page, type, change, changeAnswer = {}, answer =
const comparisonText = getSmokingChangeComparisonText(type, change, answer)
- if (page === 'smoking-frequency-change' || page === 'smoking-quantity-change') {
- const headingType = page === 'smoking-frequency-change' ? 'frequencyHeading' : 'quantityHeading'
- const baseHeading = applySmokingFrequencyPeriod(getSmokingTypeHeadings(type, true)[headingType], answer.smokingFrequency)
+ if (page === 'smoking-frequency-change') {
+ const baseHeading = applySmokingFrequencyPeriod(getSmokingTypeHeadings(type, true).frequencyHeading, answer.smokingFrequency)
- return baseHeading ? `${baseHeading.replace('?', '')} ${comparisonText}?` : ''
+ return includeComparison && comparisonText ? `${baseHeading.replace('?', '')} ${comparisonText}?` : baseHeading
+ }
+
+ if (page === 'smoking-quantity-change') {
+ const baseHeading = applySmokingFrequencyPeriod(getSmokingTypeHeadings(type, true).quantityHeading, answer.smokingFrequency)
+ const normalHeading = baseHeading
+ .replace(' did you smoke ', ' did you normally smoke ')
+ .replace(' did you smoke?', ' did you normally smoke?')
+ .replace(/ in a normal (day|week|month|year)\?$/, '?')
+
+ return includeComparison && comparisonText ? `${baseHeading.replace('?', '')} ${comparisonText}?` : normalHeading
}
if (page === 'smoking-years-change') {
@@ -701,6 +736,10 @@ const lowerFirst = (value = '') => {
return value ? `${value.charAt(0).toLowerCase()}${value.slice(1)}` : ''
}
+const upperFirst = (value = '') => {
+ return value ? `${value.charAt(0).toUpperCase()}${value.slice(1)}` : ''
+}
+
/**
* Convert a question heading into an error-message answer phrase.
*
@@ -714,6 +753,7 @@ const getAnswerPhraseFromHeading = (heading = '') => {
.replace(/^how long did you smoke /, 'how long you smoked ')
.replace(/^how long do you currently smoke /, 'how long you currently smoke ')
.replace(/^how long do you smoke /, 'how long you smoke ')
+ .replace(/^(how (?:much|many|long) .+?) did you normally smoke/, '$1 you normally smoked')
.replace(/^(how (?:much|many|long) .+?) did you smoke /, '$1 you smoked ')
.replace(/^(how (?:much|many|long) .+?) do you currently smoke /, '$1 you currently smoke ')
.replace(/^(how (?:much|many|long) .+?) do you smoke /, '$1 you smoke ')
@@ -806,7 +846,7 @@ const getSmokingContentQuestionOverrides = ({
return {
heading: {
title: smokingType.statusHeading,
- caption: smokingType.caption
+ caption: 'Your smoking history'
},
input: {
name: `answers[${step.type}][smokingStatus]`
@@ -825,9 +865,7 @@ const getSmokingContentQuestionOverrides = ({
name: `answers[${step.type}][smokingFrequency]`
},
value: answer.smokingFrequency,
- items: getQuestionItemsWithLabels('smoking-frequency', {}, {
- monthly: `Select this option if you ${isPastSmokingType ? 'smoked' : 'smoke'} at least once a month`
- })
+ items: getQuestionItemsWithLabels('smoking-frequency')
}
}
@@ -848,7 +886,7 @@ const getSmokingContentQuestionOverrides = ({
return {
heading: {
title: smokingType.changeHeading,
- caption: smokingType.caption
+ caption: 'Your smoking history'
},
input: {
name: `answers[${step.type}][smokingChange]`
@@ -861,8 +899,8 @@ const getSmokingContentQuestionOverrides = ({
if (page === 'smoking-frequency-change') {
return {
heading: {
- title: getSmokingChangeHeading(page, step.type, step.change, changeAnswer, answer),
- caption: smokingType.caption
+ title: getSmokingChangeHeading(page, step.type, step.change, changeAnswer, answer, false),
+ caption: 'Your smoking history'
},
input: {
name: `answers[${step.type}][${smokingChange.answerKey}][frequency]`
@@ -876,8 +914,8 @@ const getSmokingContentQuestionOverrides = ({
return getSmokingQuantityQuestionOverrides({
page,
step,
- heading: getSmokingChangeHeading(page, step.type, step.change, changeAnswer, answer),
- caption: smokingType.caption,
+ heading: getSmokingChangeHeading(page, step.type, step.change, changeAnswer, answer, false),
+ caption: 'Your smoking history',
name: `answers[${step.type}][${smokingChange.answerKey}][quantity]`,
value: changeAnswer.quantity,
conditionalValue: changeAnswer.smokingQuantityOther,
@@ -889,7 +927,7 @@ const getSmokingContentQuestionOverrides = ({
return {
heading: {
title: getSmokingChangeHeading(page, step.type, step.change, changeAnswer, answer),
- caption: smokingType.caption
+ caption: 'Your smoking history'
},
input: {
id: 'smoking-years-change',
@@ -926,10 +964,17 @@ const getSmokingTypePageAnswers = (step) => {
}
}
-const getSmokingTypePageHeading = (page, smokingType = {}) => {
+const getSmokingTypePageHeading = (page, smokingType = {}, step = {}, answer = {}) => {
if (page === 'tobacco-smoking-change') {
return {
- title: `${smokingType.caption} change`
+ title: getSmokingChangePageHeading(step.type, step.change, answer),
+ caption: 'Your smoking history'
+ }
+ }
+
+ if (page === 'tobacco-smoking') {
+ return {
+ title: smokingType.pageHeading || smokingType.caption
}
}
@@ -955,7 +1000,7 @@ const getSmokingContentPageOverrides = (req, page, step) => {
}, {})
return {
- heading: getSmokingTypePageHeading(page, context.smokingType),
+ heading: getSmokingTypePageHeading(page, context.smokingType, step, context.answer),
questions
}
}
diff --git a/app/prototype_v4_2/routes.js b/app/prototype_v4_2/routes.js
index 02dad54..fe7ff38 100644
--- a/app/prototype_v4_2/routes.js
+++ b/app/prototype_v4_2/routes.js
@@ -109,20 +109,17 @@ router.post(`/prototype_${version}/weight-metric`, questionController.weightMetr
router.get(`/prototype_${version}/weight-imperial`, questionController.weightImperial_get)
router.post(`/prototype_${version}/weight-imperial`, questionController.weightImperial_post)
-router.get(`/prototype_${version}/about-you`, questionController.aboutYou_get)
-router.post(`/prototype_${version}/about-you`, questionController.aboutYou_post)
+router.get(`/prototype_${version}/gender`, questionController.gender_get)
+router.post(`/prototype_${version}/gender`, questionController.gender_post)
-// router.get(`/prototype_${version}/sex`, questionController.sex_get)
-// router.post(`/prototype_${version}/sex`, questionController.sex_post)
+router.get(`/prototype_${version}/sex`, questionController.sex_get)
+router.post(`/prototype_${version}/sex`, questionController.sex_post)
-// router.get(`/prototype_${version}/gender`, questionController.gender_get)
-// router.post(`/prototype_${version}/gender`, questionController.gender_post)
+router.get(`/prototype_${version}/ethnicity`, questionController.ethnicity_get)
+router.post(`/prototype_${version}/ethnicity`, questionController.ethnicity_post)
-// router.get(`/prototype_${version}/ethnicity`, questionController.ethnicity_get)
-// router.post(`/prototype_${version}/ethnicity`, questionController.ethnicity_post)
-
-// router.get(`/prototype_${version}/education`, questionController.education_get)
-// router.post(`/prototype_${version}/education`, questionController.education_post)
+router.get(`/prototype_${version}/education`, questionController.education_get)
+router.post(`/prototype_${version}/education`, questionController.education_post)
/// Your health ------------------------------------------------------------ ///
diff --git a/app/prototype_v4_2/views/check-your-answers.html b/app/prototype_v4_2/views/check-your-answers.html
index f541116..ee18046 100644
--- a/app/prototype_v4_2/views/check-your-answers.html
+++ b/app/prototype_v4_2/views/check-your-answers.html
@@ -39,24 +39,8 @@
Quick navigation to all pages in prototype v4.1.
+Quick navigation to all pages in prototype v4.2.
Some links set default answers before opening the page, so conditional pages and check your answers have enough data to render.
Asbestos was used in a number of building materials and products. For example:
+If you or someone you lived with worked in an industry such as building or construction you are more likely to have come into contact with damaged asbestos materials and products.
+