-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ERSSUP-61674]-[JW/AO]-[Retrieve Binary R4 API design]-[FV]
- Loading branch information
1 parent
8b84bd5
commit cfee633
Showing
10 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const businessFunctionValidator = require('../../services/businessFunctionValidator') | ||
|
||
module.exports = [ | ||
/** | ||
* Sandbox implementation for retrieveBinary A039 (R4) endpoint | ||
*/ | ||
{ | ||
method: 'GET', | ||
path: '/FHIR/R4/Binary/{attachmentUuid}', | ||
handler: (request, h) => { | ||
|
||
const allowedBusinessFunctions = ["REFERRING_CLINICIAN", "REFERRING_CLINICIAN_ADMIN", "SERVICE_PROVIDER_CLINICIAN", "SERVICE_PROVIDER_CLINICIAN_ADMIN"] | ||
|
||
const validationResult = businessFunctionValidator.validateBusinessFunction(request, h, allowedBusinessFunctions) | ||
if (validationResult) { | ||
return validationResult | ||
} | ||
|
||
const uuid = request.params.attachmentUuid; | ||
const url = request.url.href; | ||
const objectStore = "/ObjectStore/RetrieveBinary/d497bbe3-f88b-45f1-b3d4-9c563e4c0f5f"; | ||
const location = url.split('/FHIR')[0] + objectStore; | ||
|
||
if (uuid === '704c3791-0873-45e9-9a04-b51996f8d93f' && request.method === 'get') { | ||
const response = h.response().code(307) | ||
response.headers["Location"] = location; | ||
return response | ||
} else { | ||
return h.file('SandboxErrorOutcome.json').code(422); | ||
} | ||
|
||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = [ | ||
/** | ||
* Sandbox implementation for retrieveBinary (R4) endpoint helper, | ||
* with an ObjectStore 'mock', allowing redirection and example file retrieval. | ||
*/ | ||
{ | ||
method: 'GET', | ||
path: '/ObjectStore/RetrieveBinary/{fileDownloadUuid}', | ||
handler: (request, h) => { | ||
|
||
const uuid = request.params.fileDownloadUuid | ||
const exampleResponsePath = 'retrieveAttachment/responses/example_attachment.pdf' | ||
const filename = 'example_attachment.pdf' | ||
const responseCode = 200 | ||
|
||
if (uuid === 'd497bbe3-f88b-45f1-b3d4-9c563e4c0f5f') { | ||
return h.file(exampleResponsePath, { | ||
mode: 'attachment', | ||
filename: filename, | ||
etagMethod: false | ||
}).code(responseCode); | ||
} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...cation/components/r4/schemas/endpoints/a042-request-pre-signed-url-for-file-download.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
security: | ||
- bearerAuth: [] | ||
description: | | ||
### TODO Add later | ||
summary: A042 - Request pre-signed URL to download file from document store | ||
operationId: a042-request-pre-signed-url-for-file-download | ||
parameters: | ||
- $ref: '../headers/request/BearerAuthorization.yaml' | ||
- $ref: '../headers/request/BusinessFunction.yaml' | ||
- $ref: '../headers/request/CorrelationID.yaml' | ||
- $ref: '../headers/request/OdsCode.yaml' | ||
- $ref: '../headers/request/OnBehalfOfUserID.yaml' | ||
- $ref: '../pathParameters/AttachmentUuid.yaml' | ||
responses: | ||
'307': | ||
$ref: '../responses/retrieveBinary/307Response.yaml' | ||
'400': | ||
$ref: '../responses/retrieveBinary/400Response.yaml' | ||
'401': | ||
$ref: '../responses/Unauthorized.yaml' | ||
'403': | ||
$ref: '../responses/Forbidden.yaml' | ||
'404': | ||
$ref: '../responses/NotFound.yaml' | ||
'429': | ||
$ref: '../responses/TooManyRequests.yaml' | ||
'500': | ||
$ref: '../responses/InternalServerError.yaml' |
8 changes: 8 additions & 0 deletions
8
specification/components/r4/schemas/pathParameters/AttachmentUuid.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
in: path | ||
name: id | ||
description: | | ||
Reference for an attachment, as provided in the response from [[HYPERLINK_A039]]. | ||
required: true | ||
schema: | ||
type: string | ||
example: '704c3791-0873-45e9-9a04-b51996f8d93f' |
12 changes: 12 additions & 0 deletions
12
specification/components/r4/schemas/responses/retrieveBinary/307Response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
description: Response redirects user agent to the large file attachment URL in the Object Store via the Location header. | ||
headers: | ||
x-correlation-id: | ||
$ref: '../../headers/response/CorrelationID.yaml' | ||
x-request-id: | ||
$ref: '../../headers/response/RequestID.yaml' | ||
Location: | ||
description: The large file attachment location in the Object Store. | ||
required: true | ||
schema: | ||
type: string | ||
example: '<ObjectStoreURL>' |
20 changes: 20 additions & 0 deletions
20
specification/components/r4/schemas/responses/retrieveBinary/400Response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
description: | | ||
Where status code 400 (Bad Request) is returned then an [NHSDigital-OperationOutcome](https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome) will be included in the body, as detailed below. | ||
Check diagnostics property for specific information regarding the error. | ||
| issue.details.coding.code | issue.code | Description | | ||
| ------------------------- | ------------ | ----------------------------------------------------- | | ||
| REC_BAD_REQUEST | required | TODO:63315 | | ||
headers: | ||
x-correlation-id: | ||
$ref: '../../headers/response/CorrelationID.yaml' | ||
x-request-id: | ||
$ref: '../../headers/response/RequestID.yaml' | ||
Content-Type: | ||
$ref: '../../headers/response/ContentTypeFhirJson.yaml' | ||
content: | ||
application/fhir+json: | ||
schema: | ||
$ref: '../../NHSDigital-OperationOutcome.yaml' | ||
example: | ||
$ref: '../../../examples/NHSDigital-OperationOutcome.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters