FHIR Chat · How to stop hapi trimming empty resource properties · hapi

Stream: hapi

Topic: How to stop hapi trimming empty resource properties


view this post on Zulip Andrew Broadbent (Nov 22 2017 at 10:07):

Hi all,

I'm trying to create resources which have missing information, but have codings to represent why data is missing. E.g. A patients birth weight is missing because they were under or over the scale limit. @Igor Sirkovich gave me advice in the implementer stream for how I should structure this, and it looks like this:

<Patient xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2017-11-21T17:01:46.879+00:00"/>
</meta>
<extension url="https://purl.org/elab/fhir/network/StructureDefinition/1/BirthWeight">
<valueDecimal>
<extension url="http://www.hl7.org/fhir/extension-data-absent-reason.html">
<valueCoding>
<system value="http://hl7.org/fhir/ValueSet/birthweight"/>
<code value="Underweight"/>
<userSelected value="false"/>
</valueCoding>
</extension>
</valueDecimal>
</extension>
<extension url="https://purl.org/elab/fhir/StructureDefinition/1/ResourceGeneratorRef">
<valueReference>
<reference value="Basic/198"/>
</valueReference>
</extension>
<identifier>
<system value="https://purl.org/elab/fhir/network/StructureDefinition/1/EuroPrevallStudySubjects"/>
<value value="1"/>
</identifier>
<gender value="female"/>
</Patient>

When I request the patient back from the server however, I get the following back:

<Patient xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2017-11-21T17:01:46.879+00:00"/>
</meta>
<extension url="https://purl.org/elab/fhir/StructureDefinition/1/ResourceGeneratorRef">
<valueReference>
<reference value="Basic/198"/>
</valueReference>
</extension>
<identifier>
<system value="https://purl.org/elab/fhir/network/StructureDefinition/1/EuroPrevallStudySubjects"/>
<value value="1"/>
</identifier>
<gender value="female"/>
</Patient>

I assume that hapi is trimming extensions which contain no value, and that the test for no value is 'has valueDecimal'. Is there a way to fix this issue? I'm guessing I could put a dummy decimal in place, however this feels like the wrong approach.

view this post on Zulip Brian Postlethwaite (Nov 22 2017 at 21:29):

That does look like a bug to me too.

view this post on Zulip Kevin Mayfield (Nov 23 2017 at 08:12):

I can sort of see why it would be absent, you don't have a value, so why would it have an code. Can you alter the extension so the absent code is at the same level - i.e. not an extension to the valueDecimal?

view this post on Zulip Andrew Broadbent (Nov 23 2017 at 15:42):

@Kevin Mayfield I can do in the case, but I'm trying to find a generic solution. So for example if it was the gender that was missing, then the missing code would just appear in place where the value was.

view this post on Zulip Kevin Mayfield (Nov 23 2017 at 16:08):

But doesn't unknown gender mean something different to not asked - in which case it would be empty?

view this post on Zulip Andrew Broadbent (Nov 23 2017 at 16:15):

@Kevin Mayfield Yes, sorry I'm struggling for a good example. I make a tool which reads a csv and a (proprietary) annotation file, it then turns rows of the csv file into fhir resources based on the contents of the annotation file (this is why I need a generic way to do this). Often in the data I'm seeing, users have coded values like 1 and 2 to represent things like male and female. They also have codes like 99, 98, 97, which they consider to be exceptions to the normal data. I'm trying to find a way to capture that exception data, and doing it in the same part of the xml as where the value is stored is computationally better for the tools which have to process the fhir resources further down the line.

view this post on Zulip Grahame Grieve (Nov 23 2017 at 20:43):

report the issue on the hapi mailing list. It is a bug in HAPI


Last updated: Apr 12 2022 at 19:14 UTC