microsoft / fhir-server

A service that implements the FHIR standard
MIT License
1.15k stars 490 forks source link

Unabled to use custom fhir resource in SearchOptionsFactory #3881

Closed CCRalfvandenBurg closed 1 day ago

CCRalfvandenBurg commented 1 month ago

Describe the bug The SearchOptionsFactory uses ResourceType enum. It will throw ResourceNotSupportedException when resource isn't matching value of the enum. This exception is throws for custom resources added to ModelInfoProvider

FHIR Version? Stu3/R4/R5

Data provider? CosmosDB/SQL Server

To Reproduce

  1. Register custom type Formulary ModelInfo.ModelInspector.ImportType(typeof(Formulary));
  2. implement and register a custom IModelProvider to return the custom resource name and types.
  3. perform a search on that resource. e.g. {{ServerUrl}}/Formulary?_id=84fab1ea-9851-4220-8b76-cc58ec2b1faf

Expected behavior A Bundle either empty or containing the item.

Actual behavior ResourceNotSupportedException is thrown. yielding a issue "Resource type 'Formulary' is not supported."

EXPEkesheth commented 3 weeks ago

@CCRalfvandenBurg - We do not support creating custom resources today and hence you are seeing the behavior. Let us know if you have any further questions.

CCRalfvandenBurg commented 3 weeks ago

@EXPEkesheth would it be better to suggest a refactoring of the SearchOptionsFactory? The SearchOptionsFactory::Create method is quite long. To achieve custom resources the only option i see (and tested) is to copy and past the class/method.

Indeed there are more thinks that need to change to fully support custom resources ( the enum is used in multiple places). although with a little tweaking we got a few custom resources "working".

I think it would be a nice thing to have the ability to support custom resources. for our case a few hooks to achieve this with more easy would be nice.

EXPEkesheth commented 2 weeks ago

@CCRalfvandenBurg - Refactoring can be suggested. It does not guarantee the change will be accepted, as it needs to go through review by the technical experts. We do not plan to support custom search parameters.

EXPEkesheth commented 1 day ago

Closing with no further comments