fhirpathpy


Namefhirpathpy JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryFHIRPath implementation in Python
upload_time2024-02-10 22:19:34
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords fhir fhirpath
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            fhirpath.py
===========

[![Build Status](https://github.com/beda-software/fhirpath-py/actions/workflows/build.yaml/badge.svg)](https://github.com/beda-software/fhirpath-py/actions)
[![codecov](https://codecov.io/gh/beda-software/fhirpath-py/branch/master/graph/badge.svg)](https://codecov.io/gh/beda-software/fhirpath-py)
[![pypi](https://img.shields.io/pypi/v/fhirpathpy.svg)](https://pypi.org/project/fhirpathpy/)
[![Supported Python version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)

[FHIRPath](https://www.hl7.org/fhir/fhirpath.html) implementation in Python

Parser was generated with [antlr4](https://github.com/antlr/antlr4)

# Getting started
## Install
`pip install fhirpathpy`

## Usage
```Python
from fhirpathpy import evaluate

patient = {
  "resourceType": "Patient",
  "id": "example",
  "name": [
    {
      "use": "official",
      "given": [
        "Peter",
        "James"
      ],
      "family": "Chalmers"
    },
    {
      "use": "usual",
      "given": [
        "Jim"
      ]
    },
    {
      "use": "maiden",
      "given": [
        "Peter",
        "James"
      ],
      "family": "Windsor",
      "period": {
        "end": "2002"
      }
    }
  ]
}

# Evaluating FHIRPath
result = evaluate(patient, "Patient.name.where(use='usual').given.first()", [])
# result: `['Jim']`
```

## evaluate
 > Evaluates the "path" FHIRPath expression on the given resource, using data
    from "context" for variables mentioned in the "path" expression.
    Parameters:
    resource (dict|list): FHIR resource, bundle as js object or array of resources This resource will be modified by this function to add type information.
    path (string): fhirpath expression, sample 'Patient.name.given'
    context (dict): a hash of variable name/value pairs.
    model (dict): The "model" data object specific to a domain, e.g. R4.
    Returns:
    int: Description of return value

## compile
> Returns a function that takes a resource and an optional context hash (see
    "evaluate"), and returns the result of evaluating the given FHIRPath
    expression on that resource.  The advantage of this function over "evaluate"
    is that if you have multiple resources, the given FHIRPath expression will
    only be parsed once.
    Parameters:
    path (string) - the FHIRPath expression to be parsed.
    model (dict) - The "model" data object specific to a domain, e.g. R4.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fhirpathpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "fhir,fhirpath",
    "author": "",
    "author_email": "\"beda.software\" <fhirpath@beda.software>",
    "download_url": "https://files.pythonhosted.org/packages/c5/b2/8a08ee75344b394a50f79c944534c9c977a8dc7b62cb2540c84c1241622d/fhirpathpy-1.1.0.tar.gz",
    "platform": null,
    "description": "fhirpath.py\n===========\n\n[![Build Status](https://github.com/beda-software/fhirpath-py/actions/workflows/build.yaml/badge.svg)](https://github.com/beda-software/fhirpath-py/actions)\n[![codecov](https://codecov.io/gh/beda-software/fhirpath-py/branch/master/graph/badge.svg)](https://codecov.io/gh/beda-software/fhirpath-py)\n[![pypi](https://img.shields.io/pypi/v/fhirpathpy.svg)](https://pypi.org/project/fhirpathpy/)\n[![Supported Python version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)\n\n[FHIRPath](https://www.hl7.org/fhir/fhirpath.html) implementation in Python\n\nParser was generated with [antlr4](https://github.com/antlr/antlr4)\n\n# Getting started\n## Install\n`pip install fhirpathpy`\n\n## Usage\n```Python\nfrom fhirpathpy import evaluate\n\npatient = {\n  \"resourceType\": \"Patient\",\n  \"id\": \"example\",\n  \"name\": [\n    {\n      \"use\": \"official\",\n      \"given\": [\n        \"Peter\",\n        \"James\"\n      ],\n      \"family\": \"Chalmers\"\n    },\n    {\n      \"use\": \"usual\",\n      \"given\": [\n        \"Jim\"\n      ]\n    },\n    {\n      \"use\": \"maiden\",\n      \"given\": [\n        \"Peter\",\n        \"James\"\n      ],\n      \"family\": \"Windsor\",\n      \"period\": {\n        \"end\": \"2002\"\n      }\n    }\n  ]\n}\n\n# Evaluating FHIRPath\nresult = evaluate(patient, \"Patient.name.where(use='usual').given.first()\", [])\n# result: `['Jim']`\n```\n\n## evaluate\n > Evaluates the \"path\" FHIRPath expression on the given resource, using data\n    from \"context\" for variables mentioned in the \"path\" expression.\n    Parameters:\n    resource (dict|list): FHIR resource, bundle as js object or array of resources This resource will be modified by this function to add type information.\n    path (string): fhirpath expression, sample 'Patient.name.given'\n    context (dict): a hash of variable name/value pairs.\n    model (dict): The \"model\" data object specific to a domain, e.g. R4.\n    Returns:\n    int: Description of return value\n\n## compile\n> Returns a function that takes a resource and an optional context hash (see\n    \"evaluate\"), and returns the result of evaluating the given FHIRPath\n    expression on that resource.  The advantage of this function over \"evaluate\"\n    is that if you have multiple resources, the given FHIRPath expression will\n    only be parsed once.\n    Parameters:\n    path (string) - the FHIRPath expression to be parsed.\n    model (dict) - The \"model\" data object specific to a domain, e.g. R4.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "FHIRPath implementation in Python",
    "version": "1.1.0",
    "project_urls": {
        "Changelog": "https://github.com/beda-software/fhirpath-py/blob/master/CHANGELOG.md",
        "Documentation": "https://github.com/beda-software/fhirpath-py#readme",
        "Homepage": "https://github.com/beda-software/fhirpath-py",
        "Source": "https://github.com/beda-software/fhirpath-py.git"
    },
    "split_keywords": [
        "fhir",
        "fhirpath"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "574109f51b3b49fe43dedbe12b1cda505152436ae853026c1041ae2f4bd6fefd",
                "md5": "264f09a7890084d83fef81772d75dbf4",
                "sha256": "baf6f94f6677bb6965c72bc3cd393c96d9ef8c86ea90752100fc4a264fa92724"
            },
            "downloads": -1,
            "filename": "fhirpathpy-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "264f09a7890084d83fef81772d75dbf4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 229409,
            "upload_time": "2024-02-10T22:19:32",
            "upload_time_iso_8601": "2024-02-10T22:19:32.045160Z",
            "url": "https://files.pythonhosted.org/packages/57/41/09f51b3b49fe43dedbe12b1cda505152436ae853026c1041ae2f4bd6fefd/fhirpathpy-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5b28a08ee75344b394a50f79c944534c9c977a8dc7b62cb2540c84c1241622d",
                "md5": "21a2e16db093dc3b2b1bc06df85c8953",
                "sha256": "38ca66ac7cfb058102ccc52166a7d09d8f60a75ebe4f2be5674cd41a4f18c44d"
            },
            "downloads": -1,
            "filename": "fhirpathpy-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "21a2e16db093dc3b2b1bc06df85c8953",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 214420,
            "upload_time": "2024-02-10T22:19:34",
            "upload_time_iso_8601": "2024-02-10T22:19:34.020924Z",
            "url": "https://files.pythonhosted.org/packages/c5/b2/8a08ee75344b394a50f79c944534c9c977a8dc7b62cb2540c84c1241622d/fhirpathpy-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-10 22:19:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "beda-software",
    "github_project": "fhirpath-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fhirpathpy"
}
        
Elapsed time: 0.21293s