Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slice on structured fields #34

Open
stephanschim opened this issue Feb 15, 2021 · 0 comments
Open

Slice on structured fields #34

stephanschim opened this issue Feb 15, 2021 · 0 comments

Comments

@stephanschim
Copy link

stephanschim commented Feb 15, 2021

I need to generate C++ code from profiles (json) containing slices on structured fields (e.g. Address).

Maybe I can implement the missing feature myself, but I need some advice.

  • Is there a function or functions in the java part, that could be used to generate the slice message?
    • I have the following use case: The address field of Organization is sliced into two slices of an Adress based profile (address-de-basis) to support two different flavours of Address.line - physical address vs. post box. (This is done in an intermediate profile base "KBV_PR_Base_Organization".)
  • Which function could be used in the C++ part to read the different slices? (I think writing just means selection of the active slice.)
  • Any Idea how to implement a default slice?

Details:

From my investigations I found two problems:

  1. In ProtoGenerator.java, slices like this are not supported:
private DescriptorProto generateMessage(
      ElementDefinition currentElement,
      List<ElementDefinition> elementList,
      DescriptorProto.Builder builder)
      throws InvalidFhirException {
   ...
   for (ElementDefinition deferredElement : deferredElements) {
      // Currently we only support slicing for Extensions and Codings
      if (isElementSupportedForSlicing(deferredElement)
         ...
      } else {
        cgmDebugOut(2, "Build field slicing (not supported yet):" + cgmStringify(deferredElement.getId().getValue()));
        builder
            .addFieldBuilder()
            .setNumber(nextTag)
            .getOptionsBuilder()
            .setExtension(
                ProtoGeneratorAnnotations.reservedReason,
                "field "
                    + nextTag
                    + " reserved for "
                    + deferredElement.getId().getValue()
                    + " which uses an unsupported slicing on "
                    + deferredElement.getType(0).getCode().getValue());
        nextTag++;
      }
    }
  ...
}
  1. Once the java generator would have been enhanced to generate a sliced proto message, serialization to and from json has to be handled correctly in the c++ part.
  • To Json: Just write the slices´ content (if any)? Maybe respecting place where the original field resides.
  • From Json: Detect sliced field by annotation. Extract slice discriminator (Maybe by reading into (new) instance of non sliced field when slice discrimination is on value?). Select correct slice by attribute. Read into that slice. Here, it is not clear to me, what infrastructure in C++ could be used.

If I'm right, some annotations have been foreseen for discrimination of the right slice.
Regarding annotation fhir_slice_by, I am not sure, if this is the intended use. As far as I understand, slicing type and path must be specified.
Something like this:
"[(.google.fhir.proto.fhir_slice_by) = "value:type"]" means the slice discriminator is by "value" from field "type".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant