Skip to content

Commit 3e6db86

Browse files
authored
Merge branch 'v2' into RITM0237151-XGov-Ai-Evaluation
2 parents 7c514fd + 07e1e88 commit 3e6db86

6 files changed

Lines changed: 108 additions & 30 deletions

File tree

runner/src/server/forms/close-contact-form-cca-nl8.json

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name": "para1",
1414
"options": {},
1515
"type": "Para",
16-
"content": "This service is for agents to contact members of the public in order to record their close contact details after they have tested positive for bird (avian) flu.",
16+
"content": "This service is for agents to contact members of the public in order to record their close contact details after they have tested positive for {{(srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}.",
1717
"schema": {}
1818
},
1919
{
@@ -81,21 +81,22 @@
8181
"schema": {}
8282
},
8383
{
84-
"name": "disease_name",
84+
"name": "d",
8585
"options": {
8686
"allowPrePopulation": true,
8787
"allowPrePopulationOverwrite": true,
8888
"classes": "govuk-!-display-none",
89+
"exposeToContext": true,
8990
"hideTitle": true,
9091
"disableChangingFromSummary": true,
9192
"required": false
9293
},
93-
"type": "TextField",
94+
"type": "RadiosField",
9495
"title": "Disease",
95-
"schema": {}
96+
"list": "disease_code_list"
9697
},
9798
{
98-
"name": "reference_id",
99+
"name": "r",
99100
"options": {
100101
"allowPrePopulation": true,
101102
"allowPrePopulationOverwrite": true,
@@ -113,7 +114,7 @@
113114
"controller": "./pages/start.js"
114115
},
115116
{
116-
"title": "Have you received a positive test result for bird (avian) flu?",
117+
"title": "Have you received a positive test result for {{(srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}",
117118
"path": "/completing-form-for",
118119
"components": [
119120
{
@@ -123,11 +124,11 @@
123124
"exposeToContext": true,
124125
"disableChangingFromSummary": true,
125126
"customValidationMessages": {
126-
"any.required": "Select 'yes' if you have received a positive test result for bird (avian) flu"
127+
"any.required": "Select 'yes' if you have received a positive test result"
127128
}
128129
},
129130
"type": "RadiosField",
130-
"title": "Have you received a positive test result for bird (avian) flu?",
131+
"title": "Have you received a positive test result for {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}",
131132
"list": "ApjoNd"
132133
}
133134
],
@@ -396,7 +397,7 @@
396397
"name": "doYouLiveWithOtherPeopleExplanation",
397398
"options": {},
398399
"type": "Para",
399-
"content": "As you've tested positive for bird (avian) flu, it's important for us to know who you live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
400+
"content": "As you've tested positive for {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, it's important for us to know who you live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
400401
},
401402
{
402403
"name": "AdEVNK",
@@ -429,7 +430,7 @@
429430
"options": {},
430431
"type": "Details",
431432
"title": "Why are we asking for this information?",
432-
"content": "We ask this to identify people you live with and may have passed bird (avian) flu on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
433+
"content": "We ask this to identify people you live with and may have passed {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }} on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
433434
}
434435
],
435436
"next": [
@@ -3678,6 +3679,15 @@
36783679
}
36793680
]
36803681
},
3682+
{
3683+
"title": "Disease Code",
3684+
"name": "disease_code_list",
3685+
"type": "string",
3686+
"items": [
3687+
{ "text": "001F00", "value": "001F00" },
3688+
{ "text": "001F01", "value": "001F01" }
3689+
]
3690+
},
36813691
{
36823692
"title": "How should we contact this person?",
36833693
"name": "TQfrjB",
@@ -4651,7 +4661,7 @@
46514661
"specialPages": {
46524662
"confirmationPage": {
46534663
"customText": {
4654-
"nextSteps": "<h2 class='govuk-heading-m'>What happens next</h2><p class='govuk-body'>We may contact the close contacts listed to ask for more information and to give them advice on what to do next.</p><h2 class='govuk-heading-m'>More information on avian flu</h2><p class='govuk-body'>If anyone they know develops symptoms of bird (avian) flu, ask them to order a test kit. For urgent medical advice, they can call NHS 111 or visit 111.nhs.uk. For life-threatening emergencies, call 999.</p><p class='govuk-body'>For more advice and information on the virus visit the NHS website.</p><h2 class='govuk-heading-m'>If they need to contact us</h2><p class='govuk-body'>If they have any concerns or questions they can contact us at <a class='govuk-link' href='mailto:surgeresponse@ukhsa.gov.uk'>surgeresponse@ukhsa.gov.uk</a>.</p>",
4664+
"nextSteps": "<h2 class='govuk-heading-m'>What happens next</h2><p class='govuk-body'>We may contact the close contacts listed to ask for more information and to give them advice on what to do next.</p><h2 class='govuk-heading-m'>More information on avian flu</h2><p class='govuk-body'>If anyone they know develops symptoms of {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, ask them to order a test kit. For urgent medical advice, they can call NHS 111 or visit 111.nhs.uk. For life-threatening emergencies, call 999.</p><p class='govuk-body'>For more advice and information on the virus visit the NHS website.</p><h2 class='govuk-heading-m'>If they need to contact us</h2><p class='govuk-body'>If they have any concerns or questions they can contact us at <a class='govuk-link' href='mailto:surgeresponse@ukhsa.gov.uk'>surgeresponse@ukhsa.gov.uk</a>.</p>",
46554665
"title": "Form submitted",
46564666
"referenceTitle": "Your reference number"
46574667
}

runner/src/server/forms/close-contact-form-nl8.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name": "para1",
1414
"options": {},
1515
"type": "Para",
16-
"content": "To help us reduce the spread of bird (avian) flu, it's important for us to know who you live with and who you've been in close contact with.",
16+
"content": "To help us reduce the spread of {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, it's important for us to know who you live with and who you've been in close contact with.",
1717
"schema": {}
1818
},
1919
{
@@ -81,21 +81,22 @@
8181
"schema": {}
8282
},
8383
{
84-
"name": "disease_name",
84+
"name": "d",
8585
"options": {
8686
"allowPrePopulation": true,
8787
"allowPrePopulationOverwrite": true,
8888
"classes": "govuk-!-display-none",
89+
"exposeToContext": true,
8990
"hideTitle": true,
9091
"disableChangingFromSummary": true,
9192
"required": false
9293
},
93-
"type": "TextField",
94+
"type": "RadiosField",
9495
"title": "Disease",
95-
"schema": {}
96+
"list": "disease_code_list"
9697
},
9798
{
98-
"name": "reference_id",
99+
"name": "r",
99100
"options": {
100101
"allowPrePopulation": true,
101102
"allowPrePopulationOverwrite": true,
@@ -347,7 +348,7 @@
347348
"name": "doYouLiveWithOtherPeopleExplanation",
348349
"options": {},
349350
"type": "Para",
350-
"content": "As you've tested positive for bird (avian) flu, it's important for us to know who you live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
351+
"content": "As you've tested positive for {{(srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, it's important for us to know who you live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
351352
},
352353
{
353354
"name": "AdEVNK",
@@ -380,7 +381,7 @@
380381
"options": {},
381382
"type": "Details",
382383
"title": "Why are we asking for this information?",
383-
"content": "We ask this to identify people you live with and may have passed bird (avian) flu on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
384+
"content": "We ask this to identify people you live with and may have passed {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }} on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
384385
}
385386
],
386387
"next": [
@@ -400,7 +401,7 @@
400401
"name": "doYouLiveWithOtherPeopleExplanation",
401402
"options": {},
402403
"type": "Para",
403-
"content": "As the person you are completing the form for has tested positive for bird (avian) flu, it's important for us to know who they live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
404+
"content": "As the person you are completing the form for has tested positive for {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, it's important for us to know who they live with, so we can help them receive the right guidance, such as how to get tested and other health advice."
404405
},
405406
{
406407
"name": "AdEVNK",
@@ -433,7 +434,7 @@
433434
"options": {},
434435
"type": "Details",
435436
"title": "Why are we asking for this information?",
436-
"content": "We ask this to identify people they live with and may have passed bird (avian) flu on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
437+
"content": "We ask this to identify people they live with and may have passed {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }} on to. This is so we can provide the right guidance to them or someone on their behalf, such as how to get tested and other health advice."
437438
}
438439
],
439440
"next": [
@@ -3632,6 +3633,15 @@
36323633
{ "text": "On behalf of someone else", "value": "they" }
36333634
]
36343635
},
3636+
{
3637+
"title": "Disease Code",
3638+
"name": "disease_code_list",
3639+
"type": "string",
3640+
"items": [
3641+
{ "text": "001F00", "value": "001F00" },
3642+
{ "text": "001F01", "value": "001F01" }
3643+
]
3644+
},
36353645
{
36363646
"title": "How should we contact this person?",
36373647
"name": "TQfrjB",
@@ -4613,7 +4623,7 @@
46134623
"specialPages": {
46144624
"confirmationPage": {
46154625
"customText": {
4616-
"nextSteps": "<h2 class='govuk-heading-m'>What happens next</h2><p class='govuk-body'>We may contact the close contacts you listed to ask for more information and to give them advice on what to do next.</p><h2 class='govuk-heading-m'>More information on avian flu</h2><p class='govuk-body'>If anyone you know develops symptoms of bird (avian) flu, ask them to <a class='govuk-link' href='#'>order a test kit</a>. For urgent medical advice, you can call NHS 111 or visit <a class='govuk-link' href='https://111.nhs.uk/'>111.nhs.uk</a>. For life-threatening emergencies, call 999.</p><p class='govuk-body'>For more advice and information on the virus visit <a class='govuk-link' href='www.nhs.uk/conditions/bird-flu'>www.nhs.uk/conditions/bird-flu</a>.</p><h2 class='govuk-heading-m'>If you need to contact us</h2><p class='govuk-body'>If you have any concerns or questions about this form, you can contact us at <a class='govuk-link' href='mailto:surgeresponse@ukhsa.gov.uk'>surgeresponse@ukhsa.gov.uk</a>.</p>",
4626+
"nextSteps": "<h2 class='govuk-heading-m'>What happens next</h2><p class='govuk-body'>We may contact the close contacts you listed to ask for more information and to give them advice on what to do next.</p><h2 class='govuk-heading-m'>More information on avian flu</h2><p class='govuk-body'>If anyone you know develops symptoms of {{ (srsContexts.diseaseInfo[d].name if srsContexts.diseaseInfo[d]) | default('bird (avian) flu', true) }}, ask them to <a class='govuk-link' href='#'>order a test kit</a>. For urgent medical advice, you can call NHS 111 or visit <a class='govuk-link' href='https://111.nhs.uk/'>111.nhs.uk</a>. For life-threatening emergencies, call 999.</p><p class='govuk-body'>For more advice and information on the virus visit <a class='govuk-link' href='www.nhs.uk/conditions/bird-flu'>www.nhs.uk/conditions/bird-flu</a>.</p><h2 class='govuk-heading-m'>If you need to contact us</h2><p class='govuk-body'>If you have any concerns or questions about this form, you can contact us at <a class='govuk-link' href='mailto:surgeresponse@ukhsa.gov.uk'>surgeresponse@ukhsa.gov.uk</a>.</p>",
46174627
"title": "Form submitted",
46184628
"referenceTitle": "Your reference number"
46194629
}

runner/src/server/plugins/engine/components/Details.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { FormData, FormSubmissionErrors } from "../types";
22
import { ComponentBase } from "./ComponentBase";
3+
import config from "../../../config";
4+
import nunjucks from "nunjucks";
35

46
export class Details extends ComponentBase {
57
getViewModel(formData: FormData, errors: FormSubmissionErrors) {
@@ -11,6 +13,10 @@ export class Details extends ComponentBase {
1113
html: this.content,
1214
};
1315

16+
if (config.allowUserTemplates) {
17+
viewModel.html = nunjucks.renderString(viewModel.html, { ...formData });
18+
}
19+
1420
if ("condition" in options && options.condition) {
1521
viewModel.condition = options.condition;
1622
}

runner/src/server/plugins/engine/models/SummaryViewModel.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { HapiRequest } from "src/server/types";
1111
import { InitialiseSessionOptions } from "server/plugins/initialiseSession/types";
1212
import { Outputs } from "server/plugins/engine/models/submission/Outputs";
1313
import { summaryDetailsTransformationMap } from "./SummaryViewModel.detailsTransformationMap";
14+
import nunjucks from "nunjucks";
1415

1516
import pino from "pino";
1617
const logger = pino().child({ name: "SummaryViewModel" });
@@ -206,7 +207,14 @@ export class SummaryViewModel {
206207

207208
sectionPages.forEach((page) => {
208209
for (const component of page.components.formItems) {
209-
const item = Item(request, component, sectionState, page, model);
210+
const item = Item(
211+
request,
212+
component,
213+
sectionState,
214+
page,
215+
state,
216+
model
217+
);
210218
if (items.find((cbItem) => cbItem.name === item.name)) return;
211219
items.push(item);
212220
if (component.items) {
@@ -217,7 +225,14 @@ export class SummaryViewModel {
217225
if (selectedItem && selectedItem.conditionallyRevealedComponents) {
218226
for (const cc of selectedItem.conditionallyRevealedComponents
219227
.formItems) {
220-
const cItem = Item(request, cc, sectionState, page, model);
228+
const cItem = Item(
229+
request,
230+
cc,
231+
sectionState,
232+
page,
233+
state,
234+
model
235+
);
221236
items.push(cItem);
222237
}
223238
}
@@ -347,6 +362,17 @@ function gatherRepeatPages(state) {
347362
});
348363
}
349364

365+
function renderTemplate(str: string, context: object): string {
366+
if (
367+
!config.allowUserTemplates ||
368+
typeof str !== "string" ||
369+
!str.includes("{{")
370+
) {
371+
return str;
372+
}
373+
return nunjucks.renderString(str, context);
374+
}
375+
350376
/**
351377
* Creates an Item object for Details
352378
*/
@@ -355,6 +381,7 @@ function Item(
355381
component,
356382
sectionState,
357383
page,
384+
state,
358385
model: FormModel,
359386
params: { num?: number; returnUrl: string } = {
360387
returnUrl: redirectUrl(request, `/${model.basePath}/summary`),
@@ -369,7 +396,7 @@ function Item(
369396
(acc: {}, p: any) => ({ ...acc, ...p }),
370397
{}
371398
);
372-
return Item(request, component, collated, page, model, {
399+
return Item(request, component, collated, page, state, model, {
373400
...params,
374401
num: i + 1,
375402
});
@@ -379,7 +406,10 @@ function Item(
379406
const item = {
380407
name: component.name,
381408
path: page.path,
382-
label: component.localisedString(component.title),
409+
label: renderTemplate(component.localisedString(component.title), {
410+
...state,
411+
...sectionState,
412+
}),
383413
value: component.getDisplayStringFromState(sectionState),
384414
rawValue: sectionState[component.name],
385415
url: redirectUrl(request, `/${model.basePath}${page.path}`, params),

runner/src/server/plugins/views.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import pkg from "../../../package.json";
77
import config from "../config";
88
import { HapiRequest } from "../types";
99
import additionalContexts from "../templates/additionalContexts.json";
10+
import srsContexts from "../templates/srsContexts.json";
1011

1112
const basedir = path.join(process.cwd(), "..");
1213

@@ -42,6 +43,7 @@ export default {
4243
watch: false,
4344
});
4445
environment.addGlobal("additionalContexts", additionalContexts);
46+
environment.addGlobal("srsContexts", srsContexts);
4547
environment.addFilter("isArray", (x) => Array.isArray(x));
4648
options.compileOptions.environment = environment;
4749

@@ -70,10 +72,16 @@ export default {
7072
appVersion: pkg.version,
7173
assetPath: "/assets",
7274
cookiesPolicy: request?.state?.cookies_policy,
73-
serviceName: request.server?.app?.forms?.[request.params?.id]?.def?.serviceName || config.serviceName,
74-
returnTo: request?.server?.app?.forms?.[request.params?.id]?.def?.returnTo || false,
75+
serviceName:
76+
request.server?.app?.forms?.[request.params?.id]?.def?.serviceName ||
77+
config.serviceName,
78+
returnTo:
79+
request?.server?.app?.forms?.[request.params?.id]?.def?.returnTo ||
80+
false,
7581
feedbackLink: config.feedbackLink,
76-
pageTitle: (request.server?.app?.forms?.[request.params?.id]?.def?.serviceName || config.serviceName) + " - GOV.UK",
82+
pageTitle:
83+
(request.server?.app?.forms?.[request.params?.id]?.def?.serviceName ||
84+
config.serviceName) + " - GOV.UK",
7785
analyticsAccount: config.analyticsAccount,
7886
gtmId1: analytics.gtmId1 || "",
7987
gtmId2: analytics.gtmId2 || "",
@@ -83,14 +91,18 @@ export default {
8391
BROWSER_REFRESH_URL: config.browserRefreshUrl,
8492
sessionTimeout: config.sessionTimeout,
8593
skipTimeoutWarning: false,
86-
serviceStartPage: request.server?.app?.forms?.[request.params?.id]?.def?.fullStartPage || config.serviceStartPage || config.serviceName || "#",
94+
serviceStartPage:
95+
request.server?.app?.forms?.[request.params?.id]?.def
96+
?.fullStartPage ||
97+
config.serviceStartPage ||
98+
config.serviceName ||
99+
"#",
87100
privacyPolicyUrl: config.privacyPolicyUrl || "/help/privacy",
88101
phaseTag: config.phaseTag,
89102
navigation: request?.auth.isAuthenticated
90103
? [{ text: "Sign out", href: "/logout" }]
91104
: null,
92105
};
93106
},
94-
95107
},
96108
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"diseaseInfo": {
3+
"001F00": {
4+
"name": "bird (avian) flu"
5+
},
6+
"001F01": {
7+
"name": "Mers-Cov"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)