FHIRPath implementation in Python.
Project description
fhirpath
fhirpath implementation in Python. This library is built in ORM like approach.
Supports multiple provider´s engine. Now Plone & guillotina 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.
Quickstart (guillotina)
This quickstarter guide is based on guillotina and elasticsearch with extra guillotina_elasticsearch dependency. If don´t know about guillotina, have a look at their nice document. Add fhirpath and guillotina_elasticsearch in your project dependencies. Install fhirpath.providers.guillotina_app from your app configuration file.
we assume you configure elasticsearch_ service properly and have FHIR_ content types and latstly of course you know about FHIR_
Example: Add Contents:
class IOrganization(IFhirContent, IContentIndex): index_field( "organization_resource", type="object", field_mapping=fhir_resource_mapping("Organization"), fhirpath_enabled=True, resource_type="Organization", fhir_version=FHIR_VERSION.DEFAULT, ) index_field("org_type", type="keyword") org_type = TextLine(title="Organization Type", required=False) organization_resource = FhirField( title="Organization Resource", resource_type="Organization", fhir_version="R4" ) @configure.contenttype(type_name="Organization", schema=IOrganization) class Organization(Folder): """ """ index(schemas=[IOrganization], settings={}) resource_type = "Organization"
Example Search:
>>> from guillotina.component import query_utility >>> from fhirpath.interfaces import ISearchContextFactory >>> from fhirpath.providers.guillotina_app.interfaces import IFhirSearch >>> search_context = query_utility(ISearchContextFactory).get( ... resource_type="Organization" ... ) >>> search_tool = query_utility(IFhirSearch) >>> 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") ... ) >>> fhir_bundle = await search_tool(params, context=search_context) >>> fhir_bundle.total == len(fhir_bundle.entry)
Example FhirPath Query:
>>> from fhirpath.providers.guillotina_app.interfaces import IElasticsearchEngineFactory >>> from guillotina.component import query_utility >>> from fhirpath.enums import SortOrderType >>> from fhirpath.fql import Q_ >>> from fhirpath.fql import T_ >>> from fhirpath.fql import V_ >>> from fhirpath.fql import sort_ >>> engine = query_utility(IElasticsearchEngineFactory).get() >>> 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)) ... .limit(20) ... ) >>> query_result = query_builder(async_result=True) >>> result = query_result.fetchall() >>> result.header.total == 100 True >>> len(result.body) == 20 True >>> async for resource in query_result: ... assert resource.resource_type == "Organization"
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.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.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d3a573733c434c5cc914dc71f87f34c4c20f445aef729c41ed273a893f89f20 |
|
MD5 | 47fa20b10512327c841d7f55402523e7 |
|
BLAKE2b-256 | d90029a48dcc66bd71c5dacbebd90fadc31e82ae02349895051e6d9473be267b |