Generating (Custom) Resource Definitions from StructureDefinition

302 views
Skip to first unread message

Rowan van Beckhoven

unread,
Apr 7, 2022, 10:54:42 AM4/7/22
to HAPI FHIR
Hi,

As a Client in FHIR I receive many data that conform to specific profiles. I have access to these profiles and I would like to have some automated way of converting these profiles in order to use them as java objects within my code. Meaning that these classes contain simple getters & setters for all fields within this StructureDefinition. 

Now I could write Custom Resource Structures for all of these https://hapifhir.io/hapi-fhir/docs/model/custom_structures.html but it seems like all information is already contained in the StructureDefinition. 
Is there a way to automatically generate models from StructureDefinitions, such that I could convert all StructureDefinitions to ResourceDefinitions? 

Kind regards,
Rowan

herb...@gmail.com

unread,
May 26, 2022, 4:00:44 PM5/26/22
to HAPI FHIR
In my opinion, you do not need create custom Java code for custom resource structures. Put your effort in validation using the FHIR definition files for those structures.

I came to this conclusion after 2 years of a project where most of time I just change the profile definition on the Java class.

You will have more work to get the custom information (use FhirPath to simplify this part) but will be more easy to support changes on the long run.

Andrea Caloni

unread,
Aug 25, 2022, 10:14:44 AM8/25/22
to HAPI FHIR
Hi, I have quite the same need as Rowan, about persisting custom resource definitions in the jpa server.
I am not able to understand how can I achieve this without creating custom Java classes.
I mean: I have the structure definition MyPatient, derived from Patient, and if I post an instance to the jpa server, I get the error:
HAPI-0302: Unknown resource type 'MyPatient' - Server knows how to handle: [Account, ActivityDefinition, etc...
even if I already persisted the StructureDefinition in the jpa server.

Kind regards,
Andrea
Reply all
Reply to author
Forward
0 new messages