FHIRPath implementation in Python.
Project description
Introduction
fhirpath implementation in Python. This library is built in ORM like approach. Our goal is to make 100% (as much as possible) fhirpath specification compliance products.
Supports multiple provider´s engine. Now Plone & guillotina framework powered providers fhirpath-guillotina and collective.fhirpath respectively are supported and more coming soon.
Supports multiple dialects, for example elasticsearch, GraphQL,PostgreSQL_. Although now elasticsearch has been supported.
Provide full support of FHIR Search with easy to use API.
Usages
This library is kind of abstract type, where all specifications from fhirpath are implemented rather than completed solution (ready to go). The main reason behind this design pattern, to support multiple database systems as well as well as any framework, there is no dependency.
fhirpath never taking care of creating indexes, mappings (elasticsearch) and storing data, if you want to use this library, you have to go through any of existing providers (see list bellow) or make your own provider (should not too hard work).
Simple example
Assumption:
Elasticsearch server 7.x.x Installed.
Mappings and indexes are handled manually.
Data (document) also are stored manually.
Create Connection and Engine:
>>> from fhirpath.connectors import create_connection >>> from fhirpath.engine.es import ElasticsearchEngine >>> from fhirpath.engine import dialect_factory >>> from fhirpath.enums import FHIR_VERSION >>> host, port = "127.0.0.1", 9200 >>> conn_str = "es://@{0}:{1}/".format(host, port) >>> connection = create_connection(conn_str, "elasticsearch.Elasticsearch") >>> connection.raw_connection.ping() True >>> engine = ElasticsearchEngine(FHIR_VERSION.R4, lambda x: connection, dialect_factory)
Basic Search:
>>> from fhirpath.search import Search >>> from fhirpath.search import SearchContext >>> search_context = SearchContext(engine, "Organization") >>> params = ( .... ("active", "true"), .... ("_lastUpdated", "2010-05-28T05:35:56+00:00"), .... ("_profile", "http://hl7.org/fhir/Organization"), .... ("identifier", "urn:oid:2.16.528.1|91654"), .... ("type", "http://hl7.org/fhir/organization-type|prov"), .... ("address-postalcode", "9100 AA"), .... ("address", "Den Burg"), .... ) >>> fhir_search = Search(search_context, params=params) >>> bundle = fhir_search() >>> len(bundle.entry) == 0 True
Basic Query:
>>> from fhirpath.enums import SortOrderType >>> from fhirpath.query import Q_ >>> from fhirpath.fql import T_ >>> from fhirpath.fql import V_ >>> from fhirpath.fql import exists_ >>> query_builder = Q_(resource="Organization", engine=engine) >>> query_builder = ( .... query_builder.where(T_("Organization.active") == V_("true")) .... .where(T_("Organization.meta.lastUpdated", "2010-05-28T05:35:56+00:00")) .... .sort(sort_("Organization.meta.lastUpdated", SortOrderType.DESC)) .... ) >>> query_result = query_builder(async_result=False) >>> for resource in query_result: .... assert resource.__class__.__name__ == "OrganizationModel" >>> # test fetch all >>> result = query_result.fetchall() >>> result.__class__.__name__ == "EngineResult" True >>> query_builder = Q_(resource="ChargeItem", engine=engine) >>> query_builder = query_builder.where(exists_("ChargeItem.enteredDate")) >>> result = query_builder(async_result=False).single() >>> result is not None True >>> isinstance(result, builder._from[0][1]) True >>> query_builder = Q_(resource="ChargeItem", engine=engine) >>> query_builder = query_builder.where(exists_("ChargeItem.enteredDate")) >>> result = query_builder(async_result=False).first() >>> result is not None True >>> isinstance(result, builder._from[0][1]) True
Available Provider (known)
Currently very few numbers of providers available, however more will coming soon.
fhirpath-guillotina
A guillotina framework powered provider, battery included, ready to go! Please follow associated documentation.
Engine: Elasticsearch
PyPi: https://pypi-hypernode.com/project/fhirpath-guillotina/
collective.fhirpath
A Plone powered provider, like fhirpath-guillotina every thing is included. ready to go, although has a dependency on plone.app.fhirfield.
Engine: Elasticsearch
PyPi: https://pypi-hypernode.com/project/collective.fhirpath/
unlisted
Why are you waiting for? You are welcome to list your provider here! Developing provider should not be so hard, as fhirpath is giving you convenient APIs.
Credits
This package skeleton was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
© Copyright HL7® logo, FHIR® logo and the flaming fire are registered trademarks owned by Health Level Seven International
History
0.3.0 (2019-09-30)
Improvements
Supports multiple AND values for same search parameter!.
Add support FHIR version STU3 compability for Money type search.[nazrulworld]
IN Query support added.[nazrulworld]
Support PathElement that contains string path with .as(), thus suports for Search also.
Supports Duration type in Search.
Add support composite type search param.
Bugfixes
Multiple search values (IN search)
Missing text for HumanName and Address search.
0.2.0 (2019-09-15)
Breakings:
Built-in providers ( guillotina_app and plone_app ) have been wiped as both becoming separate pypi project.
queries module has been moved from fql sub-package to fhirpath package and also renamed as query.
Improvements:
There are so many improvements made for almost all most modules.
FhirSearch coverages are increased.
Sort, Limit facilities added in Query as well in FhirSearch.
Bugfixes:
numbers of bugs fixed.
0.1.1 (2019-08-15)
First working version has been released. Of-course not full featured.
0.1.0 (2018-12-15)
First release on PyPI.(Just register purpose, not usable at all, next release coming soon)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fhirpath-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a70b5790da22673d3e9d29a39d1fbd6b3997104f93e9ab870782823fc49948 |
|
MD5 | d06e7661d55b7089d54457db696478db |
|
BLAKE2b-256 | c75b2ce1bf32cccce35570bdd976c18817c29ef8a9d0148abcaed2b391adf29d |