Parse FHIR query strings
Project description
fhir_parse_qs
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
Releases 0.7.x and below used FHIR R3. Releases 0.8.x and greater use FHIR R4.
The update_mappings.py
script generates the mappings from the HL7
releases.
Usage
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', 'patient.name=peter')
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fhir_parse_qs-0.8.1.tar.gz
(36.9 kB
view details)
File details
Details for the file fhir_parse_qs-0.8.1.tar.gz
.
File metadata
- Download URL: fhir_parse_qs-0.8.1.tar.gz
- Upload date:
- Size: 36.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30928b92b0942091756b30981fa62ab53f1afc0bd90614059b6dc83dc90c2f04 |
|
MD5 | 1b9655a7c7f203a66501f7f70c3f1b2c |
|
BLAKE2b-256 | 73d26c638a21340edf57e2d99070396c3dec94a5c4112b7aed1108eece4cb5c4 |