Skip to content

Commit 9a41f17

Browse files
Rename clinicType to LocationType and serviceType to clinicType
1 parent 9f00c72 commit 9a41f17

File tree

8 files changed

+56
-34
lines changed

8 files changed

+56
-34
lines changed

app/data/breast-screening-units.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = [
1515
},
1616
phoneNumber: "01865235621",
1717
abbreviation: "WSB",
18-
serviceTypes: ['screening', 'assessment'], // Can do both
18+
clinicTypes: ['screening', 'assessment'], // Can do both
1919
// Default operating hours for the BSU
2020
sessionPatterns: [
2121
{
@@ -66,7 +66,7 @@ module.exports = [
6666
name: "Mobile Unit JA1 CP7",
6767
type: "mobile_unit",
6868
isMainSite: false,
69-
serviceTypes: ['screening'], // Can only do screening
69+
clinicTypes: ['screening'], // Can only do screening
7070
registration: "JA1 CP7",
7171
// Override BSU session patterns for this location
7272
sessionPatterns: [
@@ -84,7 +84,7 @@ module.exports = [
8484
name: "Mobile Unit WX71 HCR",
8585
type: "mobile_unit",
8686
isMainSite: false,
87-
serviceTypes: ['screening'], // Can only do screening
87+
clinicTypes: ['screening'], // Can only do screening
8888
registration: "WX71 HCR",
8989
// Override BSU session patterns for this location
9090
sessionPatterns: [

app/lib/generate-seed-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const generateData = async () => {
5757
slot,
5858
participant,
5959
clinic,
60-
outcomeWeights: config.screening.outcomes[clinic.serviceType]
60+
outcomeWeights: config.screening.outcomes[clinic.clinicType]
6161
});
6262
});
6363

app/lib/generators/clinic-generator.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ const dayjs = require('dayjs');
66
const weighted = require('weighted');
77
const config = require('../../config');
88

9-
const determineServiceType = (location, breastScreeningUnit) => {
9+
const determineclinicType = (location, breastScreeningUnit) => {
1010
// First check location-specific service types
11-
const serviceTypes = location.serviceTypes || breastScreeningUnit.serviceTypes;
11+
const clinicTypes = location.clinicTypes || breastScreeningUnit.clinicTypes;
1212

1313
// If still no service types, default to screening
14-
if (!serviceTypes) {
14+
if (!clinicTypes) {
1515
return 'screening';
1616
}
1717

1818
// If location/BSU only supports one service type, use that
19-
if (serviceTypes.length === 1) {
20-
return serviceTypes[0];
19+
if (clinicTypes.length === 1) {
20+
return clinicTypes[0];
2121
}
2222

2323
// For locations that can do both, weight towards screening
@@ -27,7 +27,7 @@ const determineServiceType = (location, breastScreeningUnit) => {
2727
});
2828
};
2929

30-
const generateTimeSlots = (date, sessionTimes, serviceType) => {
30+
const generateTimeSlots = (date, sessionTimes, clinicType) => {
3131
const { slotDurationMinutes } = config.clinics;
3232

3333
const slots = [];
@@ -40,8 +40,8 @@ const generateTimeSlots = (date, sessionTimes, serviceType) => {
4040
slots.push({
4141
id: slotId,
4242
dateTime: new Date(currentTime).toISOString(),
43-
type: serviceType, // Use the clinic's service type
44-
capacity: serviceType === 'assessment' ? 1 : 2, // Assessment clinics don't double book
43+
type: clinicType, // Use the clinic's service type
44+
capacity: clinicType === 'assessment' ? 1 : 2, // Assessment clinics don't double book
4545
bookedCount: 0,
4646
period: `${sessionTimes.startTime}-${sessionTimes.endTime}`
4747
});
@@ -87,15 +87,15 @@ const determineSessionType = (sessionTimes) => {
8787
};
8888

8989
const generateClinic = (date, location, breastScreeningUnit, sessionTimes) => {
90-
const serviceType = determineServiceType(location, breastScreeningUnit);
91-
const slots = generateTimeSlots(date, sessionTimes, serviceType);
90+
const clinicType = determineclinicType(location, breastScreeningUnit);
91+
const slots = generateTimeSlots(date, sessionTimes, clinicType);
9292

9393
return {
9494
id: generateId(),
9595
date: date.toISOString().split('T')[0],
9696
breastScreeningUnitId: breastScreeningUnit.id,
97-
clinicType: location.type,
98-
serviceType,
97+
locationType: location.type,
98+
clinicType,
9999
locationId: location.id,
100100
siteName: location.type === 'mobile_unit' ? generateMobileSiteName() : null,
101101
slots,
@@ -106,9 +106,9 @@ const generateClinic = (date, location, breastScreeningUnit, sessionTimes) => {
106106
support: []
107107
},
108108
targetCapacity: {
109-
bookingPercent: serviceType === 'assessment' ? 100 : config.clinics.targetBookingPercent,
110-
attendancePercent: serviceType === 'assessment' ? 95 : config.clinics.targetAttendancePercent,
111-
totalSlots: slots.length * (serviceType === 'assessment' ? 1 : 2)
109+
bookingPercent: clinicType === 'assessment' ? 100 : config.clinics.targetBookingPercent,
110+
attendancePercent: clinicType === 'assessment' ? 95 : config.clinics.targetAttendancePercent,
111+
totalSlots: slots.length * (clinicType === 'assessment' ? 1 : 2)
112112
},
113113
notes: null,
114114
sessionTimes,

app/lib/generators/event-generator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights }) => {
6868
const isTodayBeforeCurrentTime = eventDate.isBefore(currentDateTime)
6969

7070
// If it's an assessment clinic, override the outcome weights to reflect higher probability of findings
71-
const eventWeights = clinic.serviceType === 'assessment' ?
71+
const eventWeights = clinic.clinicType === 'assessment' ?
7272
{
7373
'clear': 0.4, // Lower chance of clear results
7474
'needs_further_tests': 0.45, // Higher chance of needing more tests
7575
'cancer_detected': 0.15 // Higher cancer detection rate
7676
} : outcomeWeights;
7777

7878
// Adjust attendance probability for assessment clinics
79-
const attendanceWeights = clinic.serviceType === 'assessment' ?
79+
const attendanceWeights = clinic.clinicType === 'assessment' ?
8080
[0.9, 0.08, 0.02] : // [attended, dna, attended_not_screened]
8181
[0.65, 0.25, 0.1]; // Original weights for screening
8282

@@ -87,7 +87,7 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights }) => {
8787
participantId: participant.id,
8888
clinicId: clinic.id,
8989
slotId: slot.id,
90-
type: clinic.serviceType,
90+
type: clinic.clinicType,
9191
status: 'scheduled',
9292
details: {
9393
screeningType: 'mammogram',
@@ -110,7 +110,7 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights }) => {
110110
participantId: participant.id,
111111
clinicId: clinic.id,
112112
slotId: slot.id,
113-
type: clinic.serviceType,
113+
type: clinic.clinicType,
114114
status,
115115
details: {
116116
screeningType: 'mammogram',

app/lib/utils/strings.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,32 @@ const formatPhoneNumber = (phoneNumber) => {
203203
return `${phoneNumber.slice(0, 4)} ${phoneNumber.slice(4, 7)} ${phoneNumber.slice(7)}`;
204204
};
205205

206+
/**
207+
* Format NHS number with spaces (3-3-4 format)
208+
* @param {string|number} input - NHS number to format
209+
* @returns {string} Formatted NHS number or original input if invalid
210+
*/
211+
const formatNhsNumber = (input) => {
212+
if (!input) return '';
213+
const nhsStr = input.toString().replace(/\s/g, '');
214+
215+
if (!/^\d{10}$/.test(nhsStr)) {
216+
return input;
217+
}
218+
219+
return `${nhsStr.slice(0,3)} ${nhsStr.slice(3,6)} ${nhsStr.slice(6)}`;
220+
};
221+
222+
// Example usage:
223+
// formatNhsNumber('4857773456') // returns '485 777 3456'
224+
// formatNhsNumber(4857773456) // returns '485 777 3456'
225+
// formatNhsNumber('485 777 3456') // returns '485 777 3456'
226+
206227
module.exports = {
207228
addIndefiniteArticle,
208229
formatCurrency,
209230
formatCurrencyForCsv,
231+
formatNhsNumber,
210232
formatWords,
211233
isString,
212234
kebabCase,

app/views/clinics/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h1>{{pageHeading}}</h1>
5757
<tr>
5858
<th scope="col">Location</th>
5959
<th scope="col">Date</th>
60-
<th scope="col">Service type</th>
60+
<th scope="col">Clinic type</th>
6161
<th scope="col">Status</th>
6262
<th scope="col" class="nhsuk-table__cell--numeric">Participants</th>
6363
</tr>
@@ -79,7 +79,7 @@ <h1>{{pageHeading}}</h1>
7979
</a>
8080
</td>
8181
<td>{{ clinic.date | formatDate | noWrap }}</td>
82-
<td>{{ clinic.serviceType | sentenceCase }}</td>
82+
<td>{{ clinic.clinicType | sentenceCase }}</td>
8383
<td class="nhsuk-table__cell--numeric">
8484
{{ tag({
8585
text: clinic.status | formatWords | sentenceCase,

app/views/clinics/show.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<h1 class="nhsuk-heading-l">
1717
<span class="nhsuk-caption-l">{{ unit.name }}</span>
18-
{{ clinic.serviceType | sentenceCase }} clinic on {{ clinic.date | formatDate }}
18+
{{ clinic.clinicType | sentenceCase }} clinic on {{ clinic.date | formatDate }}
1919
</h1>
2020

2121
{% set secondaryNavItems = [] %}
@@ -69,7 +69,7 @@ <h1 class="nhsuk-heading-l">
6969
</a>
7070
</td>
7171
{# <td class="nhsuk-table__cell">{{ participant.demographicInformation.address.postcode | noWrap }}</td> #}
72-
<td class="nhsuk-table__cell">{{ participant.medicalInformation.nhsNumber }}</td>
72+
<td class="nhsuk-table__cell">{{ participant.medicalInformation.nhsNumber | formatNhsNumber}}</td>
7373
<td class="nhsuk-table__cell">
7474
{{ tag({
7575
text: event.status | formatWords | sentenceCase,
@@ -113,13 +113,13 @@ <h2 class="nhsuk-heading-m">Details</h2>
113113
</div>
114114

115115
<div class="nhsuk-summary-list__row">
116-
<dt class="nhsuk-summary-list__key">Type</dt>
117-
<dd class="nhsuk-summary-list__value">{{ clinic.clinicType | replace("_", " ") | capitalize }}</dd>
116+
<dt class="nhsuk-summary-list__key">Location</dt>
117+
<dd class="nhsuk-summary-list__value">{{ clinic.locationType | formatWords | sentenceCase }}</dd>
118118
</div>
119119

120120
<div class="nhsuk-summary-list__row">
121-
<dt class="nhsuk-summary-list__key">Service</dt>
122-
<dd class="nhsuk-summary-list__value">{{ clinic.serviceType | sentenceCase }}</dd>
121+
<dt class="nhsuk-summary-list__key">Type</dt>
122+
<dd class="nhsuk-summary-list__value">{{ clinic.clinicType | sentenceCase }}</dd>
123123
</div>
124124
</dl>
125125

app/views/participants/show.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ <h2 class="nhsuk-heading-m">Current appointment</h2>
2626

2727
<dl class="nhsuk-summary-list">
2828
<div class="nhsuk-summary-list__row">
29-
<dt class="nhsuk-summary-list__key">Service</dt>
30-
<dd class="nhsuk-summary-list__value">{{ clinic.serviceType | replace("_", " ") | capitalize }}</dd>
29+
<dt class="nhsuk-summary-list__key">Clinic type</dt>
30+
<dd class="nhsuk-summary-list__value">{{ clinic.clinicType | replace("_", " ") | capitalize }}</dd>
3131
</div>
3232
<div class="nhsuk-summary-list__row">
3333
<dt class="nhsuk-summary-list__key">Time</dt>
@@ -64,7 +64,7 @@ <h2 class="nhsuk-heading-m">Personal details</h2>
6464
<div class="nhsuk-summary-list__row">
6565
<dt class="nhsuk-summary-list__key">NHS number</dt>
6666
<dd class="nhsuk-summary-list__value">
67-
{{ participant.medicalInformation.nhsNumber }}
67+
{{ participant.medicalInformation.nhsNumber | formatNhsNumber }}
6868
</dd>
6969
</div>
7070
<div class="nhsuk-summary-list__row">

0 commit comments

Comments
 (0)