FHIR Chat · getId() vs getIdElement().getIdPart() on a resource · hapi

Stream: hapi

Topic: getId() vs getIdElement().getIdPart() on a resource


view this post on Zulip Daniel Thomson (Oct 05 2021 at 21:29):

Hi folks, hopefully this isn't a stupid question. New to HAPI and trying to understand why, when trying to retrieve the id element (logical id not Identifier) of a resource, the getId() method is returning a URL (or perhaps more accurately, why the behaviour of the getId() is designed this way).

If my resource looks like this:

"resourceType": "Patient",
"id": "4af350f43c854fceacd4b920498b004e",
"meta": {
"versionId": "2",
"lastUpdated": "2021-10-04T12:57:35.785-04:00"
},
"text": {... etc.

Calling patient.getId() returns https://wildfhir4.aegis.net/fhir4-0-1/Patient/4af350f43c854fceacd4b920498b004e/_history/2 - not what I expected.

To get the actual Patient.id element (i.e. return just "4af3...4e"), you have to call: patient.getIdElement().getIdPart()

Looking through the HAPI javadoc it looks like this is intentional. What is the thinking behind this / what is the use case for .getId()? Why is the id an IdPart in getIdElement()?

Thanks!

view this post on Zulip Patrick Werner (Oct 06 2021 at 07:45):

I think this behaviour is wrong and also leads to Problems regarding fhirpath. I already reported this issue here: https://github.com/hapifhir/hapi-fhir/issues/2785

view this post on Zulip Patrick Werner (Oct 06 2021 at 07:45):

fyi @James Agnew


Last updated: Apr 12 2022 at 19:14 UTC