Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation-patient-nhs-number #588

Open
wants to merge 6 commits into
base: live
Choose a base branch
from
Open

Conversation

eatyourpeas
Copy link
Member

Add validation in the clean method to the patient form

  • if nhs_number is present, check if does not already exists
  • if urn is present, check if does not already exist
    already exists

In both of these circumstances it raises a validation error.

this now breaks most of the tests because it causes an async error

Other things:

  1. fix for the headers in the patient table. Reorganises the filtering so that those patients that have not completed a full year or died now come at the bottom and have a dark blue header
  2. fix the hovertext console non-critical error relating to pyplot
  3. reorganise the deprivation colours so that pink and red are deprived, blue and green are not

@eatyourpeas
Copy link
Member Author

@mbarton not sure if this is going to work if we validate in this way? In this PR I have added ValidationErrors for existing NHS Numbers or URN. This works fine in the questionnaire but now breaks the CSV upload with an async error the fails in this new validation step. Is it that it thinks each row is a new patient, even through it is only the visit that is new?

@mbarton
Copy link
Member

mbarton commented Feb 11, 2025

Ah i see. The error is just that you can’t use sync database calls in an async function. Django mandates this to avoid inadvertent blocking.

We could maybe do some sync_to_async wrapping as we have elsewhere. But I’m wondering if it’s better just to get on and implement Celery. With multiple workers we would not need async at all.

@eatyourpeas
Copy link
Member Author

I agree - do you want to pair on it on Thursday? I added aexists in the form as an experiment and it worked except then it broke further down as nhs_number was now missing from cleaned_data.

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.

2 participants