Skip to main content

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

Project description

bh-sentinel-core

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.1.tar.gz (46.4 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.1-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bh_sentinel_core-0.1.1.tar.gz
  • Upload date:
  • Size: 46.4 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.1.tar.gz
Algorithm Hash digest
SHA256 517c40987dd33f3c1a92f44528b34da53176b5794895424a41d3d1cbf8ca72ab
MD5 0867af4e8e2942e20f40f3c540c794d2
BLAKE2b-256 7f6e3c19efe490fba22461f08c502e363194077bfe7c4463281e3a0336b33b76

See more details on using hashes here.

Provenance

The following attestation bundles were made for bh_sentinel_core-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bh_sentinel_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e6dfbc85c84f59cdc49722a8f53e59e7b7f135d388fb10fe1b944043aef2057
MD5 95525f6e3faf4ffeea4305591e6bd2dd
BLAKE2b-256 439adcb4e864ab160e2a507021bd12ce65c5b2f61431ec2b2241934204fc770f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bh_sentinel_core-0.1.1-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