Skip to content

senablgn/data-clinic-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClinicAgent: Clinical Data Analysis Agent

ClinicAgent is an AI-powered clinical decision support system designed to assist medical professionals in analyzing patient data, radiology reports, and medical images. It leverages OpenAI's GPT models to provide intelligent insights, generate discharge summaries (epicrisis), and facilitate natural language interaction with clinical datasets.

Key Features

1.Dataset Analysis

  • Batch Processing: Upload Excel files containing patient data to perform bulk analysis.
  • Automated Calculations: Automatically calculates Length of Stay (LoS) from admission and discharge dates.
  • ICD-10 Processing: Parses and groups diagnosis codes for easier clinical review.
  • Risk Assessment: Analyzes radiology reports to estimate cancer risk levels and lesion sizes.

Dataset Analysis

Interface where patient data in Excel format is uploaded and automated analytical processes are initiated.

2.Multimodal Radiology Analysis

  • Image & Text Co-Analysis: Upload a radiology image alongside its text report to check for consistency.
  • Pathology Detection: Identifies potential lesions and assesses cancer risk based on visual and textual data.
  • Consistency Verification: Automatically flags discrepancies between the image and the written report.

Radiology Image 1 Radiology Image 2

Multimodal module that jointly analyzes radiology images and their corresponding textual reports.
The images are displayed sequentially to emphasize image–text consistency verification.

3.Chat with Data

  • Natural Language Querying: Ask questions about your patient dataset in plain English (e.g., "How many patients have a high cancer risk?").
  • Agentic Data Analysis: The system translates your questions into analytical code to retrieve accurate answers from specific datasets.

Chat with Data

Conversational interface that enables natural language interaction with structured patient datasets.

4. Smart Discharge Letter (Epicrisis) Generator

  • Automated Drafting: Generates formal discharge summaries based on patient ID, clinical metrics, and diagnosis.
  • PDF Export: Downloads the generated epicrisis as a professional, standardized PDF report suitable for hospital records.

Epicrisis Generator

Module for generating patient-specific discharge summaries (epicrisis) and exporting them as standardized PDF documents.

5. Medical Guidelines Assistant (RAG)

  • Evidence-Based Support: Uses Retrieval-Augmented Generation (RAG) to provide answers directly from verified medical protocols (e.g., Lung Nodule Follow-up Guidelines).

-Zero Hallucination: Instead of relying on general knowledge, the agent searches internal vector databases to find specific clinical criteria.

-Source Transparency: Includes a "View Source" feature to show the exact section of the guideline used for the recommendation.

RAG Module

Example of data-driven clinical querying powered by a Retrieval-Augmented Generation (RAG) architecture.

Installation

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_name>
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    # Windows
    .\venv\Scripts\activate
    # macOS/Linux
    source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt

    Note: If requirements.txt is not present, the main dependencies are:

    • streamlit
    • pandas
    • openai
    • python-dotenv
    • fpdf
    • openpyxl
    • xlsxwriter
  4. Environment Setup: Create a .env file in the root directory and add your OpenAI API key:

    API_KEY=your_openai_api_key_here

Usage

Run the Streamlit application:

streamlit run app.py
  • Navigate through the tabs to use different features.
  • Ensure you have a valid OpenAI API key loaded via the sidebar or .env file for AI features to work.

Project Structure

The project follows a modular "Brain and Limbs" architecture to ensure scalability and separation of concerns.

data-clinic-agent/
├── app.py                   # Main Streamlit UI & Orchestration Layer
├── main.py                  # CLI/Script entry point for batch processing
├── clinic_agent/            # Core Package
│   ├── agents/              # Cognitive AI Agents (The Brain)
│   │   ├── chat_agent.py    # Natural language dataset analysis
│   │   ├── radiology.py     # Radiology report analysis logic
│   │   ├── multimodal_radiology.py # Vision + Text co-analysis
│   │   └── epicrisis_agent.py # Formal medical document generation
│   ├── tools/               # Deterministic Tools (The Limbs)
│   │   ├── rag_tool.py      # RAG query and retrieval engine
│   │   ├── tool_dates.py    # Admission/Discharge date calculations
│   │   └── tool_icd.py      # ICD-10 code parsing and grouping
│   └── utils/               # Utility Modules
│   |   ├── report_gen.py    # PDF generation logic for epicrisis
│   |    ├── lists_model.py   # Clinical reference lists and constants
│   |    └── rag_setup.py     # RAG database initialization and indexing
|   └── tests/                # Unit tests for agents and tools
├── guides/               # Clinical guidelines for RAG (PDF/Text)
├── ss/                      # README demonstration screenshots

Component Details

  • app.py
    The central orchestrator that manages session state and provides a multi-tab clinical dashboard.

  • clinic_agent/agents/
    Contains specialized GenAI modules that handle complex reasoning tasks, such as multimodal image analysis and clinical summary generation.

  • clinic_agent/tools/
    Host for rule-based and retrieval-based tools. These modules provide grounded data (ICD codes, verified guidelines) to prevent AI hallucinations.

  • guides/
    Serves as the dedicated knowledge base for the RAG system, housing expert-verified medical protocols.

Privacy Note

This tool is designed for educational and demonstration purposes. Ensure compliance with data privacy regulations (e.g., HIPAA, GDPR) before processing real patient data.


About

ClinicAgent is a multimodal AI assistant that helps healthcare professionals analyze clinical data, radiology reports, and medical images. It reduces workload and supports decision-making by transforming unstructured medical data into meaningful clinical insights.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages