Skip to content

Tests are categorised and AST structure (DrugSusceptibility) enhancement#13961

Merged
roldy merged 5 commits into
developmentfrom
feature/13948-ast-refactor
Jun 1, 2026
Merged

Tests are categorised and AST structure (DrugSusceptibility) enhancement#13961
roldy merged 5 commits into
developmentfrom
feature/13948-ast-refactor

Conversation

@roldy

@roldy roldy commented May 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #13951, #13956

Summary by CodeRabbit

  • New Features

    • Pathogen tests can be grouped by category with a new category selector; saved/legacy values remain visible where applicable.
    • Antimicrobial susceptibility now records method, zone diameter (mm), and surveillance interpretation per drug.
    • New susceptibility method and surveillance interpretation options and survey prompts added.
  • Database

    • Schema updated to store per-drug method, zone diameter, and surveillance fields.
  • Tests

    • Added tests covering pathogen test categorization, visibility, and selection behavior.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8439c5d-f963-442f-b307-b239b9c95b50

📥 Commits

Reviewing files that changed from the base of the PR and between d7c60b1 and 3e27038.

📒 Files selected for processing (3)
  • sormas-api/src/test/java/de/symeda/sormas/api/sample/PathogenTestTypeTest.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestMethodComponent.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FormComponent.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FormComponent.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestMethodComponent.java

📝 Walkthrough

Walkthrough

Adds pathogen test categories and metadata to PathogenTestType (with legacy non-selectability), replaces MIC-based drug susceptibility with method/zone-diameter/surveillance across API/backend/DB, and updates UI components, i18n, and tests to support the new structures.

Changes

Pathogen Test Categorization & Drug Susceptibility Transformation

Layer / File(s) Summary
Categorization contracts, captions & strings
sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestCategory.java, sormas-api/src/main/java/de/symeda/sormas/api/sample/NotSelectableForNewTests.java, sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestCategoryRel.java, sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java, sormas-api/src/main/resources/strings.properties
Adds PathogenTestCategory enum, @PathogenTestCategoryRel and @NotSelectableForNewTests annotations, and new i18n caption/string keys.
PathogenTestType enums & annotations
sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestType.java, sormas-api/src/main/resources/enum.properties
Annotates many PathogenTestType constants with category metadata and non-selectable legacy flags; adds reflection helpers getCategory and isSelectableForNewTests.
Unit tests & enum captions
sormas-api/src/test/java/de/symeda/sormas/api/sample/PathogenTestTypeTest.java, sormas-api/src/main/resources/enum.properties
Adds tests validating category coverage, legacy non-selectability, disease-driven visibility; expands enum.caption entries for new methods.
Test category selector & FormComponent utilities
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestMethodComponent.java, sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FormComponent.java
Adds testCategoryField UI, wires category-scoped population/synchronization with test-type, and introduces updateTestTypeItemsByCategory() and getVisibleTestCategories() helpers.
Drug susceptibility API/enums/DTO, backend mapping & DB migration
sormas-api/src/main/java/de/symeda/sormas/api/therapy/SusceptibilityMethod.java, SusceptibilitySurveillanceType.java, sormas-api/src/main/java/de/symeda/sormas/api/therapy/DrugSusceptibilityDto.java, sormas-backend/src/main/java/de/symeda/sormas/backend/therapy/DrugSusceptibility.java, DrugSusceptibilityMapper.java, sormas-backend/src/main/resources/sql/sormas_schema.sql, sormas-api/src/main/resources/enum.properties
Replaces per-drug MIC/susceptibility DTO fields with per-drug Method/ZoneDiameter/Surveillance fields, adds SusceptibilityMethod and SusceptibilitySurveillanceType enums, extends backend entity/mapper, and adds DB migration (schema v634).
Drug Susceptibility Form layout refactor
sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java
Refactors layout to render per-drug label columns, adds method/zone/surveillance fields, and synchronizes label visibility with applicable field IDs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • obinna-h-n
  • raulbob
  • KarnaiahPesula

"I hop and sort the tests with care,
Seven carrots—methods grouped in pairs,
Old roots stay planted though hidden from new plates,
Drugs now wear method, zone, and surveillance rates.
A little rabbit cheers the code that ties these threads!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: introducing pathogen test categories and enhancing the DrugSusceptibility AST structure.
Description check ✅ Passed The PR description references the fixed issues (#13951, #13956) as required by the template, but lacks additional context about the changes.
Linked Issues check ✅ Passed The PR implements all primary requirements from issue #13951: seven pathogen test categories [MOLECULAR_ASSAYS, SEROLOGICAL_TESTS, ANTIGEN_DETECTION, CULTURE_AND_ISOLATION, MICROSCOPY_AND_STAINING, ANTIMICROBIAL_SUSCEPTIBILITY_TESTING, FUNCTIONAL_IMMUNE_ASSAYS], category-based test selection UI, and enhanced method list with new test types.
Out of Scope Changes check ✅ Passed All changes are scoped to the linked issues: new enum types, test categorization logic, UI enhancements, DTO/entity updates, database schema migration, and comprehensive test coverage align with requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/13948-ast-refactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sormas-backend/src/main/resources/sql/sormas_schema.sql`:
- Around line 16055-16158: The migration only adds new per-drug columns (e.g.,
amikacinmethod, amikacinzonediameter, amikacinsurveillance and their _history
counterparts) but does not backfill existing MIC/susceptibility values, so
existing records will show NULL; add a data migration (run before switching the
mapper/UI) that copies legacy AST/MIC and susceptibility fields into the new
per-drug columns for both drugsusceptibility and drugsusceptibility_history.
Implement SQL UPDATEs that, for each drug (e.g., amikacin, rifampicin,
ciprofloxacin, etc.), set <drug>method, <drug>zonediameter, <drug>surveillance
from the existing legacy MIC/susceptibility source columns (only where the new
column IS NULL to avoid overwriting), wrap in a transaction, handle NULLs/type
conversions as needed, and include the same backfill for the _history table so
audit trail values are preserved before the application starts reading the new
columns.

In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestMethodComponent.java`:
- Around line 392-394: In TestMethodComponent.setDto ensure the savedCategory
returned by PathogenTestType.getCategory(savedType) is included in
testCategoryField's items before calling
testCategoryField.setValue(savedCategory): call getVisibleTestCategories(...) to
obtain the current List, if savedCategory is not contained add it to that list
(or create a new list including it), then call testCategoryField.setItems(...)
(or set the field’s container) and only then call
testCategoryField.setValue(savedCategory); this ensures legacy/merged categories
not normally returned by getVisibleTestCategories are visible in the ComboBox.

In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java`:
- Around line 258-268: The code fails to compile because Unit.PERCENTAGE is used
in DrugSusceptibilityForm.addMicField (and other setWidth calls) without
importing the Sizeable.Unit enum; fix by either adding the proper import (e.g.,
import com.vaadin.server.Sizeable.Unit;) at the top of DrugSusceptibilityForm or
by qualifying the enum usage as com.vaadin.server.Sizeable.Unit.PERCENTAGE in
the setWidth(...) calls (e.g., in addMicField and the other methods that call
setWidth(100, Unit.PERCENTAGE)).

In `@sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FormComponent.java`:
- Around line 321-331: updateTestTypeItemsByCategory currently builds the list
from Diseases.DiseasesConfiguration.getVisibleValues(...) which omits
disease-hidden enum values, so a saved retainType can be dropped; update the
method so that after collecting visible values you explicitly ensure retainType
(PathogenTestType retainType) is present: if retainType != null and not already
in the filtered list and it matches the selected category (or category is null)
then add retainType to the collection before sorting/setting items on comboBox
(then keep the existing comboBox.setValue(retainType) behavior if present in the
final list); reference updateTestTypeItemsByCategory, retainType,
Diseases.DiseasesConfiguration.getVisibleValues, PathogenTestType,
comboBox.setItems and comboBox.setValue.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7ea3355-c5a8-4001-8332-9db1218cbf4b

📥 Commits

Reviewing files that changed from the base of the PR and between d39bee4 and e8db943.

📒 Files selected for processing (19)
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/NotSelectableForNewTests.java
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestCategory.java
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestCategoryRel.java
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestType.java
  • sormas-api/src/main/java/de/symeda/sormas/api/therapy/DrugSusceptibilityDto.java
  • sormas-api/src/main/java/de/symeda/sormas/api/therapy/SusceptibilityMethod.java
  • sormas-api/src/main/java/de/symeda/sormas/api/therapy/SusceptibilitySurveillanceType.java
  • sormas-api/src/main/resources/captions.properties
  • sormas-api/src/main/resources/enum.properties
  • sormas-api/src/main/resources/strings.properties
  • sormas-api/src/test/java/de/symeda/sormas/api/sample/PathogenTestTypeTest.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/therapy/DrugSusceptibility.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/therapy/DrugSusceptibilityMapper.java
  • sormas-backend/src/main/resources/sql/sormas_schema.sql
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestMethodComponent.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FormComponent.java

Comment thread sormas-backend/src/main/resources/sql/sormas_schema.sql
@roldy roldy merged commit 43da043 into development Jun 1, 2026
7 checks passed
@roldy roldy deleted the feature/13948-ast-refactor branch June 1, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Laboratory - Introduce test categories and complete the method list

4 participants