Skip to content

Conversation

thomasleese
Copy link
Contributor

@thomasleese thomasleese commented Aug 29, 2025

Testing has finished and approved.

murugapl and others added 30 commits August 14, 2025 14:59
When matching consent responses, it would be useful to see the submitted parent email,
as a way to double check it is not a spoof parent, by comparing to parents stored on patient in Mavis.
Without this normalisation, the merge would fail when the NHS number
had been typed including spaces or other whitespace. We can't use the
`normalizes` mechanism as that's only available on ActiveRecord models.

Jira-Issue: MAV-1814
Adds:
* LocalAuthority::Postcode model and DB migration
* has_one :local_authority_from_postcode relation to Location
* LocalAuthority.for_postcode(..) method, to find a matching LA for a given postcode
* download/import Mavis CLI tasks for the postcode -> LA mappings.

Note that the postcode mappings file is large - c450MB when unzipped - which meant
that the simplistic approach of reading the whole CSV file into RAM and parsing it to
an array was unsuitable in this case.

move normalize_postcode back inside the block
Update PDS::Patient.search to accept history and fuzzy parameters. This allows us to
run tailored queries for MAV-1415.
…on outcome

This implements the "cascading" search in MAV-1415. In the event an NHS number isn't found
through our default search, we try different PDS search options and return any uniques Nhs number we find.
Introduces a complete test suite for `ProcessPatientChangesetsJob` to verify the cascading search flow, job enquieing process and NHS number retrieval based on various search results.
Co-authored-by: Thomas Leese <thomas@leese.io>
Nurses and Healthcare Assistants (HCAs) found that the "donuts
and diamonds" significantly helped them understand what vaccination
method (e.g., nasal or injection) was needed for a particular child.

The icon will show up on the "Vaccination method" row and also on the
record vaccination page.

(cherry picked from commit 2389449)
…Concern, so it can be used for anything with an address_postcode
This will store the results from PDS searches done during a class or cohort import.
It will store the step name, NHS number retrieved if any and result (one match, too many etc).

We can use this to surface which step found the NHS number on a record to the user in the future.
This saves all the PDS searches performed and their results on the patient and import when committing the records.
This model was not covered by any tests directly.
This covers the case where the initial and all subsequent searches do not return results from PDS, so the patient should have multiple `pds_search_results`.
When previously a signle no_patient respponse from PDS was enough, we now need to stub the whole flow to return nothing or simply return the correct NHS number in the first request.
For data consistency, and to enable flaggind PDS info in the patient activity log, it would help to store any NHS numbers retrieved from the daily lookup job as well. This is unlikely to happen given that the dialy job is more restrictive than the import pds jobs. But int he event it does, we should have the info stored.
Currently, we store any import differences that need to be flagged for review by a user to `pending_changes`. These accumulate over susequent imports. Until we can make changes specific to an import, I have implemented it so that the last changeset on a patient is used to determine whether or not a patient matched an existing patient on NHS number at the time of upload. Of course, this isn't strictly correct as an old uplaod that caused pending changes ont he patient, might not have matched on NHS number if it was done a) before MAV-1788 was live and b) the duplicate was not reviewed.

However, we expect teams to clear out their import issues after every upload and we will ensure there are no pending changes before deploying this. So whether or not a patient matched on NHS number will be true.
…m only routable on non-production environments for now
This updates the methods used to help with testing CIS2 to make it clear
what their purpose is.

- `mock_cis2_auth` constructs a hash in the same format as CIS2 will
  give us based on some inputs.
- `cis2_sign_in` calls `mock_cis2_auth` and then performs the redirect
  to the callback so it's picked up by Mavis.
- `sign_in` converts the inputs in to valid arguments that can then be
  passed to `mock_cis2_auth`.
This adds a method to `User` and `CIS2Info` which can be used to
determine with a particular user has permission to administer a
vaccination without a prescription, meaning the vaccine was supplied by
a prescriber or nurse.

Jira-Issue: MAV-1365
This change adds a check at the beginning of the vaccination records sync command to verify that the `immunisations_fhir_api_integration` feature flag is enabled before initiating the sync operation.

