FHIR Chat · Microsoft fhir-codegen-cli · dotnet

Stream: dotnet

Topic: Microsoft fhir-codegen-cli


view this post on Zulip Timo Rosenblatt (Feb 15 2021 at 07:43):

Good morning,
does anybody have experience with Microsoft's fhir-codegen-cli tool that's available on GitHub (https://github.com/microsoft/fhir-codegen)?

It generates classes for standard HL7 resources, but I can't get it to generate classes for custom profiles.

@Gino Canessa I just realized, that you're the CLI developer. Any hint how to generate those classes? The project I'm trying to generate is https://simplifier.net/erezept-workflow

view this post on Zulip Brian Postlethwaite (Feb 15 2021 at 08:38):

To my knowledge there are no code generators for custom profiles.
All fhir resources can be parsed with the standard object models.

view this post on Zulip Brian Postlethwaite (Feb 15 2021 at 08:39):

This writeup might help with some ideas.
https://brianpos.com/2018/05/03/code-generation-fhir-custom-resources/

view this post on Zulip Gino Canessa (Feb 15 2021 at 22:02):

Hi @Timo Rosenblatt , Brian is correct - it doesn't generate code for custom profiles (yet). It's on my list, but there are still a few things ahead of that.

Part of the issue is determining what the code should look like - e.g., if you are generating C# code, should it interoperate with the Firely library? I think it is more useful if it does, but it involves a bit more work up front.

view this post on Zulip Ewout Kramer (Feb 16 2021 at 12:03):

@Timo Rosenblatt - Firely is using @Gino Canessa 's code generator to generate the classes for the .NET SDK.

As Gino says, there are many ways to generate code from a profile (and I am sure there are some Java projects that do), but there are a few interesting things to consider, e.g.

  • Do the generated profiles need to be subclasses of the original resources (that would bring a lot of restrictions in generating profiles)
  • Do you want elements that are constrained from 0..* to 0..1 to be changed from a list to a single property?
  • What to do with slices? Some subclasses of slices could be turned as a separate new property in the class.

What were you looking for specifically?

view this post on Zulip Timo Rosenblatt (Feb 16 2021 at 12:21):

@Ewout Kramer I'd be happy to have anything to work with instead of having to do it all manually.
Working with XML it was perfectly okay for me to use the xsd.exe generated code - despite it's limitations/anomalies.

The profiles wouldn't have to be subclasses of the original resources.
Elements that are constrained to 0..1 may remain lists and it's no problem if slices result in separate properties.

As long as we know how to work with the classes it'd be perfectly fine.

view this post on Zulip Ward Weistra (Feb 16 2021 at 12:45):

cc @Cees de Jonge @Hans van Amstel :point_up:

view this post on Zulip Brian Postlethwaite (Feb 17 2021 at 12:59):

And as long as you don't expect to use other peoples packages to work with your classes too, and only have 1 level of profiles to worry about.
e.g. Patient from IPS, standard, USCore, other properties from the specific vendor?


Last updated: Apr 12 2022 at 19:14 UTC