fhir-sdk icon indicating copy to clipboard operation
fhir-sdk copied to clipboard

Custom Profile Support

Open Tohmua opened this issue 1 year ago • 1 comments

Support for custom profiles would be a nice to have.

https://www.hl7.org/fhir/profiling.html

Although, this would require thinking about the implementation, because you would need to generate the structs in the consuming service, so this could be quite a fundimental change.

Something like how prost-builder generates structs from protcol buffer files in the build.rs file of the consuming project could be nice. It could also help with build times as the generated types would sit in the consumers project and would be seporated from the sdk-client code.

This might not be the best approach though.

Tohmua avatar May 23 '24 18:05 Tohmua

That is indeed a fundamentally different design and sounds more like a new library if the structs are generated in user code. I don't think this will find its way into this crate.

However, due to profiling still being in conformance with the FHIR resource layout, you could make a trait on top: There could be a proc macro generating a trait for a profile. The trait is then implemented for the specified resources in the profile and validates conformance with the profile. That way you would need to remember to call the validation though.

FlixCoder avatar May 23 '24 20:05 FlixCoder

There is now even more possibilities: It would be possible to make your own structs for the profile (in what way ever, generated or not). Then you can use custom requests and parse the response to your types instead. The rest of the machinery would still be used, only URLs and response status handling would be custom. Though it might even be possible to use the normal client methods without custom requests at all. It might be possible to just implement the required traits.

That said, I don't think I will bake in custom profile support itself, but allow crates on top to implement that without a lot of effort. So, closing this for now, but feel free to reopen if you think it is not easy enough to build profiles on top.

FlixCoder avatar Aug 18 '24 20:08 FlixCoder