Generating FHIR Models (c# and java code) from XSD (other schema)

700 views
Skip to first unread message

ashish.s...@gmail.com

unread,
May 18, 2017, 3:08:47 AM5/18/17
to FHIR DOTNET
Hi,

We do polyglot development.
We need our custom FHIR resources (MyPatient subclasses STU3 Patient for example) to be available in both C# and JAVA.

How can we generate C#/JAVA classes from a common schema representation?
How does FHIR.Net generate C# classes from the FHIR XSDs (or another specification)?

Thanks

Brian Postlethwaite

unread,
May 18, 2017, 5:34:08 PM5/18/17
to FHIR DOTNET
The NuGet packages for the c# classes are code generated off the FHIR metadata that is built as part of the specification, and includes a lot more than is contained in the XSD files, and also has the FHIR validation components built in, and native support for FHIR's extensibility model and serializers for XML and JSON.
These are the recommended approaches with the .net models.

There is a similar set of classes done in a similar way for JAVA which can be found http://hapifhir.io/

Brian Postlethwaite

unread,
May 18, 2017, 5:35:45 PM5/18/17
to FHIR DOTNET
Just note that if you use the XSD files to code generate things, you're going to have a lot of other work to do, the default serializers may not work, and the JSON and XML serializers are slightly different in their formats.

ashish.s...@gmail.com

unread,
May 20, 2017, 11:22:30 PM5/20/17
to FHIR DOTNET
How are the models generated off the FHIR spec?
Is the tooling around this open source?

All I found looking at the code were some T4 templates.

The goal for us is to maintain same contracts with Java and .Net implementations. Any suggestions on how to do this would be welcome.

Mirjam Baltus

unread,
May 22, 2017, 1:20:26 PM5/22/17
to FHIR DOTNET
Is it not possible to use the existing classes in the APIs? All the classes for the FHIR model are setup as partial classes, so you can extend the code.

ashish.s...@gmail.com

unread,
May 22, 2017, 9:10:28 PM5/22/17
to FHIR DOTNET
We are extending the partial classes as of today.
This however means that we have to manually keep the Java and c# models in sync.

While hapi has a tinder plugin, I am wondering how to accomplish the same in fhir-dotnet.

Reply all
Reply to author
Forward
0 new messages