Skip to content

Commit a32e60a

Browse files
NPA-4707: Added error for patient identifier
1 parent 207de29 commit a32e60a

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

sandbox/api/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
RELATED__ERROR_IDENTIFIER_MISSING = f"{RELATED_DIRECTORY}errors/invalid-identifier-missing.yaml"
9393
RELATED__ERROR_IDENTIFIER_SYSTEM = f"{RELATED_DIRECTORY}errors/invalid-identifier-system.yaml"
9494
RELATED__ERROR_IDENTIFIER = f"{RELATED_DIRECTORY}errors/invalid-identifier.yaml"
95+
RELATED__ERROR_PATIENT_IDENTIFIER = f"{RELATED_DIRECTORY}errors/invalid-patient-identifier.yaml"
9596
RELATED__EMPTY_RESPONSE = f"{RELATED_DIRECTORY}empty_response.yaml"
9697
RELATED__LIST_RELATIONSHIP = f"{RELATED_DIRECTORY}list_relationship_9000000017.yaml"
9798
RELATED__LIST_RELATIONSHIP_WITH_INCLUDE = f"{RELATED_DIRECTORY}list_relationship_9000000017_include.yaml"

sandbox/api/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
RELATED__ERROR_IDENTIFIER_MISSING,
2121
RELATED__ERROR_IDENTIFIER_SYSTEM,
2222
RELATED_IDENTIFIERS,
23+
RELATED__ERROR_PATIENT_IDENTIFIER,
2324
)
2425

2526
FHIR_MIMETYPE = "application/fhir+json"
@@ -51,6 +52,9 @@ def check_for_get_related_person_errors(request: Request) -> Optional[tuple]:
5152
elif identifier and len(identifier_without_system) != 10:
5253
# invalid identifier
5354
return generate_response_from_example(RELATED__ERROR_IDENTIFIER, 400)
55+
elif patient and len(patient_without_system) != 10:
56+
# invalid patient identifier
57+
return generate_response_from_example(RELATED__ERROR_PATIENT_IDENTIFIER, 400)
5458
elif (
5559
isinstance(identifier, str)
5660
and "|" in identifier
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
InvalidIdentifierPatientError:
2+
summary: Invalid Patient identifier
3+
description: Error raised due to an invalid Patient identifier request parameter being specified.
4+
value:
5+
issue:
6+
- code: invalid
7+
diagnostics: "Not a valid NHS Number provided for the 'patient:identifier' parameter"
8+
details:
9+
coding:
10+
- "system": "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
11+
version: "1"
12+
code: "INVALID_PATIENT_IDENTIFIER_VALUE"
13+
display: "Provided value is invalid"
14+
severity: error
15+
resourceType: "OperationOutcome"

0 commit comments

Comments
 (0)