Skip to content

Conversation

@roldy
Copy link

@roldy roldy commented Dec 24, 2025

…form non-mandatory

Fixes #13557

Summary by CodeRabbit

  • Updates
    • "Test Result Verified" is now optional in stored records and only required when a test is marked via LIMS; database schema updated accordingly.
    • UI adds a via LIMS checkbox and dynamically enforces the conditional requirement; related field visibility/initial state improved.
  • Bug Fixes
    • Verification checks made null-safe across workflows to prevent errors when the field is unset.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

This change makes the testResultVerified ("Verified by Supervisor") field optional except when a test is marked as via LIMS. It updates DTO and entity nullability, backend validation, DB schema, UI form behavior, and adds null-safe checks in web and mobile clients.

Changes

Cohort / File(s) Summary
API / DTO
sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestDto.java
Removed @NotNull from testResultVerified, allowing null at the API layer.
Backend Entity
sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTest.java
Removed nullable = false from @Column on getTestResultVerified(), making the DB column nullable.
Backend Validation
sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTestFacadeEjb.java
Validation now requires testResultVerified only when pathogenTest.isViaLims() is true; added explanatory comment.
Database Schema
sormas-backend/src/main/resources/sql/sormas_schema.sql
Dropped NOT NULL on testresultverified (pathogentest, pathogentest_history); added schema version 603.
Web UI Form
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java
Replaced VIA_LIMS field with a CheckBox, added listener to make TEST_RESULT_VERIFIED required only when viaLims is checked; adjusted related field visibility/enablement.
Web UI Controller
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java
Replaced boolean checks with Boolean.TRUE.equals(...) for null-safe evaluation of testResultVerified across multiple flows.
Android App — Edit
sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java
Made testResultVerified checks null-safe using Boolean.TRUE.equals(...) in save flow.
Android App — New
sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestNewActivity.java
Replaced direct boolean check with Boolean.TRUE.equals(...) before showing update dialog, preventing NPEs.

Sequence Diagram(s)

sequenceDiagram
  participant User as User (Web / Mobile)
  participant UI as Web UI Form / Mobile Activity
  participant Controller as PathogenTestController
  participant Backend as PathogenTestFacadeEjb
  participant DB as Database

  Note over User,UI: Create / Edit pathogen test
  User->>UI: submit form (includes viaLims checkbox, testResultVerified may be null)
  UI->>Controller: send PathogenTestDto
  Controller->>Backend: create/update request
  alt viaLims == true
    Backend->>Backend: validate testResultVerified != null
    Backend->>Controller: validation error (if null)
  else viaLims == false
    Backend->>Backend: skip required testResultVerified validation
  end
  Backend->>DB: persist PathogenTest (nullable testResultVerified column)
  DB-->>Backend: persist result
  Backend-->>Controller: response
  Controller-->>UI: update result
  UI-->>User: show success / validation errors
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

Poem

