Skip to content

Commit e655d16

Browse files
[ERSSUP-61671]-[JW/AO]-[OAS modelling of request upload uri endpoint]-[FV]
1 parent 5785384 commit e655d16

File tree

9 files changed

+179
-1
lines changed

9 files changed

+179
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"resourceType": "Parameters",
3+
"parameter": [
4+
{
5+
"name": "uploadUri",
6+
"valueUri": "<preSignedUri>"
7+
},
8+
{
9+
"name": "reference",
10+
"valueUri": "/Binary/ce2fbda9-7c18-46ab-ae04-5b08df61e0d4"
11+
}
12+
]
13+
}

sandbox/src/routes/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const retrieveOboUsers = require('./r4/retrieveOboUsers')
4141
const retrieveHealthcareService = require('./r4/retrieveHealthcareService')
4242
const searchForHealthcareServices = require('./r4/searchForHealthcareServices')
4343
const searchServiceRequest = require('./r4/searchServiceRequest')
44+
const requestUploadUri = require('./r4/requestUploadUri')
4445

4546
const routes = [].concat(
4647
getStatus,
@@ -78,7 +79,8 @@ const routes = [].concat(
7879
cancelReferral,
7980
retrieveAppointment,
8081
retrieveAdviceAndGuidanceOverviewPdf,
81-
searchServiceRequest
82+
searchServiceRequest,
83+
requestUploadUri
8284
)
8385

8486
module.exports = routes
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const mockResponseProvider = require('./services/mockResponseProvider')
2+
const businessFunctionValidator = require('../../services/businessFunctionValidator')
3+
4+
function requestUploadUri(request, h) {
5+
const allowedBusinessFunctions = ["REFERRING_CLINICIAN", "REFERRING_CLINICIAN_ADMIN", "SERVICE_PROVIDER_CLINICIAN", "SERVICE_PROVIDER_CLINICIAN_ADMIN"]
6+
7+
const validationResult = businessFunctionValidator.validateBusinessFunction(request, h, allowedBusinessFunctions)
8+
if (validationResult) {
9+
return validationResult
10+
}
11+
12+
if(request.method == 'post') {
13+
var responsePath = mockResponseProvider.getExampleResponseForRequestUploadUri(request)
14+
if (responsePath) {
15+
return h.file(responsePath, { etagMethod: false }).code(200).type('application/fhir+json')
16+
}
17+
}
18+
19+
return h.file('SandboxErrorOutcome.json').code(422)
20+
}
21+
22+
23+
module.exports = [
24+
{
25+
method: 'POST',
26+
path: '/FHIR/R4/ServiceRequest/{id}/$ers.generateUploadURI',
27+
handler: requestUploadUri
28+
}
29+
]

sandbox/src/routes/r4/services/mockResponseProvider.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@ module.exports = {
5858
}
5959

6060
return {}
61+
},
62+
63+
getExampleResponseForRequestUploadUri: function (request) {
64+
const id = request.params.id
65+
if (id === 'r.f6dc823a-e673-4f74-9edc-a49525edd2a5') {
66+
return 'r4/requestUploadUri/responses/ResponseExample.json'
67+
}
6168
}
6269
}

