Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def handler(

if not (core_model := repository.get_by_id(pointer_id)):
logger.log(LogReference.PRODELETE002, pointer_id=pointer_id)
return SpineErrorResponse.NO_RECORD_FOUND(
diagnostics="The requested DocumentReference could not be found",
)
return NRLResponse.RESOURCE_DOES_NOT_EXIST_DELETE()

repository.delete(core_model)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_delete_document_reference_not_exists(repository: DocumentPointerReposit
body = result.pop("body")

assert result == {
"statusCode": "404",
"statusCode": "200",
"headers": default_response_headers(),
"isBase64Encoded": False,
}
Expand All @@ -150,14 +150,14 @@ def test_delete_document_reference_not_exists(repository: DocumentPointerReposit
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "not-found",
"severity": "information",
"code": "informational",
"details": {
"coding": [
{
"code": "NO_RECORD_FOUND",
"display": "No record found",
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
"code": "RESOURCE_DELETED",
"display": "Resource deleted",
"system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode",
}
]
},
Expand Down
14 changes: 14 additions & 0 deletions layer/nrlf/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ def RESOURCE_DELETED(cls):
statusCode="200",
)

@classmethod
def RESOURCE_DOES_NOT_EXIST_DELETE(cls):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can alter this however people feel, if we want the diagnostics to say its already deleted or something else thats cool too

return cls.from_issues(
issues=[
producer_model.OperationOutcomeIssue(
severity="information",
code="informational",
details=NRLResponseConcept.from_code("RESOURCE_DELETED"),
diagnostics="The requested DocumentReference could not be found",
)
],
statusCode="200",
)


class SpineErrorResponse(Response):
@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ Feature: Producer - deleteDocumentReference - Success Scenarios
| system | value |
| http://snomed.info/sct | 736253002 |
When producer 'DK94' requests to delete DocumentReference with id 'DK94-000-NoPointerHere'
Then the response status code is 404
Then the response status code is 200
And the response is an OperationOutcome with 1 issue
And the OperationOutcome contains the issue:
"""
{
"severity": "error",
"code": "not-found",
"severity": "information",
"code": "informational",
"details": {
"coding": [
{
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
"code": "NO_RECORD_FOUND",
"display": "No record found"
"system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode",
"code": "RESOURCE_DELETED",
"display": "Resource deleted"
}
]
},
Expand Down