Skip to content

Commit bade428

Browse files
committed
entities, dto for tb sample/test changes
1 parent 367b9a2 commit bade428

11 files changed

Lines changed: 770 additions & 63 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
16+
package de.symeda.sormas.api.sample;
17+
18+
import java.lang.reflect.Field;
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import de.symeda.sormas.api.i18n.I18nProperties;
24+
import de.symeda.sormas.api.utils.ApplicableToPathogenTests;
25+
26+
public enum PathogenSpecie {
27+
28+
@ApplicableToPathogenTests(value = {
29+
PathogenTestType.SPOLIGOTYPING })
30+
MYCOBATERIUM_AFRICANUM,
31+
@ApplicableToPathogenTests(value = {
32+
PathogenTestType.SPOLIGOTYPING })
33+
MYCOBATERIUM_BOVIS,
34+
@ApplicableToPathogenTests(value = {
35+
PathogenTestType.SPOLIGOTYPING })
36+
MYCOBATERIUM_TUBERCULOSIS,
37+
@ApplicableToPathogenTests(value = {
38+
PathogenTestType.SPOLIGOTYPING })
39+
OTHER_MTBC_MEMBER,
40+
@ApplicableToPathogenTests(value = {
41+
PathogenTestType.SPOLIGOTYPING })
42+
UNKNOWN,
43+
@ApplicableToPathogenTests(value = {
44+
PathogenTestType.SPOLIGOTYPING })
45+
NOT_APPLICABLE;
46+
47+
@Override
48+
public String toString() {
49+
return I18nProperties.getEnumCaption(this);
50+
}
51+
52+
public static List<PathogenSpecie> forPathogenTest(PathogenTestType pathogenTest) {
53+
return Arrays.stream(values()).filter(status -> {
54+
try {
55+
Field f = PathogenSpecie.class.getField(status.name());
56+
ApplicableToPathogenTests ann = f.getAnnotation(ApplicableToPathogenTests.class);
57+
return ann != null && Arrays.asList(ann.value()).contains(pathogenTest);
58+
} catch (NoSuchFieldException e) {
59+
return false;
60+
}
61+
}).collect(Collectors.toList());
62+
}
63+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
16+
package de.symeda.sormas.api.sample;
17+
18+
import java.lang.reflect.Field;
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
23+
import de.symeda.sormas.api.Disease;
24+
import de.symeda.sormas.api.i18n.I18nProperties;
25+
import de.symeda.sormas.api.utils.ApplicableToPathogenTests;
26+
import de.symeda.sormas.api.utils.Diseases;
27+
28+
public enum PathogenStrainCallStatus {
29+
30+
@Diseases(value = {
31+
Disease.TUBERCULOSIS })
32+
@ApplicableToPathogenTests(value = {
33+
PathogenTestType.BEJINGGENOTYPING })
34+
BEIJING,
35+
@Diseases(value = {
36+
Disease.TUBERCULOSIS })
37+
@ApplicableToPathogenTests(value = {
38+
PathogenTestType.BEJINGGENOTYPING })
39+
NOBEIJING,
40+
@Diseases(value = {
41+
Disease.TUBERCULOSIS })
42+
@ApplicableToPathogenTests(value = {
43+
PathogenTestType.BEJINGGENOTYPING })
44+
POSSBEIJING,
45+
@Diseases(value = {
46+
Disease.TUBERCULOSIS })
47+
@ApplicableToPathogenTests(value = {
48+
PathogenTestType.BEJINGGENOTYPING })
49+
UNKNOWN;
50+
51+
@Override
52+
public String toString() {
53+
return I18nProperties.getEnumCaption(this);
54+
}
55+
56+
public static List<PathogenStrainCallStatus> forDisease(Disease disease) {
57+
return Arrays.stream(values()).filter(status -> {
58+
try {
59+
Field f = PathogenStrainCallStatus.class.getField(status.name());
60+
Diseases ann = f.getAnnotation(Diseases.class);
61+
return ann != null && Arrays.asList(ann.value()).contains(disease);
62+
} catch (NoSuchFieldException e) {
63+
return false;
64+
}
65+
}).collect(Collectors.toList());
66+
}
67+
68+
public static List<PathogenStrainCallStatus> forPathogenTest(PathogenTestType pathogenTest) {
69+
return Arrays.stream(values()).filter(status -> {
70+
try {
71+
Field f = PathogenStrainCallStatus.class.getField(status.name());
72+
ApplicableToPathogenTests ann = f.getAnnotation(ApplicableToPathogenTests.class);
73+
return ann != null && Arrays.asList(ann.value()).contains(pathogenTest);
74+
} catch (NoSuchFieldException e) {
75+
return false;
76+
}
77+
}).collect(Collectors.toList());
78+
}
79+
80+
public static List<PathogenStrainCallStatus> forDiseaseAndTest(Disease disease, PathogenTestType pathogenTest) {
81+
return Arrays.stream(values()).filter(status -> {
82+
try {
83+
Field f = PathogenStrainCallStatus.class.getField(status.name());
84+
Diseases diseaseAnn = f.getAnnotation(Diseases.class);
85+
ApplicableToPathogenTests testAnn = f.getAnnotation(ApplicableToPathogenTests.class);
86+
return diseaseAnn != null
87+
&& testAnn != null
88+
&& Arrays.asList(diseaseAnn.value()).contains(disease)
89+
&& Arrays.asList(testAnn.value()).contains(pathogenTest);
90+
} catch (NoSuchFieldException e) {
91+
return false;
92+
}
93+
}).collect(Collectors.toList());
94+
}
95+
}

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto;
3838
import de.symeda.sormas.api.sormastosormas.S2SIgnoreProperty;
3939
import de.symeda.sormas.api.sormastosormas.SormasToSormasConfig;
40+
import de.symeda.sormas.api.therapy.DrugSusceptibilityDto;
4041
import de.symeda.sormas.api.user.UserDto;
4142
import de.symeda.sormas.api.user.UserReferenceDto;
4243
import de.symeda.sormas.api.utils.DataHelper;
@@ -46,6 +47,7 @@
4647
import de.symeda.sormas.api.utils.FieldConstraints;
4748
import de.symeda.sormas.api.utils.HideForCountriesExcept;
4849
import de.symeda.sormas.api.utils.SensitiveData;
50+
import de.symeda.sormas.api.utils.YesNoUnknown;
4951
import de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto;
5052

5153
@DependingOnFeatureType(featureType = FeatureType.SAMPLES_LAB)
@@ -100,6 +102,13 @@ public class PathogenTestDto extends PseudonymizableDto {
100102
public static final String PRESCRIBER_CITY = "prescriberCity";
101103
public static final String PRESCRIBER_COUNTRY = "prescriberCountry";
102104
public static final String ENVIRONMENT_SAMPLE = "environmentSample";
105+
public static final String RIFAMPICIN_RESISTANT = "rifampicinResistant";
106+
public static final String ISONIAZID_RESISTANT = "isoniazidResistant";
107+
public static final String SPECIE = "specie";
108+
public static final String PATTERN_PROFILE = "patternProfile";
109+
public static final String STRAIN_CALL_STATUS = "strainCallStatus";
110+
public static final String TEST_SCALE = "testScale";
111+
public static final String DRUG_SUSCEPTIBILITY = "drugSusceptibility";
103112
public static final String SEROTYPING_METHOD = "seroTypingMethod";
104113
public static final String SERO_TYPING_METHOD_TEXT = "seroTypingMethodText";
105114
public static final String SERO_GROUP_SPECIFICATION = "seroGroupSpecification";
@@ -202,6 +211,13 @@ public class PathogenTestDto extends PseudonymizableDto {
202211
private String prescriberCity;
203212
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_LUXEMBOURG)
204213
private CountryReferenceDto prescriberCountry;
214+
private YesNoUnknown rifampicinResistant;
215+
private YesNoUnknown isoniazidResistant;
216+
private PathogenSpecie specie;
217+
private String patternProfile;
218+
private PathogenStrainCallStatus strainCallStatus;
219+
private PathogenTestScale testScale;
220+
private DrugSusceptibilityDto drugSusceptibility;
205221
@SensitiveData
206222
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_LUXEMBOURG)
207223
@Diseases(value = {Disease.INVASIVE_PNEUMOCOCCAL_INFECTION})
@@ -233,6 +249,7 @@ public static PathogenTestDto build(SampleDto sample, UserDto currentUser) {
233249
pathogenTest.setLabDetails(sample.getLabDetails());
234250
}
235251
pathogenTest.setLabUser(currentUser.toReference());
252+
pathogenTest.setDrugSusceptibility(DrugSusceptibilityDto.build());
236253
return pathogenTest;
237254
}
238255

