FHIR Chat · Strange case with DiagnosticReport · implementers

Stream: implementers

Topic: Strange case with DiagnosticReport


view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 09:04):

Hi!

I am using HAPI and faced strange case with DiagnosticReport.
I add 3 Observation into DiagnosticReport.getContained(), but in output JSON doesn't have 'contained' section at all.

Could you help me with any advise why that can be possible?

Thanks

view this post on Zulip Michael Calderero (Feb 14 2019 at 10:20):

I believe HAPI removes contained resources if they are not being referenced by the containing resource.

This should work.

Patient pat = new Patient();
pat.setActive(true);
// do not set an id for pat; HAPI will automatically assign ids for contained resources
Observation obs = new Observation();
obs.setSubject(new Reference(pat));

In here, patient is being added as a contained resource to observation.

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 11:25):

Hi Micheal!

Thank you for good advise.
I try to do in that way.
But in my case I want add Observation to DiagnosticReport as contained resource.
It is should be possible, I see examples on test server.

But by some unknown me reason it doesn't work in my case.

view this post on Zulip Michael Calderero (Feb 14 2019 at 11:54):

You can't just go and do:

mydiagnosticreport.getContained().add(myobs);

You have to do something like (in your case):

Observation obs = new Observation();
// set observation fields; do not set resource id
DiagnosticReport diagRpt = new DiagnosticReport();
diagRpt.addResult(new Reference(obs));

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 12:17):

Thank you! Thank you a lot! You saved my life!
It works now as I want.

Could I ask one more question?

I have four STRINGS values which I want put into Observation:

 name of analysis,  result of analysis, unit of measurement, result interval

Could you advice me a way which I can do it?
I cannot use Quantity because it accepts only numeric result of analysis and result interval?

view this post on Zulip Michael Calderero (Feb 14 2019 at 13:35):

Are those the actual literal values you want to put into an Observation? Or those are just field names and you are trying to put into an Observation the following example?

Systolic BP, 120, mm[Hg], 100-120

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 13:50):

I need to put these literal values into observations.
The best way which I found is using Observation.component:
{
"resourceType": "Observation",
"id": "1",
"component": [
{
"id": "name-of-analysis",
"valueString": "a1"
},
{
"id": "result-of-analysis",
"valueString": "a2"
},
{
"id": "unit-of-measurement",
"valueString": "a3"
},
{
"id": "reference-interval",
"valueString": "a4"
}
]
}

But it does't look good. May be "more FHIR" way exists?

view this post on Zulip Michael Calderero (Feb 14 2019 at 13:58):

Not sure what you're trying to model, but in my opinion I would map your:
1. name of analysis to Observation.code
2. result of analysis to Observation.valueQuantity.value
3. unit of measurement to Observation.valueQuantity.unit or Observation.valueQuantity.code
4. reference-interval to Observation.referenceRange

See this example: http://hl7.org/fhir/STU3/observation-example-f001-glucose.json.html

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 14:21):

I cannot use Observation.valueQuantity.value, because in my case result of analysis is string, which not garanteed to be representation of numeric value.

The same about Observation.referenceRange and my referenceinterval.

view this post on Zulip Craig McClendon (Feb 14 2019 at 14:24):

I suggest you spend some time reading the Observation definition. Observation.value[x] is a "choice type" (aka variable type), and will accept values of many different data types.

view this post on Zulip Craig McClendon (Feb 14 2019 at 14:27):

It might be helpful to understand what you are modeling as well. Having a unit of measure for a string value is not common.

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 15:25):

I am already doing that - reading documentation and sources.
Observation.value[x] can accept restricted set of type and no one can satisfy my crazy uncommon case.

Thank you a lot for your help.

view this post on Zulip Lloyd McKenzie (Feb 14 2019 at 15:48):

Be careful in your use of 'contained'. It's not a packaging/delivery mechanism. In general, the Observations within a DiagnosticReport should be able to stand independently, which means they should not be sent as 'contained' resources - they should be independent resources. If you need to send them alongside the DiagnosticReport, look at the batch or transaction mechanisms.

view this post on Zulip Michael Calderero (Feb 14 2019 at 15:56):

@Valeriy Shtanko To keep things in topic, I believe your original question is largely answered. Lloyd also gives a good recommendation that you should think about.

I would suggest creating a new topic thread for your other question so answers and replies for that topic can be focused to that one instead.

view this post on Zulip Valeriy Shtanko (Feb 14 2019 at 16:17):

@Lloyd McKenzie , @Michael Calderero

Thank you.
I agree, It is right to work with Observation as independent resource and I will try to do it in that way in nearest future.
But at the moment, I have what I have.


Last updated: Apr 12 2022 at 19:14 UTC