🐰 A checkbox freed from strict demand,
Now only checked when LIMS gives command.
I hop and nibble, carrot bright,
Optional now—yet left-right-right. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making the 'Verified by Supervisor' checkbox non-mandatory in the pathogen test form, directly addressing the PR's primary objective.
Description check ✅ Passed The description includes the required issue reference (#13557) but lacks detail on the specific changes made, testing performed, and other context that would help reviewers understand the implementation approach.
Linked Issues check ✅ Passed The PR fully addresses issue #13557 by making the 'Verified by Supervisor' checkbox non-mandatory through conditional validation, database schema updates, and null-safe handling across all layers.
Out of Scope Changes check ✅ Passed All changes are directly related to making testResultVerified optional: annotation removals, validation logic updates, database schema changes, and null-safe comparisons throughout the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-13557-non-mandatory-verified-by-supervisor

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc2853 and 7ad38b2.

📒 Files selected for processing (1)
  • sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: android app test (26)
  • GitHub Check: SORMAS CI
  • GitHub Check: android app test (27)
  • GitHub Check: android app test (28)

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af6249b and c2f1e48.

📒 Files selected for processing (5)
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestDto.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTest.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTestFacadeEjb.java
  • sormas-backend/src/main/resources/sql/sormas_schema.sql
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java
💤 Files with no reviewable changes (1)
  • sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestDto.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: SORMAS CI
  • GitHub Check: android app test (28)
  • GitHub Check: android app test (26)
  • GitHub Check: android app test (27)
🔇 Additional comments (4)
sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTestFacadeEjb.java (1)

493-499: LGTM! Conditional validation logic correctly implemented.

The validation now appropriately requires testResultVerified only when the test comes via LIMS (laboratory is directly connected), matching the PR objectives. The comment clearly explains the conditional requirement, and the logic correctly handles the case where manual lab entry doesn't require supervisor verification.

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java (2)

432-432: Good practice: capturing field reference for dynamic validation.

Declaring viaLimsField as CheckBox enables the conditional validation logic added later in the method, which is a clean approach to implementing the viaLims-dependent requirement.


956-963: LGTM! Conditional UI validation correctly synchronized with backend logic.

The implementation correctly makes TEST_RESULT_VERIFIED required only when viaLims is true:

  • Value change listener (lines 957-960) handles dynamic updates when the checkbox changes
  • Initial state setup (lines 962-963) ensures correct requirement state on form load
  • Null-safe boolean check prevents NPE
  • Backend validation in PathogenTestFacadeEjb (lines 493-499) enforces the same rule
sormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTest.java (1)

369-369: Database migration script already exists for the schema change.

The removal of nullable = false aligns with the existing database migration in sormas-backend/src/main/resources/sql/sormas_schema.sql (lines 15067-15068), which properly drops the NOT NULL constraint from both pathogentest and pathogentest_history tables.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java (1)

157-160: Consider using .equals() for consistency.

Line 158 uses Boolean.TRUE == while line 103 in the same file uses Boolean.TRUE.equals(). Both are null-safe, but using .equals() consistently is more idiomatic and improves readability.

🔎 Suggested consistency improvement
 if (sampleOfPathogenTestToSave != null
-    && Boolean.TRUE == pathogenTestToSave.getTestResultVerified()
+    && Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified())
     && pathogenTestToSave.getTestedDisease() == associatedCase.getDisease()
     && pathogenTestToSave.getTestResult() != sampleOfPathogenTestToSave.getPathogenTestResult()) {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2f1e48 and 0bc2853.

📒 Files selected for processing (3)
  • sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java
  • sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestNewActivity.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: android app test (28)
  • GitHub Check: android app test (27)
  • GitHub Check: android app test (26)
  • GitHub Check: SORMAS CI
🔇 Additional comments (5)
sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditActivity.java (1)

102-104: LGTM! Null-safe verification check correctly implemented.

The use of Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified()) correctly handles the now-optional testResultVerified field, ensuring the disease variant update dialog only triggers when the test result is explicitly verified (not null or false).

sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestNewActivity.java (1)

158-160: LGTM! Null-safe verification check correctly implemented.

The use of Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified()) properly handles the now-optional testResultVerified field, ensuring the disease variant update dialog is only triggered when verification is explicitly true.

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java (3)

373-405: LGTM! Null-safe verification checks correctly implemented for case handling.

All test result verification checks in handleAssociatedCase now use Boolean.TRUE.equals(t.getTestResultVerified()), properly handling the optional testResultVerified field. This ensures that only explicitly verified positive/negative results trigger case update workflows, disease variant updates, and case cloning dialogs.


442-471: LGTM! Null-safe verification checks correctly implemented for contact handling.

All test result verification checks in handleAssociatedContact now use Boolean.TRUE.equals(t.getTestResultVerified()), ensuring that only explicitly verified results trigger contact-to-case conversion workflows and sample result updates.


505-535: LGTM! Null-safe verification checks correctly implemented for event participant handling.

All test result verification checks in handleAssociatedEventParticipant now use Boolean.TRUE.equals(t.getTestResultVerified()), ensuring that only explicitly verified results trigger event participant-to-case conversion workflows and related updates.

@sormas-vitagroup
Copy link
Contributor

1 similar comment
@sormas-vitagroup
Copy link
Contributor

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.

Make “Verified by Supervisor” checkbox in the pathogen test form non mandatory

3 participants