@@ -242,6 +259,7 @@ public static PathogenTestDto build(SampleReferenceDto sample, UserReferenceDto
242259
pathogenTest.setUuid(DataHelper.createUuid());
243260
pathogenTest.setSample(sample);
244261
pathogenTest.setLabUser(currentUser);
262+
pathogenTest.setDrugSusceptibility(DrugSusceptibilityDto.build());
245263
return pathogenTest;
246264
}
247265

@@ -635,6 +653,62 @@ public void setPrescriberCountry(CountryReferenceDto prescriberCountry) {
635653
this.prescriberCountry = prescriberCountry;
636654
}
637655

656+
public YesNoUnknown getRifampicinResistant() {
657+
return rifampicinResistant;
658+
}
659+
660+
public void setRifampicinResistant(YesNoUnknown rifampicinResistant) {
661+
this.rifampicinResistant = rifampicinResistant;
662+
}
663+
664+
public YesNoUnknown getIsoniazidResistant() {
665+
return isoniazidResistant;
666+
}
667+
668+
public void setIsoniazidResistant(YesNoUnknown isoniazidResistant) {
669+
this.isoniazidResistant = isoniazidResistant;
670+
}
671+
672+
public PathogenSpecie getSpecie() {
673+
return specie;
674+
}
675+
676+
public void setSpecie(PathogenSpecie specie) {
677+
this.specie = specie;
678+
}
679+
680+
public String getPatternProfile() {
681+
return patternProfile;
682+
}
683+
684+
public void setPatternProfile(String patternProfile) {
685+
this.patternProfile = patternProfile;
686+
}
687+
688+
public PathogenStrainCallStatus getStrainCallStatus() {
689+
return strainCallStatus;
690+
}
691+
692+
public void setStrainCallStatus(PathogenStrainCallStatus strainCallStatus) {
693+
this.strainCallStatus = strainCallStatus;
694+
}
695+
696+
public PathogenTestScale getTestScale() {
697+
return testScale;
698+
}
699+
700+
public void setTestScale(PathogenTestScale testScale) {
701+
this.testScale = testScale;
702+
}
703+
704+
public DrugSusceptibilityDto getDrugSusceptibility() {
705+
return drugSusceptibility;
706+
}
707+
708+
public void setDrugSusceptibility(DrugSusceptibilityDto drugSusceptibility) {
709+
this.drugSusceptibility = drugSusceptibility;
710+
}
711+
638712
public SerotypingMethod getSeroTypingMethod() {
639713
return seroTypingMethod;
640714
}

