Skip to main content

Parse FHIR query string

Project description

A library to parse FHIR query strings.

  • Validates type and returns correct object
  • Built-in search parameters from FHIR standard
  • Supports modifiers, prefixes, and chains


from fhir_parse_qs import Search

# supported endpoints
Search.supported --> [...]

# simple use
search = Search('Patient', 'name=bob') # Search(<endpoint>, <query_string>)

# endpoint
search.endpoint --> 'Patient'

# all the namedtuples
search.parsed --> [FHIRSearch(...)]

# index as key; each parameter/value pair gets parsed into a namedtuple
search[0] --> FHIRSearch(...)
search[0].modifier --> None
search[0].prefix --> None
search[0].value --> 'bob'
search[0].parameter --> 'name'
search[0].type_ --> 'string'
search[0].chain --> None

# act like dict with parameter as key
search['name'] --> FHIRSearch(...) #list if non-unique parameter

# iterate over the parameter/value pairs
for x in search:
     print(x) --> FHIRSearch(...)

# ignores and logs unrecognized parameters
search = Search('Patient', 'random=test')
search.error --> [...]

# supports chains (list of lists)
search = Search('Observation', '')
search[0].parameter --> 'name' # last parameter in chain
search[0].value --> 'peter'
search[0].chain --> [[FHIRChain(...), FHIRChain(...)], ...]
search[0].chain[0][0].endpoint = 'Observation'
search[0].chain[0][0].target = 'patient'
search[0].chain[0][0].ttype = 'reference'
search[0].chain[0][1].endpoint = 'Patient'
search[0].chain[0][1].target = 'name'
search[0].chain[0][1].ttype = 'string'

# return control parameters (eg, _sort, _count, etc)
search.control --> [...]

Project details

Download files

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

Files for fhir-parse-qs, version 0.7.1
Filename, size File type Python version Upload date Hashes
Filename, size fhir_parse_qs-0.7.1-py2.py3-none-any.whl (80.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size fhir_parse_qs-0.7.1.tar.gz (25.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page