FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
824 stars 342 forks source link

Streamline primitive's Value, ObjecValue and "original text" #2781

Open ewoutkramer opened 5 months ago

ewoutkramer commented 5 months ago

The Primitive POCO's currently have an internal representation that is the same as the type of their Value property. They are listed in the IReadOnlyDictionary documentation.

POCO's also have an ObjectValue property, that should contain their internal representation (so the same as Value), but can also be used to store a verbatim string (from the json or xml) if it could not be parsed into the format required by the Value (i.e. an integer in Integer that was unparseable in the XML attribute).

For some operations on these primitives, the internal representation is not good enough, i.e. FhirDateTime needs to parse the string value in it to do comparisons. Conversely, some of the constructors of FhirDateTime pass in a discrete date time (already parsed), but since it stores a string internally, these are formatted to a string and then thrown away.

The current setup has a few disadvantages:

We should fix these disadvantages, maybe like so: