Skip to content

Commit 4b86e60

Browse files
committed
NPA-5191: EB suggestions
1 parent 08ac996 commit 4b86e60

File tree

4 files changed

+109
-2
lines changed

4 files changed

+109
-2
lines changed

sandbox/api/post_questionnaire_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def post_questionnaire_response_response() -> Union[dict, tuple]:
2828
response = None
2929

3030
# Successful questionnaire response
31-
if source_identifier in ["9000000009", "9000000017"]: # Example NHS numbers for success
31+
if source_identifier in ["9000000009", "9000000017"]:
3232
response = generate_response_from_example(POST_QUESTIONNAIRE_RESPONSE__SUCCESS, 200)
3333
# Duplicate relationship
3434
elif source_identifier == "9000000049":

sandbox/api/tests/test_post_questionnaire_response.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sandbox.api.constants import (
88
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
99
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR,
10+
INTERNAL_SERVER_ERROR_EXAMPLE
1011
)
1112

1213
QUESTIONNAIRE_RESPONSE_API_ENDPOINT = "/FHIR/R4/QuestionnaireResponse"
@@ -20,11 +21,21 @@
2021
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
2122
200,
2223
),
24+
(
25+
"9000000017",
26+
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
27+
200,
28+
),
2329
(
2430
"9000000049",
2531
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR,
2632
409,
2733
),
34+
(
35+
"INVALID_NHS_NUMBER",
36+
INTERNAL_SERVER_ERROR_EXAMPLE,
37+
500,
38+
),
2839
],
2940
)
3041
@patch("sandbox.api.post_questionnaire_response.generate_response_from_example")
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
QuestionnaireResponseDuplicateRelationship:
2+
summary: Duplicate relationship request
3+
description: |
4+
Example proxy access request that triggers a 409 DUPLICATE_RELATIONSHIP error due to an existing proxy role with NHS number `9000000049` requesting access to act on behalf of a patient (Jill Jones) with NHS number `9000000006`.
5+
6+
Significant details to point out:
7+
8+
- `source.type` should be `RelatedPerson` when a proxy is applying
9+
- `source.identifier.value` should be the NHS number of the user completing the form - this should correlate with the Identity token in the request
10+
- `subject.type` should be `Patient` since it is the patient that is the subject of the application
11+
- `subject.identifier.value` should be the NHS Number of the patient to which the application relates
12+
- `patient` demographics are present in the request as a result of being provided by the applicant
13+
value:
14+
resourceType: "QuestionnaireResponse"
15+
status: "completed"
16+
authored: "2024-07-15T09:43:03.280Z"
17+
source:
18+
type: "RelatedPerson"
19+
identifier:
20+
system: "https://fhir.nhs.uk/Id/nhs-number"
21+
value: "9000000049"
22+
subject:
23+
type: "Patient"
24+
identifier:
25+
system: "https://fhir.nhs.uk/Id/nhs-number"
26+
value: "9000000006"
27+
questionnaire: "https://api.service.nhs.uk/validated-relationships/FHIR/R4/Questionnaire/01dc6813-3421-4d14-948d-a4888241add1"
28+
item:
29+
- linkId: "relatedPerson"
30+
text: "Proxy details"
31+
item:
32+
- linkId: "relatedPerson_identifier"
33+
text: "NHS number"
34+
answer:
35+
- valueString: "9000000049"
36+
- linkId: "relatedPerson_basisForAccess"
37+
text: "Basis for Access"
38+
answer:
39+
- valueCoding:
40+
system: "https://fhir.hl7.org.uk/CodeSystem/UKCore-AdditionalPersonRelationshipRole"
41+
code: "Personal"
42+
display: "Personal relationship with the patient"
43+
- linkId: "relatedPerson_relationship"
44+
text: "Relationship"
45+
answer:
46+
- valueCoding:
47+
system: "http://terminology.hl7.org/CodeSystem/v3-RoleCode"
48+
code: "SPS"
49+
display: "Spouse"
50+
- linkId: "patient"
51+
text: "Patient details"
52+
item:
53+
- linkId: "patient_identifier"
54+
text: "NHS number"
55+
answer:
56+
- valueString: "9000000006"
57+
- linkId: "patient_name"
58+
text: "Name"
59+
item:
60+
- linkId: "patient_name_first"
61+
text: "First name"
62+
answer:
63+
- valueString: "Jill"
64+
- linkId: "patient_name_family"
65+
text: "Last name"
66+
answer:
67+
- valueString: "Jones"
68+
- linkId: "patient_birthDate"
69+
text: "Date of birth"
70+
answer:
71+
- valueDate: "1965-01-01"
72+
- linkId: "requestedAccess"
73+
text: "Requested access"
74+
item:
75+
- linkId: "requestedAccess_accessLevel"
76+
text: "Requested access level"
77+
answer:
78+
- valueCoding:
79+
system: "https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-RequestedAccess"
80+
code: "APPT"
81+
display: "Appointment Booking"
82+
- valueCoding:
83+
system: "https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-RequestedAccess"
84+
code: "VACC"
85+
display: "Vaccination Records"
86+
- linkId: "requestedAccess_reasonsForAccess"
87+
text: "Reason for access"
88+
answer:
89+
- valueCoding:
90+
system: "https://fhir.nhs.uk/CodeSystem/Proxy-Placeholder-ReasonForAccess"
91+
code: "PRAC"
92+
display: "Practical Reasons"

specification/validated-relationships-service-api.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ paths:
189189
190190
| Scenario | Request | Response |
191191
| ---------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
192-
| Example request | Example questionnaire response from try it now | HTTP Status 200 Success response |
192+
| Successful request | Valid request with performer identifier value of 9000000009 or 9000000017 | HTTP Status 200 Success response |
193193
| Duplicate relationship | Request for relationship that already exists, with performer identifier value of 9000000049 | HTTP Status 409 and DUPLICATE_RELATIONSHIP error response |
194194
195195
@@ -220,6 +220,8 @@ paths:
220220
$ref: "./examples/requests/POST_QuestionnaireResponse/adult-to-adult-with-capacity.yaml#/QuestionnaireResponseAdultToAdultWithCapacityRequest"
221221
questionnaireResponseAdultNominatesAdultRequest:
222222
$ref: "./examples/requests/POST_QuestionnaireResponse/adult-nominates-adult.yaml#/QuestionnaireResponseAdultNominatesAdultRequest"
223+
questionnaireResponseDuplicateRelationship:
224+
$ref: "./examples/requests/POST_QuestionnaireResponse/duplicate_relationship.yaml#/QuestionnaireResponseDuplicateRelationship"
223225
application/fhir+json; charset=utf-8:
224226
schema:
225227
$ref: "#/components/schemas/QuestionnaireResponse"
@@ -232,6 +234,8 @@ paths:
232234
$ref: "./examples/requests/POST_QuestionnaireResponse/adult-to-adult-with-capacity.yaml#/QuestionnaireResponseAdultToAdultWithCapacityRequest"
233235
questionnaireResponseAdultNominatesAdultRequest:
234236
$ref: "./examples/requests/POST_QuestionnaireResponse/adult-nominates-adult.yaml#/QuestionnaireResponseAdultNominatesAdultRequest"
237+
questionnaireResponseDuplicateRelationship:
238+
$ref: "./examples/requests/POST_QuestionnaireResponse/duplicate_relationship.yaml#/QuestionnaireResponseDuplicateRelationship"
235239
responses:
236240
"200":
237241
description: Request was received successfully for processing

0 commit comments

Comments
 (0)