Metadata-Version: 2.4
Name: lx-dtypes
Version: 0.8.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Dist: bibtexparser>=1.4.0
Requires-Dist: django>=6.0
Requires-Dist: django-ninja>=1.5.3
Requires-Dist: django-stubs[compatible-mypy]>=5.2.8
Requires-Dist: django-stubs-ext>=5.2.8
Requires-Dist: icecream>=2.1.4
Requires-Dist: numpy>=2.2.3
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pandas>=2.2.3
Requires-Dist: pandas-stubs>=2.3.3.251201
Requires-Dist: pandera[pandas,io,mypy]>=0.27.0
Requires-Dist: pydantic>=2.10.6
Requires-Dist: python-ffmpeg>=2.0.12
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: requests>=2.32.3
Requires-Dist: scikit-learn>=1.8.0
Requires-Dist: scipy>=1.16.1
Requires-Dist: types-pyyaml>=6.0.12.20250915
Requires-Dist: platformdirs>=4
Requires-Dist: hl7>=0.4.5
Requires-Dist: defusedxml>=0.7.1
Requires-Dist: tomli-w>=1.2.0
Requires-Dist: xlrd==2.0.2 ; extra == 'dev'
Requires-Dist: build>=1.3.0 ; extra == 'dev'
Requires-Dist: flake8>=7.3.0 ; extra == 'dev'
Requires-Dist: linkify-it-py>=2.0.3 ; extra == 'dev'
Requires-Dist: myst-parser>=4.0.1 ; extra == 'dev'
Requires-Dist: mypy>=1.16.0 ; extra == 'dev'
Requires-Dist: pip>=25.2 ; extra == 'dev'
Requires-Dist: pre-commit>=4.5.0 ; extra == 'dev'
Requires-Dist: pytest>=9.0.2 ; extra == 'dev'
Requires-Dist: pytest-cov>=6.1.1 ; extra == 'dev'
Requires-Dist: pytest-env>=1.1.5 ; extra == 'dev'
Requires-Dist: pytest-mypy-plugins>=3.2.0 ; extra == 'dev'
Requires-Dist: pytest-xdist>=3.8.0 ; extra == 'dev'
Requires-Dist: pytest-django>=4.11.1 ; extra == 'dev'
Requires-Dist: pyright>=1.1.414 ; extra == 'dev'
Requires-Dist: radon>=6.0.1 ; extra == 'dev'
Requires-Dist: sphinx-autodoc-typehints>=3.5.2 ; extra == 'dev'
Requires-Dist: sphinx-copybutton>=0.5.2 ; extra == 'dev'
Requires-Dist: sphinx>=8.2.3,<9.0 ; extra == 'dev'
Requires-Dist: furo>=2025.9.25 ; extra == 'dev'
Requires-Dist: ruff>=0.14.8 ; extra == 'dev'
Requires-Dist: twine>=6.2.0,<7 ; extra == 'dev'
Requires-Dist: ziglang>=0.15.2 ; extra == 'dev'
Requires-Dist: opencv-python-headless>=4.12.0.88 ; extra == 'dev'
Requires-Dist: vulture>=2.16 ; extra == 'dev'
Requires-Dist: types-defusedxml>=0.7.0 ; extra == 'dev'
Requires-Dist: pylint>=4.1.4 ; extra == 'dev'
Requires-Dist: linkify-it-py>=2.0.3 ; extra == 'docs'
Requires-Dist: myst-parser>=4.0.1 ; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=3.5.2 ; extra == 'docs'
Requires-Dist: sphinx-copybutton>=0.5.2 ; extra == 'docs'
Requires-Dist: sphinx>=8.2.3,<9.0 ; extra == 'docs'
Requires-Dist: furo>=2025.9.25 ; extra == 'docs'
Provides-Extra: dev
Provides-Extra: docs
License-File: LICENSE
Summary: Typed clinical data models, terminology, and interoperability contracts
Keywords: clinical-data,data-models,fhir,medical-research,pydantic,terminology
Author-email: "Thomas J. Lux" <lux_t1@ukw.de>
Maintainer-email: "Thomas J. Lux" <lux_t1@ukw.de>, Max Hild <hild_m@ukw.de>
Requires-Python: >=3.12, <3.13
Description-Content-Type: text/markdown
Project-URL: Changelog, https://github.com/wg-lux/lx-data-models/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/wg-lux/lx-data-models
Project-URL: Issues, https://github.com/wg-lux/lx-data-models/issues
Project-URL: Repository, https://github.com/wg-lux/lx-data-models

# lx-data-models

