From 86aeb221d549c1cb8687fd40cda97a81e6ae55c9 Mon Sep 17 00:00:00 2001 From: kevinmason-nhs Date: Wed, 3 Jun 2026 17:38:28 +0100 Subject: [PATCH 1/6] 422 response for A042 endpoint --- .../endpoints/a042-retrieve-attachment.yaml | 2 ++ .../retrieveAttachment/422Response.yaml | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml diff --git a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml index 96200ee7d..f1b7f4a34 100644 --- a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml +++ b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml @@ -100,6 +100,8 @@ responses: $ref: '../responses/ForbiddenOrNoLR.yaml' '404': $ref: '../responses/NotFound.yaml' + '422': + $ref: '../responses/NotFound.yaml' '429': $ref: '../responses/TooManyRequests.yaml' '500': diff --git a/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml new file mode 100644 index 000000000..579178433 --- /dev/null +++ b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml @@ -0,0 +1,22 @@ +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 | + | ------------------------- | ---------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | PENDING | invalid | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The file is being scanned and cannot be retrieved. Wait at least 5 minutes before checking its availability again. | + | THREATS_FOUND | invalid | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The file has been quarantined after detecting a threat and cannot be retrieved. Contact the organisation that uploaded the file to resolve the issue and get the information you need. Details of who uploaded the file can be retrieved via any endpoint that provides details of an attachment in the success response (via the [[HYPERLINK_A005]] or [[HYPERLINK_A024]] endpoints, for example)| + | VALIDATION_FAILED | invalid | [BaRS Error Code](https://fhir.nhs.uk/CodeSystem/http-error-codes) | The file has failed validation and cannot be retrieved. Contact the organisation that uploaded the file to resolve the issue and get the information you need. Details of who uploaded a file can be retrieved via any endpoint that provides details of an attachment in the success response (via the [[HYPERLINK_A005]] or [[HYPERLINK_A024]] endpoints, for example)
Validation can fail because the: | +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-422.json' From 8bfb39638a345b0add702ee6ea4e0e353d81555b Mon Sep 17 00:00:00 2001 From: kevinmason-nhs Date: Wed, 3 Jun 2026 17:56:08 +0100 Subject: [PATCH 2/6] adds the 422 example --- .../r4/NHSDigital-OperationOutcome-422.json | 21 +++++++++++++++++++ .../endpoints/a042-retrieve-attachment.yaml | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json new file mode 100755 index 000000000..d61bdd440 --- /dev/null +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json @@ -0,0 +1,21 @@ +{ + "resourceType": "OperationOutcome", + "meta": { + "lastUpdated": "2022-03-01T10:00:00.42Z" + }, + "issue": [ + { + "severity": "error", + "code": "invalid", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "code": "PENDING" + } + ] + }, + "diagnostics": "The file is being scanned and cannot be retrieved. Wait at least 5 minutes before checking its availability again." + } + ] +} diff --git a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml index f1b7f4a34..47bfc9542 100644 --- a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml +++ b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml @@ -101,7 +101,7 @@ responses: '404': $ref: '../responses/NotFound.yaml' '422': - $ref: '../responses/NotFound.yaml' + $ref: '../responses/retrieveAttachment/422Response.yaml' '429': $ref: '../responses/TooManyRequests.yaml' '500': From 6a5dd8b3b4dc37620058dbce659ad1ba9800b9d5 Mon Sep 17 00:00:00 2001 From: TomKinghorn Date: Fri, 5 Jun 2026 11:56:00 +0100 Subject: [PATCH 3/6] Change 400 text to 422 --- .../r4/schemas/responses/retrieveAttachment/422Response.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml index 579178433..ac5be9ce0 100644 --- a/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml +++ b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml @@ -1,5 +1,5 @@ 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. + Where status code 422 (Unprocessable Content) 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 | From 687c6cb8c6f913695b83b5a64159238f43fdbdb7 Mon Sep 17 00:00:00 2001 From: TomKinghorn Date: Fri, 5 Jun 2026 12:03:51 +0100 Subject: [PATCH 4/6] Change 400 text to 422 on main A042 page --- .../r4/schemas/endpoints/a042-retrieve-attachment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml index 47bfc9542..a6327b9b6 100644 --- a/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml +++ b/specification/components/r4/schemas/endpoints/a042-retrieve-attachment.yaml @@ -29,7 +29,7 @@ description: | - `SERVICE_PROVIDER_CLINICIAN_ADMIN` ### Attachment availability - 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. + 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 422 error. See the Response HTTP 422 section for further information. 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]]. From 17bb00f7b04f694db6d50cce4fdb54a0552f7675 Mon Sep 17 00:00:00 2001 From: tom kinghorn Date: Fri, 5 Jun 2026 14:27:16 +0100 Subject: [PATCH 5/6] Change content to entity --- .../r4/schemas/responses/retrieveAttachment/422Response.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml index ac5be9ce0..e2242c433 100644 --- a/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml +++ b/specification/components/r4/schemas/responses/retrieveAttachment/422Response.yaml @@ -1,5 +1,5 @@ description: | - Where status code 422 (Unprocessable Content) is returned then an [NHSDigital-OperationOutcome](https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome) will be included in the body, as detailed below. + Where status code 422 (Unprocessable Entity) 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 | From a75df204e8695a3ba02ea9c14222629c956403d3 Mon Sep 17 00:00:00 2001 From: tom kinghorn Date: Fri, 5 Jun 2026 16:11:16 +0100 Subject: [PATCH 6/6] change coding system url --- sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json index d61bdd440..a7475c324 100755 --- a/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json +++ b/sandbox/src/mocks/r4/NHSDigital-OperationOutcome-422.json @@ -10,7 +10,7 @@ "details": { "coding": [ { - "system": "https://fhir.nhs.uk/CodeSystem/http-error-codes", + "system": "https://fhir.nhs.uk/CodeSystem/ers-error-codes", "code": "PENDING" } ]