Skip to content

#14058 - Add 'performedByReferenceLaboratory' field to TestReport and related classes#14074

Merged
raulbob merged 2 commits into
developmentfrom
bugfix-14058-ipi_lab_message_reference_laboratory
Jun 29, 2026
Merged

#14058 - Add 'performedByReferenceLaboratory' field to TestReport and related classes#14074
raulbob merged 2 commits into
developmentfrom
bugfix-14058-ipi_lab_message_reference_laboratory

Conversation

@raulbob

@raulbob raulbob commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #14058

Summary by CodeRabbit

  • New Features

    • Added a “performed by reference laboratory” flag to lab test reports and exposed it in the user-facing lab message data.
  • Bug Fixes

    • Ensured the flag is preserved correctly when converting between lab message formats and when saving/loading test report records (including history).
    • Updated the database schema to store the new value for both current and historical entries.
  • Tests

    • Extended mapping tests to verify the flag is handled correctly in both directions (DTO ↔ persisted/report objects).

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b8633519-38c5-46cc-8216-77d8bc0a4ca7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e748bb and f3bf8f0.

📒 Files selected for processing (1)
  • sormas-backend/src/main/resources/sql/sormas_schema.sql

📝 Walkthrough

Walkthrough

Adds performedByReferenceLaboratory to the lab test report DTO and entity, propagates it through facade and external-message mapping, updates the database schema, and extends mapping tests.

Changes

performedByReferenceLaboratory field propagation

Layer / File(s) Summary
DTO and entity fields
sormas-api/.../labmessage/TestReportDto.java, sormas-backend/.../labmessage/TestReport.java
TestReportDto adds the PERFORMED_BY_REFERENCE_LABORATORY constant, private Boolean field, and getter/setter. TestReport adds the persistent Boolean field and @Column-mapped accessor methods.
Facade and external-message mapping
sormas-backend/.../labmessage/TestReportFacadeEjb.java, sormas-api/.../processing/ExternalMessageMapper.java
TestReportFacadeEjb copies performedByReferenceLaboratory in both DTO conversion paths, and ExternalMessageMapper.mapToPathogenTest adds the PathogenTestDto.PERFORMED_BY_REFERENCE_LABORATORY mapping.
Schema migration and tests
sormas-backend/src/main/resources/sql/sormas_schema.sql, sormas-backend/.../labmessage/TestReportFacadeEjbMappingTest.java
The schema adds performedbyreferencelaboratory to testreport and testreport_history and records versions 642 and 643; mapping tests set and assert the new field in both directions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

🐇 A tiny boolean hopped into place,
through DTO, entity, and mapping space.
The schema got a column, the tests gave a cheer,
and the lab message trail is now perfectly clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. 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 clearly describes the added field and affected classes.
Description check ✅ Passed The description matches the template by specifying Fixes #14058.
Linked Issues check ✅ Passed The field is added, mapped, persisted, and tested, which addresses the bug in #14058.
Out of Scope Changes check ✅ Passed The schema version bump appears necessary for the new migration and does not look unrelated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix-14058-ipi_lab_message_reference_laboratory

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.

@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: 1

🧹 Nitpick comments (1)
sormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjbMappingTest.java (1)

198-198: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for ExternalMessageMapper.mapToPathogenTest.

These assertions only cover DTO/entity propagation. The linked bug is fixed on the TestReportDto -> PathogenTestDto mapping path, so this PR still needs a test that proves performedByReferenceLaboratory toggles on the resulting pathogen test.

Also applies to: 353-353

🤖 Prompt for 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.

In
`@sormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjbMappingTest.java`
at line 198, Add a regression test for ExternalMessageMapper.mapToPathogenTest
that verifies performedByReferenceLaboratory is propagated to the resulting
PathogenTestDto. The current assertions only check DTO/entity round-tripping in
TestReportFacadeEjbMappingTest, so add a focused test that maps a TestReportDto
with the flag set and asserts the produced PathogenTestDto toggles
performedByReferenceLaboratory accordingly. Use the existing mapping method and
related DTO types as the reference points so the test covers the fixed bug path
directly.
🤖 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`:
- Line 16405: The migration comment contains an invalid date string that breaks
traceability. Update the date in the schema migration comment near the lab
messages entry to a real calendar date, keeping the same descriptive text and
ensuring the comment remains a valid migration marker.

---

Nitpick comments:
In
`@sormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjbMappingTest.java`:
- Line 198: Add a regression test for ExternalMessageMapper.mapToPathogenTest
that verifies performedByReferenceLaboratory is propagated to the resulting
PathogenTestDto. The current assertions only check DTO/entity round-tripping in
TestReportFacadeEjbMappingTest, so add a focused test that maps a TestReportDto
with the flag set and asserts the produced PathogenTestDto toggles
performedByReferenceLaboratory accordingly. Use the existing mapping method and
related DTO types as the reference points so the test covers the fixed bug path
directly.
🪄 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: 34415b2f-61ee-4343-bb02-512b57daa1f8

📥 Commits

Reviewing files that changed from the base of the PR and between 5e5e8a1 and 2e748bb.

📒 Files selected for processing (6)
  • sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/labmessage/TestReportDto.java
  • sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/ExternalMessageMapper.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReport.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjb.java
  • sormas-backend/src/main/resources/sql/sormas_schema.sql
  • sormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjbMappingTest.java

Comment thread sormas-backend/src/main/resources/sql/sormas_schema.sql Outdated

@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: 1

🤖 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 16436-16455: Update the NOTICE strings in the migration block for
the `pathogentest` and `pathogentest_history` truncation handling so they report
`Migration 643` instead of `Migration 642`. Keep the message wording consistent
with the schema version entry in this block, and verify the `RAISE NOTICE`
statements in the related migration section use the same version label as the
`schema_version` record.
🪄 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: b8633519-38c5-46cc-8216-77d8bc0a4ca7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e748bb and f3bf8f0.

📒 Files selected for processing (1)
  • sormas-backend/src/main/resources/sql/sormas_schema.sql

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 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 16436-16455: Update the NOTICE strings in the migration block for
the `pathogentest` and `pathogentest_history` truncation handling so they report
`Migration 643` instead of `Migration 642`. Keep the message wording consistent
with the schema version entry in this block, and verify the `RAISE NOTICE`
statements in the related migration section use the same version label as the
`schema_version` record.
🪄 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: b8633519-38c5-46cc-8216-77d8bc0a4ca7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e748bb and f3bf8f0.

📒 Files selected for processing (1)
  • sormas-backend/src/main/resources/sql/sormas_schema.sql
🛑 Comments failed to post (1)
sormas-backend/src/main/resources/sql/sormas_schema.sql (1)

16436-16455: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the NOTICE labels aligned with schema version 643.

Lines 16436 and 16455 still emit Migration 642, but this block is recorded as version 643 on Line 16469. That makes rollout logs point at the wrong migration when operators try to reconcile notices with schema_version.

Suggested fix
-            RAISE NOTICE 'Migration 642: % pathogentest row(s) had their preserved resultdetails truncated to fit varchar(4096).', truncated_count;
+            RAISE NOTICE 'Migration 643: % pathogentest row(s) had their preserved resultdetails truncated to fit varchar(4096).', truncated_count;
@@
-            RAISE NOTICE 'Migration 642: % pathogentest_history row(s) had their preserved resultdetails truncated to fit varchar(4096).', truncated_count;
+            RAISE NOTICE 'Migration 643: % pathogentest_history row(s) had their preserved resultdetails truncated to fit varchar(4096).', truncated_count;

Also applies to: 16469-16469

🤖 Prompt for 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.

In `@sormas-backend/src/main/resources/sql/sormas_schema.sql` around lines 16436 -
16455, Update the NOTICE strings in the migration block for the `pathogentest`
and `pathogentest_history` truncation handling so they report `Migration 643`
instead of `Migration 642`. Keep the message wording consistent with the schema
version entry in this block, and verify the `RAISE NOTICE` statements in the
related migration section use the same version label as the `schema_version`
record.

@raulbob raulbob merged commit ada10be into development Jun 29, 2026
7 checks passed
@raulbob raulbob deleted the bugfix-14058-ipi_lab_message_reference_laboratory branch June 29, 2026 18:32
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.

IPI - Lab message - Performed by reference laboratory not toggled

2 participants