FHIR Chat · Using Java Core Code Generator · implementers

Stream: implementers

Topic: Using Java Core Code Generator


view this post on Zulip Dimi (Jun 16 2020 at 05:10):

Hi everyone,

I'm looking into a way of converting structure definitions from IG into customized resource implementation which I then can use with validator.

I saw this utility https://github.com/hapifhir/org.hl7.fhir.core/tree/master/org.hl7.fhir.core.generator which if I understand correctly helps building custom R5 by applying customization on top of core R5.

Can someone please explain what steps should I take to enable this flow: IG -> Structure Definition -> Customized R5?

view this post on Zulip Grahame Grieve (Jun 16 2020 at 07:53):

we don't really support that workflow - that's why it's not really working for you

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 12:01):

The point of FHIR is to have a single consistent schema across all FHIR implementations for a given version. If your notion of customization is defining what extensions are allowed, that's fine. If your notion is changing what elements or resources exist, then you're no longer really using FHIR - and that's not something we feel would be helpful to interoperability across the community. That doesn't mean you can't do it, but it's not something we'd invest in supporting.

view this post on Zulip Dimi (Jun 16 2020 at 20:25):

Thanks @Grahame Grieve and @Lloyd McKenzie ,

As you suggested my intention is not to change the default resource implementation, but define a new model by appending default resource with all possible extensions, so then I can use this model for validation later.

Will I be able to do this using java core code generator?

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 20:37):

The code in the various reference implementations (Java, .NET, etc) already supports extensions all the places they're allowed to be. We don't have a code generator that generates code specific to particular profiles - so no getters for specific extensions, though because you can grab an extension by URL, that generally isn't too much of an issue.

view this post on Zulip Dimi (Jun 16 2020 at 20:43):

Thanks @Lloyd McKenzie , looks like I misunderstood the meaning of java core code generator then, would you be able to clarify please what is the use case when I would use java code generator?

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 20:46):

Generally, you wouldn't. It is used to produce the base HAPI, .NET and other interfaces. If you wanted to tweak the code generated somehow to meet special requirements, you could do that, but otherwise it's probably simpler (and you'd certainly have more community support if you ran into issues) to just use the officially published reference implementation.

view this post on Zulip Steven Wang (Jun 16 2020 at 20:50):

Thanks @Lloyd McKenzie , we have our custom StructureDefinition for our patient(by add few new fields), and we are using HAPI FHIR, does that means we need manually create our custom Patient java code by extend hapi Patient?

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 22:04):

Are you adding new fields or are you using extensions? (Because you should be doing the latter...)

view this post on Zulip Dimi (Jun 16 2020 at 22:31):

@Lloyd McKenzie we are adding extensions, the example resource that we need to serve via API: http://build.fhir.org/ig/HL7NZ/northernRegion/branches/master/StructureDefinition-HaPatient.html

Can you please advise what will be the most efficient way taking that this resource is derived from a resource in another IG?

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 22:46):

You are the authors of the HaPatient profile and you're wanting to indicate it's derived from a profile defined in another IG?

view this post on Zulip Lloyd McKenzie (Jun 16 2020 at 22:48):

If you're using extensions, no need to extend HAPI Patient. If you really feel the need to have custom accessors for your extensions, you could define a class on top that adds alias methods for those, but the default extension methods should work fine.

view this post on Zulip Steven Wang (Jun 16 2020 at 22:54):

@Lloyd McKenzie from the HAPI FHIR guide, it recommend using custom type https://hapifhir.io/hapi-fhir/docs/model/profiles_and_extensions.html

view this post on Zulip Dimi (Jun 16 2020 at 23:13):

@Lloyd McKenzie yes, we are maintaining implementation of haPatient derived from nzPatient(we don't maintain) and we are looking for efficient way of maintaining haPatient using HAPI FHIR.

Building a class on top of Patient seems like a good approach, but I'm not sure about how to handle the fact that haPatient is derived from another custom type (nzPatient) maintained in another IG.

I'm trying to avoid building class for resource that we don't maintain but need to derive from.

view this post on Zulip Lloyd McKenzie (Jun 17 2020 at 01:04):

@James Agnew

view this post on Zulip Grahame Grieve (Jun 17 2020 at 01:04):

see https://chat.fhir.org/#narrow/stream/179167-hapi/topic/Generating.20code.20for.20Profiles


Last updated: Apr 12 2022 at 19:14 UTC