Skip to main content

lx-data-models

PyPI Python CI Documentation codecov License: MIT

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.

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.

python -m pip install lx-dtypes

Quick start

Create a local package of definitions from a working example:

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 for editing and registration.

Validate a study setup without raising for invalid input:

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 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 require an exact module version. The knowledge-base authoring guide explains versioning and deployment.

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

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

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 for setup, checks, and pull requests. See CHANGELOG.md for release notes and SECURITY.md for 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.8.0

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.8.0
File Size Uploaded Provenance Actions
lx_dtypes-0.8.0.tar.gz 1.1 MB Without provenance Details for lx_dtypes-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lx-dtypes 0.8.0
File Interpreter ABI Platform Actions
lx_dtypes-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for lx_dtypes-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl

Total release size: 3.9 MB

Release files / lx_dtypes-0.8.0.tar.gz

Download URL lx_dtypes-0.8.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
acc08ac1f4748160a75126443fa4c95bb7dd37b7c24b2cdac74389bd37cb71d3
BLAKE2b-256 checksum
How to use checksums
d0b112d66294ab20849ed21e25ad9048f51ea779a7801727072d8c48a3d50fef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / lx_dtypes-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL lx_dtypes-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f9947a6588b89f58d46d4a1670be02fa83cf00873752455cf604e48dfcf7bdfd
BLAKE2b-256 checksum
How to use checksums
890cb1ca4b2b7ad9908f52638822ab9a9cee405e9821387033aa63e928b2d78f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for lx-dtypes 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files No provenance

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