fhirsearchhelper


Namefhirsearchhelper JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryA package to help with FHIR searching when needed search parameters are not available
upload_time2023-12-15 14:24:33
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2022 Andrew Stevens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fhir fhirsearching
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FHIR Search Helper

<a href="https://pypi.python.org/pypi/fhirsearchhelper" rel="PyPi Package Link">![PyPi Package Link](https://img.shields.io/pypi/v/fhirsearchhelper.svg)</a>
<a href="https://pypi.python.org/pypi/fhirsearchhelper" rel="Supported Python versions">![Supported Python versions](https://img.shields.io/pypi/pyversions/fhirsearchhelper.svg)</a>
[![Downloads](https://pepy.tech/badge/fhirsearchhelper)](https://pepy.tech/project/fhirsearchhelper)

A Python package to support FHIR Searching in contexts where needed search parameters are not supported

## Quick Start

*NOTE*: Currently, the only option for capability_statement_file is 'epic_r4_metadata_edited.json'

``` python
from fhirsearchhelper import run_fhir_query

# This is using objects to store search params
output: Bundle | None = run_fhir_query(base_url='https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/', query_headers={'Authorization': 'Bearer 1234567'}, resource_type='Patient', search_params={'resourceType': 'Patient', 'search_params': {'name': 'Smith', 'deceased': 'true'}}, capability_statement_file='epic_r4_metadata_edited.json')

# This is using a raw query
output: Bundle | None = run_fhir_query(query_headers={'Authorization': 'Bearer 1234567'}, query='https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient?name=Smith&deceased=true', capability_statement_file='epic_r4_metadata_edited.json')
```

## A Note on Data Transformations
FHIRSearchHelper performs some data transformation when retrieving data from Epic to handle potential upstream data processing issues.

### DocumentReferences
To support NLP of documents, all DocumentReferences that are retrieved that contain URLs that reference a Binary resource where the document text is stored, are "expanded" by retrieving that Binary resource and inserting the content into the DocumentReference.content field of the resource. If one of the attachment types is text/html and text/plain is not also present, the HTML is converted into base64-encoded plain-text for easier upstream NLP operations, without removing existing data.

### MedicationRequests
All MedicationRequests that are retrieved that contain medicationReferences instead of medicationCodeableConcepts are "expanded" by retrieving the referenced Medication resource and inserting the codes of that resource into MedicationRequest.medicationCodeableConcept, and removing MedicationRequest.medicationReference.

### Encounter Diagnosis Conditions
All Conditions that are retieved that have a Condition.category.code of encounter-diagnosis and do not have Condition.onsetDateTime, are "expanded" by retrieving the referenced Encounter in Condition.encounter and setting Condition.onsetDateTime to Encounter.period.start to indicate the beginning of a Condition. If there is no referenced Encounter or the referenced Encounter does not have a period, the onsetDateTime is set to `9999-12-31`.

## A Note on CapabilityStatements

In their current form, `CapabilityStatement`s do not have a way to express when a search parameter for a resource is conditionally accepted. For example, in the Epic R4 `CapabilityStatement`, for the `Condition` resource, there exists a listed search parameter of `code`. In the description, there is a note that this search parameter is only accepted when the `category` is equal to `infection`. The only way that this conditional information would be known is by manual reading of the description. To alleviate this issue, and to avoid extreme custom handling in this package, currently you must edit the `CapabilityStatement` of any server with which you would like to use this package and add custom extensions to the search parameter. Keeping with the above example of the search parameter `code` for the `Condition` resource, here is what the `CapabilityStatement.rest[0].resource.where(type = 'Condition').searchParam.where(name = 'code')` element looks like:

``` json
{
    "name": "code",
    "type": "token",
    "documentation": "Search for Conditions with a specified code. This is only used when searching for infections.",
    "extension": [
        {
            "url": "true-when",
            "valueString": "category==infection"
        }
    ]
}
```

Here we have added an extension with a url of `true-when` that is a machine readable statement denoting when a search parameter is accepted by the server. It currently only supports == to show equality and in to show membership of a list (e.g. "category in [infection, health-problem]"). This also works for when a search parameter is limited in the values it will successfully search for. For example, here is what the `CapabilityStatement.rest[0].resource.where(type = 'Condition').searchParam.where(name = 'category')` element looks like:

``` json
{
    "name": "category",
    "type": "token",
    "documentation": "Search for Condition resources by category.",
    "extension": [
        {
            "url": "true-when",
            "valueString": "category in [dental-finding, encounter-diagnosis, genomics, health-concern, infection, medical-history, problem-list-item, reason-for-visit]"
        }
    ]
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fhirsearchhelper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Andrew Stevens <andrew.stevens@gtri.gatech.edu>",
    "keywords": "fhir,fhirsearching",
    "author": "",
    "author_email": "Andrew Stevens <andrew.stevens@gtri.gatech.edu>",
    "download_url": "https://files.pythonhosted.org/packages/79/8b/fc8de6d036ea80a390d09de5f91137933d6ce6a8702280b3bb118df38d98/fhirsearchhelper-0.3.1.tar.gz",
    "platform": null,
    "description": "# FHIR Search Helper\n\n<a href=\"https://pypi.python.org/pypi/fhirsearchhelper\" rel=\"PyPi Package Link\">![PyPi Package Link](https://img.shields.io/pypi/v/fhirsearchhelper.svg)</a>\n<a href=\"https://pypi.python.org/pypi/fhirsearchhelper\" rel=\"Supported Python versions\">![Supported Python versions](https://img.shields.io/pypi/pyversions/fhirsearchhelper.svg)</a>\n[![Downloads](https://pepy.tech/badge/fhirsearchhelper)](https://pepy.tech/project/fhirsearchhelper)\n\nA Python package to support FHIR Searching in contexts where needed search parameters are not supported\n\n## Quick Start\n\n*NOTE*: Currently, the only option for capability_statement_file is 'epic_r4_metadata_edited.json'\n\n``` python\nfrom fhirsearchhelper import run_fhir_query\n\n# This is using objects to store search params\noutput: Bundle | None = run_fhir_query(base_url='https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/', query_headers={'Authorization': 'Bearer 1234567'}, resource_type='Patient', search_params={'resourceType': 'Patient', 'search_params': {'name': 'Smith', 'deceased': 'true'}}, capability_statement_file='epic_r4_metadata_edited.json')\n\n# This is using a raw query\noutput: Bundle | None = run_fhir_query(query_headers={'Authorization': 'Bearer 1234567'}, query='https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient?name=Smith&deceased=true', capability_statement_file='epic_r4_metadata_edited.json')\n```\n\n## A Note on Data Transformations\nFHIRSearchHelper performs some data transformation when retrieving data from Epic to handle potential upstream data processing issues.\n\n### DocumentReferences\nTo support NLP of documents, all DocumentReferences that are retrieved that contain URLs that reference a Binary resource where the document text is stored, are \"expanded\" by retrieving that Binary resource and inserting the content into the DocumentReference.content field of the resource. If one of the attachment types is text/html and text/plain is not also present, the HTML is converted into base64-encoded plain-text for easier upstream NLP operations, without removing existing data.\n\n### MedicationRequests\nAll MedicationRequests that are retrieved that contain medicationReferences instead of medicationCodeableConcepts are \"expanded\" by retrieving the referenced Medication resource and inserting the codes of that resource into MedicationRequest.medicationCodeableConcept, and removing MedicationRequest.medicationReference.\n\n### Encounter Diagnosis Conditions\nAll Conditions that are retieved that have a Condition.category.code of encounter-diagnosis and do not have Condition.onsetDateTime, are \"expanded\" by retrieving the referenced Encounter in Condition.encounter and setting Condition.onsetDateTime to Encounter.period.start to indicate the beginning of a Condition. If there is no referenced Encounter or the referenced Encounter does not have a period, the onsetDateTime is set to `9999-12-31`.\n\n## A Note on CapabilityStatements\n\nIn their current form, `CapabilityStatement`s do not have a way to express when a search parameter for a resource is conditionally accepted. For example, in the Epic R4 `CapabilityStatement`, for the `Condition` resource, there exists a listed search parameter of `code`. In the description, there is a note that this search parameter is only accepted when the `category` is equal to `infection`. The only way that this conditional information would be known is by manual reading of the description. To alleviate this issue, and to avoid extreme custom handling in this package, currently you must edit the `CapabilityStatement` of any server with which you would like to use this package and add custom extensions to the search parameter. Keeping with the above example of the search parameter `code` for the `Condition` resource, here is what the `CapabilityStatement.rest[0].resource.where(type = 'Condition').searchParam.where(name = 'code')` element looks like:\n\n``` json\n{\n    \"name\": \"code\",\n    \"type\": \"token\",\n    \"documentation\": \"Search for Conditions with a specified code. This is only used when searching for infections.\",\n    \"extension\": [\n        {\n            \"url\": \"true-when\",\n            \"valueString\": \"category==infection\"\n        }\n    ]\n}\n```\n\nHere we have added an extension with a url of `true-when` that is a machine readable statement denoting when a search parameter is accepted by the server. It currently only supports == to show equality and in to show membership of a list (e.g. \"category in [infection, health-problem]\"). This also works for when a search parameter is limited in the values it will successfully search for. For example, here is what the `CapabilityStatement.rest[0].resource.where(type = 'Condition').searchParam.where(name = 'category')` element looks like:\n\n``` json\n{\n    \"name\": \"category\",\n    \"type\": \"token\",\n    \"documentation\": \"Search for Condition resources by category.\",\n    \"extension\": [\n        {\n            \"url\": \"true-when\",\n            \"valueString\": \"category in [dental-finding, encounter-diagnosis, genomics, health-concern, infection, medical-history, problem-list-item, reason-for-visit]\"\n        }\n    ]\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Andrew Stevens  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A package to help with FHIR searching when needed search parameters are not available",
    "version": "0.3.1",
    "project_urls": {
        "Bug Reports": "https://github.com/SmartChartSuite/FHIRSearchHelper/issues",
        "Homepage": "https://github.com/SmartChartSuite/FHIRSearchHelper",
        "Source": "https://github.com/SmartChartSuite/FHIRSearchHelper"
    },
    "split_keywords": [
        "fhir",
        "fhirsearching"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a40adb166c987c9ddfa213d46a84a41c7a72a29d8a391a3bbd84a8d1f27e705e",
                "md5": "8b49dc2473150a3f40fb82ed1104251c",
                "sha256": "a79c7ac0b259061ab4e9cad2dc7192e76404e5fb5120b238c2c26276834f887e"
            },
            "downloads": -1,
            "filename": "fhirsearchhelper-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b49dc2473150a3f40fb82ed1104251c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 58846,
            "upload_time": "2023-12-15T14:23:56",
            "upload_time_iso_8601": "2023-12-15T14:23:56.965754Z",
            "url": "https://files.pythonhosted.org/packages/a4/0a/db166c987c9ddfa213d46a84a41c7a72a29d8a391a3bbd84a8d1f27e705e/fhirsearchhelper-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "798bfc8de6d036ea80a390d09de5f91137933d6ce6a8702280b3bb118df38d98",
                "md5": "b5b6266f0cd1a7a3d3425237ad1bcf43",
                "sha256": "bff635bf366d21d44a04a99f382e1fd574c186bd59d702bc5aa6b994585ab271"
            },
            "downloads": -1,
            "filename": "fhirsearchhelper-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b5b6266f0cd1a7a3d3425237ad1bcf43",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 55260,
            "upload_time": "2023-12-15T14:24:33",
            "upload_time_iso_8601": "2023-12-15T14:24:33.921312Z",
            "url": "https://files.pythonhosted.org/packages/79/8b/fc8de6d036ea80a390d09de5f91137933d6ce6a8702280b3bb118df38d98/fhirsearchhelper-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 14:24:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SmartChartSuite",
    "github_project": "FHIRSearchHelper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "fhirsearchhelper"
}
        
Elapsed time: 0.16852s