Search code examples
hl7-fhirauto-generateprotohapi-fhir

How can proto files be generated from a specification(as in google-fhir protos are generated from FHIR Spec)?


I've been looking at the Google fhir repo(https://github.com/google/fhir). The proto files within this repo are generated from the FHIR spec(something like this: http://hl7.org/fhir/account.html). I want to understand how proto files can be generated from a specification. I'm working on a project which has a specification(this could be a JSON/ spreadsheet any other data representation), from these specifications I want to generate proto files. Any other workaround to generate the protos would be appreciated.


Solution

  • The FHIR proto generation code is included in the same repo - https://github.com/google/fhir/tree/master/java/src/main/java/com/google/fhir/protogen

    There's generally a bootstrapping step, which for FHIR is the StructureDefinition resource. Once you can parse a StructureDefinition, all the other resources are defined using instances of StructureDefinition.