Skip to content

Commit 83c5ad0

Browse files
committed
Rename createInContext to match repo conventions
Also fix errors from suggested changes commited in PR #223
1 parent 1eba6c6 commit 83c5ad0

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const bookIntoClinicController = {
6969
const { sessionPreset } = response.locals
7070

7171
// Create a new clinic booking in the wizard context
72-
const booking = ClinicBooking.createInContext(
72+
const booking = ClinicBooking.create(
7373
{
7474
sessionPreset
7575
},
@@ -308,17 +308,17 @@ export const bookIntoClinicController = {
308308
const childrenToAdd = Math.max(0, desiredCount - existingCount)
309309
const childrenToRemove = Math.max(0, existingCount - desiredCount)
310310
Array.from({ length: childrenToAdd }).forEach(() => {
311-
const appointment = ClinicAppointment.createInContext(
311+
const appointment = ClinicAppointment.create(
312312
{ primary_programme_ids: booking.primaryProgrammeIDs },
313313
data.wizard
314314
)
315315

316316
booking.addAppointment(appointment)
317-
}
317+
})
318318
Array.from({ length: childrenToRemove }).forEach(() => {
319319
const appointment_uuid = booking.removeLastAppointment()
320320
ClinicAppointment.delete(appointment_uuid, data.wizard)
321-
}
321+
})
322322

323323
// Start the appointment journey for the first child
324324
const firstAppointment = booking.appointments[0]

app/models/clinic-appointment.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,6 @@ export class ClinicAppointment {
6565
this.healthAnswers = options?.healthAnswers || {}
6666
}
6767

68-
/**
69-
* Create a new clinic appointment, adding it to the context
70-
*
71-
* @param {object} appointment - an appointment to copy or an object with any subset of its properties
72-
* @param {object} context - the context into which we'll add the new appointment
73-
* @returns {ClinicAppointment} A new clinic booking, added to the context, and possibly with a new UUID
74-
*/
75-
static createInContext(appointment, context) {
76-
const createdAppointment = new ClinicAppointment(appointment)
77-
78-
// Update context
79-
context.clinicAppointments = context.clinicAppointments || {}
80-
context.clinicAppointments[createdAppointment.uuid] = createdAppointment
81-
82-
return createdAppointment
83-
}
84-
8568
/**
8669
* Get URI of the booking journey
8770
*
@@ -341,6 +324,23 @@ export class ClinicAppointment {
341324
}
342325
}
343326

327+
/**
328+
* Create a new clinic appointment, adding it to the context
329+
*
330+
* @param {object} appointment - an appointment to copy or an object with any subset of its properties
331+
* @param {object} context - the context into which we'll add the new appointment
332+
* @returns {ClinicAppointment} A new clinic booking, added to the context, and possibly with a new UUID
333+
*/
334+
static create(appointment, context) {
335+
const createdAppointment = new ClinicAppointment(appointment)
336+
337+
// Update context
338+
context.clinicAppointments = context.clinicAppointments || {}
339+
context.clinicAppointments[createdAppointment.uuid] = createdAppointment
340+
341+
return createdAppointment
342+
}
343+
344344
/**
345345
* Update
346346
*

app/models/clinic-booking.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ export class ClinicBooking {
3030
this.appointments_ids = options?.appointments_ids ?? []
3131
}
3232

33-
/**
34-
* Create a new clinic booking, adding it to the context
35-
*
36-
* @param {object} booking
37-
* @param {object} context
38-
* @returns {ClinicBooking} A new clinic booking, added to the context, and possibly with a new UUID
39-
*/
40-
static createInContext(booking, context) {
41-
const createdBooking = new ClinicBooking(booking)
42-
43-
// Update context
44-
context.clinicBookings = context.clinicBookings || {}
45-
context.clinicBookings[createdBooking.uuid] = createdBooking
46-
47-
return createdBooking
48-
}
49-
5033
/**
5134
*
5235
* @returns {string} Generate a new, random booking reference
@@ -173,6 +156,23 @@ export class ClinicBooking {
173156
}
174157
}
175158

159+
/**
160+
* Create a new clinic booking, adding it to the context
161+
*
162+
* @param {object} booking
163+
* @param {object} context
164+
* @returns {ClinicBooking} A new clinic booking, added to the context, and possibly with a new UUID
165+
*/
166+
static create(booking, context) {
167+
const createdBooking = new ClinicBooking(booking)
168+
169+
// Update context
170+
context.clinicBookings = context.clinicBookings || {}
171+
context.clinicBookings[createdBooking.uuid] = createdBooking
172+
173+
return createdBooking
174+
}
175+
176176
/**
177177
* Update
178178
*

0 commit comments

Comments
 (0)