|
1 | 1 | import wizard from '@x-govuk/govuk-prototype-wizard' |
2 | 2 | import _ from 'lodash' |
3 | 3 |
|
4 | | -import { PatientStatus } from '../enums.js' |
5 | | -import { School } from '../models.js' |
| 4 | +import { PatientStatus, SessionType } from '../enums.js' |
| 5 | +import { Patient, School, Session } from '../models.js' |
6 | 6 | import { generateNewSiteCode } from '../utils/location.js' |
7 | 7 | import { getResults, getPagination } from '../utils/pagination.js' |
8 | 8 | import { formatYearGroup } from '../utils/string.js' |
@@ -450,5 +450,29 @@ export const schoolController = { |
450 | 450 | request.flash('success', __(`school.delete.success`)) |
451 | 451 |
|
452 | 452 | response.redirect(referrer) |
| 453 | + }, |
| 454 | + |
| 455 | + inviteToClinic(request, response) { |
| 456 | + const { school_id } = request.params |
| 457 | + const { data } = request.session |
| 458 | + const { __mf } = response.locals |
| 459 | + |
| 460 | + const school = School.findOne(school_id, data) |
| 461 | + |
| 462 | + // Find patients to invite to clinic |
| 463 | + const patientSessionsForClinic = school.patients.map( |
| 464 | + (patient) => patient.uuid |
| 465 | + ) |
| 466 | + |
| 467 | + // TODO: Move patients to clinic |
| 468 | + |
| 469 | + request.flash( |
| 470 | + 'success', |
| 471 | + __mf(`school.inviteToClinic.success`, { |
| 472 | + count: patientSessionsForClinic.length |
| 473 | + }) |
| 474 | + ) |
| 475 | + |
| 476 | + response.redirect(school.uri) |
453 | 477 | } |
454 | 478 | } |
0 commit comments