Previously, the command claimed that the sync was successful, even though nothing had happened.
This part of the process isn't required, and if there have been any
errors with PDS then we simply treat them as lookup failures.
Add `can_administer_without_prescription?`
…thority-from-postcode

Add inference of patient local authority from postcode
Add /api/reporting controllers, config and tests
It's not being used anywhere so it can be safely removed.

Jira-Issue: MAV-1818
This replaces the foreign key association between Gillick assessments
and patient sessions to instead link directly to the patient and the
session (via the date). This is needed as we eventually want to replace
the `PatientSession` model and to do that we need to make sure all
foreign keys to it have been replaced.

The functionality should be the same before and after, actually slightly
improved as Gillick assessment is only supposed to exist on the day it
happened, so now we link directly to the session date rather than the
overall session.

Jira-Issue: MAV-1818
…n-foreign-key

Replace Gillick assessment patient session foreign key
Add parent details to consent summary
Do not allow "keep both records" when match is on NHS number
misaka and others added 22 commits August 28, 2025 13:33
Sidekiq will automatically retry these jobs for us if we let it receive
the error.
Re-raise TooManyRequestsError from PDS
The GithubDeployDataReplicationInfrastructure role has an explicit Deny in the policy for all tagged resources which prevents taking DB snapshots

Jira-Issue: MAV-1864
Bumps [aws-sdk-ec2](https://github.com/aws/aws-sdk-ruby) from 1.552.0 to 1.553.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-ec2/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-ec2
  dependency-version: 1.553.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [aws-sdk-rds](https://github.com/aws/aws-sdk-ruby) from 1.289.0 to 1.290.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-rds/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-rds
  dependency-version: 1.290.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [solargraph-rails](https://github.com/iftheshoefritz/solargraph-rails) from 1.2.0 to 1.2.2.
- [Changelog](https://github.com/iftheshoefritz/solargraph-rails/blob/main/CHANGELOG.md)
- [Commits](iftheshoefritz/solargraph-rails@v1.2.0...v1.2.2)

---
updated-dependencies:
- dependency-name: solargraph-rails
  dependency-version: 1.2.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [annotaterb](https://github.com/drwl/annotaterb) from 4.18.0 to 4.19.0.
- [Changelog](https://github.com/drwl/annotaterb/blob/main/CHANGELOG.md)
- [Commits](drwl/annotaterb@v4.18.0...v4.19.0)

---
updated-dependencies:
- dependency-name: annotaterb
  dependency-version: 4.19.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [aws-sdk-ecr](https://github.com/aws/aws-sdk-ruby) from 1.109.0 to 1.110.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-ecr/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-ecr
  dependency-version: 1.110.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
These environments are used for testing and can often be broken, and by
sending errors to Sentry it makes Sentry harder to use for production as
it includes lots of noise to filter through.
On-demand DB snapshot for data replication environment
Also add extra unit test to cover this case
With the new background process where PDS checks are performed, we're
seeing a problem where if any of the PDS checks fail due to a 429 error,
the users see an unexpected error page because we catch the error
expecting Sidekiq to re-process it. However, if the user uploads a file
that is smaller than 15 rows we currently process it synchronously
meaning we can't take advantage of the retry behaviour in the job.

Rather than trying to make the synchronous process work well with
retries, it seems simpler to make all imports run in the background,
especially since in practice the vast majority of files are larger than
15 rows.
Always run imports in the background
This improves how the feature tests wait for imports to finish by
introducing a method, `wait_for_import_to_complete`, which can be used
after uploading a file to ensure that all the related jobs have
processed before moving on to the other parts of the test.

I've also removed the slow cohort import as that was designed to test
the background processing, but now all imports are processed in the
background so this saves a bit of time running the tests.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@thomasleese thomasleese marked this pull request as ready for review August 29, 2025 14:05
@thomasleese thomasleese requested review from a team as code owners August 29, 2025 14:05
@thomasleese thomasleese enabled auto-merge August 29, 2025 14:10
@thomasleese thomasleese merged commit 20fe030 into main Aug 29, 2025
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants