@@ -2,7 +2,7 @@ import wizard from '@x-govuk/govuk-prototype-wizard'
22import _ from 'lodash'
33
44import { PatientStatus } from '../enums.js'
5- import { Patient , School } from '../models.js'
5+ import { School } from '../models.js'
66import { generateNewSiteCode } from '../utils/location.js'
77import { getResults , getPagination } from '../utils/pagination.js'
88import { formatYearGroup } from '../utils/string.js'
@@ -18,7 +18,10 @@ export const schoolController = {
1818 } ,
1919
2020 readAll ( request , response , next ) {
21- response . locals . schools = School . findAll ( request . session . data )
21+ // Combine children with no known school with home-schooled children)
22+ response . locals . schools = School . findAll ( request . session . data ) . filter (
23+ ( school ) => school . id !== '888888'
24+ )
2225
2326 next ( )
2427 } ,
@@ -93,17 +96,12 @@ export const schoolController = {
9396 } ,
9497
9598 readPatients ( request , response , next ) {
96- const { school_id } = request . params
9799 const { option, programme_id, q, yearGroup } = request . query
98100 const { data } = request . session
99101 const { school } = response . locals
100102
101- const patients = Patient . findAll ( data ) . filter (
102- ( patient ) => patient . school_id === school_id
103- )
104-
105103 // Sort
106- let results = _ . sortBy ( patients , 'lastName' )
104+ let results = _ . sortBy ( school . patients , 'lastName' )
107105
108106 // Query
109107 if ( q ) {
@@ -207,7 +205,7 @@ export const schoolController = {
207205
208206 // Results
209207 response . locals . school = school
210- response . locals . patients = patients
208+ response . locals . patients = school . patients
211209 response . locals . results = getResults ( results , request . query )
212210 response . locals . pages = getPagination ( results , request . query )
213211
0 commit comments