Metadata-Version: 2.1
Name: mcs
Version: 0.0.1
Summary: Paper - Pytorch
Home-page: https://github.com/The-Swarm-Corporation/MedicalCoderSwarm
License: MIT
Keywords: artificial intelligence,deep learning,optimizers,Prompt Engineering
Author: Kye Gomez
Author-email: kye@apac.ai
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: loguru
Requires-Dist: swarms
Project-URL: Documentation, https://github.com/The-Swarm-Corporation/MedicalCoderSwarm
Project-URL: Repository, https://github.com/The-Swarm-Corporation/MedicalCoderSwarm
Description-Content-Type: text/markdown

# Medical Diagnosis Swarm Architecture


[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)

A production-grade multi-agent system for comprehensive medical diagnosis and coding using specialized AI agents.

## Architecture Overview

```mermaid
flowchart TB
    CMO[Chief Medical Officer] --> V[Virologist]
    V --> I[Internist]
    I --> MC[Medical Coder]
    MC --> S[Synthesizer]
    
    style CMO fill:#f9f,stroke:#333,stroke-width:2px
    style V fill:#bbf,stroke:#333,stroke-width:2px
    style I fill:#bbf,stroke:#333,stroke-width:2px
    style MC fill:#bfb,stroke:#333,stroke-width:2px
    style S fill:#fbb,stroke:#333,stroke-width:2px
```

## 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

```mermaid
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
```

## Installation

```bash
pip install swarms
```

## Usage

```python
from swarms import Agent, AgentRearrange
from datetime import datetime

# Initialize agents
chief_medical_officer = Agent(
    agent_name="Chief Medical Officer",
    system_prompt="""...""",
    model_name="gpt-4o",
    max_loops=1
)

# Create agent list and flow
agents = [chief_medical_officer, virologist, internist, medical_coder, synthesizer]
flow = "Chief Medical Officer -> Virologist -> Internist -> Medical Coder -> Synthesizer"

# Initialize swarm system
diagnosis_system = AgentRearrange(
    name="Medical-coding-diagnosis-swarm",
    description="Comprehensive medical diagnosis and coding system",
    agents=agents,
    flow=flow,
    max_loops=1,
    output_type="all"
)

# Process patient case
patient_case = """
Patient: 45-year-old White Male
Lab Results:
- egfr: 59 ml/min/1.73
- non african-american
"""

diagnosis = diagnosis_system.run(patient_case)
```

## Diagnostic Flow Process

```mermaid
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
```

## Output Format

The system generates two main types of reports:

1. **Medical Diagnosis Report**: Clinical findings and recommendations
2. **Coding Report**: Structured ICD-10 codes and documentation

Example Report Structure:
```markdown
# Medical Diagnosis and Coding Report
Generated: [Timestamp]

## Clinical Summary
[Diagnosis Details]

## Coding Summary
### Primary Diagnosis Codes
[ICD-10 Codes]

### Secondary Diagnosis Codes
[Additional Codes]

## Recommendations
[Next Steps]
```

## 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](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.

