Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ router.post('/modify/:id/submit', function (req, res) {
const userValues = req.session.data['userValues-' + serviceId] || {}
const fields = ['address','addressName','addressPostcode','odsCode','odsOrgName','odsNotKnown','orgName','orgType',
'serviceCategory','serviceType','attendInPerson']
fields.forEach(f => { if (req.body[f] !== undefined) userValues[f] = req.body[f] })
fields.forEach(f => {
if (req.body[f] !== undefined) {
// The prototype kit sends '_unchecked' for unchecked checkboxes; treat as empty
userValues[f] = req.body[f] === '_unchecked' ? '' : req.body[f]
}
})
req.session.data['userValues-' + serviceId] = userValues
res.redirect('/confirm/' + serviceId)
})
Expand Down Expand Up @@ -299,7 +304,9 @@ router.get('/edit/:id/:field', function (req, res) {
router.post('/edit/:id/:field/submit', function (req, res) {
const serviceId = req.params.id
const userValues = req.session.data['userValues-' + serviceId] || {}
Object.keys(req.body).forEach(k => { userValues[k] = req.body[k] })
Object.keys(req.body).forEach(k => {
userValues[k] = req.body[k] === '_unchecked' ? '' : req.body[k]
})
req.session.data['userValues-' + serviceId] = userValues
res.redirect('/confirm/' + serviceId)
})
Expand Down
2 changes: 1 addition & 1 deletion app/views/guidance.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h4 class="nhsuk-heading-s">ODS - additional information and guidance</h4>
{{ insetText({
html: insetTextHtml
}) }}
<h4 class="nhsuk-heading-s">Organisations that don not have ODS codes</h4>
<h4 class="nhsuk-heading-s">Organisations that do not have ODS codes</h4>
<p class="nhsuk-body">There are some services in DoS that are run by organisations that are not known to ODS. Where both you and the AI are unable to find an ODS record for the organisation, you can select this option and enter the organisation details separately. This will require you to manually enter the name and select an organisation type from a list. The ODS code field will not be shown and will not be populated.<br><br>The organisation type list is closely aligned with ODS organisation categories.</p>

<h3 class="nhsuk-heading-m">Service Category and Type</h3>
Expand Down
26 changes: 22 additions & 4 deletions app/views/review.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<table class="dos-review-table">
<thead>
<tr>
<th style="width:20%">Field</th>
<th style="width:28%">Current</th>
<th style="width:34%">Suggested</th>
<th style="width:18%">Action</th>
<th style="width:19%">Field</th>
<th style="width:33%">Current</th>
<th style="width:33%">Suggested</th>
<th style="width:15%">Action</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -86,6 +86,9 @@
<span class="dos-tag dos-tag--warning">Manual input needed</span>
{% else %}
{{ service.fields.odsCode.suggested if service.fields.odsCode.suggested else ('<span class="dos-not-applicable">No data</span>' | safe) }}
{% if service.fields.odsCode.suggested %}
<br><span class="nhsuk-u-secondary-text-color nhsuk-body-s nhsuk-u-margin-bottom-0" id="ods-suggested-name"></span>
{% endif %}
{% endif %}
<button type="button" class="dos-reasoning-toggle" aria-expanded="false" aria-controls="reasoning-odsCode">View reasoning</button>
</td>
Expand Down Expand Up @@ -329,6 +332,21 @@
btn.setAttribute('aria-expanded', 'true');
}
});

// Look up ODS org name for suggested code
var odsNameEl = document.getElementById('ods-suggested-name');
{% if service.fields.odsCode.suggested and not odsManual %}
if (odsNameEl) {
var code = '{{ service.fields.odsCode.suggested }}';
fetch('https://directory.spineservices.nhs.uk/ORD/2-0-0/organisations/' + encodeURIComponent(code))
.then(function (r) { if (!r.ok) throw new Error('Not found'); return r.json(); })
.then(function (data) {
var name = (data.Organisation && data.Organisation.Name) ? data.Organisation.Name : null;
if (name) odsNameEl.textContent = name;
})
.catch(function () {});
}
{% endif %}
})();
</script>
{% endblock %}