-1

I have a use case where we generate a lot of custom profiles based on the specific data modelling requirements. I am trying to find a way to create models out of it(c# classes) so that it can be serialized and deserialized and represented in the way that conforms to the profile constraints. I have seen many implementations to validate against profiles, but none on the generation aspect. Please let me know if there is a way to achieve this.

PS: All the resource types used are FHIR base resources.

  • Your question is completely unclear to me. What do you mean by a "profile"? If I understand you correctly, you want to automatically generate C#-classes based on some kind of a schema, e.g. an xsd, an UML or whatever structural description, right? – MakePeaceGreatAgain Aug 19 '20 at 10:35
  • Would this help? https://www.nuget.org/packages/Hl7.Fhir.Serialization – Carl Aug 19 '20 at 10:37
  • Right I have an XML file and want to create a class if there is a way to do it using firely API's that would be of great help – Harsh Agarwal Aug 19 '20 at 10:38
  • You should read [ask]. Seriously. Read it. Then apply what you've learnt there to improve your question. – Enigmativity Aug 19 '20 at 10:38

1 Answers1

1

Serialization and deserialization of FHIR instances is the same for all resources, regardless of profile. As such, there's no need for profile-specific code. Just use the generic .NET reference implementation. Profiles only change constraints, not what elements are named or how they appear in instances. If you're wanting profile-specific code to handle validation, there currently aren't any general-purpose solutions that do that - you'd have to create your own. However, the generic .NET reference implementation will perform the necessary validation if provided with the relevant StructureDefinitions.

Lloyd McKenzie
  • 6,345
  • 1
  • 13
  • 10