Skip to content

Don't create unknown school move from cohort upload#6141

Merged
MartinVanIJcken merged 9 commits intonextfrom
dont-create-unknown-school-move-from-cohort-upload
Mar 5, 2026
Merged

Don't create unknown school move from cohort upload#6141
MartinVanIJcken merged 9 commits intonextfrom
dont-create-unknown-school-move-from-cohort-upload

Conversation

@murugapl
Copy link
Copy Markdown
Contributor

@murugapl murugapl commented Feb 27, 2026

When new teams onboard and upload their cohorts, many of their patients already exist in Mavis at known schools in other teams' areas. If the uploading team's CHIS data is out of date, the import moves these children to "unknown school", generating large volumes of school moves that both the uploading team and existing teams have to review. This is causing significant noise — newly onboarding teams are seeing hundreds of school moves, and existing teams are being disrupted by moves they didn't initiate.

During a cohort import, if a child is already registered at a known school in another team's area, we don't move them to "unknown school". We skip those children from the import instead. On the import review screen, we show a summary line explaining how many children were skipped and why (e.g. "250 records not imported"). This summary remains visible on the completed import screen too, so teams can refer back to it.

https://nhsd-jira.digital.nhs.uk/browse/MAV-3920

Screenshots

screencapture-file-Users-lakshmimurugappan-Documents-Mavis-manage-vaccinations-in-schools-tmp-capybara-screenshot-2023-05-20-00-00-00-000-html-2026-02-27-13_47_02 screencapture-file-Users-lakshmimurugappan-Documents-Mavis-manage-vaccinations-in-schools-tmp-capybara-screenshot-2023-05-20-00-00-00-000-html-2026-02-27-13_46_36

Pre-release tasks

  • ...

Post-release tasks

SchoolMove.where(school: nil, home_educated: false).includes(patient: :changesets).select do
  changeset = it.patient.changesets.last 
  changeset.import_type == "CohortImport" && changeset.school_move_to_unknown_school_from_another_team? 
end.each(&:ignore!)

@murugapl murugapl added this to the v7.2.0 milestone Feb 27, 2026
@murugapl murugapl added the feature New functionality label Feb 27, 2026
@murugapl murugapl force-pushed the dont-create-unknown-school-move-from-cohort-upload branch from 6a53a94 to 5b821a9 Compare February 27, 2026 13:46
@murugapl murugapl marked this pull request as ready for review February 27, 2026 13:52
@murugapl murugapl requested a review from a team as a code owner February 27, 2026 13:52
@murugapl murugapl force-pushed the dont-create-unknown-school-move-from-cohort-upload branch from 5b821a9 to 7d255b3 Compare February 27, 2026 16:22
Comment thread app/models/patient_changeset.rb Outdated
Comment thread app/models/patient_changeset.rb Outdated
Comment thread spec/models/patient_changeset_spec.rb Outdated
Comment thread spec/models/patient_changeset_spec.rb Outdated
Comment thread app/components/app_import_review_component.rb
Comment thread app/views/imports/show.html.erb
Comment thread app/jobs/commit_import_job.rb Outdated
Comment thread app/jobs/commit_patient_changesets_job.rb Outdated
@thomasleese thomasleese changed the title Dont create unknown school move from cohort upload Don't create unknown school move from cohort upload Mar 4, 2026
@MartinVanIJcken MartinVanIJcken force-pushed the dont-create-unknown-school-move-from-cohort-upload branch from 7d255b3 to 7cbd98a Compare March 5, 2026 13:21
@MartinVanIJcken MartinVanIJcken dismissed their stale review March 5, 2026 13:24

Changes have been implemented

@MartinVanIJcken MartinVanIJcken force-pushed the dont-create-unknown-school-move-from-cohort-upload branch from 7cbd98a to 867b2c2 Compare March 5, 2026 13:52
…ol moves

Prevents cohort imports from moving children to unknown schools when they're already registered at a known school in another team's area. These children should remain at their current school rather than being moved to an unknown school.
Displays a dedicated section for children who are skipped during import because they're already registered at a known school in another team's area. These children will not be moved to an unknown school.
This displays the skipped school moves on the import review screen and the
completed import screen.
This will not work if the import review screen flag is off, but given we
want to remove the flag soon, and always have it on, that shouldn't be a problem.
These records should be skipped entirely from the import so no changes to the
base patient are made from data that is very likely to be outdated (why we're skipping
the school moves in the first place)
The team is delegated so we do not need to navigate to it ourselves through
import. It is also not null so we do not need to check for presence.

We need not explicitly check for empty current teams as [].include?(x) is
always false.

Jira-Issue: MAV-3920
…m?` through variable names

Jira-Issue: MAV-3920
When these changes were approved, they might have been presented as changes
that would be processed. Now they may have moved from changes that will be
skipped due to a change performed by the other team. In that case they should
not be processed so the user is aware that their status has changed.

Jira-Issue: MAV-3920
@MartinVanIJcken MartinVanIJcken force-pushed the dont-create-unknown-school-move-from-cohort-upload branch from 867b2c2 to f8a681c Compare March 5, 2026 14:22
@MartinVanIJcken MartinVanIJcken merged commit 312d486 into next Mar 5, 2026
13 checks passed
@MartinVanIJcken MartinVanIJcken deleted the dont-create-unknown-school-move-from-cohort-upload branch March 5, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants