VED-872 Tighten given name validation#915
Conversation
|
This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket: VED-872 |
| if len(field_value) == 0: | ||
| raise ValueError(f"{field_location} must be a non-empty array") | ||
|
|
||
| if max_length: |
There was a problem hiding this comment.
This needs to be used carefully by us. Can add a docstring if you think useful, but when using this method you need to ensure you either use defined_length OR max_length. Though the code won't blow up, it does not really make sense to use both together, but nothing prevents you doing so.
| ([], "contained[?(@.resourceType=='Patient')].name[0].given must be a non-empty array"), | ||
| ([""], "contained[?(@.resourceType=='Patient')].name[0].given[0] must be a non-empty string"), | ||
| ([" \n"], "contained[?(@.resourceType=='Patient')].name[0].given[0] must be a non-empty string"), | ||
| (["Test", " "], "contained[?(@.resourceType=='Patient')].name[0].given[1] must be a non-empty string"), |
There was a problem hiding this comment.
Need to run past Krupa & Fatima. Have made a minor adjustment to the error message so that, when the error is to do with the element within the list, then we flag the index of the item with the problem.
|



Summary
Patient given name validation has been tightened up to align with PDS FHIR API validation. https://digital.nhs.uk/developer/api-catalogue/personal-demographics-service-fhir#post-/Patient
Namely:
By extension, the Practitioner given name also now is checked to ensure it is not a whitespace string. However, no further validation to do with the length is applied.
Check with testers: this change makes the given name validation error more specific by flagging which item in the array had an issue. Hopefully this is acceptable but needs checking and e2e tests may need updating accordingly.
Reviews Required
Review Checklist
ℹ️ This section is to be filled in by the reviewer.