Skip to content

Commit 0750f0b

Browse files
committed
NPA-5191: Update POST QuestionnaireResponse DUPLICATE_RELATIONSHIP
1 parent 6d7ca04 commit 0750f0b

File tree

4 files changed

+103
-15
lines changed

4 files changed

+103
-15
lines changed

postman/Validate Relationship Service Sandbox.postman_collection.json

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,73 @@
578578
},
579579
"response": []
580580
},
581+
{
582+
"name": "Duplicate relationship",
583+
"event": [
584+
{
585+
"listen": "test",
586+
"script": {
587+
"exec": [
588+
"const expectedResponseBody = {",
589+
" \"issue\": [",
590+
" {",
591+
" \"code\": \"invalid\",",
592+
" \"diagnostics\": \"Proxy role already exists.\",",
593+
" \"details\": {",
594+
" \"coding\": [",
595+
" {",
596+
" \"code\": \"DUPLICATE_RELATIONSHIP\",",
597+
" \"display\": \"Request must be for a new proxy role.\",",
598+
" \"system\": \"https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode\",",
599+
" \"version\": \"1\"",
600+
" }",
601+
" ]",
602+
" },",
603+
" \"severity\": \"error\"",
604+
" }",
605+
" ],",
606+
" \"resourceType\": \"OperationOutcome\"",
607+
"}",
608+
"",
609+
"pm.test(\"Status code is 409\", function () {",
610+
" pm.response.to.have.status(409);",
611+
"});",
612+
"",
613+
"pm.test(\"Should have correct response body\", () => {",
614+
" var responseJson = pm.response.json();",
615+
" pm.expect(responseJson).to.eql(expectedResponseBody);",
616+
"});",
617+
""
618+
],
619+
"type": "text/javascript",
620+
"packages": {}
621+
}
622+
}
623+
],
624+
"request": {
625+
"method": "POST",
626+
"header": [],
627+
"body": {
628+
"mode": "raw",
629+
"raw": "{\n \"resourceType\": \"QuestionnaireResponse\",\n \"status\": \"completed\",\n \"authored\": \"2024-07-15T09:43:03.280Z\",\n \"source\": {\n \"type\": \"RelatedPerson\",\n \"identifier\": {\n \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",\n \"value\": \"9000000049\"\n }\n },\n \"subject\": {\n \"type\": \"Patient\",\n \"identifier\": {\n \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",\n \"value\": \"9000000006\"\n }\n },\n \"questionnaire\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Questionnaire/01dc6813-3421-4d14-948d-a4888241add1\",\n \"item\": [\n {\n \"linkId\": \"relatedPerson\",\n \"text\": \"Proxy details\",\n \"item\": [\n {\n \"linkId\": \"relatedPerson_identifier\",\n \"text\": \"NHS number\",\n \"answer\": [\n {\n \"valueString\": \"9000000049\"\n }\n ]\n },\n {\n \"linkId\": \"relatedPerson_basisForAccess\",\n \"text\": \"Basis for Access\",\n \"answer\": [\n {\n \"valueCoding\": {\n \"system\": \"https://fhir.hl7.org.uk/CodeSystem/UKCore-AdditionalPersonRelationshipRole\",\n \"code\": \"Personal\",\n \"display\": \"Personal relationship with the patient\"\n }\n }\n ]\n },\n {\n \"linkId\": \"relatedPerson_relationship\",\n \"text\": \"Relationship\",\n \"answer\": [\n {\n \"valueCoding\": {\n \"system\": \"http://terminology.hl7.org/CodeSystem/v3-RoleCode\",\n \"code\": \"SPS\",\n \"display\": \"Spouse\"\n }\n }\n ]\n }\n ]\n },\n {\n \"linkId\": \"patient\",\n \"text\": \"Patient details\",\n \"item\": [\n {\n \"linkId\": \"patient_identifier\",\n \"text\": \"NHS number\",\n \"answer\": [\n {\n \"valueString\": \"9000000006\"\n }\n ]\n },\n {\n \"linkId\": \"patient_name\",\n \"text\": \"Name\",\n \"item\": [\n {\n \"linkId\": \"patient_name_first\",\n \"text\": \"First name\",\n \"answer\": [\n {\n \"valueString\": \"Jill\"\n }\n ]\n },\n {\n \"linkId\": \"patient_name_family\",\n \"text\": \"Last name\",\n \"answer\": [\n {\n \"valueString\": \"Jones\"\n }\n ]\n }\n ]\n },\n {\n \"linkId\": \"patient_birthDate\",\n \"text\": \"Date of birth\",\n \"answer\": [\n {\n \"valueDate\": \"1965-01-01\"\n }\n ]\n }\n ]\n },\n {\n \"linkId\": \"requestedAccess\",\n \"text\": \"Requested access\",\n \"item\": [\n {\n \"linkId\": \"requestedAccess_accessLevel\",\n \"text\": \"Requested access level\",\n \"answer\": [\n {\n \"valueCoding\": {\n \"system\": \"https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-RequestedAccess\",\n \"code\": \"APPT\",\n \"display\": \"Appointment Booking\"\n }\n },\n {\n \"valueCoding\": {\n \"system\": \"https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-RequestedAccess\",\n \"code\": \"VACC\",\n \"display\": \"Vaccination Records\"\n }\n }\n ]\n },\n {\n \"linkId\": \"requestedAccess_reasonsForAccess\",\n \"text\": \"Reason for access\",\n \"answer\": [\n {\n \"valueCoding\": {\n \"system\": \"https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-ReasonForAccess\",\n \"code\": \"PRAC\",\n \"display\": \"Practical Reasons\"\n }\n }\n ]\n }\n ]\n }\n ]\n}",
630+
"options": {
631+
"raw": {
632+
"language": "json"
633+
}
634+
}
635+
},
636+
"url": {
637+
"raw": "{{api_base_url}}/QuestionnaireResponse",
638+
"host": [
639+
"{{api_base_url}}"
640+
],
641+
"path": [
642+
"QuestionnaireResponse"
643+
]
644+
}
645+
},
646+
"response": []
647+
},
581648
{
582649
"name": "Adult to adult without ability to consent access request",
583650
"event": [
@@ -10183,4 +10250,4 @@
1018310250
"type": "string"
1018410251
}
1018510252
]
10186-
}
10253+
}

