{"id":19618881,"url":"https://github.com/nazrulworld/fhirpath","last_synced_at":"2026-03-15T14:06:30.991Z","repository":{"id":33781676,"uuid":"161941045","full_name":"nazrulworld/fhirpath","owner":"nazrulworld","description":"FHIRPath implementation in Python.","archived":false,"fork":false,"pushed_at":"2023-01-24T20:17:31.000Z","size":2990,"stargazers_count":33,"open_issues_count":12,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T05:41:23.815Z","etag":null,"topics":["fhir","fhir-api","fhir-profiles","fhirpath","healthcare","hl7"],"latest_commit_sha":null,"homepage":"https://nazrul.me/fhirpath/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nazrulworld.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-15T20:25:23.000Z","updated_at":"2024-04-22T22:55:07.000Z","dependencies_parsed_at":"2023-02-14T01:15:59.362Z","dependency_job_id":null,"html_url":"https://github.com/nazrulworld/fhirpath","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazrulworld%2Ffhirpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazrulworld%2Ffhirpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazrulworld%2Ffhirpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazrulworld%2Ffhirpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nazrulworld","download_url":"https://codeload.github.com/nazrulworld/fhirpath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251238236,"owners_count":21557423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fhir","fhir-api","fhir-profiles","fhirpath","healthcare","hl7"],"created_at":"2024-11-11T11:11:10.641Z","updated_at":"2026-03-15T14:06:25.949Z","avatar_url":"https://github.com/nazrulworld.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"============\nIntroduction\n============\n\n.. image:: https://img.shields.io/travis/com/nazrulworld/fhirpath.svg\n        :target: https://travis-ci.com/nazrulworld/fhirpath\n\n.. image:: https://readthedocs.org/projects/fhirpath/badge/?version=latest\n        :target: https://fhirpath.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n.. image:: https://codecov.io/gh/nazrulworld/fhirpath/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/nazrulworld/fhirpath/branch/master\n   :alt: Test Coverage\n\n.. image:: https://img.shields.io/pypi/pyversions/fhirpath.svg\n   :target: https://pypi.python.org/pypi/fhirpath/\n   :alt: Python Versions\n\n.. image:: https://img.shields.io/lgtm/grade/python/g/nazrulworld/fhirpath.svg?logo=lgtm\u0026logoWidth=18\n    :target: https://lgtm.com/projects/g/nazrulworld/fhirpath/context:python\n    :alt: Language grade: Python\n\n.. image:: https://img.shields.io/pypi/v/fhirpath.svg\n   :target: https://pypi.python.org/pypi/fhirpath\n\n.. image:: https://img.shields.io/pypi/l/fhirpath.svg\n   :target: https://pypi.python.org/pypi/fhirpath/\n   :alt: License\n\n.. image:: https://static.pepy.tech/personalized-badge/fhirpath?period=total\u0026units=international_system\u0026left_color=black\u0026right_color=green\u0026left_text=Downloads\n    :target: https://pepy.tech/project/fhirpath\n    :alt: Downloads\n\n.. image:: https://www.hl7.org/fhir/assets/images/fhir-logo-www.png\n        :target: https://www.hl7.org/fhir/fhirpath.html\n        :alt: HL7® FHIR®\n\nFHIRPath_ Normative Release (v2.0.0) implementation in Python, along side it\nprovides support for `FHIR Search \u003chttps://www.hl7.org/fhir/search.html\u003e`_ API and\nQuery (we called it ``fql(FHIR Query Language)``)\nAPI to fetch FHIR resources from any data-source(database).\nThis library is built in ORM_ like approach. Our goal is to make 100% (as much as possible)\nFHIRPath_ Normative Release (v2.0.0) specification compliance product.\n\n* Supports FHIR® ``STU3`` and ``R4``.\n* Supports multiple provider´s engine. Now Plone_ \u0026 guillotina_ framework powered providers `fhirpath-guillotina`_ and `collective.fhirpath`_ respectively are supported and more coming soon.\n* Supports multiple dialects, for example elasticsearch_, GraphQL_, PostgreSQL_. Although now elasticsearch_ has been supported.\n* Provide full support of `FHIR Search \u003chttps://www.hl7.org/fhir/search.html\u003e`_ with easy to use API.\n\n\nUsages\n------\n\nThis library is kind of abstract type, where all specifications from FHIRPath_ Normative Release (v2.0.0) are implemented rather than completed solution (ready to go).\nThe main reason behind this design pattern, to support multiple database systems as well as well as any framework, there is no dependency.\n\n``fhirpath`` never taking care of creating indexes, mappings (elasticsearch) and storing data, if you want to use this library, you have to go\nthrough any of existing providers (see list bellow) or make your own provider (should not too hard work).\n\n\nSimple example\n~~~~~~~~~~~~~~\n\nAssumption:\n\n1. Elasticsearch server 7.x.x Installed.\n\n2. Mappings and indexes are handled manually.\n\n3. Data (document) also are stored manually.\n\n\nCreate Connection and Engine::\n\n    \u003e\u003e\u003e from fhirpath.connectors import create_connection\n    \u003e\u003e\u003e from fhirpath.engine.es import ElasticsearchEngine\n    \u003e\u003e\u003e from fhirpath.engine import dialect_factory\n    \u003e\u003e\u003e from fhirpath.enums import FHIR_VERSION\n\n    \u003e\u003e\u003e host, port = \"127.0.0.1\", 9200\n    \u003e\u003e\u003e conn_str = \"es://@{0}:{1}/\".format(host, port)\n    \u003e\u003e\u003e connection = create_connection(conn_str, \"elasticsearch.Elasticsearch\")\n    \u003e\u003e\u003e connection.raw_connection.ping()\n    True\n    \u003e\u003e\u003e engine = ElasticsearchEngine(FHIR_VERSION.R4, lambda x: connection, dialect_factory)\n\n\nBasic Search::\n\n    \u003e\u003e\u003e from fhirpath.search import Search\n    \u003e\u003e\u003e from fhirpath.search import SearchContext\n\n    \u003e\u003e\u003e search_context = SearchContext(engine, \"Organization\")\n    \u003e\u003e\u003e params = (\n    ....    (\"active\", \"true\"),\n    ....    (\"_lastUpdated\", \"2010-05-28T05:35:56+00:00\"),\n    ....    (\"_profile\", \"http://hl7.org/fhir/Organization\"),\n    ....    (\"identifier\", \"urn:oid:2.16.528.1|91654\"),\n    ....    (\"type\", \"http://hl7.org/fhir/organization-type|prov\"),\n    ....    (\"address-postalcode\", \"9100 AA\"),\n    ....    (\"address\", \"Den Burg\"),\n    .... )\n    \u003e\u003e\u003e fhir_search = Search(search_context, params=params)\n    \u003e\u003e\u003e bundle = fhir_search()\n    \u003e\u003e\u003e len(bundle.entry) == 0\n    True\n\nBasic Query::\n\n    \u003e\u003e\u003e from fhirpath.enums import SortOrderType\n    \u003e\u003e\u003e from fhirpath.query import Q_\n    \u003e\u003e\u003e from fhirpath.fql import T_\n    \u003e\u003e\u003e from fhirpath.fql import V_\n    \u003e\u003e\u003e from fhirpath.fql import exists_\n    \u003e\u003e\u003e query_builder = Q_(resource=\"Organization\", engine=engine)\n    \u003e\u003e\u003e  query_builder = (\n    ....    query_builder.where(T_(\"Organization.active\") == V_(\"true\"))\n    ....    .where(T_(\"Organization.meta.lastUpdated\", \"2010-05-28T05:35:56+00:00\"))\n    ....    .sort(sort_(\"Organization.meta.lastUpdated\", SortOrderType.DESC))\n    .... )\n    \u003e\u003e\u003e query_result = query_builder(async_result=False)\n    \u003e\u003e\u003e for resource in query_result:\n    ....    assert resource.__class__.__name__ == \"OrganizationModel\"\n    \u003e\u003e\u003e # test fetch all\n    \u003e\u003e\u003e result = query_result.fetchall()\n    \u003e\u003e\u003e result.__class__.__name__ == \"EngineResult\"\n    True\n\n    \u003e\u003e\u003e query_builder = Q_(resource=\"ChargeItem\", engine=engine)\n    \u003e\u003e\u003e query_builder = query_builder.where(exists_(\"ChargeItem.enteredDate\"))\n    \u003e\u003e\u003e result = query_builder(async_result=False).single()\n    \u003e\u003e\u003e result is not None\n    True\n    \u003e\u003e\u003e isinstance(result, builder._from[0][1])\n    True\n\n    \u003e\u003e\u003e query_builder = Q_(resource=\"ChargeItem\", engine=engine)\n    \u003e\u003e\u003e query_builder = query_builder.where(exists_(\"ChargeItem.enteredDate\"))\n    \u003e\u003e\u003e result = query_builder(async_result=False).first()\n    \u003e\u003e\u003e result is not None\n    True\n    \u003e\u003e\u003e isinstance(result, builder._from[0][1])\n    True\n\n\nAvailable Provider (known)\n--------------------------\n\nCurrently very few numbers of providers available, however more will coming soon.\n\n`fhirpath-guillotina`_\n~~~~~~~~~~~~~~~~~~~~~~\n\nA `guillotina`_ framework powered provider, battery included, ready to go! `Please follow associated documentation. \u003chttps://fhirpath-guillotina.readthedocs.io/en/latest/\u003e`_\n\n1. **Engine**: Elasticsearch\n\n2. **PyPi**: https://pypi.org/project/fhirpath-guillotina/\n\n3. **Source**: https://github.com/nazrulworld/fhirpath_guillotina\n\n\n`collective.fhirpath`_\n~~~~~~~~~~~~~~~~~~~~~~\n\nA `Plone`_ powered provider, like `fhirpath-guillotina`_ every thing is included. ready to go, although has a dependency\non `plone.app.fhirfield`_.\n\n1. **Engine**: Elasticsearch\n\n2. **PyPi**: https://pypi.org/project/collective.fhirpath/\n\n3. **Source**: https://github.com/nazrulworld/collective.fhirpath\n\n\nunlisted\n~~~~~~~~\nWhy are you waiting for? You are welcome to list your provider here!\nDeveloping provider should not be so hard, as ``fhirpath`` is giving you convenient APIs.\n\n\nElasticsearch Custom Analyzer\n-----------------------------\nTo get some special search features for reference type field, you will need to setup custom analyzer for your elasticsearch index.\n\nExample Custom Analyzer::\n\n    settings = {\n        \"analysis\": {\n            \"normalizer\": {\n                \"fhir_token_normalizer\": {\"filter\": [\"lowercase\", \"asciifolding\"]}\n            },\n            \"analyzer\": {\n                \"fhir_reference_analyzer\": {\n                    \"tokenizer\": \"keyword\",\n                    \"filter\": [\"fhir_reference_filter\"],\n                },\n            },\n            \"filter\": {\n                \"fhir_reference_filter\": {\n                    \"type\": \"pattern_capture\",\n                    \"preserve_original\": True,\n                    \"patterns\": [r\"(?:\\w+\\/)?(https?\\:\\/\\/.*|[a-zA-Z0-9_-]+)\"],\n                },\n            },\n            \"char_filter\": {},\n            \"tokenizer\": {},\n        }\n\n\nExample Mapping (Reference Field)::\n\n    \"properties\": {\n      \"reference\": {\n        \"type\": \"text\",\n        \"index\": true,\n        \"store\": false,\n        \"analyzer\": \"fhir_reference_analyzer\"\n    }\n\n\nToDo\n----\n\n1. `fhirbase`_ engine aka provider implementation.\n\n2. All methods/functions are defined in `FHIRPath`_ specification, would be completed.\n\n3. Implement https://github.com/ijl/orjson\n4. https://developers.redhat.com/blog/2017/11/16/speed-python-using-rust/\n\nCredits\n-------\n\nThis package skeleton was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _`FHIRPath`: http://hl7.org/fhirpath/N1/\n.. _`FHIR`: http://hl7.org/fhir/\n.. _`ORM`: https://en.wikipedia.org/wiki/Object-relational_mapping\n.. _`Plone`: https://plone.org\n.. _`guillotina`: https://guillotina.readthedocs.io/en/latest/\n.. _`elasticsearch`: https://www.elastic.co/products/elasticsearch\n.. _`GraphQL`: https://graphql.org/\n.. _`PostgreSQL`: https://www.postgresql.org/\n.. _`fhirpath-guillotina`: https://pypi.org/project/fhirpath-guillotina/\n.. _`collective.fhirpath`: https://pypi.org/project/collective.fhirpath/\n.. _`plone.app.fhirfield`: https://pypi.org/project/plone.app.fhirfield/\n.. _`fhirbase`: https://github.com/fhirbase/fhirbase\n\n\n© Copyright HL7® logo, FHIR® logo and the flaming fire are registered trademarks\nowned by `Health Level Seven International \u003chttps://www.hl7.org/legal/trademarks.cfm?ref=https://pypi.org/project/fhir-resources/\u003e`_\n\n**\"FHIR® is the registered trademark of HL7 and is used with the permission of HL7.\nUse of the FHIR trademark does not constitute endorsement of this product by HL7\"**\nhttps://github.com/beda-software/fhirpath-py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazrulworld%2Ffhirpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnazrulworld%2Ffhirpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazrulworld%2Ffhirpath/lists"}