Skip to main content

FHIRPath implementation in Python

Project description

fhirpath.py

Build Status codecov pypi Supported Python version

FHIRPath implementation in Python

Parser was generated with antlr4

Getting started

Install

pip install fhirpathpy

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 Distribution

fhirpathpy-1.1.1.tar.gz (214.4 kB view details)

Uploaded Source

Built Distribution

fhirpathpy-1.1.1-py3-none-any.whl (229.4 kB view details)

Uploaded Python 3

File details

Details for the file fhirpathpy-1.1.1.tar.gz.

File metadata

  • Download URL: fhirpathpy-1.1.1.tar.gz
  • Upload date:
  • Size: 214.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for fhirpathpy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 46149398002f9669bc4aa59d5f32dad7637dddc2c5b81ab8c0ddb09a1ceec9b9
MD5 594114a92dc882156da47c4a2deb58de
BLAKE2b-256 6bca2c3c11f4b14f31604f2ed2ba4f2d1e45ef235c04c6ce70c688c82099f7b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fhirpathpy-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 229.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for fhirpathpy-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9247fc88234dc5dccdc4b1d814c1d7d7734001ae9825c7f444aade34bcfcd80
MD5 e87a95421db8a820f92797b6c32b8a7d
BLAKE2b-256 246f81d2a02499d6e3f176bcaffbfbb50905ce38fd78cd37483c90754ef2445b

See more details on using hashes here.

Supported by

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