How to Translate FHIR Resources

589 views
Skip to first unread message

Patrick Palacin

unread,
Jun 15, 2021, 12:12:46 PM6/15/21
to HAPI FHIR
According the FHIR Docs there are several options to translate attributes and let the server serve them in the requested language of the client by using the proper HTTP header.

However i don''t find any working sample so far how to apply the Extension probably.
I would like to use it with ActivityDefintion and Questionnaires.

Does someone have a working example he could share?

Patrick Palacin

unread,
Jun 16, 2021, 10:03:47 AM6/16/21
to HAPI FHIR
For the ones who are interested. I am discussing with Graham here:


Try to narrow down the problem and write a better example than we have today for the docs.

Patrick Palacin

unread,
Jun 16, 2021, 11:01:23 AM6/16/21
to HAPI FHIR
I tried it now with XML and the outcome is kinda funny.

When I load my ActivityDefinition (as json) that I have been created with XML it returns the title attribute with underscore. Any idea why it does that?


e.g.


<ActivityDefinition xmlns="http://hl7.org/fhir">
<meta>
<versionId value="1"/>
<lastUpdated value="2021-06-16T14:07:02.778+00:00"/>
<source value="#43f5d7dbb47e259a"/>
</meta>
<version value="1"/>
<name value="fish_vs_veggie"/>
<title>
<extension url="lang">
<!-- ?? 1..1 Code for Language -->
<valueCode value="de"/>
<!-- ?? 1..1 Value of extension -->
</extension>
<extension url="content">
<valueString value="Ein Deutscher Satz"/>
</extension>
</extension>
<extension url="lang">
<!-- ?? 1..1 Code for Language -->
<valueCode value="es"/>
<!-- ?? 1..1 Value of extension -->
</extension>
<extension url="content">
<valueString value="En Espanol"/>
</extension>
</extension>
<extension url="lang">
<!-- ?? 1..1 Code for Language -->
<valueCode value="en"/>
<!-- ?? 1..1 Value of extension -->
</extension>
<extension url="content">
<valueString value="In Englisch"/>
</extension>
</extension>
<valueString>
Default Value
</valueString>
</title>
....

Returns

"resourceType": "ActivityDefinition",
"id": "3059b708-ae00-4e02-81b8-c6bffe1d229c",
"meta": {
"versionId": "1",
"lastUpdated": "2021-06-16T14:53:37.959+00:00",
"source": "#73db4c41d0ddfd7e"
},
"version": "1",
"name": "fish_vs_veggie",
"_title": {
"extension": [
{
"extension": [
{
"url": "lang",
"valueCode": "de"
},
{
"url": "content",
"valueString": "Ein Deutscher Satz"
}
]
},
{
"extension": [
{
"url": "lang",
"valueCode": "es"
},
{
"url": "content",
"valueString": "En Espanol"
}
]
},
{
"extension": [
{
"url": "lang",
"valueCode": "en"
},
{
"url": "content",
"valueString": "In Englisch"
}
]
}
]
},
"subtitle": "fish for the win",
"status": "active",


Is that expected behavior and yes where is it defined?

Ian Bacher

unread,
Jun 16, 2021, 11:52:23 AM6/16/21
to Patrick Palacin, HAPI FHIR
That’s just how FHIR represents extensions to elements with primitive data types in JSON. The title element in ActivityDefinition has a type of string, meaning it’s a FHIR primitive data type. This is documented in the JSON format docs here: https://www.hl7.org/fhir/json.html#primitive.

-- 
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/45b95e6c-9ac1-46fe-9d29-d7e6cf4693f0n%40googlegroups.com.

Patrick Palacin

unread,
Jun 16, 2021, 5:32:43 PM6/16/21
to HAPI FHIR
I Ian,

thanks for the explanation. Helped me to understand why the _ is there, makes sense.
However, now I wonder why it does not return the title as primitive similar to the example in the page you linked.

"birthDate": "1970-03-30", "_birthDate": { "id": "314159", "extension" : [ { "url" : "http://example.org/fhir/StructureDefinition/text", "valueString" : "Easter 1970" }] }

Shouldnt it return the respective primitive based on the HTTP Language Header? So if I call it with Accept-Language: de-DE, the value defined for German should be served for the title attribute.
Maybe I got sth wrong?
Reply all
Reply to author
Forward
0 new messages