3

I have been working with the HL7 FHIR .NET API reference implementation - utilizing the existing resource models embedded in the library. Now, I am trying to use the Forge tool to modify the resources (contraints/extensions) to suit my requirements. I noticed that the HL7 publishing mechanism does not generate C# models from DSTU 2 onwards and was wondering - what is the best way of converting profiles created using Forge into C# resource classes such that they may be included into the HL7.Fhir.Model assembly that is part of the reference implementation.

RahulB
  • 197
  • 1
  • 8

1 Answers1

1

The generation of the models not being part of the official build is correct.

This has now moved to https://github.com/ewoutkramer/fhir-net-api where the rest of the API is maintained more easily. It is done using T4 templates on the output from the official builds.

There is a simple process for updating the models with the new versions of the spec, and we keep it fresh as people need it, and for each connectathon we publish a new build in NuGet and have a branch of the code in GitHub. (Its a powershell script that downloads all the latest build outputs and puts them in the appropriate folders, then you need to run the t4 templates in Visual Studio)

Such as this one for the May Connectathon in Montreal

https://github.com/ewoutkramer/fhir-net-api/tree/ft-connectathon-may2016

This is able to be done yourself with a little assistance.

As for generating code for a profile, we haven't done that as yet, but will theoretically be possible. Don't know that I'd advise this at the moment while the profiles are in so much development and change.

  • Please let me know if my understanding is correct - in order to enhance a base resource, say Patient, I would need to profile the resource (Forge..) using a constraint for example. To work with the modified resource, the resulting xml/xsd would need to be converted to a representation in the target language - in this case C#. When you say that you would not recommend converting profiles into code, what would be your suggestion for the case described above - should I directly modify the base resource xsd and run it through the build/T4 template generation process you have mentioned? – RahulB Jun 24 '16 at 13:47
  • Sort of, extending a base FHIR resource is done using profile (which you can do using the Forge tool) as you described. However, you do not need to change any code to be able to use the extended resource. This is one of the strengths of FHIR. This feature of FHIR is described here http://hl7.org/fhir/dstu2/extensibility.html Without this feature, profiled content cannot interoperate easily. – Brian Postlethwaite Jun 25 '16 at 22:54
  • 1
    @BrianPostlethwaite It's been two years now, Is there any update? I want to use fhir-net-api with my extended version of resources. Of course, I will make structure definitions with forge. How can I have my extended resources in fhir-net-api? Thank you. Considering that I don't know what is t4 templates! – Abubakar Ikram Apr 24 '18 at 13:38