Skip to main content

lx-data-models

PyPI Python CI Documentation codecov License: MIT

lx-dtypes validates research data against predefined study rules and versioned medical terminology. Applications can collect structured validation findings without interrupting data capture, while using strict typed contracts at storage and exchange boundaries. The package also provides FHIR interoperability and Django host integration.

Highlights

  • Strict, reusable contracts for knowledge-base, ledger, reporting, and host integration boundaries.
  • Version-aware YAML knowledge bases and deterministic loaders.
  • Report-template graph, structure, coverage, and runtime validation.
  • FHIR clinical and terminology conversion contracts.
  • Typed package data with Pyright, pytest, and documentation checks in CI.

The package is currently in alpha. Public imports are kept stable where possible, but releases before 1.0 may contain documented breaking changes.

Installation

lx-dtypes supports Python 3.12.

python -m pip install lx-dtypes

Quick start

Validate a study setup without raising for invalid input:

from lx_dtypes.models.contracts.study_setup import StudySetupDefinition
from lx_dtypes.validation 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 for error codes, evaluation status, and strict persistence boundaries.

Load a knowledge-base module shipped with the package:

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 should supply the exact module version. See the knowledge-base authoring guide and graph API guide for the complete workflow.

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

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

This boundary is strict: invalid registry state or an unloadable packaged identity exits nonzero and must block host startup.

Documentation

Start with the documentation index. Key guides include:

Build the documentation locally with:

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

Development

git clone https://github.com/wg-lux/lx-data-models.git
cd lx-data-models
uv sync --extra dev
uv run python scripts/lint_structure.py
uv run pyright
uv run pytest -q
uv run make -C docs html

Knowledge-base fixtures and tests must not contain patient data, credentials, or machine-local paths. Generated output belongs in temp/generated_exports/ or a test-local temporary directory.

See CONTRIBUTING.md for the full contributor and release workflow, CHANGELOG.md for release notes, and SECURITY.md for responsible vulnerability reporting.

For scoped repository navigation, start at structure.yml and follow the agent context guide.

License and citation

Distributed under the MIT License. If you use lx-dtypes in published work, cite the project using CITATION.cff.

Metadata

Release files for lx-dtypes 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lx-dtypes 0.5.2
File Size Uploaded
lx_dtypes-0.5.2.tar.gz 3.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for lx-dtypes 0.5.2
File Interpreter ABI Platform
lx_dtypes-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 4.3 MB

Release files / lx_dtypes-0.5.2.tar.gz

Download URL lx_dtypes-0.5.2.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
2f2b7f16d143ea63fefe51e042dc6a256d95eec9d6ddefcc4f4f7f4f7635f816
BLAKE2b-256 checksum
How to use checksums
10da82f5b1f90cc6ebc4fab95a778dd2afc5b66f4c40d091af9c2359fee4ff5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / lx_dtypes-0.5.2-py3-none-any.whl

Download URL lx_dtypes-0.5.2-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f1b9d1acb47056bc2ffa7d2d033d18c1ffa0c61e706f81963bca79dc9f8d6730
BLAKE2b-256 checksum
How to use checksums
35f30cdc226b2718cc836a28ac2a3647df800ce24ad7a4b31b4a7ed88b8561ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

0.5.4

2 release files

0.5.3

2 release files

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.32

2 release files

0.2.31

2 release files

0.2.30

2 release files

0.2.29

2 release files

0.2.28

2 release files

0.2.27

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.24

2 release files

0.2.23

2 release files

0.2.22

2 release files

0.2.21

2 release files

0.2.20

2 release files

0.2.19

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page