[![PyPI](https://img.shields.io/pypi/v/lx-dtypes.svg)](https://pypi.org/project/lx-dtypes/)
[![Python](https://img.shields.io/pypi/pyversions/lx-dtypes.svg)](https://pypi.org/project/lx-dtypes/)
[![CI](https://github.com/wg-lux/lx-data-models/actions/workflows/ci.yml/badge.svg)](https://github.com/wg-lux/lx-data-models/actions/workflows/ci.yml)
[![Documentation](https://github.com/wg-lux/lx-data-models/actions/workflows/docs.yml/badge.svg)](https://github.com/wg-lux/lx-data-models/actions/workflows/docs.yml)
[![codecov](https://codecov.io/github/wg-lux/lx-data-models/graph/badge.svg?token=132HVE8KSF)](https://codecov.io/github/wg-lux/lx-data-models)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

`lx-dtypes` provides typed models for clinical research data. It checks data
against study rules and versioned medical terminology. Applications can collect
validation findings during data capture and validate records before storage or
exchange. The package also supports FHIR conversion and Django integration.

> [!IMPORTANT]
> This project is research software. It is not a medical device and must not be
> used as the sole basis for clinical decisions.

## Highlights

- Reusable models for terminology, patient records, reports, and host integration.
- Shared model policies and an explicit contract/evaluation boundary.
- Versioned YAML knowledge bases with deterministic loading.
- Report-template checks for structure, coverage, and captured data.
- FHIR clinical data and terminology conversion.
- Type, test, and documentation checks in CI.

The package is in **alpha**. We aim to keep public imports stable. Releases
before `1.0` may include documented breaking changes.

## Installation

`lx-dtypes` supports Python 3.12.

```bash
python -m pip install lx-dtypes
```

## Quick start

Create a local package of definitions from a working example:

```sh
lx-dtypes-package init my_terminology
# Edit my_terminology/data/records.yml in a text editor.
lx-dtypes-package check my_terminology
```

Use `init my_study --kind study` for a study preset with an example centre.
The command creates the manifest and assigns the initial version. See the
[first-package guide](docs/guides/dtypes-package-structure.md#start-here-your-first-study-package)
for editing and registration.

Validate a study setup without raising for invalid input:

```python
from lx_dtypes.models.contracts.study_setup import StudySetupDefinition
from lx_dtypes.evaluation import validate_contract

result = validate_contract(StudySetupDefinition, {"schema_version": "1.0"})
for issue in result.report.issues:
    print(issue.code, issue.path, issue.message)

# result.value contains the typed model only when the contract is valid.
```

For ledger data, `assess_examination(knowledge_base, payload,
template_name="...")` checks terminology provenance and applies the selected
template's study rules. Findings are advisory; the host decides when to require
correction. See the [cross-layer validation guide](docs/guides/cross-layer-validation.md)
for error codes, evaluation status, and strict persistence boundaries.

Load a knowledge-base module shipped with the package:

```python
from lx_dtypes import load_knowledge_base

knowledge_base = load_knowledge_base("report_template_examples")

print(knowledge_base.config.knowledge_base_identity)
print(sorted(knowledge_base.report_template))
```

Registry-backed deployments require an exact module version. The
[knowledge-base authoring guide](docs/guides/knowledge-base-authoring.md)
explains versioning and deployment.

Provision the packaged catalog before starting a registry-backed host:

```bash
export LX_DTYPES_KB_REGISTRY=/var/lib/my-host/terminology/registry.json
lx-dtypes-kb-registry bootstrap
```

The command exits nonzero if the registry is invalid or a packaged identity
cannot load. Hosts must treat that failure as a startup blocker.

## Documentation

Follow the [reader roadmap](docs/index.md#reader-roadmap) from the model overview
to a working example, then choose terminology, reporting, or application
integration. You can start with the topic that fits your work.

Build the documentation locally with:

```bash
python -m pip install -e ".[docs]"
make -C docs html
```

## Development

Questions, documentation fixes, synthetic examples, and code changes are useful
ways to contribute. Start with [CONTRIBUTING.md](CONTRIBUTING.md) for setup,
checks, and pull requests. See [CHANGELOG.md](CHANGELOG.md) for release notes
and [SECURITY.md](SECURITY.md) for vulnerability reporting.

For scoped repository navigation, start at [structure.yml](structure.yml) and
follow the [agent context guide](docs/agent_context.md).

## License and citation

Distributed under the [MIT License](LICENSE). If you use `lx-dtypes` in
published work, cite the project using [CITATION.cff](CITATION.cff).

