#13948 sample & test form changes#13967
Conversation
…al messages survey
…ake "Add pathogen test" administrator-configurable
…ake "Add pathogen test" administrator-configurable
…ake "Add pathogen test" administrator-configurable
…ake "Add pathogen test" administrator-configurable
…al messages survey
…n-config for required tests / add new test
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces a server-side feature configuration framework alongside sample lab field enhancements. It adds two feature toggles for lab workflows ( ChangesFeature Configuration and Sample Lab Workflow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
sormas-backend/src/test/java/de/symeda/sormas/backend/sample/SampleFacadeEjbTest.java (1)
1233-1235: ⚡ Quick winConsider verifying
performedByReferenceLaboratory's default value.The comment on line 1234 states that
performedByReferenceLaboratoryis "unset" initially, but there's no assertion to validate this. OnlyretestRequestedis checked. For comprehensive default-value coverage, consider adding an assertion forperformedByReferenceLaboratoryas well.📋 Suggested addition
SampleDto sample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility); // New samples default retestRequested to false and leave performedByReferenceLaboratory unset. + assertNull(getSampleFacade().getSampleByUuid(sample.getUuid()).getPerformedByReferenceLaboratory()); assertEquals(Boolean.FALSE, getSampleFacade().getSampleByUuid(sample.getUuid()).getRetestRequested());🤖 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/sample/SampleFacadeEjbTest.java` around lines 1233 - 1235, The test creates a SampleDto via creator.createSample and currently only asserts retestRequested; add an assertion that the returned SampleDto's performedByReferenceLaboratory is unset (null) to match the comment. Locate the call using SampleDto sample = creator.createSample(...) and the fetch via getSampleFacade().getSampleByUuid(sample.getUuid()), then add an assertNull (or assertEquals(null, ...)) against getPerformedByReferenceLaboratory() on that fetched SampleDto to verify the default.sormas-ui/src/main/java/de/symeda/sormas/ui/samples/AbstractSampleForm.java (1)
192-219: ⚡ Quick winRemove now-unused disease fetch logic after unconditional sample-source hiding.
Lines 192-200 no longer influence behavior because Line 218 always hides
SAMPLE_SOURCE. Keeping this block adds unnecessary facade calls during form initialization.Proposed cleanup
- Disease disease = null; - final CaseReferenceDto associatedCase = getValue().getAssociatedCase(); - if (associatedCase != null && UiUtil.permitted(UserRight.CASE_VIEW)) { - disease = FacadeProvider.getCaseFacade().getCaseDataByUuid(associatedCase.getUuid()).getDisease(); - } else { - final ContactReferenceDto associatedContact = getValue().getAssociatedContact(); - if (associatedContact != null && UiUtil.permitted(UserRight.CONTACT_VIEW)) { - disease = FacadeProvider.getContactFacade().getByUuid(associatedContact.getUuid()).getDisease(); - } - } - // The sample source dropdown is no longer shown for any disease (`#13948` issue `#13959`); the field is // kept bound so existing values still round-trip and appear in exports. getField(SampleDto.SAMPLE_SOURCE).setVisible(false);🤖 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-ui/src/main/java/de/symeda/sormas/ui/samples/AbstractSampleForm.java` around lines 192 - 219, Remove the now-unused disease lookup block: delete the local variable "Disease disease = null;" and the conditional block that reads associated case/contact using getValue().getAssociatedCase(), CaseReferenceDto/ContactReferenceDto and FacadeProvider.getCaseFacade()/getContactFacade() since SAMPLE_SOURCE is unconditionally hidden via getField(SampleDto.SAMPLE_SOURCE).setVisible(false) and those facade calls only cause unnecessary work; after removal, ensure any imports or references exclusively used by that block (e.g., Disease, CaseReferenceDto, ContactReferenceDto, FacadeProvider calls) are cleaned up.sormas-backend/src/main/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjb.java (1)
357-360: ⚡ Quick winAlign initial creation with entity-scoped server feature contracts.
Line 358 currently creates a single row when none exists. If a server feature supports multiple entity types, this can persist an incomplete configuration set and diverge from the entity-aware creation contract already used in
FeatureConfigurationService.createMissingFeatureConfigurations.Proposed adjustment
List<FeatureConfiguration> configurations = service.getServerFeatureConfigurationsByType(featureType); if (configurations.isEmpty()) { - FeatureConfiguration configuration = FeatureConfiguration.build(featureType, enabled); - configuration.setProperties(featureType.getSupportedPropertyDefaults()); - service.ensurePersisted(configuration); + if (featureType.getEntityTypes() != null) { + for (DeletableEntityType entityType : featureType.getEntityTypes()) { + FeatureConfiguration configuration = FeatureConfiguration.build(featureType, enabled); + configuration.setEntityType(entityType); + configuration.setProperties(featureType.getSupportedPropertyDefaults()); + service.ensurePersisted(configuration); + } + } else { + FeatureConfiguration configuration = FeatureConfiguration.build(featureType, enabled); + configuration.setProperties(featureType.getSupportedPropertyDefaults()); + service.ensurePersisted(configuration); + } } else {🤖 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/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjb.java` around lines 357 - 360, When no configurations exist (the configurations.isEmpty() branch in FeatureConfigurationFacadeEjb), do not create a single generic row via FeatureConfiguration.build; instead create per-entity configurations to match the entity-scoped contract used by FeatureConfigurationService.createMissingFeatureConfigurations. Replace the single-feature creation with logic that iterates the featureType's supported entity types (or delegate to FeatureConfigurationService.createMissingFeatureConfigurations) and call service.ensurePersisted for each generated FeatureConfiguration (using FeatureConfiguration.build and setting properties via featureType.getSupportedPropertyDefaults()) so all required entity-specific rows are created.
🤖 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-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java`:
- Around line 140-141: migrateAttributesOfPhysicalSample and buildReferralDto
currently omit the performedByReferenceLaboratory and retestRequested flags,
causing them to be lost during referral creation; update
migrateAttributesOfPhysicalSample to copy
sampleDto.getPerformedByReferenceLaboratory() and sampleDto.getRetestRequested()
into the target/referral DTO, and ensure buildReferralDto sets those same fields
on the new SampleDto (or copies the source SampleDto fields) so both
performedByReferenceLaboratory and retestRequested are preserved during referral
migration.
In `@sormas-backend/src/main/resources/sql/sormas_schema.sql`:
- Around line 16307-16312: The migration currently adds a nullable boolean
column retestrequested and only backfills existing rows, allowing future NULLs;
change the migration to enforce a DB-level default and NOT NULL so new rows
default to FALSE. Specifically, for both samples and samples_history ensure you:
(1) ALTER TABLE ... ADD COLUMN IF NOT EXISTS retestrequested boolean DEFAULT
false; (2) UPDATE ... SET retestrequested = false WHERE retestrequested IS NULL;
and (3) ALTER TABLE ... ALTER COLUMN retestrequested SET NOT NULL; reference the
tables samples and samples_history and the column name retestrequested when
making these changes.
---
Nitpick comments:
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjb.java`:
- Around line 357-360: When no configurations exist (the
configurations.isEmpty() branch in FeatureConfigurationFacadeEjb), do not create
a single generic row via FeatureConfiguration.build; instead create per-entity
configurations to match the entity-scoped contract used by
FeatureConfigurationService.createMissingFeatureConfigurations. Replace the
single-feature creation with logic that iterates the featureType's supported
entity types (or delegate to
FeatureConfigurationService.createMissingFeatureConfigurations) and call
service.ensurePersisted for each generated FeatureConfiguration (using
FeatureConfiguration.build and setting properties via
featureType.getSupportedPropertyDefaults()) so all required entity-specific rows
are created.
In
`@sormas-backend/src/test/java/de/symeda/sormas/backend/sample/SampleFacadeEjbTest.java`:
- Around line 1233-1235: The test creates a SampleDto via creator.createSample
and currently only asserts retestRequested; add an assertion that the returned
SampleDto's performedByReferenceLaboratory is unset (null) to match the comment.
Locate the call using SampleDto sample = creator.createSample(...) and the fetch
via getSampleFacade().getSampleByUuid(sample.getUuid()), then add an assertNull
(or assertEquals(null, ...)) against getPerformedByReferenceLaboratory() on that
fetched SampleDto to verify the default.
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/AbstractSampleForm.java`:
- Around line 192-219: Remove the now-unused disease lookup block: delete the
local variable "Disease disease = null;" and the conditional block that reads
associated case/contact using getValue().getAssociatedCase(),
CaseReferenceDto/ContactReferenceDto and
FacadeProvider.getCaseFacade()/getContactFacade() since SAMPLE_SOURCE is
unconditionally hidden via getField(SampleDto.SAMPLE_SOURCE).setVisible(false)
and those facade calls only cause unnecessary work; after removal, ensure any
imports or references exclusively used by that block (e.g., Disease,
CaseReferenceDto, ContactReferenceDto, FacadeProvider calls) are cleaned up.
🪄 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: 97623fea-8d9d-42a2-9acf-9cc1c4760ad1
📒 Files selected for processing (29)
sormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureConfigurationFacade.javasormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureType.javasormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.javasormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.javasormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.javasormas-api/src/main/java/de/symeda/sormas/api/sample/SampleExportDto.javasormas-api/src/main/resources/captions.propertiessormas-api/src/main/resources/enum.propertiessormas-api/src/main/resources/strings.propertiessormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/ExternalMessageFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/ExternalMessageService.javasormas-backend/src/main/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/feature/FeatureConfigurationService.javasormas-backend/src/main/java/de/symeda/sormas/backend/sample/PathogenTestFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/sample/Sample.javasormas-backend/src/main/java/de/symeda/sormas/backend/sample/SampleFacadeEjb.javasormas-backend/src/main/resources/sql/sormas_schema.sqlsormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/ExternalMessageFacadeEjbUnitTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjbTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/sample/PathogenTestFacadeEjbTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/sample/SampleFacadeEjbTest.javasormas-ui/src/main/java/de/symeda/sormas/ui/configuration/AbstractConfigurationView.javasormas-ui/src/main/java/de/symeda/sormas/ui/configuration/featureconfiguration/FeatureConfigurationView.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/AbstractSampleForm.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/components/TestResultComponent.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/diseasesection/PathogenTestFormConfig.javasormas-ui/src/main/java/de/symeda/sormas/ui/samples/humansample/SampleController.java
…migration & Enforce a DB-level default/constraint for retestrequested
Re-sequence schema versions after development renumbered the tail: the sample-form "reference laboratory + retest indicators" migration moves from 638 to 637. Revert ExternalMessage* changes (schema JSONB->JSON / config-key rename block and the countDistinct(...get(ID)) Java fixes).
Fixes #13953 #13954 #13958 #13959
Summary by CodeRabbit