Git Product home page Git Product logo

Comments (7)

nickgeorge avatar nickgeorge commented on May 3, 2024 2

For reference, raw json-to-proto functionality like google.protobuf.json_format will never work with FHIR JSON, because there's not a 1-1 between FHIR JSON and fields on proto - easiest example there is the "datetime" object is a string in FHIR, but a well-structured, multi-field object in FhirProto. Another example is extensions on primitives like String - in FHIR JSON these are represented as _myStringField, but in FhirProto extensions are fields on primitive "objects", so myStringField.extension.

As for other options, I think our time scale is short enough - O(weeks) - that I wouldn't recommend trying to hack together alternatives, but the best option I can think of is, if you have a static FHIR JSON dataset you're interested in using, you could write a quick C++ program to parse the JSON to proto, and persist it on disk as proto binary files that you could read in python.

But, again, I don't really recommend this - in addition to just parsing and printing, the upcoming python release will have common library functions like those in e.g., https://github.com/google/fhir/blob/master/cc/google/fhir/codes.h that make working with FHIR in python a lot easier.

from fhir.

gitpushdashf avatar gitpushdashf commented on May 3, 2024

Actually, it sounds like this will be addressed here: #19 (comment)

Is there another option in the meanwhile?

from fhir.

gitpushdashf avatar gitpushdashf commented on May 3, 2024

Thank you, Nick! I'm really looking forward to the new release.

We have a Java program that can do it for now, may integrate it for the time being.

from fhir.

gitpushdashf avatar gitpushdashf commented on May 3, 2024

I'm curious, I see some code that looks like it's for JSON and Proto comparison (https://github.com/google/fhir/tree/master/py/google/fhir/testing) and some code that's Cython (https://github.com/google/fhir/blob/master/bazel/cython.bzl).

Is there a way to compile the C++ code as a Python library that we can call?

While we can convert files one-off with Java, it would be great to do it in real time with Python.

from fhir.

gitpushdashf avatar gitpushdashf commented on May 3, 2024

Not really sure how to work bazel, but not seeing any c/python targets. Been trying to select just the bazel/cython.BUILD file but it doesn't seem to load any targets no matter what I do.

localhost:~/repos/fhir$ bazel query //... | grep -i ython
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded

If we could import the C++ library into Python it would help a ton.

from fhir.

nickgeorge avatar nickgeorge commented on May 3, 2024

It is possible - the specific cython dependency you're seeing there is related to some machine learning code - specifically, the Bundle-to-seqex code is in C++ and is wrapped by the python tensorflow code. Theoretically the same could work for other aspects of the C++ library, e.g., profiling, but we'd rather invest the time and maintenance burden in native implementations. What would be really nice is if there were a pattern that would allow consumers of the fhirproto library to write their own cython wrappers - that way you people could leverage parts that they needed, and switch over to native implementations when they become available. I can take a look in to what that would look like.

As always, thanks a lot for the feedback - it's really helpful to me to hear what new features are top of mind for y'all!

from fhir.

Cam2337 avatar Cam2337 commented on May 3, 2024

Per conversation over in #19, as of 0.6.0 we have native Python3 parsing, printing, and basic resource validation support for FHIR STU3 and FHIR R4 (among other functionality for extensions, codes, etc.). For more information on the available pypi package, see: https://pypi.org/project/google-fhir/.

You can see https://github.com/google/fhir-examples/tree/master/py/google/fhir_examples for some additional Python FHIR examples around json_format and resource validation.

Note that we also have full bazel support, and so if you would rather, you can simply clone the repository, and bazel build/test as needed. We strongly recommend performing this in a venv to help ensure that the execution of the Python interpreter by bazel is hermetically-sealed.

We're continuing to work on adding stronger validation support (akin to what is available in C++ with fhir_path), as well as continuing to profile+test+iterate.

Going to mark this issue as "closed" for now, but feel free to re-open or create a new issue if you have any questions/comments/concerns. We'd love your feedback and are excited to keep working on this with the community! :)

from fhir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.