FHIR icon indicating copy to clipboard operation
FHIR copied to clipboard

Unify approach for adding operation outcome issues for search operation

Open PrasannaHegde1 opened this issue 2 years ago • 0 comments

Describe the bug The search operation outcome issues are currently being added to two different components : FHIRSearchContext and MultiResourceResult. To prepare the final search response Bundle, only the FHIRSearchContext operation outcome issues are considered and the MultiResourceResult operation outcome issues are ignored in the FHIRRestHelper.createSearchResponseBundle() method. We should consider adding the operation outcome issues to only MultiResourceResult and not the FHIRSearchContext. The FHIRSearchContext should be made immutable and no further changes must be made to it in the persistence layer. We should also consider the operation outcome issue severity along with the search operation leniency configuration. Environment Which version of LinuxForHealth FHIR Server? 5.0

To Reproduce Steps to reproduce the behavior:

  1. Go to FHIRPersistenceJDBCImpl.search() method where the validatePagingContext() is being called and the operation outcome issues generated from validatePagingContext(if any) are being added to the MultiResourceResult builder. Go to SearchHelper.parseQueryParameters() method(The one which returns FHIRSearchContext) and he operation outcome issues generated in the catch block are added to FHIRSearchContext. In the FHIRRestHelper.createSearchResponseBundle() method only the FHIRSearchContext operation outcome issues are added to the search response Bundle.

  2. Try a search operation with an invalid page number. https://localhost:9443/fhir-server/api/v4/Patient?_count=2&_page=0 The search response does not contain a warning or error for the invalid page number.

{
	"resourceType": "Bundle",
	"id": "9342baf2-e9d4-468f-bb03-3edd57e2dbaa",
	"type": "searchset",
	"total": 258,
	"link": [
		{
			"relation": "self",
			"url": "https://localhost:9443/fhir-server/api/v4/Patient?_count=2&_page=0"
		},
		{
			"relation": "next",
			"url": "https://localhost:9443/fhir-server/api/v4/Patient?_count=2&_page=1"
		}
	]
}

Expected behavior The search response should have a warning for the invalid page if the search operation is lenient.

[{
    "severity": "error",
    "code": "invalid",
    "details": {
        "text": "Invalid page number: 0"
    }
}]

PrasannaHegde1 avatar Oct 07 '22 08:10 PrasannaHegde1