Comments (7)
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.
Actually, it sounds like this will be addressed here: #19 (comment)
Is there another option in the meanwhile?
from fhir.
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.
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.
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.
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.
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)
- Patient Id is not accepting string expecting type object
- Consider tagging submodule "go"? HOT 2
- [Go] How to parse profile HOT 3
- Unmarshaller support for R5 versions HOT 3
- Canonical FHIR Resource Enum HOT 2
- go: module source tree too large HOT 1
- R5 support
- py/ subtree accidentally deleted? HOT 1
- Idiomatic way of dealing with unknown fields? [golang] HOT 3
- Export extensions to their own fields on analytics print? HOT 2
- No need to require backports.zoneinfo on Python 3.9+ HOT 2
- Python 3.10 + 3.11 support HOT 2
- Python: Upgrade to abseil-py v1.0.0
- Missing GoalAchievementStatus code system
- Go - Task_Output encoded REST message does not match FHIR Store model HOT 4
- FHIR 4.3.0 / R4B support
- protobuf 4.21 support HOT 1
- Building under Windows using MSVC HOT 1
- FR: Exposing a list of maven deps HOT 1
- Example for Generating Protos Using the scripts seems broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fhir.