Skip to content

Commit ecf46b0

Browse files
authored
Merge pull request #156 from NHSDigital/dev/NPA-4514_Status_Codes
NPA-4514 Update POST /FHIR/R4/Consent Status Codes
2 parents 8ce0c48 + 5aec0d3 commit ecf46b0

File tree

8 files changed

+58
-116
lines changed

8 files changed

+58
-116
lines changed

sandbox/api/app.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
RELATED__VERIFY_RELATIONSHIP_25_WITH_INCLUDE,
1414
POST_CONSENT__SUCCESS,
1515
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR,
16-
POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR,
17-
POST_CONSENT__INVALID_EVIDENCE_ERROR,
18-
POST_CONSENT__INVALID_PATIENT_AGE_ERROR,
1916
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR,
2017
)
2118
from .get_consent import get_consent_response
@@ -148,26 +145,12 @@ def post_consent() -> Union[dict, tuple]:
148145
header = {"location": f"{APP_BASE_PATH}/{patient_identifier}"}
149146
response = generate_response_from_example(POST_CONSENT__SUCCESS, 201, headers=header)
150147

151-
# Invalid access level
152-
elif patient_identifier == "9000000025":
153-
response = generate_response_from_example(POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 403)
154-
155-
# Missing required evidence
156-
elif patient_identifier == "9000000033":
157-
response = generate_response_from_example(POST_CONSENT__INVALID_EVIDENCE_ERROR, 422)
158-
159-
# Patient age validation failure
160-
elif patient_identifier == "9000000041":
161-
response = generate_response_from_example(POST_CONSENT__INVALID_PATIENT_AGE_ERROR, 422)
162-
163148
# Duplicate relationship
164149
elif patient_identifier == "9000000049":
165150
response = generate_response_from_example(POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409)
166-
167151
# Invalid performer NHS number
168152
elif patient_identifier == "9000000000":
169153
response = generate_response_from_example(POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422)
170-
171154
else:
172155
# Out of scope errors
173156
raise ValueError("Invalid Request")

sandbox/api/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
5252
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"
5353
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR = f"{POST_CONSENT__DIRECTORY}errors/duplicate_relationship_error.yaml"
54-
POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR = f"{POST_CONSENT__DIRECTORY}errors/invalid_access_level_error.yaml"
55-
POST_CONSENT__INVALID_EVIDENCE_ERROR = f"{POST_CONSENT__DIRECTORY}errors/invalid_evidence_error.yaml"
56-
POST_CONSENT__INVALID_PATIENT_AGE_ERROR = f"{POST_CONSENT__DIRECTORY}errors/invalid_patient_age_error.yaml"
5754
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR = f"{POST_CONSENT__DIRECTORY}errors/invalid_performer_identifier_error.yaml"
5855

5956
QR_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"

sandbox/api/tests/test_app.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
from sandbox.api.constants import (
88
POST_CONSENT__SUCCESS,
99
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR,
10-
POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR,
11-
POST_CONSENT__INVALID_EVIDENCE_ERROR,
12-
POST_CONSENT__INVALID_PATIENT_AGE_ERROR,
1310
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR,
1411
)
1512

@@ -203,9 +200,6 @@ def test_get_consent(
203200
),
204201
("9000000000", POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422, None),
205202
("9000000049", POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409, None),
206-
("9000000041", POST_CONSENT__INVALID_PATIENT_AGE_ERROR, 422, None),
207-
("9000000033", POST_CONSENT__INVALID_EVIDENCE_ERROR, 422, None),
208-
("9000000025", POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 403, None),
209203
],
210204
)
211205
@patch(f"{APP_FILE_PATH}.generate_response_from_example")

specification/examples/responses/POST_Consent/errors/invalid_access_level_error.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

specification/examples/responses/POST_Consent/errors/invalid_evidence_error.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

specification/examples/responses/POST_Consent/errors/invalid_patient_age_error.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
PostConsentInvalidPerformerIdentifierError:
22
summary: Bad request performer identifier invalid
3-
description: 400 error response bundle for an invalid performer NHS number
3+
description: Error response bundle for an invalid performer NHS number
44
value:
55
issue:
66
- code: invalid
7-
diagnostics: "Performer identifier is not a valid NHS number."
7+
diagnostics: "Not a valid NHS Number provided for the Performer identifier parameter"
88
details:
99
coding:
10-
- code: "INVALID_NHS_NUMBER"
11-
display: "Performer identifier is invalid."
12-
system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
13-
version: '1'
10+
- system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
11+
version: "1"
12+
code: "INVALID_IDENTIFIER"
13+
display: "Provided value is invalid"
1414
severity: error
15-
resourceType: "OperationOutcome"
15+
resourceType: "OperationOutcome"

