Skip to main content

FHIRPath implementation in Python

Project description

fhirpath.py

Build Status codecov Supported Python version

FHIRPath implementation in Python

Parser was generated with antlr4

Getting started

Install

pip install git+https://github.com/beda-software/fhirpath-py.git

Usage

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhirpathpy-0.0.1-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file fhirpathpy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fhirpathpy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 48.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13

File hashes

Hashes for fhirpathpy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f623eedd018a6721ed6c03a9eeccc07f31fb124721581d3f0d812282f56ea1
MD5 36a8531a29551f21b13e6a9729d16b5f
BLAKE2b-256 0d950f221fd00a5210da530e683261e86bd7ddc2a914c3f84c775adcd9256552

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page