OM-334 Add lab reference range flag helper#560
Open
Ispagiytiy wants to merge 3 commits into
Open
Conversation
maziyarpanahi
approved these changes
Jun 22, 2026
maziyarpanahi
left a comment
Owner
There was a problem hiding this comment.
Thank you @Ispagiytiy. I reviewed this against #524 / OM-334 and added one maintainer follow-up merge commit: Merge master into lab values helper.
What I changed:
- resolved the
CHANGELOG.mdconflict against currentmasterwhile preserving the lab-values entry; - kept the already-merged cardiology label-map changes from
masterin the PR branch; - added the advisory disclaimer that derived lab flags are heuristic and not a substitute for source lab flagging or clinical review;
- made value parsing stricter so arbitrary strings with embedded numbers return
unknownrather than guessing; - added normal/critical explicit-flag aliases and broader tests for decimal ranges, one-sided inclusive bounds, explicit flags, and unparseable parsed ranges.
Verification on the current PR checkout:
PYTHONPATH=/private/tmp/openmed-pr-560 /Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/clinical/test_lab_values.py tests/unit/ner/test_label_map_consistency.py -q-> 73 passed/Users/maziyar/Developer/openmed/.venv/bin/ruff check openmed/clinical/lab_values.py tests/unit/clinical/test_lab_values.py openmed/core/model_registry.py tests/unit/ner/test_label_map_consistency.py CHANGELOG.md-> passed/Users/maziyar/Developer/openmed/.venv/bin/ruff format --check openmed/clinical/lab_values.py tests/unit/clinical/test_lab_values.py openmed/core/model_registry.py tests/unit/ner/test_label_map_consistency.py-> passed
I also copied the labels from #524 onto the PR. The branch is mergeable with no conflicts; GitHub has not attached hosted checks to the new head commit yet, so I verified the touched behavior locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds deterministic lab reference range parsing and abnormal flag derivation helpers for numeric lab ranges, with focused unit tests and a changelog entry.
Type of Change
Changes Made
parse_reference_range()for numeric lab reference range strings such as135-145,0.5 - 1.2,<5, and>10.derive_abnormal_flag()to returnlow,normal,high,critical, orunknownfrom a value, parsed reference range, and optional explicit flag.HandLflags tohighandlowbefore numeric range comparison.Testing
Documentation
Code Quality
make format,make lint, andmake format-checkmake format-swiftandmake lint-swiftDependencies
Checklist
Related Issues
Closes #524
Screenshots/Examples
N/A - no UI changes. Covered by unit tests in
tests/unit/clinical/test_lab_values.py.