Skip to content

Commit 4029062

Browse files
committed
Revert "VED-980 Increased given name length constraint (#1102)"
Not cleared for release due to need to run past Clinical Safety colleagues :@?!*** This reverts commit da273a6.
1 parent 5e22d5d commit 4029062

3 files changed

Lines changed: 11 additions & 20 deletions

File tree

lambdas/shared/src/common/models/constants.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,10 @@ class Constants:
4848

4949
ALLOWED_CONTAINED_RESOURCES = {"Practitioner", "Patient"}
5050

51-
# As per Personal Demographics Service (PDS) FHIR API, the maximum length of a family name is 35 characters:
51+
# As per Personal Demographics Service FHIR API, the maximum length of a given name element or surname is 35 chars.
52+
# Given name is a list with a maximum 5 elements. For more info see:
5253
# https://digital.nhs.uk/developer/api-catalogue/personal-demographics-service-fhir#post-/Patient
53-
FAMILY_NAME_MAX_LENGTH = 35
54-
55-
# VED-980 The PDS constraint is that the given name list entry has a maximum of 5 entries and each item may be a
56-
# maximum of 35 characters. Due to batch limitations, all entries are concatenated into one string. Therefore, the
57-
# Imms FHIR API team agreed to use a more lenient figure given the nature of data flows we handle. i.e 5 * 35 +
58-
# some extra wriggle room i.e. spaces between.
59-
GIVEN_NAME_ELEMENT_MAX_LENGTH = 180
54+
PERSON_NAME_ELEMENT_MAX_LENGTH = 35
6055

6156
COMPLETED_STATUS = "completed"
6257
REINSTATED_RECORD_STATUS = "reinstated"

lambdas/shared/src/common/models/fhir_immunization_pre_validators.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ def pre_validate_patient_name(self, values: dict) -> None:
301301
def pre_validate_patient_name_given(self, values: dict) -> None:
302302
"""
303303
Pre-validate that, if contained[?(@.resourceType=='Patient')].name[{index}].given index dynamically determined
304-
(legacy CSV field name:PERSON_FORENAME) exists, then it is an array containing a maximum of 5 items an no items
305-
may exceed the GIVEN_NAME_ELEMENT_MAX_LENGTH value
304+
(legacy CSV field name:PERSON_FORENAME) exists, then it is an array containing a single non-empty string
306305
"""
307306
field_location = patient_name_given_field_location(values)
308307

@@ -313,21 +312,21 @@ def pre_validate_patient_name_given(self, values: dict) -> None:
313312
field_location,
314313
elements_are_strings=True,
315314
max_length=5,
316-
string_element_max_length=Constants.GIVEN_NAME_ELEMENT_MAX_LENGTH,
315+
string_element_max_length=Constants.PERSON_NAME_ELEMENT_MAX_LENGTH,
317316
)
318317
except (KeyError, IndexError, AttributeError):
319318
pass
320319

321320
def pre_validate_patient_name_family(self, values: dict) -> None:
322321
"""
323322
Pre-validate that, if a contained[?(@.resourceType=='Patient')].name[{index}].family (legacy CSV field name:
324-
PERSON_SURNAME) exists, index dynamically determined then it is a non-empty string no longer than the
325-
FAMILY_NAME_MAX_LENGTH value
323+
PERSON_SURNAME) exists, index dynamically determined then it is a non-empty string of maximum length
324+
35 characters
326325
"""
327326
field_location = patient_name_family_field_location(values)
328327
try:
329328
field_value, _ = patient_and_practitioner_value_and_index(values, "family", "Patient")
330-
PreValidation.for_string(field_value, field_location, max_length=Constants.FAMILY_NAME_MAX_LENGTH)
329+
PreValidation.for_string(field_value, field_location, max_length=Constants.PERSON_NAME_ELEMENT_MAX_LENGTH)
331330
except (KeyError, IndexError, AttributeError):
332331
pass
333332

lambdas/shared/tests/test_common/test_immunization_pre_validator.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,8 @@ def test_pre_validate_patient_name_given_rejects_invalid_input(self):
504504
"contained[?(@.resourceType=='Patient')].name[0].given must be an array of maximum length 5",
505505
),
506506
(
507-
[
508-
"Stringtoolongtoolongtoolongtoolongt Stringtoolongtoolongtoolongtoolongt Stringtoolongtoolongtoolongto"
509-
"olongt Stringtoolongtoolongtoolongtoolongt Stringtoolongtoolongtoolongtoolongt Oops"
510-
],
511-
"contained[?(@.resourceType=='Patient')].name[0].given[0] must be 180 or fewer characters",
507+
["Stringtoolongeruti olgkriahfyrtoiuhg"],
508+
"contained[?(@.resourceType=='Patient')].name[0].given[0] must be 35 or fewer characters",
512509
),
513510
]
514511

@@ -549,7 +546,7 @@ def test_pre_validate_patient_name_family(self):
549546
self,
550547
field_location=patient_name_family_field_location(valid_json_data),
551548
valid_strings_to_test=["test", "Quitelongsurname", "Surnamewithjustthirtyfivecharacters"],
552-
max_length=Constants.FAMILY_NAME_MAX_LENGTH,
549+
max_length=Constants.PERSON_NAME_ELEMENT_MAX_LENGTH,
553550
invalid_length_strings_to_test=["Surnamethathasgotthirtysixcharacters"],
554551
)
555552

0 commit comments

Comments
 (0)