Stream: hapi
Topic: Handling Custom Profiles
Georg Fette (Nov 15 2018 at 13:53):
Hi,
I would like to make some experiments like in the Yosemite Project by parsing FHIR profiles and transform them into graph structures.
To achieve that, I am looking for a method to take a FHIR profile definition String (e.g. the XML resource content from http://www.hl7.org/fhir/observation.html#tabs-xml) and parse it to receive a Java runtime object.
I hoped that in the HAPI Java structure package (hapi-fhir-structures-dstu3-3.6.0.jar) I could find a parser that I could use to accomplish this task.
However in some threads in the last two years there have been discussions that HAPI is not capable of handling custom profile definitions because it rather uses concrete classes for each profile.
Is this true, so it is of no use to search the HAPI code base for a component that I could use ? If this were true, is there an alternative that could be used to parse custom profiles ?
Greetings
Georg
Patrick Werner (Nov 16 2018 at 09:33):
If you have a XML representation of a FHIR resource you can parse it using HAPI with no extra effort like this:
FhirContext ctx = FhirContext.forDstu3(); Observation obs = (Observation) ctx.newXmlParser().parseResource(resourceString);
The profile this instance is claiming to be compliant to doesn't matter as every profiled resource is still a resource, in your example still an observation.
@Georg Fette
Georg Fette (Nov 22 2018 at 10:17):
Ah, thank you. That worked well. I now managed to store the StructureDefinitions of a set of handcrafted profiles in a HAPI server.
Would it now also be possible to store instances/resources of these custom profiles in the same HAPI server ?
Patrick Werner (Nov 22 2018 at 10:50):
sure. Profiles are always based on the base resources. http://fhir.de/StructureDefinition/patient-de-basis-0.2 for example is based on patient. You can store the profile as a StructureDefinition on a HAPI Server.
Patient instances claiming their compliance to a profile through the meta tag, stating "i am conforming to profile XY".
Patrick Werner (Nov 22 2018 at 10:52):
If you want to have an instance of patient-de-basis, then you create a patient conforming to the profile, include the profile(s) url(s) in meta and of course you then can persist it to a FHIR Server like HAPI.
Patrick Werner (Nov 22 2018 at 10:53):
To check if the instance is conform to the profile you then can use the $validate operation on the instance.
Last updated: Apr 12 2022 at 19:14 UTC