sormas-api/src/main/java/de/symeda/sormas/api/sample/SpoligotypeSpecie.java renamed to sormas-api/src/main/java/de/symeda/sormas/api/sample/PathogenTestScale.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,40 @@
1515

1616
package de.symeda.sormas.api.sample;
1717

18+
import java.lang.reflect.Field;
19+
import java.util.Arrays;
20+
import java.util.List;
21+
import java.util.stream.Collectors;
22+
1823
import de.symeda.sormas.api.i18n.I18nProperties;
24+
import de.symeda.sormas.api.utils.ApplicableToPathogenTests;
1925

20-
public enum SpoligotypeSpecie {
26+
public enum PathogenTestScale {
2127

22-
MYCOBATERIUM_AFRICANUM,
23-
MYCOBATERIUM_BOVIS,
24-
MYCOBATERIUM_TUBERCULOSIS,
25-
OTHER_MTBC_MEMBER,
26-
UNKNOWN,
27-
NOT_APPLICABLE;
28+
@ApplicableToPathogenTests(value = {
29+
PathogenTestType.MICROSCOPY })
30+
ONE_PLUS,
31+
@ApplicableToPathogenTests(value = {
32+
PathogenTestType.MICROSCOPY })
33+
TWO_PLUS,
34+
@ApplicableToPathogenTests(value = {
35+
PathogenTestType.MICROSCOPY })
36+
THREE_PLUS;
2837

2938
@Override
3039
public String toString() {
3140
return I18nProperties.getEnumCaption(this);
3241
}
42+
43+
public static List<PathogenTestScale> forPathogenTest(PathogenTestType pathogenTest) {
44+
return Arrays.stream(values()).filter(status -> {
45+
try {
46+
Field f = PathogenTestScale.class.getField(status.name());
47+
ApplicableToPathogenTests ann = f.getAnnotation(ApplicableToPathogenTests.class);
48+
return ann != null && Arrays.asList(ann.value()).contains(pathogenTest);
49+
} catch (NoSuchFieldException e) {
50+
return false;
51+
}
52+
}).collect(Collectors.toList());
53+
}
3354
}

0 commit comments

Comments
 (0)