Skip to main content

Clinical decision support: pattern-based safety signal detection for behavioral health. Not a diagnostic tool.

Project description

bh-sentinel-core

PyPI Downloads

Clinical decision support: pattern-based safety signal detection for behavioral health. Not a diagnostic tool.

Clinical Use Notice: bh-sentinel is clinical decision support software. It is not a diagnostic tool, not FDA-cleared, and not a substitute for clinical judgment. All outputs are signals for clinician review. See CLINICAL_DISCLAIMER.md.

bh-sentinel-core is the foundational library of the bh-sentinel project. It provides deterministic, regex-based safety signal detection with configurable rules, negation handling, temporal awareness, and an emotion lexicon.

Installation

pip install bh-sentinel-core

Dependencies

Minimal: pydantic, pyyaml. No ML libraries required.

What's Included

  • Pattern Matcher -- compiled regex engine with negation and temporal awareness
  • Rules Engine -- configurable severity escalation, de-escalation, and compound risk detection
  • Flag Taxonomy -- 40 flags across 6 clinical domains (self-harm, harm to others, medication, substance use, clinical deterioration, protective factors)
  • Text Preprocessor -- sentence splitting, normalization, and character offset tracking
  • Negation Detector -- "denies SI", "no suicidal ideation" handling
  • Temporal Detector -- past vs. present tense detection ("used to cut" vs. "is cutting")
  • Emotion Lexicon -- project-owned behavioral health lexicon with 11-category density scoring
  • Pipeline -- orchestrator that runs all layers and produces structured results

Quick Start

from bh_sentinel.core import Pipeline

pipeline = Pipeline()
result = pipeline.analyze_sync(
    "Patient reports suicidal ideation for the past two days. "
    "Stopped taking my medication last week."
)

for flag in result.flags:
    print(f"[{flag.severity}] {flag.name} (confidence: {flag.confidence})")

print(f"Immediate review: {result.summary.requires_immediate_review}")
print(f"Recommended: {result.summary.recommended_action}")

Adding the ML Layer

For semantic classification on top of pattern matching, install the companion bh-sentinel-ml package and enable Layer 2:

pip install bh-sentinel-ml
from bh_sentinel.core import Pipeline

pipeline = Pipeline(enable_transformer=True)  # auto-downloads pinned model on first run

bh-sentinel-core remains installable and usable on its own -- it has no runtime dependency on onnxruntime, tokenizers, or huggingface_hub. The ml imports are lazy-loaded only when enable_transformer=True.

Documentation

See the main repository for full documentation, architecture details, flag taxonomy reference, and the release process.

License

Apache License 2.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bh_sentinel_core-0.1.2.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bh_sentinel_core-0.1.2-py3-none-any.whl (54.9 kB view details)

Uploaded Python 3

File details

Details for the file bh_sentinel_core-0.1.2.tar.gz.

File metadata

  • Download URL: bh_sentinel_core-0.1.2.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bh_sentinel_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 73a3dde325bfa260a69eac8686849fb48526d460c141837cfb3762663f1eb260
MD5 591b1042cc18ada877e5d9cad4f6ea43
BLAKE2b-256 71c30ed1d095a19ead60c456044765acd68892287e8686d9dee1940623ed2efd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bh_sentinel_core-0.1.2.tar.gz:

Publisher: publish-core.yml on bh-healthcare/bh-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bh_sentinel_core-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for bh_sentinel_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cef51e4f3d1c5d57f606ea95b3b290c7137c8424095074d23eb8a86f47615522
MD5 260c910fa541a1b2ff9710aa574cd97d
BLAKE2b-256 2fdbee5f18979f5d2a5a17d757d027f5f1c5e8485ff95b67eacdeea774cd55f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bh_sentinel_core-0.1.2-py3-none-any.whl:

Publisher: publish-core.yml on bh-healthcare/bh-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page