Skip to content

Commit f93dbba

Browse files
add wording, fix helpers and path param
1 parent e5fa056 commit f93dbba

File tree

7 files changed

+84
-14
lines changed

7 files changed

+84
-14
lines changed

sandbox/src/routes/r4/retrieveBinary.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = [
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module.exports = [
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
11+
const fileId = request.params.fileId
1212
const filename = 'example_attachment.pdf'
1313
const filePath = `./r4/requestUrlForFileDownload/${filename}`
1414
const responseCode = 200
1515

16-
if (uuid === 'd497bbe3-f88b-45f1-b3d4-9c563e4c0f5f') {
16+
if (fileId === 'd497bbe3-f88b-45f1-b3d4-9c563e4c0f5f') {
1717
return h.file(filePath).code(responseCode).header('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
1818
.header('Content-Type', 'application/pdf');
1919
}

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
}

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

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,74 @@
11
security:
22
- bearerAuth: []
33
description: |
4-
### TODO Add later
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+
572
summary: Request pre-signed URL to download file from document store (A042, FHIR R4)
673
operationId: a042-request-pre-signed-url-for-file-download
774
tags:
@@ -12,7 +79,7 @@ parameters:
1279
- $ref: '../headers/request/BusinessFunctionOnlyUserRestricted.yaml'
1380
- $ref: '../headers/request/OdsCodeOnlyUserRestricted.yaml'
1481
- $ref: '../headers/request/OnBehalfOfUserIDOnlyUserRestricted.yaml'
15-
- $ref: '../pathParameters/AttachmentUuid.yaml'
82+
- $ref: '../pathParameters/BinaryId.yaml'
1683
responses:
1784
'307':
1885
$ref: '../responses/retrieveBinary/307Response.yaml'

specification/components/r4/schemas/pathParameters/AttachmentUuid.yaml renamed to specification/components/r4/schemas/pathParameters/BinaryId.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
in: path
22
name: id
33
description: |
4-
The identifier for the attachment.
4+
The identifier for the binary.
55
required: true
66
schema:
77
type: string

specification/components/stu3/schemas/headers/response/ContentDispositionAttachment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ description: |
33
required: true
44
schema:
55
type: string
6-
example: 'attachment; filename="000000070000_Appointment_Confirmation_Summary_20210603121353"'
6+
example: 'attachment; filename="000000070000_Appointment_Confirmation_Summary_20210603121353.pdf"'

0 commit comments

Comments
 (0)