dotimplement / HealthChain

Simplify prototyping and testing LLM applications in healthcare context πŸ’« πŸ₯
https://dotimplement.github.io/HealthChain/
Apache License 2.0
10 stars 1 forks source link
ai ehr healthcare llm mlops nlp
# HealthChain πŸ’« πŸ₯ HealthChain Logo ![GitHub License](https://img.shields.io/github/license/dotimplement/HealthChain) ![PyPI Version](https://img.shields.io/pypi/v/healthchain) ![Python Versions](https://img.shields.io/pypi/pyversions/healthchain) ![Downloads](https://img.shields.io/pypi/dm/healthchain)

Simplify testing and evaluating AI and NLP applications in a healthcare context πŸ’« πŸ₯.

Building applications that integrate in healthcare systems is complex, and so is designing reliable, reactive algorithms involving unstructured data. Let's try to change that.

pip install healthchain

First time here? Check out our Docs page!

Features

Why use HealthChain?

Clinical Decision Support (CDS)

CDS Hooks is an HL7 published specification for clinical decision support.

When is this used? CDS hooks are triggered at certain events during a clinician's workflow in an electronic health record (EHR), e.g. when a patient record is opened, when an order is elected.

What information is sent: the context of the event and FHIR resources that are requested by your service, for example, the patient ID and information on the encounter and conditions they are being seen for.

What information is returned: β€œcards” displaying text, actionable suggestions, or links to launch a SMART app from within the workflow.

What you need to decide: What data do I want my EHR client to send, and how will my service process this data.

import healthchain as hc

from healthchain.use_cases import ClinicalDecisionSupport
from healthchain.models import Card, CdsFhirData, CDSRequest
from healthchain.data_generator import DataGenerator

from typing import List

# Decorate class with sandbox and pass in use case
@hc.sandbox
class myCDS(ClinicalDecisionSupport):
    def __init__(self) -> None:
        self.data_generator = DataGenerator()

    # Sets up an instance of a mock EHR client of the specified workflow
    @hc.ehr(workflow="patient-view")
    def ehr_database_client(self) -> CdsFhirData:
        self.data_generator.generate()
        return self.data_generator.data

    # Define your application logic here
    @hc.api
    def my_service(self, request: CdsRequest) -> List[Card]:
        result = "Hello " + request["patient_name"]
        return result

if __name__ == "__main__":
    cds = myCDS()
    cds.start_sandbox()

Then run:

healthchain run mycds.py

This will populate your EHR client with the data generation method you have defined, send requests to your server for processing, and save the data in ./output by default.

Clinical Documentation

The ClinicalDocumentation use case implements a real-time Clinical Documentation Improvement (CDI) service. It helps convert free-text medical documentation into coded information that can be used for billing, quality reporting, and clinical decision support.

When is this used? Triggered when a clinician opts in to a CDI functionality (e.g. Epic NoteReader) and signs or pends a note after writing it.

What information is sent: A CDA (Clinical Document Architecture) document which contains continuity of care data and free-text data, e.g. a patient's problem list and the progress note that the clinician has entered in the EHR.

What information is returned: A CDA document which contains additional structured data extracted and returned by your CDI service.

import healthchain as hc

from healthchain.use_cases import ClinicalDocumentation
from healthchain.models import CcdData, ProblemConcept, Quantity,

@hc.sandbox
class NotereaderSandbox(ClinicalDocumentation):
    def __init__(self):
        self.cda_path = "./resources/uclh_cda.xml"

    # Load an existing CDA file
    @hc.ehr(workflow="sign-note-inpatient")
    def load_data_in_client(self) -> CcdData:
        with open(self.cda_path, "r") as file:
            xml_string = file.read()

        return CcdData(cda_xml=xml_string)

    # Define application logic
    @hc.api
    def my_service(self, ccd_data: CcdData) -> CcdData:
        # Apply method from ccd_data.note and access existing entries from ccd.problems

        new_problem = ProblemConcept(
            code="38341003",
            code_system="2.16.840.1.113883.6.96",
            code_system_name="SNOMED CT",
            display_name="Hypertension",
            )
        ccd_data.problems.append(new_problem)
        return ccd_data

Streamlit dashboard

Note this is currently not meant to be a frontend to the EHR client, so you will have to run it separately from the sandbox application.

pip install streamlit
streamlit streamlit-demo/app.py

Road Map

Contribute

We are always eager to hear feedback and suggestions, especially if you are a developer or researcher working with healthcare systems!

Acknowledgement

This repository makes use of CDS Hooks developed by Boston Children’s Hospital.