dhti-elixir-base 1.5.1
DHTI Elixir Base
Requires Python: <4.0,>=3.10
Keywords: Gen AI, dhti, python

# [DHTI ELIXIR BASE](https://github.com/dermatologist/dhti)

<p align="center">
  <img src="https://github.com/dermatologist/dhti/blob/develop/notes/dhti-logo.jpg" />
</p>

[![Release](https://img.shields.io/github/v/release/dermatologist/dhti-elixir-base)](https://img.shields.io/github/v/release/dermatologist/dhti-elixir-base)
[![Build status](https://img.shields.io/github/actions/workflow/status/dermatologist/dhti-elixir-base/pytest.yml?branch=develop)](https://github.com/dermatologist/dhti-elixir-base/actions/workflows/pytest.yml?query=branch%3Adevelop)
[![codecov](https://codecov.io/gh/dermatologist/dhti-elixir-base/branch/develop/graph/badge.svg)](https://codecov.io/gh/dermatologist/dhti-elixir-base)
[![Commit activity](https://img.shields.io/github/commit-activity/m/dermatologist/dhti-elixir-base)](https://img.shields.io/github/commit-activity/m/dermatologist/dhti-elixir-base)
[![Downloads](https://img.shields.io/pypi/dm/dhti-elixir-base)](https://pypi.org/project/dhti-elixir-base)
[![Documentation](https://badgen.net/badge/icon/documentation?icon=libraries&label)](https://dermatologist.github.io/dhti-elixir-base/)

Base library for creating new [DHTI](https://github.com/dermatologist/dhti) Elixirs.

[What is DHTI?](https://github.com/dermatologist/dhti) DHTI (Digital Health Tooling Interface) provides building blocks for interoperable, healthcare-focused AI tooling. This repository is the minimal foundation you extend to build your own "Elixir"—a reusable, testable component (chain/agent/server) that plugs into the wider DHTI ecosystem.

Status: WIP, but stable enough to scaffold new Elixirs and iterate quickly.

<!-- gh-dependents-info-used-by-start -->
[![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by&message=2&color=informational&logo=slickpic)](https://github.com/dermatologist/dhti-elixir-base/blob/develop/docs/github-dependents-info.md)<!-- gh-dependents-info-used-by-end -->


## Overview

This package exposes lightweight, composable base classes:

- `BaseChain` – a LangChain-compatible chain scaffold with sensible defaults.
- `BaseAgent` – an agent scaffold that can bind tools and work with LangGraph.
- `BaseGraph`, `BaseLLM`, `BaseServer`, `BaseSpace`, and `BaseDhtiModel` – helpers to organize more complex Elixirs.

Use these to rapidly create a new Elixir with a consistent structure, tests, and docs.

### Dependency Injection (mydi.py / di)

The codebase uses a simple dependency injection pattern via `mydi.py` and the `get_di` function. This allows you to:
- Configure FHIR endpoints, authentication, and other settings at runtime
- Swap out implementations for testing or customization
- Keep your code modular and maintainable

### CDS Hook Module (Frontend Integration)

The `cds_hook` module now provides  request parsing and context extraction for CDS Hooks workflows. It supports:
- Parsing various CDS Hooks request formats
- Extracting patient and order context

This enables integration with frontend CDS Hooks clients.

### FHIR Module (Backend Integration: SMART on FHIR & FHIRPath)

The `fhir` module  includes advanced backend features:
- **SMART on FHIR**: The `SmartOnFhirSearch` class provides secure, standards-based access to FHIR resources using OAuth2 and the SMART on FHIR protocol. It supports:
	- Patient-centric resource queries (Conditions, Observations, Procedures, MedicationRequests, AllergyIntolerances)
	- $everything operation for comprehensive patient data
	- Automatic token management and authentication
- **FHIRPath Support**: All resource queries can apply FHIRPath expressions for flexible data extraction and transformation.

### CrewAI Integration (Optional)

The `crewai` module provides wrapper classes that make DHTI's LangChain-based components compatible with the [CrewAI](https://www.crewai.com/) framework:
- **CrewAILLMWrapper**: Wraps `BaseLLM` and `BaseChatLLM` for use with CrewAI agents
- **CrewAIAgentWrapper**: Wraps `BaseAgent` to create CrewAI-compatible agents
- **CrewAIChainToolWrapper**: Wraps `BaseChain` as a CrewAI tool
- **CrewAILangChainToolWrapper**: Wraps LangChain tools for use in CrewAI

To use CrewAI integration, install with the optional dependency:
```bash
pip install dhti-elixir-base[crewai]
```

See the [CrewAI documentation](https://dermatologist.github.io/dhti-elixir-base/crewai/) for detailed usage examples.

[![Documentation](https://badgen.net/badge/icon/documentation?icon=libraries&label)](https://dermatologist.github.io/dhti-elixir-base/)

## Project layout

- `src/dhti_elixir_base/` – base classes and minimal utilities.
- `tests/` – example tests to keep your Elixir robust.
- `examples/` – quick patterns for chains/graphs.
- `docs/` – MkDocs configuration for documentation.


## Learn more

- DHTI home: https://github.com/dermatologist/dhti
- This template docs: https://dermatologist.github.io/dhti-elixir-base/

## Give us a star ⭐️
If you find this project useful, give us a star. It helps others discover the project.

## Contributors

* [Bell Eapen](https://nuchange.ca) | [![Twitter Follow](https://img.shields.io/twitter/follow/beapen?style=social)](https://twitter.com/beapen)