Stream: dotnet
Topic: Observation Values
Lars Ewert (Jan 28 2022 at 10:54):
Hey i got the problem, that Observations can have different values, which the Frontend cant parse.
Im using the .Net SDK from firely and they provide this implementation:
image.png
When i get my Resources from the hl7 server this is my output before sending it to the frontend
image.png
So far so good, but as we can see, there is just a Property called Value, but the Frontend npm package @types/fhir provides different property names for the different values that could appear.
image.png
Is there a way to map these properties correctly, before the information is lost? Or is there another npm package, that covers this automaticaly?
This is my incoming Object at the Frontend:
image.png
I thought about sending to the frontend as Object, since i have the "typeName" of the value i could parse it to the corresponding Object, but that looks unusual to me.
Im happy for any advice ;-)
Greetings Lars
Gino Canessa (Jan 28 2022 at 16:55):
Hi Lars, oddly enough, both are correct.
When serializing choice elements, the type is appended to the element name. A good example is the deceased[x]
element on the Patient resource. The element itself is actually defined as Patient.deceased
, with a choice of boolean or date-time data types. When processed, the tooling appends the [x]
to signify it is a choice type, and in serialization you may have either Patient.deceasedBoolean
or Patient.deceasedDateTime
present. What is important to note is that these are two different data types in the same element. So, it not allowed to have both of them present.
In your case, the C# SDK is providing convenience access by representing Value
as a single property which may have multiple types. In the TypeScript types it is showing the raw models that match the JSON serialization format*.
*There are a few of us that are looking into making a TS/JS 'SDK' that uses classes and has a cleaner interface... it is a lot of work with a long-term commitment though, so it may be a while yet.
Lars Ewert (Jan 28 2022 at 17:49):
Hi Gino,
thank you for the Answer. Well since it is also in my interest, to make use of an compatible SDK, i would like to help you too. But only, if you're searching more Developers for that.
In the meantime, i will go around that problem and parse these values separatly.
Gino Canessa (Jan 28 2022 at 18:40):
No problem! The #javascript stream is where all the TS-related conversations happen, feel free to jump in at any time.
Brian Postlethwaite (Jan 28 2022 at 19:49):
Note that the C# library there serialises with the valueString or whichever route you have in the object model. That's how they are both compatible with each other, and the fhir spec.
Dennis Brox (Jan 29 2022 at 22:26):
Is there an example of an SDK blood pressure observation somewhere. I assume the 2 values go into a codeableconcept but the data types are driving me crazy. Thanks.
Dennis Brox (Jan 30 2022 at 23:32):
I figured out how to create blood pressure observations but, moving on, I use getproperties() to find all the properties in a class. Working on a fhir class like Person though, I get a lot of things that SDK adds by itself or are inherited. Is there a way to select from the properties list only those declared in the fhir documentation for that resource?
Marco Visser (Jan 31 2022 at 08:30):
When you are working with Pocos, which you do I think, you can enumerate through all elements of a resource with the property NamedChildren
or the property Children
. See here an example:
var resource = new Patient();
foreach (var child in resource.NamedChildren)
{
Console.WriteLine($"property: { child.ElementName} with value {child.Value}");
}
The property Children
of a resource gives you the values of all child elements of a resource.
Brian Postlethwaite (Jan 31 2022 at 11:40):
What are you trying to do with enumerating the properties?
Dennis Brox (Feb 12 2022 at 08:11):
In the user interface I want to bring up the properties in the resource that they can change and, based on their type, allow editing them in a C# form.
Brian Postlethwaite (Feb 12 2022 at 09:40):
Check the Firely docs for the classmapping and property mapping classes, they would let you do that quite generically.
Last updated: Apr 12 2022 at 19:14 UTC