Skip to content

Conversation

thomasleese
Copy link
Contributor

@thomasleese thomasleese commented Apr 4, 2025

This makes quite a significant refactor to the way we do error handling and validation when importing CSV files, which has no user-facing changes, but allows us to make further enhancements in the future.

Specifically, we can now link errors to specific columns and reference their row, column and cell (e.g. A1) in the error messages. There's no design for this at the moment, but if we want to we could build this easily now.

It also allows us to easily support different column names while making sure that the user is presented with the column name they uploaded, for example NHS Number vs nhs-number.

There's definitely scope for further refactoring and enhancements, but this PR was already big enough:

  • Standardise our error message content design
  • Reduce duplication of our error messages
  • Remove duplicate error messages on :base for each row
  • Display the cell reference on each error message, for example NHS_NUMBER (A1).

@thomasleese thomasleese added the refactor Improving maintainability label Apr 4, 2025
@thomasleese thomasleese added this to the v2.2.0 milestone Apr 4, 2025
@thomasleese thomasleese marked this pull request as ready for review April 7, 2025 07:30
@thomasleese thomasleese force-pushed the csv-parser-field branch 2 times, most recently from 1b4aad1 to 8503e8e Compare April 8, 2025 09:36
Base automatically changed from csv-parser-field to main April 8, 2025 11:56
This updates the validators to support passing a `nil` value, with
`allow_blank` set and accept that `nil` is a blank value and therefore
don't raise a validation error.
This refactors the validations in preparation for updating the error
handling to present the user with the original header and the cell that
was that invalid.
This renames it to `REASONS_NOT_ADMINISTERED` to make it clear what the
reason is referring to.
This refactors the validations in preparation for updating the error
handling to present the user with the original header and the cell that
was that invalid.
This updates the error handling on the class and cohort imports to use
the header values that were provided by the user in the CSV file to
ensure that what we're showing to the user matches exactly what they
uploaded.
This updates the error handling on the immunisation imports to use
the header values that were provided by the user in the CSV file to
ensure that what we're showing to the user matches exactly what they
uploaded.
@tvararu tvararu temporarily deployed to mavis-pr-3325 April 8, 2025 12:11 Inactive
Copy link

sonarqubecloud bot commented Apr 8, 2025

@thomasleese thomasleese merged commit 7246ece into main Apr 8, 2025
14 checks passed
@thomasleese thomasleese deleted the csv-parser-errors branch April 8, 2025 12:33
thomasleese added a commit that referenced this pull request Apr 8, 2025
This updates the import process to allow users to upload a file in the
SystmOne format which has a different set of fields to the existing
format. We haven't got a real example of this type of file for testing,
so this is a best guess at how the format should be parsed.

We haven't updated any parts of the UI in this change, we might want to
do this in a follow up PR to describe the two different formats.

To build this, the import mechanism required a substantial refactor,
which is covered by:

- #3312
- #3317
- #3318
- #3325
- #3326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improving maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants