Skip to content

Commit 8787eea

Browse files
[ERSSUP-80439]-[JW/AP]-[Finalise R4 download endpoint schema, wording and examples]-[FV]
1 parent 5cff4b8 commit 8787eea

File tree

15 files changed

+154
-63
lines changed

15 files changed

+154
-63
lines changed
Binary file not shown.

sandbox/src/routes/r4/retrieveBinary.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const businessFunctionValidator = require('../../services/businessFunctionValida
22

33
module.exports = [
44
/**
5-
* Sandbox implementation for retrieveBinary A039 (R4) endpoint
5+
* Sandbox implementation for retrieveBinary A042 (R4) endpoint
66
*/
77
{
88
method: 'GET',
9-
path: '/FHIR/R4/Binary/{attachmentUuid}',
9+
path: '/FHIR/R4/Binary/{attachmentId}',
1010
handler: (request, h) => {
1111

1212
const allowedBusinessFunctions = ["REFERRING_CLINICIAN", "REFERRING_CLINICIAN_ADMIN", "SERVICE_PROVIDER_CLINICIAN", "SERVICE_PROVIDER_CLINICIAN_ADMIN"]
@@ -16,17 +16,20 @@ module.exports = [
1616
return validationResult
1717
}
1818

19-
const uuid = request.params.attachmentUuid;
19+
const attachmentId = request.params.attachmentId;
2020
const url = request.url.href;
2121
const objectStore = "/ObjectStore/RetrieveBinary/d497bbe3-f88b-45f1-b3d4-9c563e4c0f5f";
2222
const location = url.split('/FHIR')[0] + objectStore;
23+
const uuidPattern = /^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
24+
const attPattern = /^att-\d+-\d+$/;
2325

24-
if (uuid === '704c3791-0873-45e9-9a04-b51996f8d93f' && request.method === 'get') {
26+
27+
if ((uuidPattern.test(attachmentId) || attPattern.test(attachmentId)) && request.method === 'get') {
2528
const response = h.response().code(307)
2629
response.headers["Location"] = location;
2730
return response
2831
} else {
29-
return h.file('SandboxErrorOutcome.json').code(422);
32+
return h.file('./r4/R4-SandboxErrorOutcome.json').code(400);
3033
}
3134

3235
}

sandbox/src/routes/r4/retrieveBinaryHelper.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
module.exports = [
22
/**
33
* Sandbox implementation for retrieveBinary (R4) endpoint helper,
4-
* with an ObjectStore 'mock', allowing redirection and example file retrieval.
4+
* with an ObjectStore 'mock', allowing redirection and simple file retrieval.
55
*/
66
{
77
method: 'GET',
8-
path: '/ObjectStore/RetrieveBinary/{fileDownloadUuid}',
8+
path: '/ObjectStore/RetrieveBinary/{fileId}',
99
handler: (request, h) => {
1010

11-
const uuid = request.params.fileDownloadUuid
12-
const exampleResponsePath = 'retrieveAttachment/responses/example_attachment.pdf'
11+
const fileId = request.params.fileId
1312
const filename = 'example_attachment.pdf'
13+
const filePath = `./r4/requestUrlForFileDownload/${filename}`
1414
const responseCode = 200
1515

16-
if (uuid === 'd497bbe3-f88b-45f1-b3d4-9c563e4c0f5f') {
17-
return h.file(exampleResponsePath, {
18-
mode: 'attachment',
19-
filename: filename,
20-
etagMethod: false
21-
}).code(responseCode);
16+
if (fileId === 'd497bbe3-f88b-45f1-b3d4-9c563e4c0f5f') {
17+
return h.file(filePath).code(responseCode).header('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
18+
.header('Content-Type', 'application/pdf');
2219
}
2320
}
2421
}

sandbox/src/routes/r4/retrieveBusinessFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = [
1616
}
1717

1818
// this should never happen as we always get a valid response for this endpoint
19-
return h.file('R4-SandboxErrorOutcome.json').code(400);
19+
return h.file('./r4/R4-SandboxErrorOutcome.json').code(400);
2020

2121

2222
}

sandbox/src/routes/r4/retrieveOboUsers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = [
1212
// check that the query exists and is correct
1313
const query = request.query._query;
1414
if (query == undefined || query != "onBehalfOf") {
15-
return h.file('R4-SandboxErrorOutcome.json').code(400);
15+
return h.file('./r4/R4-SandboxErrorOutcome.json').code(400);
1616
}
1717

1818
if (request.headers["nhsd-ers-business-function"] !== "SERVICE_PROVIDER_CLINICIAN_ADMIN")
@@ -27,7 +27,7 @@ module.exports = [
2727
}
2828

2929
// this should never happen as we always get a valid response for this endpoint
30-
return h.file('R4-SandboxErrorOutcome.json').code(400);
30+
return h.file('./r4/R4-SandboxErrorOutcome.json').code(400);
3131

3232

3333
}

scripts/populate_placeholders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main():
4343
"[[HYPERLINK_A038]]": "[Retrieve appointment (A038)](#get-/STU3/Appointment/-id-)",
4444
"[[HYPERLINK_A040]]": "[Retrieve “on-behalf-of” practitioner user information (A040)](#get-/R4/Practitioner)",
4545
"[[HYPERLINK_A041]]": "[Search for service requests (A041)](#get-/R4/ServiceRequest)",
46-
"[[HYPERLINK_A042]]": "[Request pre-signed URL to download file from document store (A042)](#get-/R4/Binary/-id-)",
46+
"[[HYPERLINK_A042]]": "[Retrieve attachment (A042)](#get-/R4/Binary/-id-)",
4747
"[[HYPERLINK_A043]]": "[Retrieve advice and guidance overview PDF (A043)](#post-/STU3/CommunicationRequest/-ubrn-/$ers.generateCRI)",
4848
"[[HYPERLINK_A044]]": "[Create advice and guidance request (A044)](#post-/STU3/CommunicationRequest/$ers.createAdviceAndGuidance)",
4949
"[[HYPERLINK_ONBOARDING]]": "[onboarding](#overview--onboarding)",

specification/components/r4/schemas/endpoints/a042-request-pre-signed-url-for-file-download.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
security:
2+
- bearerAuth: []
3+
description: |
4+
## Overview
5+
Use this endpoint to retrieve a file that is attached to a referral or advice request.
6+
7+
## Supported security patterns
8+
- Application-restricted, unattended access
9+
- Healthcare worker, user-restricted access
10+
11+
## Pre-requisites
12+
### Application-restricted, unattended access
13+
In order to use this endpoint you must be an authenticated e-RS calling application, working in the context of a Service Provider Organisation.
14+
15+
### Healthcare worker, user-restricted access
16+
In order to use this endpoint you must be an authenticated e-RS user or application and use one of the following e-RS roles:
17+
- `REFERRING_CLINICIAN`
18+
- `REFERRING_CLINICIAN_ADMIN`
19+
- `SERVICE_PROVIDER_CLINICIAN`
20+
- `SERVICE_PROVIDER_CLINICIAN_ADMIN`
21+
22+
### Attachment availability
23+
To use this endpoint, the attachment must be available for download. Attachments are only available after successful validation and malware scans. A request to retrieve an attachment that is not available for download will result in a 400 error. See the Response HTTP 400 section for further information.
24+
25+
The availability status of an attachment can be retrieved via any endpoint that provides details of an attachment in the success response. Details of the availability statuses that may be returned via these endpoints can be found in the specification for [[HYPERLINK_A005]].
26+
27+
Prior to retrieving an attachment, you will need to have retrieved the referral or advice request the attachment is associated with (via the [[HYPERLINK_A005]] or [[HYPERLINK_A024]] endpoints, for example). Referrals and advice requests include resolvable URLs to the files currently attached to them, which can be used with this endpoint to retrieve the attachments themselves.
28+
29+
## Support for a temporary redirect
30+
This endpoint makes use of a HTTP 307 temporary redirect. It redirects the caller to a temporary location from which the file contents can be downloaded directly.
31+
32+
The temporary location is only valid for a short period of time and should be used immediately.
33+
34+
Callers of this endpoint must ensure they:
35+
- follow this redirect to retrieve the file
36+
- do not cache the temporary location
37+
- generate a new redirect each time the file is downloaded
38+
39+
See the Response HTTP 307 section for further information.
40+
41+
## Important notes
42+
A referral pathway in e-RS can be made up of more than one UBRN. For example: a referral is booked and seen in a general knee clinical assessment service (UBRN #1), and the service decides to onward refer to a more specialist knee meniscus service (UBRN #2). This would result in two UBRNs for the referral pathway. There may be additional related UBRNs if there are multiple onward referrals.
43+
44+
As such, it is important that all clinical information is obtained from across all the related UBRNs referenced in [[HYPERLINK_A005]]. You can do this using the following endpoints:
45+
- [[HYPERLINK_A006]]
46+
- [[HYPERLINK_A007]]
47+
48+
Note: It is possible that the initial UBRN may be the only one in the referral pathway to have clinical information and/or attachments associated.
49+
50+
## Use case
51+
As an authenticated user
52+
53+
I need to retrieve a clinical attachment associated with a referral or advice request
54+
55+
So that I can assess its content and decide what further action may be needed.
56+
57+
## Related endpoints
58+
- [[HYPERLINK_A005]] to retrieve details of a referral. This includes references to clinical attachments, related referrals and other important data.
59+
- [[HYPERLINK_A024]] to retrieve the summary of an advice and guidance request. This endpoint provides important contextual information about the advice and guidance request (e.g. the service/specialty to which advice has been requested, etc).
60+
- [[HYPERLINK_A025]] to retrieve the advice and guidance conversation between the referring organisation and service providing organisation.
61+
- [[HYPERLINK_A007]] to generate a PDF file that summarises clinical information for a referral.
62+
63+
## Sandbox test scenarios
64+
The sandbox for this endpoint is a simple implementation that only supports success cases.
65+
66+
Inline with the behaviour described in "Support for a temporary redirect", the sandbox will return a HTTP 307 temporary redirect. For simplicity, the temporary location will be static and never expire, unlike the live environment.
67+
68+
A successful response will always be returned, provided the Binary ID is in a valid format. The Availability Status of a file is not considered in the sandbox and a file will always be considered to be available for retrieval.
69+
70+
Successful responses will always return the same example PDF file.
71+
72+
summary: Retrieve attachment (A042, FHIR R4)
73+
operationId: a042-retrieve-attachment
74+
tags:
75+
- Retrieve clinical information
76+
parameters:
77+
- $ref: '../headers/request/BearerAuthorization.yaml'
78+
- $ref: '../headers/request/CorrelationID.yaml'
79+
- $ref: '../headers/request/BusinessFunctionOnlyUserRestricted.yaml'
80+
- $ref: '../headers/request/OdsCodeOnlyUserRestricted.yaml'
81+
- $ref: '../headers/request/OnBehalfOfUserIDOnlyUserRestricted.yaml'
82+
- $ref: '../pathParameters/BinaryId.yaml'
83+
responses:
84+
'307':
85+
$ref: '../responses/retrieveBinary/307Response.yaml'
86+
'400':
87+
$ref: '../responses/retrieveBinary/400Response.yaml'
88+
'401':
89+
$ref: '../responses/Unauthorized.yaml'
90+
'403':
91+
$ref: '../responses/ForbiddenOrNoLR.yaml'
92+
'404':
93+
$ref: '../responses/NotFound.yaml'
94+
'429':
95+
$ref: '../responses/TooManyRequests.yaml'
96+
'500':
97+
$ref: '../responses/InternalServerError.yaml'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
in: header
2+
name: NHSD-eRS-On-Behalf-Of-User-ID
3+
description: |
4+
The (SDS) user ID of the user that the authenticating user wishes to act on behalf of (OBO).
5+
6+
"On behalf of" is only supported for a Service Provider Clinician Admin (SPCA) acting on behalf of a Service Provider Clinician (SPC).
7+
8+
Where an OBO User ID is supplied the authenticating user must be an SPCA and the OBO User ID must be that of an appropriate SPC.
9+
10+
Not allowed for application-restricted access.
11+
12+
Required for user-restricted access where the Service Provider Clinician Admin Business Function is used for authentication.
13+
required: false
14+
schema:
15+
type: string
16+
example: '021600556514'
17+

specification/components/r4/schemas/pathParameters/AttachmentUuid.yaml

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

0 commit comments

Comments
 (0)