Skip to content

Commit 0a39398

Browse files
authored
Merge pull request #13967 from SORMAS-Foundation/feature/13948-sample-test-form-changes
#13948 sample & test form changes
2 parents e1224d8 + 22707c1 commit 0a39398

26 files changed

Lines changed: 430 additions & 47 deletions

sormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureConfigurationFacade.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ Page<FeatureConfigurationIndexDto> getIndexPage(
5555

5656
void saveFeatureConfiguration(@Valid FeatureConfigurationIndexDto configuration, FeatureType featureType);
5757

58+
/**
59+
* Enables or disables a server-level feature (one with no region/district/disease scope), seeding the
60+
* configuration row if it does not exist yet. Intended for the administrator feature-configuration view.
61+
*/
62+
void setServerFeatureEnabled(FeatureType featureType, boolean enabled);
63+
5864
void deleteAllFeatureConfigurations(FeatureConfigurationCriteria criteria);
5965

6066
void deleteAllExpiredFeatureConfigurations(Date date);

sormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureType.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@
1414
*/
1515
package de.symeda.sormas.api.feature;
1616

17-
import static de.symeda.sormas.api.common.DeletableEntityType.*;
17+
import static de.symeda.sormas.api.common.DeletableEntityType.CASE;
18+
import static de.symeda.sormas.api.common.DeletableEntityType.CONTACT;
19+
import static de.symeda.sormas.api.common.DeletableEntityType.EVENT;
20+
import static de.symeda.sormas.api.common.DeletableEntityType.EVENT_PARTICIPANT;
21+
import static de.symeda.sormas.api.common.DeletableEntityType.IMMUNIZATION;
22+
import static de.symeda.sormas.api.common.DeletableEntityType.TRAVEL_ENTRY;
1823

19-
import java.util.*;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.Set;
2029

2130
import com.google.common.collect.ImmutableMap;
2231

@@ -57,6 +66,18 @@ public enum FeatureType {
5766
SAMPLES_LAB },
5867
null,
5968
null),
69+
SAMPLE_ADD_PATHOGEN_TEST(true,
70+
true,
71+
new FeatureType[] {
72+
SAMPLES_LAB },
73+
null,
74+
null),
75+
PATHOGEN_TEST_RESULT_REQUIRED(true,
76+
true,
77+
new FeatureType[] {
78+
SAMPLES_LAB },
79+
null,
80+
null),
6081
TASK_MANAGEMENT(true, true, null, null, ImmutableMap.of(FeatureTypeProperty.ALLOW_FREE_EDITING, Boolean.FALSE)),
6182
WEEKLY_REPORTING(true, true, null, null, null),
6283
IMMUNIZATION_MANAGEMENT(true, true, null, null, ImmutableMap.of(FeatureTypeProperty.REDUCED, Boolean.FALSE)),

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,7 @@ public interface Captions {
20782078
String facilityArchivedFacilities = "facilityArchivedFacilities";
20792079
String facilityType = "facilityType";
20802080
String facilityTypeGroup = "facilityTypeGroup";
2081+
String featureConfiguration = "featureConfiguration";
20812082
String FeatureConfiguration_districtName = "FeatureConfiguration.districtName";
20822083
String FeatureConfiguration_enabled = "FeatureConfiguration.enabled";
20832084
String FeatureConfiguration_endDate = "FeatureConfiguration.endDate";
@@ -2691,6 +2692,7 @@ public interface Captions {
26912692
String Sample_pathogenTestCount = "Sample.pathogenTestCount";
26922693
String Sample_pathogenTestingRequested = "Sample.pathogenTestingRequested";
26932694
String Sample_pathogenTestResult = "Sample.pathogenTestResult";
2695+
String Sample_performedByReferenceLaboratory = "Sample.performedByReferenceLaboratory";
26942696
String Sample_received = "Sample.received";
26952697
String Sample_receivedDate = "Sample.receivedDate";
26962698
String Sample_referredToUuid = "Sample.referredToUuid";
@@ -2704,6 +2706,7 @@ public interface Captions {
27042706
String Sample_requestedOtherPathogenTests = "Sample.requestedOtherPathogenTests";
27052707
String Sample_requestedPathogenTests = "Sample.requestedPathogenTests";
27062708
String Sample_requestedPathogenTestsTags = "Sample.requestedPathogenTestsTags";
2709+
String Sample_retestRequested = "Sample.retestRequested";
27072710
String Sample_sampleCode = "Sample.sampleCode";
27082711
String Sample_sampleDateTime = "Sample.sampleDateTime";
27092712
String Sample_sampleMaterial = "Sample.sampleMaterial";
@@ -3628,6 +3631,8 @@ public interface Captions {
36283631
String View_configuration_emailTemplates_short = "View.configuration.emailTemplates.short";
36293632
String View_configuration_facilities = "View.configuration.facilities";
36303633
String View_configuration_facilities_short = "View.configuration.facilities.short";
3634+
String View_configuration_featureConfiguration = "View.configuration.featureConfiguration";
3635+
String View_configuration_featureConfiguration_short = "View.configuration.featureConfiguration.short";
36313636
String View_configuration_laboratories = "View.configuration.laboratories";
36323637
String View_configuration_laboratories_short = "View.configuration.laboratories.short";
36333638
String View_configuration_linelisting = "View.configuration.linelisting";

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ public interface Strings {
702702
String headingExternalMessagesDeleted = "headingExternalMessagesDeleted";
703703
String headingExternalMessagesNotDeleted = "headingExternalMessagesNotDeleted";
704704
String headingFatalities = "headingFatalities";
705+
String headingFeatureConfiguration = "headingFeatureConfiguration";
705706
String headingFetchExternalMessages = "headingFetchExternalMessages";
706707
String headingFileExists = "headingFileExists";
707708
String headingFilters = "headingFilters";
@@ -1069,6 +1070,7 @@ public interface Strings {
10691070
String infoExternalMessageHospitalizationMissingHospital = "infoExternalMessageHospitalizationMissingHospital";
10701071
String infoFacilityCsvImport = "infoFacilityCsvImport";
10711072
String infoFacilityNeedsDistrict = "infoFacilityNeedsDistrict";
1073+
String infoFeatureConfiguration = "infoFeatureConfiguration";
10721074
String infoHeadingAefiDashboardMap = "infoHeadingAefiDashboardMap";
10731075
String infoHeadingEnvironmentSampleDashboardMap = "infoHeadingEnvironmentSampleDashboardMap";
10741076
String infoHeadingSampleDashboardMap = "infoHeadingSampleDashboardMap";
@@ -1510,6 +1512,7 @@ public interface Strings {
15101512
String messageFacilityDearchived = "messageFacilityDearchived";
15111513
String messageFacilityDearchivingNotPossible = "messageFacilityDearchivingNotPossible";
15121514
String messageFacilityMulitChanged = "messageFacilityMulitChanged";
1515+
String messageFeatureConfigurationSaved = "messageFeatureConfigurationSaved";
15131516
String messageFollowUpCanceled = "messageFollowUpCanceled";
15141517
String messageFollowUpStatusChanged = "messageFollowUpStatusChanged";
15151518
String messageForwardedExternalMessageFound = "messageForwardedExternalMessageFound";

sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public class SampleDto extends SormasToSormasShareableDto implements IsSample {
7878
public static final String SAMPLING_REASON_DETAILS = "samplingReasonDetails";
7979
public static final String DELETION_REASON = "deletionReason";
8080
public static final String OTHER_DELETION_REASON = "otherDeletionReason";
81+
public static final String PERFORMED_BY_REFERENCE_LABORATORY = "performedByReferenceLaboratory";
82+
public static final String RETEST_REQUESTED = "retestRequested";
8183

8284
private CaseReferenceDto associatedCase;
8385
private ContactReferenceDto associatedContact;
@@ -135,6 +137,8 @@ public class SampleDto extends SormasToSormasShareableDto implements IsSample {
135137

136138
private Boolean pathogenTestingRequested;
137139
private Boolean additionalTestingRequested;
140+
private Boolean performedByReferenceLaboratory;
141+
private Boolean retestRequested = Boolean.FALSE;
138142
private Set<PathogenTestType> requestedPathogenTests;
139143
private Set<AdditionalTestType> requestedAdditionalTests;
140144
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
@@ -368,6 +372,22 @@ public void setAdditionalTestingRequested(Boolean additionalTestingRequested) {
368372
this.additionalTestingRequested = additionalTestingRequested;
369373
}
370374

375+
public Boolean getPerformedByReferenceLaboratory() {
376+
return performedByReferenceLaboratory;
377+
}
378+
379+
public void setPerformedByReferenceLaboratory(Boolean performedByReferenceLaboratory) {
380+
this.performedByReferenceLaboratory = performedByReferenceLaboratory;
381+
}
382+
383+
public Boolean getRetestRequested() {
384+
return retestRequested;
385+
}
386+
387+
public void setRetestRequested(Boolean retestRequested) {
388+
this.retestRequested = retestRequested;
389+
}
390+
371391
@ImportIgnore
372392
public Set<PathogenTestType> getRequestedPathogenTests() {
373393
return requestedPathogenTests;
@@ -489,6 +509,8 @@ private static void migrateAttributesOfPhysicalSample(SampleDto source, SampleDt
489509
target.setSampleSource(source.getSampleSource());
490510
target.setPathogenTestingRequested(source.getPathogenTestingRequested());
491511
target.setAdditionalTestingRequested(source.getAdditionalTestingRequested());
512+
target.setPerformedByReferenceLaboratory(source.getPerformedByReferenceLaboratory());
513+
target.setRetestRequested(source.getRetestRequested());
492514
target.setRequestedPathogenTests(source.getRequestedPathogenTests());
493515
target.setRequestedAdditionalTests(source.getRequestedAdditionalTests());
494516
target.setFieldSampleID(source.getFieldSampleID());

sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleExportDto.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public class SampleExportDto extends AbstractUuidDto implements IsSample {
8989
private Boolean additionalTestingRequested;
9090
private Set<AdditionalTestType> requestedAdditionalTests;
9191
private String requestedOtherAdditionalTests;
92+
private Boolean performedByReferenceLaboratory;
93+
private Boolean retestRequested;
9294
private boolean shipped;
9395
private Date shipmentDate;
9496
@SensitiveData
@@ -159,6 +161,7 @@ public SampleExportDto(long id, String uuid, String labSampleId, Date sampleRepo
159161
String contactRegion, String contactDistrict, String contactCommunity, String contactCaseRegion, String contactCaseDistrict, String contactCaseCommunity,
160162
Date contactReportDate, Date lastContactDate, ContactClassification contactClassification, ContactStatus contactStatus, String eventParticipantRegion, String eventParticipantDistrict,
161163
String labUuid, String caseHealthFacilityUuid, String caseResponsibleRegion, String caseResponsibleDistrict, String caseResponsibleCommunity,
164+
Boolean performedByReferenceLaboratory, Boolean retestRequested,
162165
boolean isInJurisdiction, boolean isCaseInJurisdiction, boolean isContactInJurisdiction, boolean isContactCaseInJurisdiction, boolean isEventParticipantInJurisdiction) {
163166
//@formatter:on
164167
super(uuid);
@@ -231,6 +234,8 @@ public SampleExportDto(long id, String uuid, String labSampleId, Date sampleRepo
231234
}
232235
}
233236
this.requestedOtherAdditionalTests = requestedOtherAdditionalTests;
237+
this.performedByReferenceLaboratory = performedByReferenceLaboratory;
238+
this.retestRequested = retestRequested;
234239
this.shipped = shipped;
235240
this.shipmentDate = shipmentDate;
236241
this.shipmentDetails = shipmentDetails;
@@ -858,6 +863,24 @@ public String getSampleMaterialSnomedCode() {
858863
return material != null ? material.getSnomedCode() : null;
859864
}
860865

866+
@Order(105)
867+
public Boolean getPerformedByReferenceLaboratory() {
868+
return performedByReferenceLaboratory;
869+
}
870+
871+
public void setPerformedByReferenceLaboratory(Boolean performedByReferenceLaboratory) {
872+
this.performedByReferenceLaboratory = performedByReferenceLaboratory;
873+
}
874+
875+
@Order(106)
876+
public Boolean getRetestRequested() {
877+
return retestRequested;
878+
}
879+
880+
public void setRetestRequested(Boolean retestRequested) {
881+
this.retestRequested = retestRequested;
882+
}
883+
861884
public SampleExportPathogenTest getPathogenTest1() {
862885
return pathogenTest1;
863886
}

sormas-api/src/main/resources/captions.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ epiWeekFrom=From Epi Week
3131
epiWeekTo=To Epi Week
3232
facilityType=Facility type
3333
facilityTypeGroup=Facility category
34+
featureConfiguration=Feature Configuration
3435
firstName=First name
3536
sex=Sex
3637
nationalHealthId=National health ID
@@ -2285,6 +2286,7 @@ Sample.otherLab=Referral laboratory
22852286
Sample.pathogenTestingRequested=Request pathogen tests to be performed?
22862287
Sample.pathogenTestCount=Number of tests
22872288
Sample.pathogenTestResult=Final laboratory result
2289+
Sample.performedByReferenceLaboratory=Performed by reference laboratory
22882290
Sample.received=Received
22892291
Sample.receivedDate=Date sample received at lab
22902292
Sample.referredToUuid=Sample referred to
@@ -2297,6 +2299,7 @@ Sample.requestedOtherAdditionalTests=Other requested additional tests
22972299
Sample.requestedOtherPathogenTests=Other requested pathogen tests
22982300
Sample.requestedPathogenTests=If you wish to request specific additional tests, tick each of them in the list below
22992301
Sample.requestedPathogenTestsTags=Requested pathogen tests:
2302+
Sample.retestRequested=Retest requested
23002303
Sample.sampleCode=Sample code
23012304
Sample.sampleDateTime=Date sample was collected
23022305
Sample.sampleMaterial=Type of sample
@@ -3360,6 +3363,8 @@ View.configuration.documentTemplates=Document Templates Management
33603363
View.configuration.documentTemplates.short=Document Templates
33613364
View.configuration.facilities=Facilities Configuration
33623365
View.configuration.facilities.short=Facilities
3366+
View.configuration.featureConfiguration=Feature Configuration
3367+
View.configuration.featureConfiguration.short=Features
33633368
View.configuration.laboratories=Laboratories Configuration
33643369
View.configuration.laboratories.short=Laboratories
33653370
View.configuration.pointsofentry=Points of Entry Configuration

sormas-api/src/main/resources/enum.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ FacilityType.CARE_RECIPIENT_HABITATION = Care recipient habitation
872872
FacilityType.VISITING_AMBULATORY_AID = Visiting ambulatory aid
873873
FacilityType.AFTER_SCHOOL = After school facility
874874

875+
#FeatureType
876+
FeatureType.SAMPLE_ADD_PATHOGEN_TEST=Allow adding pathogen tests from a sample
877+
FeatureType.PATHOGEN_TEST_RESULT_REQUIRED=Require a result when entering a pathogen test
878+
875879
#FacilityTypeGroup
876880
FacilityTypeGroup.ACCOMMODATION=Accommodation
877881
FacilityTypeGroup.CARE_FACILITY=Care facility

sormas-api/src/main/resources/strings.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ headingEventsNotDeleted = None of the events were deleted
609609
headingEventsNotRestored = None of the events were restored
610610
headingExportFailed = Export failed
611611
headingFatalities=Fatalities
612+
headingFeatureConfiguration = Feature Configuration
612613
headingFileExists = Duplicate File
613614
headingFilters = Filters
614615
headingStoppedFollowUp = Stopped Follow-up
@@ -1016,6 +1017,7 @@ infoExpectedFollowUpUntilDateContact = The expected follow-up until date for thi
10161017
infoExportNoFilters = <b>Warning:</b> No filters have been selected. Export may take a while.
10171018
infoFacilityCsvImport = Name of a configured facility (requires FacilityType), OTHER_FACILITY (requires FacilityType and FacilityDetails) or NO_FACILITY
10181019
infoFacilityNeedsDistrict = Please define a district in order to select a facility.
1020+
infoFeatureConfiguration = Enable or disable optional system features. Changes take effect immediately and apply to the whole server.
10191021
infoImmunizationPeriod = Immunization period of this immunization
10201022
infoImmunizationStatusAcquired = Only immunizations with acquired status are considered
10211023
infoImmunizationValidFromClosest = Selects the immunization with the valid from date closest to (but not after) the case report date
@@ -1361,6 +1363,7 @@ messageCountEventsNotDeletedSormasToSormasReason = %s events not deleted because
13611363
messageExportFailed = There was an error preventing the data to be exported. Please contact an admin and inform them about this issue.
13621364
messageExportConfigurationDeleted = Export configuration deleted
13631365
messageExportConfigurationSaved = Export configuration saved
1366+
messageFeatureConfigurationSaved = Feature configuration saved
13641367
messageFollowUpCanceled = Follow-up of all selected contacts has been canceled
13651368
messageFollowUpStatusChanged = Follow-up of all selected contacts that have follow-up has been set to lost to follow-up
13661369
messageFacilityChanged = You have changed the facility of this case. Do you want to transfer the case to the new facility (the hospitalization may be updated) or do you only want to edit the data to correct a mistake?

sormas-backend/src/main/java/de/symeda/sormas/backend/feature/FeatureConfigurationFacadeEjb.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,26 @@ public void saveFeatureConfiguration(@Valid FeatureConfigurationIndexDto configu
346346
service.ensurePersisted(entity);
347347
}
348348

349+
@Override
350+
public void setServerFeatureEnabled(FeatureType featureType, boolean enabled) {
351+
352+
if (!featureType.isServerFeature()) {
353+
throw new IllegalArgumentException("FeatureType " + featureType + " is not a server feature and cannot be toggled here.");
354+
}
355+
356+
List<FeatureConfiguration> configurations = service.getServerFeatureConfigurationsByType(featureType);
357+
if (configurations.isEmpty()) {
358+
FeatureConfiguration configuration = FeatureConfiguration.build(featureType, enabled);
359+
configuration.setProperties(featureType.getSupportedPropertyDefaults());
360+
service.ensurePersisted(configuration);
361+
} else {
362+
for (FeatureConfiguration configuration : configurations) {
363+
configuration.setEnabled(enabled);
364+
service.ensurePersisted(configuration);
365+
}
366+
}
367+
}
368+
349369
@Override
350370
public void deleteAllFeatureConfigurations(FeatureConfigurationCriteria criteria) {
351371

0 commit comments

Comments
 (0)