Welcome to fhirpath-guillotina’s documentation!¶
Introduction¶
A guillotina framework powered fhirpath provider. Full battery included to use fhirpath more efficiently.
If you don’t know about FHIR® and HL7®, Please have a look here.
Quickstart¶
Make sure
fhirpath_guillotina
is added as addon in your guillotina configure file.Make sure elasticsearch server configured properly.
Make sure you have FHIR resource contenttypes registered (see example bellow).
Make sure you have FHIR resources mapping (correct version) for elasticsearch.
Example: Add Contents:
>>> from fhirpath_guillotina.field import FhirField
class IOrganization(IFhirContent, IContentIndex):
index_field(
"organization_resource",
type="object",
field_mapping=fhir_resource_mapping("Organization"),
fhirpath_enabled=True,
resource_type="Organization",
fhir_release=FHIR_VERSION.R4,
)
index_field("org_type", type="keyword")
org_type = TextLine(title="Organization Type", required=False)
organization_resource = FhirField(
title="Organization Resource", resource_type="Organization", fhir_release="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.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.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"
Free software: GNU General Public License v3
Documentation: https://fhirpath-guillotina.readthedocs.io.
Credits¶
This package skeleton was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install fhirpath-guillotina, run this command in your terminal:
$ pip install fhirpath_guillotina
This is the preferred method to install fhirpath-guillotina, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for fhirpath-guillotina can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/nazrulworld/fhirpath_guillotina
Or download the tarball:
$ curl -OL https://github.com/nazrulworld/fhirpath_guillotina/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
fhirpath_guillotina¶
fhirpath_guillotina package¶
Submodules¶
fhirpath_guillotina.engine module¶
-
class
fhirpath_guillotina.engine.
ElasticsearchConnection
(conn)[source]¶ Bases:
fhirpath.connectors.factory.es.ElasticsearchConnection
Elasticsearch Connection
-
async
fetch
(index, compiled_query)[source]¶ xxx: must have use scroll+slice https://stackoverflow.com/questions/43211387/what-does-elasticsearch-automatic-slicing-do https://stackoverflow.com/questions/50376713/elasticsearch-scroll-api-with-multi-threading
-
async
fhirpath_guillotina.field module¶
-
class
fhirpath_guillotina.field.
DefaultFhirFieldSchemaSerializer
(field, schema, request)[source]¶ Bases:
guillotina.json.serialize_schema_field.DefaultSchemaFieldSerializer
-
property
field_type
¶
-
property
-
class
fhirpath_guillotina.field.
FhirField
(resource_class=None, resource_interface=None, resource_type=None, fhir_release=None, **kw)[source]¶ Bases:
guillotina.schema._field.Object
FhirResource also known as FHIR field is the schema field derrived from z3c.form’s field.
It takes all initilial arguments those are derrived from standard schema field, with additionally
model
,resource_type
andresource_interface
Note
field name must be start with lowercase name of FHIR Resource.
-
class
fhirpath_guillotina.field.
FhirFieldValue
(obj: NewType.<locals>.new_type = None)[source]¶ Bases:
object
FhirResourceValue is a proxy class for holding any object derrived from fhir.resources.resource.Resource
-
fhirpath_guillotina.field.
fhir_field_from_resource_type
(resource_type: str, cache: bool = True) → Optional[dict][source]¶
-
fhirpath_guillotina.field.
fhir_field_from_schema
(schema: <InterfaceClass zope.interface.Interface>, resource_type: str = None) → Optional[fhirpath_guillotina.field.FhirField][source]¶
fhirpath_guillotina.helpers module¶
fhirpath_guillotina.interfaces module¶
Module where all interfaces, events and exceptions live.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/nazrulworld/fhirpath_guillotina/issues.
If you are reporting a bug, please include:
Your operating system name and version.
Any details about your local setup that might be helpful in troubleshooting.
Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
fhirpath-guillotina could always use more documentation, whether as part of the official fhirpath-guillotina docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/nazrulworld/fhirpath_guillotina/issues.
If you are proposing a feature:
Explain in detail how it would work.
Keep the scope as narrow as possible, to make it easier to implement.
Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up fhirpath_guillotina for local development.
Fork the fhirpath_guillotina repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/fhirpath_guillotina.git
Install your local copy into a virtualenv. Assuming you have
pipenv
installed, this is how you set up your fork for local development:$ cd fhirpath_guillotina/ $ pipenv install --dev -e .[test] $ pipenv shell $ pytest tests
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ make lint $ pytest tests $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
The pull request should include tests.
If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
The pull request should work for Python 3.7, 3.8, and optionally for PyPy. Check https://travis-ci.org/nazrulworld/fhirpath_guillotina/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
Md Nazrul Islam <email2nazrul@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.4.0 (2020-05-16)¶
Improvements
supports
fhirpath
0.6.1 or later version.supports
guillotina
5.3.x but not 6.x.x
0.3.0 (2019-11-13)¶
Improvements
supports
https://pypi.org/project/fhirpath/
0.4.0 or later version.
0.2.0 (2019-10-10)¶
Full (almost) featured FHIR Search R4 supports.
0.1.0 (2019-08-24)¶
First release on PyPI. [nazrulworld]