diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-400.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-400.json new file mode 100755 index 000000000..cfcc161f6 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-400.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "required", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "REC_BAD_REQUEST" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-401.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-401.json new file mode 100755 index 000000000..7a2261f95 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-401.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "login", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/NHSD-API-ErrorOrWarningCode", + "code": "ACCESS_DENIED" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-403.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-403.json new file mode 100755 index 000000000..bd5f90f64 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-403.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "forbidden", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "REC_FORBIDDEN" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-404.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-404.json new file mode 100755 index 000000000..00567b297 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-404.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "not-found", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "REC_NOT_FOUND" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-406.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-406.json new file mode 100755 index 000000000..c79c1b7e5 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-406.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "not-supported", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "REC_NOT_ACCEPTABLE" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-429.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-429.json new file mode 100755 index 000000000..40ebcb0cf --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-429.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "throttled", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/NHSD-API-ErrorOrWarningCode", + "code": "TOO_MANY_REQUESTS" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-500.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-500.json new file mode 100755 index 000000000..1e37c9ead --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-500.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "exception", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "REC_SERVER_ERROR" + } + ] + }, + "diagnostics": "Example diagnostics message." + } + ] +} diff --git a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExample.json b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExample.json deleted file mode 100644 index 5d7a5d18d..000000000 --- a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExample.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "id": "123e4567-e89b-12d3-a456-426614174002", - "resourceType": "Bundle", - "meta": { - "profile": [ - "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Bundle" - ], - "lastUpdated": "2022-03-01T10:00:00.42Z" - }, - "timestamp": "2022-04-06T15:42:00.42Z", - "link": [ - { - "relation": "self", - "url": "_baseUrl_/FHIR/R4/ServiceRequest?identifier=https://fhir.nhs.uk/Id/UBRN%7C000000070000" - } - ], - "total": 1, - "type": "searchset", - "entry": [ - { - "fullUrl": "_baseUrl_/ServiceRequest/r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", - "resource": { - "id": "r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", - "meta": { - "profile": [ - "https://fhir.nhs.uk/StructureDefinition/NHSDigital-ServiceRequest" - ], - "versionId": "5" - }, - "resourceType": "ServiceRequest", - "extension": [ - { - "url": "https://fhir.nhs.uk/StructureDefinition/Extension-ServiceRequest-Priority", - "valueCoding": { - "system": "https://fhir.nhs.uk/CodeSystem/eRS-Priority", - "code": "ROUTINE", - "display": "Routine" - } - } - ], - "contained": [ - { - "resourceType": "PractitionerRole", - "id": "PractitionerRole-R69-000000000101", - "meta": { - "profile": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole-Minimal" - }, - "practitioner": { - "identifier": { - "system": "https://fhir.nhs.uk/Id/sds-user-id", - "value": "000000000101" - } - }, - "organization": { - "identifier": { - "system": "https://fhir.nhs.uk/Id/ods-organization-code", - "value": "R69" - } - } - } - ], - "identifier": [ - { - "system": "https://fhir.nhs.uk/Id/UBRN", - "value": "000000070000" - } - ], - "status": "active", - "intent": "order", - "category": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "3457005", - "display": "Patient referral" - } - ] - } - ], - "priority": "routine", - "subject": { - "identifier": { - "system": "https://fhir.nhs.uk/Id/nhs-number", - "value": "9912003888" - } - }, - "authoredOn": "2022-01-11T10:00:00.000Z", - "requester": { - "reference": "#PractitionerRole-R69-000000000101" - } - }, - "search": { - "mode": "match" - } - } - ] -} diff --git a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleAdvice.json b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleAdvice.json new file mode 100644 index 000000000..6ccbb724f --- /dev/null +++ b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleAdvice.json @@ -0,0 +1,63 @@ +{ + "id": "123e4567-e89b-12d3-a456-426614174002", + "resourceType": "Bundle", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "timestamp": "2022-04-06T15:42:00.42Z", + "link": [ + { + "relation": "self", + "url": "_baseUrl_/R4/ServiceRequest?identifier=https://fhir.nhs.uk/Id/UBRN%7C000000070001" + } + ], + "total": 1, + "type": "searchset", + "entry": [ + { + "fullUrl": "_baseUrl_/R4/ServiceRequest/a.86b486e8-13fc-4623-8c25-3c0af85c649f", + "resource": { + "id": "a.86b486e8-13fc-4623-8c25-3c0af85c649f", + "meta": { + "versionId": "5" + }, + "resourceType": "ServiceRequest", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/UBRN", + "value": "000000070001" + } + ], + "status": "active", + "intent": "order", + "category": [ + { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/message-category-servicerequest", + "code": "request" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/servicerequest-code", + "code": "advice-and-guidance" + } + ] + }, + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9912003888" + } + } + }, + "search": { + "mode": "match" + } + } + ] +} diff --git a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleEmpty.json b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleEmpty.json new file mode 100644 index 000000000..8688f5eb7 --- /dev/null +++ b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleEmpty.json @@ -0,0 +1,16 @@ +{ + "id": "123e4567-e89b-12d3-a456-426614174002", + "resourceType": "Bundle", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "timestamp": "2022-04-06T15:42:00.42Z", + "link": [ + { + "relation": "self", + "url": "_baseUrl_/R4/ServiceRequest?identifier=https://fhir.nhs.uk/Id/UBRN%7C000000070003" + } + ], + "total": 0, + "type": "searchset" +} diff --git a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferral.json b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferral.json new file mode 100644 index 000000000..625898ebc --- /dev/null +++ b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferral.json @@ -0,0 +1,55 @@ +{ + "id": "123e4567-e89b-12d3-a456-426614174002", + "resourceType": "Bundle", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "timestamp": "2022-04-06T15:42:00.42Z", + "link": [ + { + "relation": "self", + "url": "_baseUrl_/R4/ServiceRequest?identifier=https://fhir.nhs.uk/Id/UBRN%7C000000070000" + } + ], + "total": 1, + "type": "searchset", + "entry": [ + { + "fullUrl": "_baseUrl_/R4/ServiceRequest/r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "resource": { + "id": "r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "meta": { + "versionId": "5" + }, + "resourceType": "ServiceRequest", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/UBRN", + "value": "000000070000" + } + ], + "status": "active", + "intent": "order", + "category": [ + { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/message-category-servicerequest", + "code": "referral" + } + ] + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9912003888" + } + } + }, + "search": { + "mode": "match" + } + } + ] +} diff --git a/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json new file mode 100644 index 000000000..9a73e418a --- /dev/null +++ b/sandbox/src/mocks/r4/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json @@ -0,0 +1,100 @@ +{ + "id": "123e4567-e89b-12d3-a456-426614174002", + "resourceType": "Bundle", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "timestamp": "2022-04-06T15:42:00.42Z", + "link": [ + { + "relation": "self", + "url": "_baseUrl_/R4/ServiceRequest?identifier=https://fhir.nhs.uk/Id/UBRN%7C000000070002" + } + ], + "total": 2, + "type": "searchset", + "entry": [ + { + "fullUrl": "_baseUrl_/R4/ServiceRequest/r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "resource": { + "id": "r.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "meta": { + "versionId": "5" + }, + "resourceType": "ServiceRequest", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/UBRN", + "value": "000000070002" + } + ], + "status": "active", + "intent": "order", + "category": [ + { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/message-category-servicerequest", + "code": "referral" + } + ] + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9912003888" + } + } + }, + "search": { + "mode": "match" + } + }, + { + "fullUrl": "_baseUrl_/R4/ServiceRequest/a.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "resource": { + "id": "a.832db7fa-ebdd-44b6-ab3b-8329c2d43149", + "meta": { + "versionId": "5" + }, + "resourceType": "ServiceRequest", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/UBRN", + "value": "000000070002" + } + ], + "status": "completed", + "intent": "order", + "category": [ + { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/message-category-servicerequest", + "code": "request" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/servicerequest-code", + "code": "advice-and-guidance" + } + ] + }, + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9912003888" + } + } + }, + "search": { + "mode": "match" + } + } + ] +} diff --git a/sandbox/src/routes/r4/searchServiceRequest.js b/sandbox/src/routes/r4/searchServiceRequest.js index 82b90edf5..771da3a47 100644 --- a/sandbox/src/routes/r4/searchServiceRequest.js +++ b/sandbox/src/routes/r4/searchServiceRequest.js @@ -16,7 +16,7 @@ function searchServiceRequest(request, h) { } } - return h.file('SandboxErrorOutcome.json').code(422) + return h.file('SandboxErrorOutcome.json').code(400) } diff --git a/sandbox/src/routes/r4/services/mockResponseProvider.js b/sandbox/src/routes/r4/services/mockResponseProvider.js index e88fe081e..46c13017b 100644 --- a/sandbox/src/routes/r4/services/mockResponseProvider.js +++ b/sandbox/src/routes/r4/services/mockResponseProvider.js @@ -54,10 +54,17 @@ module.exports = { } if (ubrn === '000000070000') { - return 'r4/searchServiceRequest/responses/ResponseExample.json' + return 'r4/searchServiceRequest/responses/ResponseExampleReferral.json' + } + else if (ubrn === '000000070001') { + return 'r4/searchServiceRequest/responses/ResponseExampleAdvice.json' + } + else if (ubrn === '000000070002') { + return 'r4/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json' + } + else if (ubrn === '000000070003') { + return 'r4/searchServiceRequest/responses/ResponseExampleEmpty.json' } - - return {} }, getExampleResponseForRequestUploadUri: function (request) { diff --git a/scripts/populate_placeholders.py b/scripts/populate_placeholders.py index de9b020de..097461a4d 100644 --- a/scripts/populate_placeholders.py +++ b/scripts/populate_placeholders.py @@ -45,7 +45,7 @@ def main(): "[[HYPERLINK_A038]]": "[A038 - Retrieve appointment](#api-Default-a038-retrieve-appointment)", "[[HYPERLINK_A039]]": "[A039 - Request pre-signed URL to upload file to document store](#api-Default-a039-request-pre-signed-url-for-file-upload)", "[[HYPERLINK_A040]]": "[A040 - Retrieve e-RS-Specific Practitioner Information](#api-Default-a040-retrieve-practitioner-info)", - "[[HYPERLINK_A041]]": "[A041 - Search service request](#api-Default-a041-search-service-request)", + "[[HYPERLINK_A041]]": "[A041 - Search for service requests](#api-Default-a041-search-service-request)", "[[HYPERLINK_A042]]": "[A042 - Request pre-signed URL to download file from document store](#api-Default-a042-request-pre-signed-url-for-file-download)", "[[HYPERLINK_A043]]": "[A043 - Retrieve advice and guidance overview PDF](#api-Default-a043-retrieve-advice-and-guidance-overview-pdf)", "[[HYPERLINK_ONBOARDING]]": "[onboarding](#api-description__onboarding)", diff --git a/specification/components/r4/schemas/NHSDigital-OperationOutcome.yaml b/specification/components/r4/schemas/NHSDigital-OperationOutcome.yaml index 0d2bdf8f4..691d44e27 100755 --- a/specification/components/r4/schemas/NHSDigital-OperationOutcome.yaml +++ b/specification/components/r4/schemas/NHSDigital-OperationOutcome.yaml @@ -19,15 +19,6 @@ properties: type: string format: date-time example: '2021-08-04T14:35:00.000Z' - profile: - type: array - items: - type: string - enum: - - 'https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome' - example: 'https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome' - minItems: 1 - maxItems: 1 issue: type: array items: @@ -48,10 +39,10 @@ properties: example: 'error' code: type: string - example: 'forbidden' + example: 'required' diagnostics: type: string - example: "Appointment request is not in a valid state." + example: "Incorrect or missing expected value." details: type: object required: @@ -70,10 +61,8 @@ properties: enum: - 'https://fhir.nhs.uk/CodeSystem/http-error-codes' - 'https://fhir.nhs.uk/CodeSystem/NHSD-API-ErrorOrWarningCode' + - 'https://fhir.nhs.uk/CodeSystem/ers-error-codes' example: 'https://fhir.nhs.uk/CodeSystem/http-error-codes' code: type: string example: 'REC_BAD_REQUEST' - display: - type: string - example: 'Receiver Bad Request' diff --git a/specification/components/r4/schemas/eRS-ServiceRequest.yaml b/specification/components/r4/schemas/eRS-ServiceRequest.yaml index 4c80adde6..e157dbb45 100644 --- a/specification/components/r4/schemas/eRS-ServiceRequest.yaml +++ b/specification/components/r4/schemas/eRS-ServiceRequest.yaml @@ -5,16 +5,11 @@ required: - id - meta - resourceType - - extension - - contained - identifier - status - intent - category - - priority - subject - - authoredOn - - requester properties: id: type: string @@ -22,16 +17,8 @@ properties: meta: type: object required: - - profile - versionId properties: - profile: - type: array - items: - type: string - enum: - - 'https://fhir.nhs.uk/StructureDefinition/NHSDigital-ServiceRequest' - example: 'https://fhir.nhs.uk/StructureDefinition/NHSDigital-ServiceRequest' versionId: type: string example: '3834a43e-8696-4e77-aea4-b4fa0b6ef29e' @@ -40,79 +27,6 @@ properties: enum: - ServiceRequest example: 'ServiceRequest' - extension: - type: array - minItems: 1 - maxItems: 1 - items: - $ref: 'extensions/Extension-eRS-ServiceRequest-Priority.yaml' - contained: - type: array - items: - type: object - required: - - resourceType - - id - - meta - - practitioner - - organization - properties: - resourceType: - type: string - enum: - - PractitionerRole - example: PractitionerRole - id: - type: string - example: requester - meta: - type: object - required: - - profile - properties: - profile: - type: string - enum: - - https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole-Minimal - example: https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole-Minimal - practitioner: - type: object - required: - - identifier - properties: - identifier: - type: object - required: - - system - - value - properties: - system: - type: string - enum: - - https://fhir.nhs.uk/Id/sds-user-id - example: https://fhir.nhs.uk/Id/sds-user-id - value: - type: string - example: '000000000101' - organization: - type: object - required: - - identifier - properties: - identifier: - type: object - required: - - system - - value - properties: - system: - type: string - enum: - - https://fhir.nhs.uk/Id/ods-organization-code - example: https://fhir.nhs.uk/Id/ods-organization-code - value: - type: string - example: 'R69' identifier: type: array items: @@ -131,8 +45,20 @@ properties: example: '000000070000' status: type: string + description: | + Whilst a potential value to return is `draft`, we are not currently returning this value, but may choose to do so in the future. + + | ServiceRequest.status | Description | + |-----------------------|---------------------------------------------------------------------------------- | + | active | The `ServiceRequest` is ready to be acted upon. | + | completed | The `ServiceRequest` has been fully performed and no further activity will occur. | + | draft | The `ServiceRequest` is incomplete and is not yet ready to be processed. | + | revoked | The `ServiceRequest` has been terminated and no further activity will occur. | enum: - active + - completed + - draft + - revoked example: 'active' intent: type: string @@ -153,26 +79,40 @@ properties: required: - system - code - - display properties: system: type: string enum: - - 'http://snomed.info/sct' + - 'https://fhir.nhs.uk/CodeSystem/message-category-servicerequest' code: type: string - example: '820641000000100' - display: - type: string - example: 'Choose and book advice and guidance request' - priority: - type: string - enum: - - routine - - urgent - - asap - - stat - example: 'asap' + enum: + - referral + - request + example: 'referral' + code: + type: object + required: + - coding + properties: + coding: + type: array + items: + type: object + required: + - system + - code + properties: + system: + type: string + enum: + - 'https://fhir.nhs.uk/CodeSystem/servicerequest-code' + example: 'https://fhir.nhs.uk/CodeSystem/servicerequest-code' + code: + type: string + enum: + - advice-and-guidance + example: 'advice-and-guidance' subject: type: object required: @@ -192,16 +132,3 @@ properties: value: type: string example: '9912003888' - authoredOn: - type: string - format: date-time - example: '2022-01-11T10:00:00.000Z' - requester: - type: object - required: - - reference - properties: - reference: - description: This will be a reference to the contained PractitionerRole id. - type: string - example: '#requester' diff --git a/specification/components/r4/schemas/path/ServiceRequestId.yaml b/specification/components/r4/schemas/path/ServiceRequestId.yaml index 0dc72ec15..178063547 100644 --- a/specification/components/r4/schemas/path/ServiceRequestId.yaml +++ b/specification/components/r4/schemas/path/ServiceRequestId.yaml @@ -1,7 +1,7 @@ name: id in: path description: | - An identifier that uniquely identifies a referral request or an advice and guidance. + An identifier that uniquely identifies a `ServiceRequest` resource. required: true schema: type: string diff --git a/specification/components/r4/schemas/queryParameters/Category.yaml b/specification/components/r4/schemas/queryParameters/Category.yaml deleted file mode 100644 index 0de2dfa94..000000000 --- a/specification/components/r4/schemas/queryParameters/Category.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: category -in: query -description: | - A code that classifies the service for searching, sorting and display purposes. - The pattern follows that of a [token](https://www.hl7.org/fhir/search.html#token), with `code` (the SNOMED CT ID) being mandatory and `system` being optional. - In this case, the code system will be SNOMED CT (http://snomed.info/sct). - - [parameter]=[code] - - [parameter]=[system]|[code] -required: false -style: form -explode: false -schema: - type: array - items: - type: string - format: token - minItems: 1 - maxItems: 1 -examples: - system_and_ubrn: - value: [ 'http://snomed.info/sct|3457005' ] - summary: Code system and category code - ubrn: - value: [ '3457005' ] - summary: Category code only diff --git a/specification/components/r4/schemas/queryParameters/Identifier.yaml b/specification/components/r4/schemas/queryParameters/Identifier.yaml index 3e583dd49..2a8bef30f 100644 --- a/specification/components/r4/schemas/queryParameters/Identifier.yaml +++ b/specification/components/r4/schemas/queryParameters/Identifier.yaml @@ -1,7 +1,7 @@ name: identifier in: query description: | - The UBRN which identifies the referral or advice and guidance. + The Unique Booking Reference Number (UBRN) used to search for `ServiceRequest` resources. The format follows that of a [token](https://www.hl7.org/fhir/search.html#token), with `code` (UBRN) being mandatory and `system` being optional. In this case, the code system will be eRS UBRN (https://fhir.nhs.uk/Id/UBRN). - [parameter]=[code] @@ -10,16 +10,12 @@ required: true style: form explode: false schema: - type: array - items: - type: string - format: token - minItems: 1 - maxItems: 1 + type: string + format: token examples: system_and_ubrn: - value: [ 'https://fhir.nhs.uk/Id/UBRN|000000070000' ] + value: 'https://fhir.nhs.uk/Id/UBRN|000000070000' summary: Code system and UBRN ubrn: - value: [ '000000070000' ] + value: '000000070000' summary: UBRN only diff --git a/specification/components/r4/schemas/responses/R4-Forbidden.yaml b/specification/components/r4/schemas/responses/R4-Forbidden.yaml index c8262cc1b..2474dd048 100644 --- a/specification/components/r4/schemas/responses/R4-Forbidden.yaml +++ b/specification/components/r4/schemas/responses/R4-Forbidden.yaml @@ -2,10 +2,10 @@ description: | Where status code 403 (Forbidden) 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_FORBIDDEN | forbidden | Information can only be retrieved for an authenticated user. | - | NO_RELATIONSHIP | forbidden | The user has no legitimate relationship with the resource. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ---------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | + | REC_FORBIDDEN | forbidden | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | A call attempts to access or operate upon a resource without proper authorisation. | + | NO_RELATIONSHIP | forbidden | [eRS Error Code](https://fhir.nhs.uk/CodeSystem/ers-error-codes) | The caller has no legitimate relationship with the resource. | headers: x-correlation-id: $ref: '../headers/response/CorrelationID.yaml' @@ -18,4 +18,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-403.json' diff --git a/specification/components/r4/schemas/responses/R4-InternalServerError.yaml b/specification/components/r4/schemas/responses/R4-InternalServerError.yaml index 56a4fcdb0..2ef93c870 100644 --- a/specification/components/r4/schemas/responses/R4-InternalServerError.yaml +++ b/specification/components/r4/schemas/responses/R4-InternalServerError.yaml @@ -2,9 +2,9 @@ description: | Where status code 500 (Internal Server Error) 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_SERVER_ERROR | exception | The server encountered an unexpected condition that prevented it from fulfilling the request. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ---------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- | + | REC_SERVER_ERROR | exception | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The server encountered an unexpected condition that prevented it from fulfilling the request. | headers: x-correlation-id: $ref: '../headers/response/CorrelationID.yaml' @@ -17,4 +17,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-500.json' diff --git a/specification/components/r4/schemas/responses/R4-NotAcceptable.yaml b/specification/components/r4/schemas/responses/R4-NotAcceptable.yaml index 152f81203..245e02c25 100644 --- a/specification/components/r4/schemas/responses/R4-NotAcceptable.yaml +++ b/specification/components/r4/schemas/responses/R4-NotAcceptable.yaml @@ -2,9 +2,9 @@ description: | Where status code 406 (Not Acceptable) 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 | - | ------------------------- | ------------- | --------------------------------------------------------------------------------------- | - | NOT_ACCEPTABLE | not-supported | The requested resource does not have a current representation that would be acceptable. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------- | + | REC_NOT_ACCEPTABLE | not-supported | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The requested resource does not have a current representation that would be acceptable. | headers: x-correlation-id: $ref: '../headers/response/CorrelationID.yaml' @@ -17,4 +17,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-406.json' diff --git a/specification/components/r4/schemas/responses/R4-NotFound.yaml b/specification/components/r4/schemas/responses/R4-NotFound.yaml index edf5af32e..9cccc1cd4 100644 --- a/specification/components/r4/schemas/responses/R4-NotFound.yaml +++ b/specification/components/r4/schemas/responses/R4-NotFound.yaml @@ -2,9 +2,9 @@ description: | Where status code 404 (Not Found) 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_NOT_FOUND | not-found | The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ---------- | ------------------------------------------------------------------ | ---------------------------------------------------------- | + | REC_NOT_FOUND | not-found | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The supplied URL or Resource does not exist on the server. | headers: x-correlation-id: $ref: '../headers/response/CorrelationID.yaml' @@ -17,4 +17,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-404.json' diff --git a/specification/components/r4/schemas/responses/R4-TooManyRequests.yaml b/specification/components/r4/schemas/responses/R4-TooManyRequests.yaml index b1e346a9e..e5cb113de 100644 --- a/specification/components/r4/schemas/responses/R4-TooManyRequests.yaml +++ b/specification/components/r4/schemas/responses/R4-TooManyRequests.yaml @@ -2,9 +2,9 @@ description: | Where status code 429 (Too Many Requests) 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 | - | ------------------------- | ---------- | ---------------------------------------------------- | - | TOO_MANY_REQUESTS | throttled | A maximum number of transactions has been reached. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ---------- | ----------------------------------------------------------------------------- | ---------------------------------- | + | TOO_MANY_REQUESTS | throttled | [APIM Error Code](https://fhir.nhs.uk/CodeSystem/NHSD-API-ErrorOrWarningCode) | The rate limit has been reached. | The e-Referral service APIs limit the number of transactions you can make per unit of time. This protects our service against excessive use and denial-of-service (DoS) attacks, and is also to encourage you to use our APIs efficiently. @@ -38,4 +38,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-429.json' diff --git a/specification/components/r4/schemas/responses/R4-Unauthorized.yaml b/specification/components/r4/schemas/responses/R4-Unauthorized.yaml index a74c878fb..cd3dc33fd 100644 --- a/specification/components/r4/schemas/responses/R4-Unauthorized.yaml +++ b/specification/components/r4/schemas/responses/R4-Unauthorized.yaml @@ -2,9 +2,9 @@ description: | Where status code 401 (Unauthorized) 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. - | FHIR issue.details code | FHIR issue.code | Description | - | ----------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------- | - | ACCESS_DENIED | forbidden | The request has not been applied because it lacks valid authentication credentials for the target resource. | + | issue.details.coding.code | issue.code | Coding System | Description | + | ------------------------- | ---------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | ACCESS_DENIED | login | [APIM Error Code](https://fhir.nhs.uk/CodeSystem/NHSD-API-ErrorOrWarningCode) | The request could not be authenticated due to either no credentials being provided or the provided credentials no longer being valid. Callers receiving this code should reauthenticate. | headers: x-correlation-id: $ref: '../headers/response/CorrelationID.yaml' @@ -15,4 +15,4 @@ content: schema: $ref: '../NHSDigital-OperationOutcome.yaml' example: - $ref: '../../examples/NHSDigital-OperationOutcome.json' + $ref: '../../examples/NHSDigital-OperationOutcome-401.json' diff --git a/specification/components/r4/schemas/responses/searchServiceRequest/200Response.yaml b/specification/components/r4/schemas/responses/searchServiceRequest/200Response.yaml index ddedef47c..bad122559 100644 --- a/specification/components/r4/schemas/responses/searchServiceRequest/200Response.yaml +++ b/specification/components/r4/schemas/responses/searchServiceRequest/200Response.yaml @@ -1,4 +1,4 @@ -description: Bundle resource containg the service requests associated to the supplied UBRN. +description: Bundle resource containg the `ServiceRequest` resources associated to the supplied UBRN. headers: x-correlation-id: $ref: '../../headers/response/CorrelationID.yaml' @@ -17,7 +17,6 @@ content: - timestamp - total - link - - entry properties: id: type: string @@ -25,15 +24,8 @@ content: meta: type: object required: - - profile + - lastUpdated properties: - profile: - type: array - items: - type: string - enum: - - 'https://fhir.hl7.org.uk/StructureDefinition/UKCore-Bundle' - example: 'https://fhir.hl7.org.uk/StructureDefinition/UKCore-Bundle' lastUpdated: type: string format: date-time @@ -96,7 +88,19 @@ content: - match example: 'match' examples: - minimal-example: - summary: One UBRN associated with one ServiceRequest (referral) + minimal-example-empty: + summary: An empty bundle might be returned when the search completes but matches no requests. + value: + $ref: '../../../examples/searchServiceRequest/responses/ResponseExampleEmpty.json' + minimal-example-referral: + summary: A response containing a single Request ID for a `ServiceRequest` of category `referral`. + value: + $ref: '../../../examples/searchServiceRequest/responses/ResponseExampleReferral.json' + minimal-example-advice: + summary: A response containing a single Request ID for a `ServiceRequest` of category `request`. + value: + $ref: '../../../examples/searchServiceRequest/responses/ResponseExampleAdvice.json' + complex-example-referral-and-advice: + summary: A response containing two Request IDs. value: - $ref: '../../../examples/searchServiceRequest/responses/ResponseExample.json' + $ref: '../../../examples/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json' diff --git a/specification/components/r4/schemas/responses/searchServiceRequest/400Response.yaml b/specification/components/r4/schemas/responses/searchServiceRequest/400Response.yaml new file mode 100644 index 000000000..6a095b0fc --- /dev/null +++ b/specification/components/r4/schemas/responses/searchServiceRequest/400Response.yaml @@ -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 | Coding System | Description | + | ------------------------- | ---------- | ------------------------------------------------------------------ | ------------------------------------------------------------ | + | REC_BAD_REQUEST | required | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | Incorrect or missing expected value. | +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-400.json' diff --git a/specification/components/r4/schemas/responses/searchServiceRequest/422Response.yaml b/specification/components/r4/schemas/responses/searchServiceRequest/422Response.yaml deleted file mode 100644 index 67da27d15..000000000 --- a/specification/components/r4/schemas/responses/searchServiceRequest/422Response.yaml +++ /dev/null @@ -1,20 +0,0 @@ -description: | - Where status code 422 (Unprocessable Entity) is returned then an eRS-OperationOutcome-1 will be included in the body, as detailed below. - Check diagnostics property for specific information regarding the error. - - | Error code | Description | - | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | - | NO_RELATIONSHIP | The user does not have a legitimate relationship with the request or service. | -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: '../../R4-OperationOutcome.yaml' - example: - $ref: '../../../examples/R4-OperationOutcome.json' diff --git a/specification/e-referrals-service-api.yaml b/specification/e-referrals-service-api.yaml index c9dc0e6fc..ce9a54d7f 100644 --- a/specification/e-referrals-service-api.yaml +++ b/specification/e-referrals-service-api.yaml @@ -3658,8 +3658,57 @@ paths: security: - bearerAuth: [] description: | - # TO ADD LATER - summary: A041 - Search service request + ## Overview + + The e-RS FHIR API represents an advice and guidance request and a referral in FHIR R4 as a ServiceRequest. This endpoint allows you to search for attributes about a ServiceRequest. + + At present the following is the only permitted use case for using this endpoint, but it is expected that additional use cases will be added as future needs are identified and prioritised. + - For FHIR R4 endpoints, the e-RS FHIR API requires a unique identifier for the ServiceRequest, instead of the UBRN, to identify an advice and guidance request or referral request. To support partners to transition from previous FHIR versions, and utilise the newer FHIR endpoints, this endpoint can be used as a bridging mechanism so that you can search for the required unique identifiers using a UBRN. + + ## Supported security patterns + + - Healthcare worker, user-restricted access + + ## Pre-requisites + To use this endpoint, you must be an authenticated e-RS user and use one of the following e-RS roles: + + - `REFERRING_CLINICIAN` + - `REFERRING_CLINICIAN_ADMIN` + - `SERVICE_PROVIDER_CLINICIAN` + - `SERVICE_PROVIDER_CLINICIAN_ADMIN` + + You need to use the Unique Booking Reference Number (UBRN) of an advice and guidance request or referral request. + + + ## Important notes + + When searching for a unique identifier for a ServiceRequest, it’s important to note that one UBRN can relate to both an advice and guidance request and a referral. In this case, the response could contain two unique identifiers: one relating to the advice and guidance request and one relating to the referral. + + ## Use case + + As an authenticated user  + + I need the unique identifier for a given advice and guidance request or referral request + + So that I can view or action an advice and guidance request or referral + + ## Related endpoints + + Once the unique identifier has been retrieved it can then be used to call the following endpoint to upload a clinical attachment + - [[HYPERLINK_A042]] + - [[HYPERLINK_A039]] + - [[HYPERLINK_A012]] + + ## Sandbox test scenarios + You can test the following scenarios in our sandbox environment + + | Scenario | UBRN | + | --------------------------------------------------------------------------------------- | -------------- | + | A response containing a single Request ID for a `ServiceRequest` of category `referral` | `000000070000` | + | A response containing a single Request ID for a `ServiceRequest` of category `request` | `000000070001` | + | A response containing two Request IDs | `000000070002` | + | A response containing an empty bundle | `000000070003` | + summary: A041 - Search for service requests operationId: a041-search-service-request parameters: - $ref: 'components/r4/schemas/headers/request/BearerAuthorization.yaml' @@ -3667,13 +3716,12 @@ paths: - $ref: 'components/r4/schemas/headers/request/CorrelationID.yaml' - $ref: 'components/r4/schemas/headers/request/OdsCode.yaml' - $ref: 'components/r4/schemas/headers/request/OnBehalfOfUserID.yaml' - - $ref: 'components/r4/schemas/queryParameters/Category.yaml' - $ref: 'components/r4/schemas/queryParameters/Identifier.yaml' responses: '200': $ref: 'components/r4/schemas/responses/searchServiceRequest/200Response.yaml' '400': - $ref: 'components/r4/schemas/responses/BadRequest.yaml' + $ref: 'components/r4/schemas/responses/searchServiceRequest/400Response.yaml' '401': $ref: 'components/r4/schemas/responses/R4-Unauthorized.yaml' '403': diff --git a/tests/sandbox/r4/test_a041_search_for_service_requests.py b/tests/sandbox/r4/test_a041_search_for_service_requests.py new file mode 100644 index 000000000..7c46ea9b0 --- /dev/null +++ b/tests/sandbox/r4/test_a041_search_for_service_requests.py @@ -0,0 +1,85 @@ +from typing import Callable, Dict, Iterable, List +from urllib import response + +import pytest +import asserts + +from requests import Response +from SandboxTest import SandboxTest +from data import Actor +from utils import HttpMethod + + +@pytest.mark.sandbox +class TestSearchForServiceRequests(SandboxTest): + authorised_actor_data = [Actor.RC, Actor.RCA, Actor.RC_DEV, Actor.SPC, Actor.SPCA] + + allowed_business_function_data = [ + "REFERRING_CLINICIAN", + "REFERRING_CLINICIAN_ADMIN", + "SERVICE_PROVIDER_CLINICIAN", + "SERVICE_PROVIDER_CLINICIAN_ADMIN", + ] + + testdata = [ + ( + "000000070000", + "r4/searchServiceRequest/responses/ResponseExampleReferral.json", + ), + ( + "000000070001", + "r4/searchServiceRequest/responses/ResponseExampleAdvice.json", + ), + ( + "000000070002", + "r4/searchServiceRequest/responses/ResponseExampleReferralAndAdvice.json", + ), + ( + "000000070003", + "r4/searchServiceRequest/responses/ResponseExampleEmpty.json", + ), + ] + + @pytest.fixture + def endpoint_url(self) -> str: + return "FHIR/R4/ServiceRequest" + + @pytest.fixture + def http_method(self) -> HttpMethod: + return HttpMethod.GET + + @pytest.fixture + def authorised_actors(self) -> Iterable[Actor]: + return TestSearchForServiceRequests.authorised_actor_data + + @pytest.fixture + def allowed_business_functions(self) -> Iterable[str]: + return TestSearchForServiceRequests.allowed_business_function_data + + @pytest.fixture + def call_endpoint( + self, call_endpoint_url_with_query: Callable[[Actor, Dict[str, str]], Response], + ) -> Callable[[Actor], Response]: + return lambda actor, headers={}: call_endpoint_url_with_query( + actor, {"identifier": "000000070000"}, headers, + ) + + @pytest.mark.parametrize("actor", authorised_actor_data) + @pytest.mark.parametrize("identifier,response", testdata) + def test_success( + self, + call_endpoint_url_with_query: Callable[[Actor, Dict[str, str]], Response], + load_json: Callable[[str], Dict[str, str]], + actor: Actor, + identifier, + response, + ): + expected_response = load_json(response) + actual_response = call_endpoint_url_with_query( + actor, {"identifier": identifier} + ) + + asserts.assert_status_code(200, actual_response.status_code) + asserts.assert_response(expected_response, actual_response) + + asserts.assert_json_response_headers(actual_response,)