Reading extensions #2511
-
Hello. I have problems about reading Extension. At the moment, I am reading the patient informations from this fixed bundle JSON string (it is an example)
For reading the Extension, I have this code JsonSerializerOptions options = new JsonSerializerOptions().ForFhir(); foreach (var entry in bundle.Entry) No one instruction is working but there are Url. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You are not on the correct level in the tree that is your FHIR resource. Your code gets extensions out of the extension, instead of extensions of the Patient. Use a pat_entry.GetExtension instead of your current code. Also, the GetStringExtension and GetBoolExtension will not work, since the datatype used in the birthplace extension is the Address datatype, not string or bool. This also means that you cannot use birth_place.Length. You will have to check for the City or other fields in the Address and display that. |
Beta Was this translation helpful? Give feedback.
-
Hi @mbaltus Thanks. After the use of pat_entry.GetExtension, how can I get the informations about the model?
Can you help me? Many thanks. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your support. Now it works. Thanks again. |
Beta Was this translation helpful? Give feedback.
With GetExtension you get the whole Extension object. Since you know that this extension's value will have an Address as datatype, you can cast the Extension.Value to its actual Address type and then use that.
Or, if you are only interested in the value anyway, you can use the GetExtensionValue method to get just the Address part: