Skip to content

feat: add microbiology domain scaffolding (closes #314)#410

Open
Zeesky-code wants to merge 2 commits into
maziyarpanahi:masterfrom
Zeesky-code:feat-microbiology-domain
Open

feat: add microbiology domain scaffolding (closes #314)#410
Zeesky-code wants to merge 2 commits into
maziyarpanahi:masterfrom
Zeesky-code:feat-microbiology-domain

Conversation

@Zeesky-code

Copy link
Copy Markdown

Pull Request

Description

Adds the microbiology NER domain scaffolding across the label taxonomy,
zero-shot label map, model registry, and policy profiles. This allows
organism/antibiotic/susceptibility extraction for infectious-disease and
antimicrobial-stewardship use cases, distinct from the existing generic
Species family.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition/improvement

Changes Made

  • openmed/zero_shot/data/label_maps/defaults.json: added microbiology
    domain with labels Microorganism, Antibiotic, Susceptibility, Specimen
    source, Culture result
  • openmed/core/labels.py: added canonical labels MICROORGANISM,
    ANTIBIOTIC, SUSCEPTIBILITY as CLINICAL_CONCEPT with system hints
    (SNOMED/LOINC/RxNorm) and alias entries (organism, pathogen,
    antimicrobial, etc.)
  • openmed/core/model_registry.py: added Microbiology entry to
    _CATEGORY_ENTITY_TYPES; added dedicated routing keywords (culture,
    gram stain, mrsa, resistant, susceptib…) to get_model_suggestions
    distinct from the Species pattern
  • openmed/core/policies/*.json: added keep/mask actions for the three
    new labels across all six policy profiles to satisfy the
    CANONICAL_LABELS coverage invariant enforced at load time

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change with different models/inputs

uv run pytest tests/ --ignore=tests/integration -q1600 passed, 12 skipped

New TestMicrobiologyDomain class in tests/unit/ner/test_label_map_consistency.py
covers all acceptance criteria from the issue:

  • available_domains() includes microbiology
  • get_default_labels('microbiology') returns a non-empty label set
  • normalize_label('susceptibility') == 'SUSCEPTIBILITY'
  • normalize_label('antibiotic') == 'ANTIBIOTIC'
  • normalize_label('microorganism') == 'MICROORGANISM'
  • normalize_label('organism') == 'MICROORGANISM' (alias)
  • get_model_suggestions('Blood culture grew MRSA, resistant to oxacillin') runs without error

Documentation

  • I have updated the documentation accordingly
  • I have added docstrings to new functions/classes
  • I have updated the CHANGELOG.md

Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

Dependencies

  • I have not added any new dependencies

Checklist

  • I have read the contributing guidelines
  • My commits have clear, descriptive messages
  • I have squashed/organized my commits appropriately

Related Issues

Closes #314
Related to #289 (zero-shot domain label maps for biomedical NER families)

…hi#314)

Add the microbiology NER domain across the label taxonomy, zero-shot label map, model registry routing, and policy profiles.
@maziyarpanahi maziyarpanahi added help wanted Extra attention is needed good first issue Good for newcomers roadmap-v2 OpenMed V2 roadmap backlog feature New capability P3 Strategic labels Jun 22, 2026
…omain

# Conflicts:
#	openmed/core/labels.py
#	openmed/core/model_registry.py
#	openmed/zero_shot/data/label_maps/defaults.json
#	tests/unit/ner/test_label_map_consistency.py
@maziyarpanahi

Copy link
Copy Markdown
Owner

Thank you @Zeesky-code. I reviewed this against #314 and the related #289 context, then added a maintainer merge-resolution commit: Merge remote-tracking branch 'origin/master' into feat-microbiology-domain.

What changed:

  • resolved the branch against current master, preserving the newer Cardiology domain work while adding Microbiology;
  • kept the policy profile changes minimal by adding only MICROORGANISM, ANTIBIOTIC, and SUSCEPTIBILITY actions, removing the older full-file JSON formatting churn;
  • tightened the regression coverage so microbiology text routes through _match_categories() before generic Species, while get_model_suggestions() still returns only live registered model categories until a dedicated Microbiology model exists;
  • kept the microbiology zero-shot labels in the current letters-only display-label style: SpecimenSource and CultureResult.

Verification:

  • /Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/core/test_labels_policy_spine.py tests/unit/core/test_policy_profiles.py tests/unit/ner/test_label_map_consistency.py tests/unit/ner/test_labels.py -q -> 78 passed
  • /Users/maziyar/Developer/openmed/.venv/bin/ruff check openmed/core/labels.py openmed/core/model_registry.py tests/unit/core/test_labels_policy_spine.py tests/unit/ner/test_label_map_consistency.py -> passed
  • /Users/maziyar/Developer/openmed/.venv/bin/ruff format --check openmed/core/labels.py openmed/core/model_registry.py tests/unit/core/test_labels_policy_spine.py tests/unit/ner/test_label_map_consistency.py -> passed

I copied #314 labels onto the PR. The branch is mergeable with no conflicts. GitHub has not reported hosted checks for this fork head, so the validation above is local.

@Zeesky-code

Copy link
Copy Markdown
Author

Thank you for the review and the merge-resolution commit. I'll take note of the display-label style (CamelCase, no spaces) and the JSON formatting conventions for future contributions.

@maziyarpanahi maziyarpanahi self-requested a review June 22, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability good first issue Good for newcomers help wanted Extra attention is needed P3 Strategic roadmap-v2 OpenMed V2 roadmap backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add microbiology domain to NER catalog and zero-shot label maps

2 participants