specification/validated-relationships-service-api.yaml

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
openapi: "3.0.0"
44
info:
55
title: "Validated Relationships Service API"
6-
version: "1.3.2"
6+
version: "1.3.3"
77
description: |
88
## Overview
99
Use this API to access the Validated Relationships Service - the national electronic database of relationships
@@ -503,15 +503,12 @@ paths:
503503
The sandbox supports a limited number of scenarios, and does not attempt to validate requests. The returned result is dependant on the `performer.identifier.value`.
504504
505505
See the postman collection for an example request body.
506-
| Scenario | Request | Response |
507-
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
508-
| Successful parent-child proxy creation | Valid request with a legal basis of parental responsibility, with performer identifier value of 9000000009 | HTTP Status 201 and OperationOutcome response |
509-
| Successful adult-adult proxy creation | Valid request with legal basis of consent, with performer identifier value of 9000000017 | HTTP Status 201 and OperationOutcome response |
510-
| Invalid access level | Request with undefined access level code, with performer identifier value of 9000000025 | HTTP Status 403 and INVALID_ACCESS_LEVEL error response |
511-
| Invalid performer NHS number | Request with invalid NHS number format, with performer identifier value of 9000000000 | HTTP Status 422 and INVALID_NHS_NUMBER error response |
512-
| Missing required evidence | Request without evidence of responsibility, with performer identifier value of 9000000033 | HTTP Status 422 and MISSING_EVIDENCE error response |
513-
| Patient age validation failure | Request for child proxy where child is over 16, with performer identifier value of 9000000041 | HTTP Status 422 and INVALID_PATIENT_AGE error response |
514-
| Duplicate relationship | Request for relationship that already exists, with performer identifier value of 9000000049 | HTTP Status 409 and DUPLICATE_RELATIONSHIP error response |
506+
| Scenario | Request | Response |
507+
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
508+
| Successful parent-child proxy creation | Valid request with a legal basis of parental responsibility, with performer identifier value of 9000000009 | HTTP Status 201 and OperationOutcome response |
509+
| Successful adult-adult proxy creation | Valid request with legal basis of consent, with performer identifier value of 9000000017 | HTTP Status 201 and OperationOutcome response |
510+
| Invalid performer NHS number | Request with invalid NHS number format, with performer identifier value of 9000000000 | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response |
511+
| Duplicate relationship | Request for relationship that already exists, with performer identifier value of 9000000049 | HTTP Status 409 and DUPLICATE_RELATIONSHIP error response |
515512
516513
operationId: create-proxy-role
517514
parameters:
@@ -551,15 +548,23 @@ paths:
551548
552549
| HTTP status | Error code | Description |
553550
| ----------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
551+
| 400 | `MISSING_IDENTIFIER` | Missing performer or patient identifier. For details, see the `diagnostics` field. |
552+
| 400 | `MISSING_STATUS` | Missing status. |
553+
| 400 | `MISSING_SCOPE` | Missing scope. |
554+
| 400 | `MISSING_CATEGORY` | Missing category. |
555+
| 400 | `MISSING_DATETIME` | Missing datetime. |
554556
| 401 | `ACCESS_DENIED` | Missing or invalid OAuth 2.0 bearer token in request. |
555557
| 403 | `FORBIDDEN` | Access denied to resource. |
556-
| 403 | `INVALID_ACCESS_LEVEL` | Invalid authorisation access level |
557558
| 404 | `INVALIDATED_RESOURCE` | Resource that has been marked as invalid was requested - invalid resources cannot be retrieved |
559+
| 405 | `METHOD_NOT_ALLOWED` | The method is not allowed. |
558560
| 408 | `TIMEOUT` | Request timed out. |
559561
| 409 | `DUPLICATE_RELATIONSHIP` | Conflict with requested proxy role. |
560-
| 422 | `INVALID_NHS_NUMBER` | Invalid NHS number. |
561-
| 422 | `INVALID_PATIENT_AGE` | Patient age is invalid. |
562-
| 422 | `MISSING_EVIDENCE` | Evidence of responsibility is missing. |
562+
| 422 | `INVALID_IDENTIFIER` | Invalid performer or patient identifier. For details, see the `diagnostics` field. |
563+
| 422 | `INVALID_STATUS` | Invalid status. |
564+
| 422 | `INVALID_SCOPE` | Invalid scope. |
565+
| 422 | `INVALID_CATEGORY` | Invalid category. |
566+
| 422 | `INVALID_DATETIME` | Invalid datetime. |
567+
| 422 | `INVALID_PROVISION` | Invalid provision. |
563568
| 429 | `THROTTLED` | You have exceeded your application's [rate limit](https://digital.nhs.uk/developer/guides-and-documentation/reference-guide#rate-limits). |
564569
565570
content:
@@ -569,12 +574,6 @@ paths:
569574
examples:
570575
postConsentInvalidPerformerIdentifier:
571576
$ref: "./examples/responses/POST_Consent/errors/invalid_performer_identifier_error.yaml#/PostConsentInvalidPerformerIdentifierError"
572-
postConsentInvalidAccessLevel:
573-
$ref: "./examples/responses/POST_Consent/errors/invalid_access_level_error.yaml#/PostConsentInvalidAccessLevelError"
574-
postConsentMissingEvidence:
575-
$ref: "./examples/responses/POST_Consent/errors/invalid_evidence_error.yaml#/PostConsentInvalidEvidenceError"
576-
postConsentInvalidPatientAge:
577-
$ref: "./examples/responses/POST_Consent/errors/invalid_patient_age_error.yaml#/PostConsentInvalidPatientAgeError"
578577
postConsentDuplicateRelationship:
579578
$ref: "./examples/responses/POST_Consent/errors/duplicate_relationship_error.yaml#/PostConsentDuplicateRelationshipError"
580579
"5XX":
@@ -707,7 +706,6 @@ paths:
707706
patchConsentInvalidStateTransitionError:
708707
$ref: "./examples/responses/PATCH_Consent/error.yaml#/PatchConsentInvalidStateTransitionError"
709708

