Skip to main content

Paper - Pytorch

Project description

Medical Diagnosis Swarm Architecture

Join our Discord Subscribe on YouTube Connect on LinkedIn Follow on X.com

MedicalSwarm is a sophisticated medical diagnosis and coding platform that leverages a coordinated swarm of specialized AI agents to deliver comprehensive medical assessments, accurate ICD-10 coding, and detailed clinical documentation. The system employs a hierarchical approach with specialized agents working in concert to analyze patient data, generate diagnoses, and ensure coding compliance.

Key Features

Multi-Agent Architecture

  • Chief Medical Officer: Coordinates diagnosis workflow and synthesizes findings
  • Virologist: Specializes in viral disease analysis and progression
  • Internist: Provides comprehensive internal medicine evaluation
  • Medical Coder: Ensures accurate ICD-10 coding and compliance
  • Diagnostic Synthesizer: Creates final integrated assessments

Enterprise Integration

  • RAG (Retrieval-Augmented Generation) API support
  • Comprehensive logging and telemetry
  • Scalable batch processing capabilities
  • Configurable output formats and storage

Clinical Documentation

  • Automated ICD-10 code assignment
  • Hierarchical Condition Category (HCC) coding
  • Evidence-based diagnostic rationale
  • Detailed clinical progression timelines

Installation

pip install mcs

Onboarding

To get started you must first set some envs in your .env

WORKSPACE_DIR="agent_workspace"
OPENAI_API_KEY="your_key"

Usage

from mcs.main import MedicalCoderSwarm
import json

if __name__ == "__main__":
  # Example patient case
  patient_case = """
  Patient: 45-year-old White Male
  Location: New York, NY

  Lab Results:
  - egfr 
  - 59 ml / min / 1.73
  - non african-american
  
  """
  
  swarm = MedicalCoderSwarm(patient_id="Patient-001", max_loops=1, patient_documentation="")
  
  swarm.run(task=patient_case)
  
  print(json.dumps(swarm.to_dict()))

Architecture Overview

flowchart TB
    CMO[Chief Medical Officer] --> V[Virologist]
    V --> I[Internist]
    I --> MC[Medical Coder]
    MC --> S[Synthesizer]
    

Features

  • Specialized Agent Roles: Each agent has specific medical expertise and responsibilities
  • Structured Diagnostic Flow: Organized pipeline from initial assessment to final synthesis
  • ICD-10 Coding Integration: Comprehensive medical coding at each diagnostic stage
  • Automated Report Generation: Standardized medical and coding reports
  • Evidence-Based Decision Making: Multi-stage verification and synthesis process

Agent Responsibilities

mindmap
  root((Medical Swarm))
    Chief Medical Officer
      Initial Assessment
      Coordinate Specialists
      Treatment Plans
      Lab Range Analysis
    Virologist
      Viral Analysis
      Disease Progression
      Risk Assessment
    Internist
      System Review
      Vitals Analysis
      Comorbidity Evaluation
    Medical Coder
      ICD-10 Assignment
      Coding Compliance
      Documentation Review
    Synthesizer
      Integration
      Reconciliation
      Final Assessment

Diagnostic Flow Process

sequenceDiagram
    participant P as Patient Case
    participant CMO as Chief Medical Officer
    participant V as Virologist
    participant I as Internist
    participant MC as Medical Coder
    participant S as Synthesizer
    
    P->>CMO: Initial Data
    CMO->>V: Preliminary Assessment
    V->>I: Viral Analysis
    I->>MC: Comprehensive Review
    MC->>S: Coded Diagnosis
    S->>P: Final Report

API Usage

We have established an api in the /api folder. To run the api locally you must git clone, and then run:

cd api

chmod +x bootup.sh

./bootup.sh

API Testing

When you launch your api you can run the tests to see if it works ;)

cd api

python3 test.py

Docker Usage

To build and run the Docker container for the Medical Coder Swarm, follow these steps:

  1. Build the Docker Image:
docker build -t mcs .
  1. Run the Docker Container:
docker run --rm mcs

Docker Compose

docker-compose up

To stop the services, run:

docker-compose down

Lab Range Analysis

The system includes specialized functionality for analyzing lab results against diagnostic criteria:

  • Automated range checking for common tests (e.g., eGFR)
  • Diagnosis-specific range validation
  • Multi-factor analysis for complex diagnoses

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Built with the Swarms framework
  • Utilizes GPT-4 for advanced medical reasoning
  • ICD-10 coding standards compliance

Contact

For questions and support, please open an issue in the repository.

Project details


Download files

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

Source Distribution

mcs-0.0.6.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcs-0.0.6-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file mcs-0.0.6.tar.gz.

File metadata

  • Download URL: mcs-0.0.6.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.3.0

File hashes

Hashes for mcs-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0e75f22e0202b3466637aed24e0837afa2aa2984ba41e661050f41a459e08205
MD5 819515a041a459cb7e396bc8647440f0
BLAKE2b-256 6b7a60c9fa845f14aa1030fc809d210277adf57277f97f4d8a0e7d085b0885cd

See more details on using hashes here.

File details

Details for the file mcs-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: mcs-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.3.0

File hashes

Hashes for mcs-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4bd97fc824185e63d54a0d90a15ba8b00cf653caf76ee6e362795f9492614c
MD5 67d57ca956ab61cbaf10c989e8b51ab8
BLAKE2b-256 7f95838440b726a4892c4555465e7cf657b583e76cf2675958086c6fa2a70d9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page