scripts/populate_placeholders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def main():
4343
"[[HYPERLINK_A036]]": "[A036 - Cancel referral](#api-Default-a036-cancel-referral)",
4444
"[[HYPERLINK_A037]]": "[A037 - Retrieve healthcare service version](#api-Default-a037-retrieve-healthcare-service-version)",
4545
"[[HYPERLINK_A038]]": "[A038 - Retrieve appointment](#api-Default-a038-retrieve-appointment)",
46+
"[[HYPERLINK_A039]]": "[A039 - Request pre-signed URL to upload file to document store](#api-Default-a039-request-pre-signed-url-for-file-upload)",
4647
"[[HYPERLINK_A040]]": "[A040 - Retrieve e-RS-Specific Practitioner Information](#api-Default-a040-retrieve-practitioner-info)",
4748
"[[HYPERLINK_A041]]": "[A041 - Search service request](#api-Default-a041-search-service-request)",
4849
"[[HYPERLINK_A043]]": "[A043 - Retrieve advice and guidance overview PDF](#api-Default-a043-retrieve-advice-and-guidance-overview-pdf)",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: id
2+
in: path
3+
description: |
4+
An identifier that uniquely identifies a referral request or an advice and guidance.
5+
required: true
6+
schema:
7+
type: string
8+
example: 'r.f6dc823a-e673-4f74-9edc-a49525edd2a5'
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
description: Parameters resource containg the upload URI (object store) and the file reference (eRS).
2+
headers:
3+
x-correlation-id:
4+
$ref: '../../headers/response/CorrelationID.yaml'
5+
x-request-id:
6+
$ref: '../../headers/response/RequestID.yaml'
7+
Content-Type:
8+
$ref: '../../headers/response/ContentTypeFhirJson.yaml'
9+
content:
10+
application/fhir+json:
11+
schema:
12+
type: object
13+
required:
14+
- resourceType
15+
- parameter
16+
properties:
17+
resourceType:
18+
type: string
19+
enum:
20+
- Parameters
21+
example: 'Parameters'
22+
parameter:
23+
type: array
24+
description: |
25+
| Field | Cardinality | Notes |
26+
| ------------ | ----------- | -------------------- |
27+
| `uploadUri` | `1..1` | |
28+
| `reference` | `1..1` | |
29+
items:
30+
oneOf:
31+
- title: uploadUri
32+
type: object
33+
required:
34+
- name
35+
- valueUri
36+
properties:
37+
name:
38+
type: string
39+
enum:
40+
- 'uploadUri'
41+
example: uploadUri
42+
valueUri:
43+
type: string
44+
example: "<preSignedUri>"
45+
- title: reference
46+
type: object
47+
required:
48+
- name
49+
- valueUri
50+
properties:
51+
name:
52+
type: string
53+
enum:
54+
- 'reference'
55+
example: reference
56+
valueUri:
57+
type: string
58+
example: "/Binary/ce2fbda9-7c18-46ab-ae04-5b08df61e0d4"
59+
minItems: 2
60+
maxItems: 2
61+
uniqueItems: true
62+
examples:
63+
minimal-example:
64+
summary: Generate oject store upload URI and eRS reference
65+
value:
66+
$ref: '../../../examples/requestUploadUri/responses/ResponseExample.json'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
description: |
2+
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.
3+
Check diagnostics property for specific information regarding the error.
4+
5+
| issue.details.coding.code | issue.code | Description |
6+
| ------------------------- | ------------ | ----------------------------------------------------- |
7+
| REC_BAD_REQUEST | required | The service request is not in a valid state. |
8+
headers:
9+
x-correlation-id:
10+
$ref: '../../headers/response/CorrelationID.yaml'
11+
x-request-id:
12+
$ref: '../../headers/response/RequestID.yaml'
13+
Content-Type:
14+
$ref: '../../headers/response/ContentTypeFhirJson.yaml'
15+
content:
16+
application/fhir+json:
17+
schema:
18+
$ref: '../../NHSDigital-OperationOutcome.yaml'
19+
example:
20+
$ref: '../../../examples/NHSDigital-OperationOutcome.json'

specification/e-referrals-service-api.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3684,6 +3684,38 @@ paths:
36843684
$ref: 'components/r4/schemas/responses/R4-TooManyRequests.yaml'
36853685
'500':
36863686
$ref: 'components/r4/schemas/responses/R4-InternalServerError.yaml'
3687+
/R4/ServiceRequest/{id}/$ers.generateUploadURI:
3688+
post:
3689+
security:
3690+
- bearerAuth: []
3691+
description: |
3692+
### TODO Add later
3693+
summary: A039 - Request pre-signed URL to upload file to document store
3694+
operationId: a039-request-pre-signed-url-for-file-upload
3695+
parameters:
3696+
- $ref: 'components/r4/schemas/headers/request/BearerAuthorization.yaml'
3697+
- $ref: 'components/r4/schemas/headers/request/BusinessFunction.yaml'
3698+
- $ref: 'components/r4/schemas/headers/request/CorrelationID.yaml'
3699+
- $ref: 'components/r4/schemas/headers/request/OdsCode.yaml'
3700+
- $ref: 'components/r4/schemas/headers/request/OnBehalfOfUserID.yaml'
3701+
- $ref: 'components/r4/schemas/path/ServiceRequestId.yaml'
3702+
responses:
3703+
'200':
3704+
$ref: 'components/r4/schemas/responses/requestUploadUri/200Response.yaml'
3705+
'400':
3706+
$ref: 'components/r4/schemas/responses/requestUploadUri/400Response.yaml'
3707+
'401':
3708+
$ref: 'components/r4/schemas/responses/R4-Unauthorized.yaml'
3709+
'403':
3710+
$ref: 'components/r4/schemas/responses/R4-Forbidden.yaml'
3711+
'404':
3712+
$ref: 'components/r4/schemas/responses/R4-NotFound.yaml'
3713+
'406':
3714+
$ref: 'components/r4/schemas/responses/R4-NotAcceptable.yaml'
3715+
'429':
3716+
$ref: 'components/r4/schemas/responses/R4-TooManyRequests.yaml'
3717+
'500':
3718+
$ref: 'components/r4/schemas/responses/R4-InternalServerError.yaml'
36873719
components:
36883720
securitySchemes:
36893721
bearerAuth:

0 commit comments

Comments
 (0)