sandbox/api/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
# POST QuestionnaireResponse
9494
POST_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"
9595
POST_QUESTIONNAIRE_RESPONSE__SUCCESS = f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
96+
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR = f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/duplicate_relationship_error.yaml"
9697

9798
# GET QuestionnaireResponse
9899
GET_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/GET_QuestionnaireResponse/"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PostQuestionnaireResponseDuplicateRelationshipError:
2+
summary: Duplicate request for proxy role that already exists
3+
description: Error response for a duplicate proxy role
4+
value:
5+
issue:
6+
- code: invalid
7+
diagnostics: "Proxy role already exists."
8+
details:
9+
coding:
10+
- code: "DUPLICATE_RELATIONSHIP"
11+
display: "Request must be for a new proxy role."
12+
system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
13+
version: '1'
14+
severity: error
15+
resourceType: "OperationOutcome"

specification/validated-relationships-service-api.yaml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ paths:
187187
188188
## Sandbox test scenarios
189189
190-
| Scenario | Request | Response |
191-
| --------------- | ----------------------------------------------- | -------------------------------- |
192-
| Example request | Example questionnaire response from try it now | HTTP Status 200 Success response |
190+
| Scenario | Request | Response |
191+
| ---------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
192+
| Example request | Example questionnaire response from try it now | HTTP Status 200 Success response |
193+
| Duplicate relationship | Request for relationship that already exists, with performer identifier value of 9000000049 | HTTP Status 409 and DUPLICATE_RELATIONSHIP error response |
194+
193195
194196
### Sandbox constraints
195197
- Questionnaire Response is not validated.
@@ -244,17 +246,18 @@ paths:
244246
description: |
245247
Errors will be returned for the first error encountered in the request. An error occurred as follows:
246248
247-
| HTTP status | Error code | Description |
248-
| ----------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
249-
| 400 | `MISSING_VALUE` | Missing header or parameter. For details, see the `diagnostics` field. |
250-
| 400 | `INVALID_VALUE` | Invalid Parameter or Invalid operation. |
251-
| 401 | `ACCESS_DENIED` | Missing or invalid OAuth 2.0 bearer token in request. |
252-
| 403 | `FORBIDDEN` | Access denied to resource. |
253-
| 404 | `INVALIDATED_RESOURCE` | Resource that has been marked as invalid was requested - invalid resources cannot be retrieved |
254-
| 405 | `METHOD_NOT_ALLOWED` | The method is not allowed. |
255-
| 408 | `TIMEOUT` | Request timed out. |
256-
| 415 | `UNSUPPORTED_MEDIA` | Unsupported media type. |
257-
| 429 | `THROTTLED` | You have exceeded your application's [rate limit](https://digital.nhs.uk/developer/guides-and-documentation/reference-guide#rate-limits). |
249+
| HTTP status | Error code | Description |
250+
| ----------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
251+
| 400 | `MISSING_VALUE` | Missing header or parameter. For details, see the `diagnostics` field. |
252+
| 400 | `INVALID_VALUE` | Invalid Parameter or Invalid operation. |
253+
| 401 | `ACCESS_DENIED` | Missing or invalid OAuth 2.0 bearer token in request. |
254+
| 403 | `FORBIDDEN` | Access denied to resource. |
255+
| 404 | `INVALIDATED_RESOURCE` | Resource that has been marked as invalid was requested - invalid resources cannot be retrieved |
256+
| 405 | `METHOD_NOT_ALLOWED` | The method is not allowed. |
257+
| 408 | `TIMEOUT` | Request timed out. |
258+
| 409 | `DUPLICATE_RELATIONSHIP` | A proposed proxy role already exists for this proxy/patient relationship. |
259+
| 415 | `UNSUPPORTED_MEDIA` | Unsupported media type. |
260+
| 429 | `THROTTLED` | You have exceeded your application's [rate limit](https://digital.nhs.uk/developer/guides-and-documentation/reference-guide#rate-limits). |
258261
259262
content:
260263
application/fhir+json:
@@ -263,6 +266,8 @@ paths:
263266
examples:
264267
accessDeniedError:
265268
$ref: "./examples/responses/errors/access-denied.yaml#/AccessDeniedError"
269+
postQuestionnaireResponseDuplicateRelationshipError:
270+
$ref: "./examples/responses/POST_QuestionnaireResponse/errors/duplicate_relationship_error.yaml#/PostQuestionnaireResponseDuplicateRelationshipError"
266271
"5XX":
267272
description: |
268273
Errors will be returned for the first error encountered in the request. An error occurred as follows:

0 commit comments

Comments
 (0)