Stream: implementers
Topic: Extend hapi-fhir-jpaserver-starter with custom extensions
Luca Toldo (Nov 22 2019 at 08:47):
Dear all,
I am using hapi-fhir-hpaserver-starter for local testing. I need to extend it with custom extensions.
I 've created in main/java/ca/uhn/fhir/jpa/starter/ MyPatient,java and filled with the appropriate code as specified in (https://hapifhir.io/doc_extensions.html)
Then mvn clean package
and mvn jetty:run
The capability statement however does not show petName.
Could you please explain how to extend it ?
Thanks
Patrick Werner (Nov 22 2019 at 08:54):
Hey, i'm assuming that you want to handle "custom" profiled Patient instances.
This can be handled by hapi, or any other FHIR server, without any modifications as a profiled Patient is still a Patient and FHIR Servers know how to handle profiled Resources and added Extensions.
Luca Toldo (Nov 22 2019 at 09:01):
Thankyou Patrick for your quick reply.
I need to extend Patient with additional field that is not present in the class.
And I need to be able to search on that field too.
For practical reasons I am using api-fhir-hpaserver-starter and I understood that I need to implement the java class as in the doc_extension.html
I did it but when I run jetty it does not show petName. Additionally, if I query or post a Patient resource with the petName attribute it gets ignored, and in the log it is written that the attribute is unknown
Patrick Werner (Nov 22 2019 at 09:03):
If you want to add extra fields/information, the FHIR compliant way to do this is adding Extensions. Just adding new fields will break your FHIR compatibility.
Patrick Werner (Nov 22 2019 at 09:04):
Hapi has the technical capability of extending/modifying/adding new classes, but this shouldn't be needed as FHIR already has mechanisms to handle "extra fields".
Luca Toldo (Nov 22 2019 at 09:07):
Can you please provide a link to a tutorial or practical example on how to add an Extension ?
Luca Toldo (Nov 22 2019 at 09:08):
I was trying to follow the https://hapifhir.io/doc_extensions.html documentation
Patrick Werner (Nov 22 2019 at 09:36):
You need to:
- create your Extension as a StructureDefinition
- create your Profile(s) as StructureDefinitions
- Upload everything on your hapi server ( {base_url}/StructureDefinition)
- you are done
Luca Toldo (Nov 22 2019 at 10:01):
Thankyou
Last updated: Apr 12 2022 at 19:14 UTC