FHIR Chat · Indexing Properties in HAPI base · hapi

Stream: hapi

Topic: Indexing Properties in HAPI base


view this post on Zulip Andrew Broadbent (Mar 13 2017 at 14:44):

Hi all,

I'm using the HAPI base client API to interact with the server, I've created a system to deal with referencing other resources, in which I insert a temporary uri in the ResourceReference, and then at a later point, I use this information to search the fhir database, convert temporary uri's to logical ones, and then set the correct value.

The issue I'm having is that I can't find any obvious way to index what's inside an IResource, so I'm having to write a lot of custom code to handle each property on each resource. E.g. instead of:

for (IResource resource: resources)
for (Property property: resource.properties)
hookup(property)

I have to do:

for (IResource resource: resources)
if (resource instanceof Patient)
hookup(((Patient)resource).getSibling())
...

The only way I can think to get around this is serialise the resource to xml, walk the tree, then deserialize it, but I don't think that is a very efficient solution. Am I missing some functionality in the API? (DSTU2)

view this post on Zulip Gary Teichrow (Mar 21 2017 at 20:25):

Sounds like a case for generics, no?


Last updated: Apr 12 2022 at 19:14 UTC