Stream: implementers
Topic: How do I add a bundle entry for a "custom" resource
Anthony Rocco (Mar 21 2022 at 19:51):
I'm using HAPI FHIR, and have described a new resource through a structure definition. I have that resource in json form, and want to know if it is possible to add it to a Bundle object's entries.
for ex:
Bundle bundle = new Bundle();
BundleEntryComponent entry = new BundleEntryComponent();
entry.setResource(...);
bundle.addEntry(entry);
From what I've seen this is not possible unless I just build the bundle as a json string.
Oliver Egger (Mar 21 2022 at 19:56):
you can parse your json resource and then add that directly to the bundle: bundle.addEntry().setResource(...your resource...)
Anthony Rocco (Mar 21 2022 at 20:03):
@Oliver Egger
is it possible to do that without creating a class for my custom resource?
The example for the parser here requires a class object along with the serialized resource.
https://hapifhir.io/hapi-fhir/docs/model/parsers.html
Oliver Egger (Mar 21 2022 at 20:10):
I don't think you can add custom new resource to a bundle, this is restricted to the base resource types ... i was thinking that you made a profile on an existing resource, sorry.
Michele Mottini (Mar 21 2022 at 20:12):
No custom resource in FHIR, if you want something custom you have to use Basic + extensions
René Spronk (Mar 22 2022 at 06:59):
That having been said, some people will consciously decide to step outside of the boundaries/rules/framework as offered by FHIR, and be non-compliant. Some of the FHIR servers actually support non-FHIR-defined resource-types, others don't. Choosing to go down that path means you're on your own when it comes to tooling, so you'll likely have to extend HAPI on your own, and maintain your own code base going forward.
Using Basic w/ extensions is the FHIR way of creating a new resource type, which is supported by the various tools.
Anthony Rocco (Mar 22 2022 at 23:58):
Thanks all. The reason I ask is that I'm using the fhir mapping language to map non-fhir data models to fhir models - which also requires me to define structure definitions for the non fhir models. Ideally I'd like to combine my non fhir models into a bundle so I can map that bundle to a bundle of fhir models.
Anthony Rocco (Mar 23 2022 at 00:06):
"Using Basic w/ extensions is the FHIR way of creating a new resource type, which is supported by the various tools."
@René Spronk
Do you have an example of this?
Jean Duteau (Mar 23 2022 at 01:30):
http://hl7.org/fhir/us/davinci-drug-formulary/2022Jan/StructureDefinition-usdf-FormularyItem.html
Oliver Egger (Mar 23 2022 at 07:09):
Anthony Rocco said:
Thanks all. The reason I ask is that I'm using the fhir mapping language to map non-fhir data models to fhir models - which also requires me to define structure definitions for the non fhir models. Ideally I'd like to combine my non fhir models into a bundle so I can map that bundle to a bundle of fhir models.
Another possibility would be to treat the 'non fhir model data' as a binary (see https://chat.fhir.org/#narrow/stream/179252-IG-creation/topic/binary.20resources), i did not try it yet out, but I would like to use that as input for the FHIR Mapping Language.
Last updated: Apr 12 2022 at 19:14 UTC