710-
711709
components:
712710
schemas:
713711
QuestionnaireResponse:
@@ -1073,7 +1071,17 @@ components:
10731071
display:
10741072
type: string
10751073
description: Evidence of responsibility type.
1076-
enum: ['Birth certificate', 'Adoption certificate', 'Court-witnessed parental responsibility agreement','Court-witnessed step-parent parental responsibility agreement', 'Parental order', 'Special guardianship order', 'Other court order', 'Other' ]
1074+
enum:
1075+
[
1076+
"Birth certificate",
1077+
"Adoption certificate",
1078+
"Court-witnessed parental responsibility agreement",
1079+
"Court-witnessed step-parent parental responsibility agreement",
1080+
"Parental order",
1081+
"Special guardianship order",
1082+
"Other court order",
1083+
"Other",
1084+
]
10771085

10781086
- type: object
10791087
properties:
@@ -1717,7 +1725,7 @@ components:
17171725
enum:
17181726
[
17191727
"https://fhir.nhs.uk/Id/nhs-number",
1720-
"https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier"
1728+
"https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier",
17211729
]
17221730
value:
17231731
type: string
@@ -1801,7 +1809,7 @@ components:
18011809
enum:
18021810
[
18031811
"https://fhir.nhs.uk/Id/nhs-number",
1804-
"https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier"
1812+
"https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier",
18051813
]
18061814
value:
18071815
type: string
@@ -1930,27 +1938,33 @@ components:
19301938
items:
19311939
$ref: "#/components/schemas/Reference"
19321940
description: "Individuals or organizations that agreed to the consent."
1933-
verification:
1941+
provision:
19341942
type: array
1935-
description: Whether consent was verified with the patient, or another authorized person.
1943+
maxItems: 1
19361944
items:
1937-
type: object
1938-
properties:
1939-
verified:
1940-
type: boolean
1941-
description: Whether the consent has been verified
1942-
verifiedWith:
1943-
$ref: "#/components/schemas/Reference"
1944-
verificationDate:
1945-
type: string
1946-
description: The date and time when consent was collected.
1947-
format: date-time
1945+
$ref: "#/components/schemas/Provision"
19481946
extension:
19491947
type: array
19501948
description: Model the status reason.
19511949
items:
19521950
$ref: "#/components/schemas/Extension"
19531951

1952+
Provision:
1953+
type: object
1954+
properties:
1955+
period:
1956+
type: object
1957+
description: "Timeframe for this provision."
1958+
properties:
1959+
start:
1960+
type: string
1961+
description: "Starting time with inclusive boundary"
1962+
format: date-time
1963+
end:
1964+
type: string
1965+
description: "End time with inclusive boundary, if not ongoing"
1966+
format: date-time
1967+
19541968
Extension:
19551969
type: object
19561970
properties:
@@ -1962,7 +1976,6 @@ components:
19621976
items:
19631977
$ref: "#/components/schemas/CodeableConcept"
19641978

1965-
19661979
OperationOutcome:
19671980
type: object
19681981
description: |

0 commit comments

Comments
 (0)