Open sttawm opened 4 years ago
This sounds like an interesting feature to consider. You may also want to look into FHIR shorthand (FSH) as that is intended to make the process of authoring extensions/profiles easier.
Hey Matt - this is one of the most poorly documented parts of the code base, sorry! Nik is right that Fhir Shorthand is a super interesting project that we're looking in to, too, but to be clear, FhirProto DOES support defining extensions and profiles via a proto - that's what profile_config.proto defines. I know you're working through the protogen example here: https://github.com/google/fhir-examples/tree/master/proto/google/fhir_examples/myprofile, that is an example defining custom extensions and profiles in an implementation guide (you can define Terminologies, too, although it hasn't been added to the example yet).
Finally, a wonky technical point - .proto
files do not actually contain data e.g., data to define profiles and extensions, .proto
files define the schema of the data - e.g., what fields are on patient. When we want to store actual data in a given proto schema in a text file, we use .prototxt
- e.g., a text representation of an actual proto instance, not the difiner for a proto.
So, e,g., in https://github.com/google/fhir-examples/tree/master/proto/google/fhir_examples/myprofile, the .prototxt
files are the user input, that is passed via the bazel rule to the generator.
Heya - I'm working through the protogen example as well and I'm trying to understand what is intended with the script meant to generate the myprofile.proto
Here is my terminal output;
bash % ~/bin/generate_definitions_and_protos.sh //proto/google/fhir_examples/myprofile:myprofile
INFO: Analyzed target //proto/google/fhir_examples/myprofile:myprofile_definitions (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //proto/google/fhir_examples/myprofile:myprofile_definitions up-to-date:
bazel-bin/proto/google/fhir_examples/myprofile/myprofile.json
bazel-bin/proto/google/fhir_examples/myprofile/myprofile_extensions.json
bazel-bin/proto/google/fhir_examples/myprofile/myprofile_terminologies.json
INFO: Elapsed time: 0.130s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
ERROR: Skipping '//proto/google/fhir_examples/myprofile:myprofile_proto_files': no such target '//proto/google/fhir_examples/myprofile:myprofile_proto_files': target 'myprofile_proto_files' not declared in package 'proto/google/fhir_examples/myprofile' (did you mean 'myprofile_proto_zip'?) defined by ~/fhir-examples/proto/google/fhir_examples/myprofile/BUILD
WARNING: Target pattern parsing failed.
ERROR: no such target '//proto/google/fhir_examples/myprofile:myprofile_proto_files': target 'myprofile_proto_files' not declared in package 'proto/google/fhir_examples/myprofile' (did you mean 'myprofile_proto_zip'?) defined by /Users/jake/Projects/occ-ds-sandbox/POC/gemini-fhir-proto/fhir-examples/proto/google/fhir_examples/myprofile/BUILD
INFO: Elapsed time: 0.107s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
Build Failed: //proto/google/fhir_examples/myprofile:myprofile_proto_files
If I understand the flow here - the initial generate_protos_utils.sh
script completes the build of the _definitions
target, but doesn't construct the _proto_files
target.
In the rule for generating FHIR protos I see a _proto_zip
target being defined but not utilized.
When I change the generate_definitions_and_protos.sh
script to build the _proto_zip
target instead of _proto_files
it successfully builds.
When I check bazel-bin/proto/google/fhir-examples/myprofile
I find the zip file with the myprofile.proto
inside - is this the intended behavior?
Currently, it's a little tricky to figure out how to write an extension and/or profile. Assuming the users of this library are already familiar with protobufs, I'd say it'd be simpler if an extension could be generated from a protobuf file (i.e. if
generate_protos_from_config.sh
accepted a.proto
).That said, I am not sure about whether in general a
.proto
has "too much" or "not enough" information to generate an extension (as I still figure out how to write an extension and profile).