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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
517c40987dd33f3c1a92f44528b34da53176b5794895424a41d3d1cbf8ca72ab
|
|
| MD5 |
0867af4e8e2942e20f40f3c540c794d2
|
|
| BLAKE2b-256 |
7f6e3c19efe490fba22461f08c502e363194077bfe7c4463281e3a0336b33b76
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bh_sentinel_core-0.1.1.tar.gz -
Subject digest:
517c40987dd33f3c1a92f44528b34da53176b5794895424a41d3d1cbf8ca72ab - Sigstore transparency entry: 1344889262
- Sigstore integration time:
-
Permalink:
bh-healthcare/bh-sentinel@043b964b8840038812831902ece33cb54717ce91 -
Branch / Tag:
refs/tags/core-v0.1.1 - Owner: https://github.com/bh-healthcare
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-core.yml@043b964b8840038812831902ece33cb54717ce91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bh_sentinel_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bh_sentinel_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 54.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6dfbc85c84f59cdc49722a8f53e59e7b7f135d388fb10fe1b944043aef2057
|
|
| MD5 |
95525f6e3faf4ffeea4305591e6bd2dd
|
|
| BLAKE2b-256 |
439adcb4e864ab160e2a507021bd12ce65c5b2f61431ec2b2241934204fc770f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bh_sentinel_core-0.1.1-py3-none-any.whl -
Subject digest:
3e6dfbc85c84f59cdc49722a8f53e59e7b7f135d388fb10fe1b944043aef2057 - Sigstore transparency entry: 1344889399
- Sigstore integration time:
-
Permalink:
bh-healthcare/bh-sentinel@043b964b8840038812831902ece33cb54717ce91 -
Branch / Tag:
refs/tags/core-v0.1.1 - Owner: https://github.com/bh-healthcare
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-core.yml@043b964b8840038812831902ece33cb54717ce91 -
Trigger Event:
push
-
Statement type: