fhir_models icon indicating copy to clipboard operation
fhir_models copied to clipboard

support for datatype extension

Open esbakker opened this issue 3 years ago • 0 comments

If you have a primitive datatype with an extension the value can not be read. We have a QuestionnaireResponse with extended datatypes for the answers (in this example a date):

"item": [
    {
        "linkId": "date_1",
        "answer": [
            {
                "_valueDate": {
                    "extension": [
                        {
                            "url": "http://localhost/fhir/StructureDefinition/custom-dateType",
                            "valueString": "someDateString"
                        }
                    ]
                }
            }
        ]
    }
]

As you can see the date is emitted with a _ prefix by HAPI. As described here.

There is no way to access these values. If I do a JSON.dump of the item I only get the linkId:

{"linkId":"date_1"}

For non-primitive datatypes like Coding it works as expected

For XML responses it works a little better, since the extension value is set as hash on the valueDate field:

<FHIR::QuestionnaireResponse::Item::Answer:0x000055c8b430afc0
 @extension=[],
 @id=nil,
 @item=[],
 @modifierExtension=[],
 @valueAttachment=nil,
 @valueBoolean=nil,
 @valueCoding=nil,
 @valueDate=nil,
 @valueDateTime=nil,
 @valueDecimal=
  {"extension"=>
    {"valueString"=> "someDateString",
     "url"=>"http://localhost/fhir/StructureDefinition/custom-dateType"}},
 @valueInteger=nil,
 @valueQuantity=nil,
 @valueReference=nil,
 @valueString=nil,
 @valueTime=nil,
 @valueUri=nil>

esbakker avatar Aug 09 '21 12:08 esbakker