Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "overflow" to POCOs #2851

Open
ewoutkramer opened this issue Sep 9, 2024 · 0 comments
Open

Add support for "overflow" to POCOs #2851

ewoutkramer opened this issue Sep 9, 2024 · 0 comments
Labels
breaking change This issue/commit causes a breaking change, and requires a major version upgrade enhancement idea Something to think about needs research SDK-6 Issues related to the development of firely-net-sdk v6

Comments

@ewoutkramer
Copy link
Member

ewoutkramer commented Sep 9, 2024

At this moment, POCOs only have properties for the elements defined in the FHIR specification. In many POCO serialization/deserialization frameworks, there is support for overflow, where "unknown" data can still be retained while parsing, and thus be processed and serialized later on. Also, metadata can be modified to supply type information for such unknown properties. Implemented at its fullest we could:

  • Deserialize unknown properties to a kind of Dictionary that all resources support (part of Base?). If we don't have type information for that property, we would represent the contents of the json as a Dictionary.
  • If we would have type information, we could parse such unknown elements into the proper FHIR datatypes. This could be done by providing type information as described in Change ClassMappings so it can support custom resources  #2850.

Going even further we could try to support not only unknown, but incorrect data too:

  • repeating data if the property does not repeat (put those extra repeats in the overflow dictionary?)
  • mistyped data, especially when dealing with choices
  • unknown resources, by introducing a fully dynamic (e.g. overflow-only) base resource (which we've dubbed "DynamicResource" for now).

This would greatly enhance our capabilities to deal with newer data by older clients, or start working with newer (unpublished) versions of FHIR, without having to work with prereleases or multiple versions of the SDK. Or even fully custom resources.

There are numerous ways to achieve this, and also a number of issues that may arise, and I will just start off a list below:

  • This will require changing the parsers and serializers to know about overflow.
  • Unless we make them work against IDictionary (with setters), so that the implementation of this interface will either store it as a real property, or store it in an overflow dictionary.
  • It would change our current error categories and parser family definitions. E.g. "Ostrich" will become even more flexible and the whole notion of whether parsing would discard information will shift too.
  • When dealing with unknown properties (so, also no metadata as per Change ClassMappings so it can support custom resources  #2850 available), we could store the unknown data as dictionaries, but there will always be differences whether the source is json or xml which cannot be reconciled. The developer would have to deal with this.
  • We have found that implementing IReadOnlyDictionary directly by POCO's confuses libraries and tools and we would like to undo that design. This means that, if we chose to implement IDictionary, we should also not directly do this on the public interface of a resource. The projected C# 13 extension interfaces and adapters would have been a great help here, if they'd ever see the light.
  • We could tune the current PocoBuilder to exploit Overflow/dynamicresource so we can fully support bridging ITypedElement with POCOs.
@ewoutkramer ewoutkramer added enhancement needs research idea Something to think about labels Sep 9, 2024
@ewoutkramer ewoutkramer added the breaking change This issue/commit causes a breaking change, and requires a major version upgrade label Sep 23, 2024
@Kasdejong Kasdejong added the SDK-6 Issues related to the development of firely-net-sdk v6 label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This issue/commit causes a breaking change, and requires a major version upgrade enhancement idea Something to think about needs research SDK-6 Issues related to the development of firely-net-sdk v6
Projects
None yet
Development

No branches or pull requests

2 participants