Skip to content

Commit 576aeff

Browse files
committed
Fix linter warnings and remove/tidy up TODOs.
1 parent 17c24fb commit 576aeff

8 files changed

Lines changed: 37 additions & 44 deletions

File tree

app/controllers/book-into-a-clinic.js

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ import {
1010
} from '../utils/clinic-appointment.js'
1111
import { kebabToCamelCase } from '../utils/string.js'
1212

13+
/**
14+
* @typedef {import('express').Request} Request
15+
* @typedef {import('express').Response} Response
16+
* @typedef {import('express').NextFunction} Next
17+
*/
18+
1319
export const bookIntoClinicController = {
1420
/**
1521
* Record the session preset
1622
*
17-
* @param {*} request
18-
* @param {*} response
19-
* @param {*} next
20-
* @param {*} session_preset_slug
23+
* @param {Request} request
24+
* @param {Response} response
25+
* @param {Next} next
26+
* @param {string} session_preset_slug
2127
*/
2228
read(request, response, next, session_preset_slug) {
2329
const serviceName = 'Book into a clinic'
@@ -43,8 +49,8 @@ export const bookIntoClinicController = {
4349
/**
4450
* Send to the start page
4551
*
46-
* @param {*} request
47-
* @param {*} response
52+
* @param {Request} request
53+
* @param {Response} response
4854
*/
4955
redirect(request, response) {
5056
const { sessionPreset } = response.locals
@@ -55,8 +61,8 @@ export const bookIntoClinicController = {
5561
/**
5662
* Start a new clinic booking for clinics with the primary programme we've been given
5763
*
58-
* @param {*} request
59-
* @param {*} response
64+
* @param {Request} request
65+
* @param {Response} response
6066
*/
6167
new(request, response) {
6268
const { data } = request.session
@@ -81,16 +87,17 @@ export const bookIntoClinicController = {
8187
* This includes code to set up radio button groups for various pages (we set them up
8288
* regardless of which specific route we're handling).
8389
*
84-
* @param {*} request
85-
* @param {*} response
86-
* @param {*} next
90+
* @param {Request} request
91+
* @param {Response} response
92+
* @param {Next} next
8793
*/
8894
readForm(request, response, next) {
8995
const { session_preset_slug, booking_uuid } = request.params
9096
const appointment_uuid = request.params.appointment_uuid
9197
const { data, referrer } = request.session
9298

93-
/** NOTE:
99+
/**
100+
* NOTE:
94101
*
95102
* The nature of the journey here is complex, as there are two separate sections in which we need to
96103
* iterate over children. Or over appointments, if you want to think of it that way (each child has
@@ -113,7 +120,7 @@ export const bookIntoClinicController = {
113120
* - Health question n <-- final page of the per-child health question journey; iterate to next child if required
114121
* - Confirmation
115122
*
116-
* */
123+
*/
117124

118125
// Create objects on the global context to allow us to check branching conditions, etc.
119126
// And make them available to the view.
@@ -204,8 +211,8 @@ export const bookIntoClinicController = {
204211
/**
205212
* Render the requested form page
206213
*
207-
* @param {*} request
208-
* @param {*} response
214+
* @param {Request} request
215+
* @param {Response} response
209216
*/
210217
showForm(request, response) {
211218
const { appointment } = response.locals
@@ -258,24 +265,14 @@ export const bookIntoClinicController = {
258265
]
259266
}
260267

261-
/////////////////////
262-
// console.log(`view: ${view}`)
263-
// console.log(
264-
// `data.wizard: ${JSON.stringify(request.session.data.wizard, null, 2)}`
265-
// )
266-
// console.log(
267-
// `data.appointment: ${JSON.stringify(request.session.data.appointment, null, 2)}`
268-
// )
269-
/////////////////////
270-
271268
response.render(`book-into-a-clinic/form/${view}`, { key, hasSubQuestions })
272269
},
273270

274271
/**
275272
* Store the latest values entered into a form in the booking journey
276273
*
277-
* @param {*} request
278-
* @param {*} response
274+
* @param {Request} request
275+
* @param {Response} response
279276
*/
280277
updateForm(request, response) {
281278
const { booking_uuid, appointment_uuid, view } = request.params
@@ -357,8 +354,8 @@ export const bookIntoClinicController = {
357354
/**
358355
* Catch-all for pages not needing to reference a given clinic booking
359356
*
360-
* @param {*} request
361-
* @param {*} response
357+
* @param {Request} request
358+
* @param {Response} response
362359
*/
363360
show(request, response) {
364361
const view = request.params.view || 'start'

app/generators/clinic-booking.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ClinicBooking } from '../models.js'
66
/**
77
* Generate fake clinic booking (initially without any appointments, which can be added later)
88
*
9-
* @param context
9+
* @param {object} context
1010
* @returns {ClinicBooking} ClinicBooking
1111
*/
1212
export function generateEmptyClinicBooking(context) {

app/models/clinic-appointment.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { stringToArray, stringToBoolean } from '../utils/string.js'
2121
* @property {string} booking_uuid - Unique ID for the booking in which this appointment was made
2222
* @property {string} [patient_uuid] - Patient UUID (if matched to a patient record)
2323
* @property {import('./child.js').Child} [child] - child details recorded from form input values
24-
* @property {Boolean} needsExtraTime - Does the child need extra time for their vaccinations?
24+
* @property {boolean} needsExtraTime - Does the child need extra time for their vaccinations?
2525
* @property {string} [extraTimeReason] - The reason why the child needs extra time for their appointment
26-
* @property {ParentalRelationship} [parentalRelationship] - The relationship of the person booking the appointment to the child
26+
* @property {import('../enums.js').ParentalRelationship} [parentalRelationship] - The relationship of the person booking the appointment to the child
2727
* @property {string} [parentalRelationshipOther] - User-defined parental relationship to the child for this appointment
2828
* @property {boolean} [parentHasParentalResponsibility] - Does the parent/carer have legal parental responsibility for the child?
2929
* @property {string} [session_id] - The ID of the clinic session in which the appointment's booked
@@ -124,6 +124,8 @@ export class ClinicAppointment {
124124
/**
125125
* Get a parent object combining the parent's contact details held in the
126126
* booking with the parental relationship for this appointment's child
127+
*
128+
* @returns {Parent} - a Parent with the correct relationship to this appointment's child
127129
*/
128130
get parent() {
129131
const booking = this.clinicBooking

app/models/clinic-booking.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { formatMonospace, stringToBoolean } from '../utils/string.js'
1313
* @property {object} [context] - Context
1414
* @property {string} uuid - Clinic booking UUID
1515
* @property {string} bookingReference - Booking reference number
16-
* @property {SessionPreset} sessionPreset - the primary programme for which the parent was invited to book e.g. doubles
16+
* @property {import('../enums.js').SessionPreset} sessionPreset - the primary programme for which the parent was invited to book e.g. doubles
1717
* @property {Parent} parent - contact details for the parent making the booking; see appointments for parental relationship details
1818
* @property {Array<string>} [appointments_ids] - Unique IDs of children's appointments (one parent may book in multiple children under one booking)
1919
*/
@@ -49,7 +49,7 @@ export class ClinicBooking {
4949

5050
/**
5151
*
52-
* @returns Generate a new, random booking reference
52+
* @returns {string} Generate a new, random booking reference
5353
*/
5454
static generateReference() {
5555
return faker.helpers.replaceSymbols('CLN-####-####')
@@ -81,7 +81,6 @@ export class ClinicBooking {
8181
* @returns {Array<Programme>} the set of Programme objects represented by the session preset
8282
*/
8383
get primaryProgrammes() {
84-
// MAL: is this gonna trip me up, relying on the global context if called from the booking journey?
8584
return this.primaryProgrammeIDs.map((id) =>
8685
Programme.findOne(id, this.context)
8786
)

app/routes/book-into-a-clinic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ router.get(
3232
bookIntoClinic.showForm
3333
)
3434

35-
// MAL: Not convinced I need this special case for clinic bookings... unless it's to perform the final 'save'?
35+
// TODO: save the completed booking to the global context
3636
// router.post('/:session_preset_slug/:booking_uuid/new/check-answers', bookIntoClinic.update)
3737

3838
router.post(

app/utils/clinic-appointment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export const getAllAppointmentPaths = (sessionData, booking) => {
8282
* Get the path for a single health question
8383
*
8484
* @param {string} key
85-
* @param {ClinicAppointment} appointment
85+
* @param {import('../models/clinic-appointment.js').ClinicAppointment} appointment
8686
* @param {string} pathPrefix
87-
* @returns
87+
* @returns {string} The full path to the given health question
8888
*/
8989
const getHealthQuestionPath = (key, appointment, pathPrefix) => {
9090
return `${pathPrefix}${appointment.uuid}/health-question-${camelToKebabCase(key)}`

app/utils/clinic-booking.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SessionPresets } from '../enums.js'
44
* Generate a URL for booking into a clinic whose primary programme is given by the session preset
55
*
66
* @param {string} sessionPresetName - the primary programme for the clinic
7+
* @returns {string} - path to the start of the clinic booking journey for the given programme
78
*/
89
export const getClinicBookingUrl = (sessionPresetName) => {
910
const sessionPreset = SessionPresets.find(

app/views/book-into-a-clinic/form/vaccination-choice.njk

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
{{ firstName }} is also eligible for other vaccinations.
1414
</p>
1515

16-
{% set programmeOptions = [] %}
17-
{% for programme in appointment.eligibleProgrammes %}
18-
{# MAL: where did I copy this from? Do I need to add name property to ensure the programme IDs (and not the programme titles) are put into the request body? #}
19-
{% set programmeOptions = (programmeOptions.push({ text: programme.title, value: programme.id }), programmeOptions) %}
20-
{% endfor %}
21-
2216
{{ checkboxes({
2317
fieldset: {
2418
legend: {

0 commit comments

Comments
 (0)