Metadata-Version: 2.4
Name: clinical-ddi-check
Version: 0.1.0
Summary: Drug-drug interaction check tool for clinical AI agents. Curated JSON data, RxNorm normalization, LangChain-ready.
Project-URL: Homepage, https://github.com/openemr/openemr-clinical-intelligence-service
Project-URL: Repository, https://github.com/openemr/openemr-clinical-intelligence-service
Author: OpenEMR Clinical Intelligence
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-agent,clinical,ddi,drug-interaction,healthcare,langchain
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Healthcare Industry
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.9
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
Description-Content-Type: text/markdown

# clinical-ddi-check

Drug-drug interaction (DDI) check tool for clinical AI agents. Curated JSON data, RxNorm normalization, LangChain-ready.

## Features

- **Curated DDI data** – Bundled JSON with common interactions (aspirin/warfarin, metformin/contrast, etc.)
- **RxNorm normalization** – Resolves "Aspirin 81mg" → "aspirin" via NLM RxNorm API
- **Structured output** – Pydantic models with severity, description, clinical advice
- **LangChain adapter** – Drop-in tool for LangGraph / OpenAI function calling

## Installation

```bash
pip install clinical-ddi-check
```

For LangChain/LangGraph integration:

```bash
pip install clinical-ddi-check[langchain]
```

## Quick Start

### Standalone

```python
from clinical_ddi_check import drug_interaction_check

# Check interactions between current meds
result = drug_interaction_check(medications=["warfarin", "aspirin"])
# result["count"] == 1, result["has_major_or_contraindicated"] == True

# Check proposed drug against current meds
result = drug_interaction_check(
    medications=["metformin"],
    proposed_drug="contrast media",
)
# result["interactions"][0]["severity"] == "contraindicated"
```

### LangChain / LangGraph

```python
from clinical_ddi_check import create_langchain_tool, LANGCHAIN_TOOL_SCHEMA

# Create a LangChain tool
tool = create_langchain_tool()
# Use with model.bind_tools([tool]) or in a LangGraph node

# Or use the raw schema for OpenAI function calling
# LANGCHAIN_TOOL_SCHEMA matches the format expected by bind_tools
```

### Custom DDI Data

```python
result = drug_interaction_check(
    medications=["drug_a", "drug_b"],
    ddi_data_path="/path/to/your/ddi.json",
)
```

DDI JSON format:

```json
{
  "interactions": [
    {
      "drug_a": "aspirin",
      "drug_b": "warfarin",
      "severity": "major",
      "description": "Increased bleeding risk.",
      "clinical_advice": "Monitor for signs of bleeding."
    }
  ]
}
```

Severities: `contraindicated`, `major`, `moderate`, `minor`.

## API

### `drug_interaction_check(medications, proposed_drug=None, patient_id=None, ddi_data_path=None)`

Returns a dict:

- **Success:** `interactions`, `medications_checked`, `proposed_drug`, `patient_id`, `count`, `has_major_or_contraindicated`
- **Error:** `error_code`, `message`, `details`

### `normalize_medication_names(medications)`

Normalizes drug names via RxNorm. Returns `{"normalized": [...]}` or error dict.

## License

Apache-2.0
