Skip to content

Commit

Permalink
#11574 Add environment samples to sample status map - added test for …
Browse files Browse the repository at this point in the history
…getting samples by Most relevant date
  • Loading branch information
Levente Gal committed Oct 9, 2023
1 parent 7f0d310 commit 2bfab27
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import de.symeda.sormas.api.environment.EnvironmentReferenceDto;
import de.symeda.sormas.api.environment.environmentsample.EnvironmentSampleDto;
import de.symeda.sormas.api.environment.environmentsample.EnvironmentSampleMaterial;
import de.symeda.sormas.api.environment.environmentsample.EnvironmentSampleReferenceDto;
import de.symeda.sormas.api.environment.environmentsample.Pathogen;
import de.symeda.sormas.api.epidata.EpiDataDto;
import de.symeda.sormas.api.event.EventDto;
Expand Down Expand Up @@ -1524,6 +1525,32 @@ public PathogenTestDto createPathogenTest(
return sampleTest;
}

public PathogenTestDto createPathogenTest(
EnvironmentSampleReferenceDto sample,
PathogenTestType testType,
Disease testedDisease,
Date testDateTime,
FacilityReferenceDto lab,
UserReferenceDto labUser,
PathogenTestResultType testResult,
Consumer<PathogenTestDto> extraConfig) {

PathogenTestDto sampleTest = PathogenTestDto.build(sample, labUser);
sampleTest.setTestedDisease(testedDisease);
sampleTest.setTestType(testType);
sampleTest.setTestDateTime(testDateTime);
sampleTest.setLab(lab);
sampleTest.setTestResult(testResult);
sampleTest.setTestResultVerified(true);

if (extraConfig != null) {
extraConfig.accept(sampleTest);
}

sampleTest = beanTest.getPathogenTestFacade().savePathogenTest(sampleTest);
return sampleTest;
}

public PathogenTestDto createPathogenTest(CaseDataDto associatedCase, PathogenTestType testType, PathogenTestResultType resultType) {
return createPathogenTest(associatedCase, null, testType, resultType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,34 @@ public void testGetSamplesForMap() {
.count());
}

@Test
public void testGetEnvironmentSamplesByPathogenTestDate() {
EnvironmentDto environment = creator.createEnvironment("Test river", EnvironmentMedia.WATER, user.toReference(), rdcf, null);

FacilityDto lab = creator.createFacility("Test lab", rdcf.region, rdcf.district, null, FacilityType.LABORATORY);
EnvironmentSampleDto sample = creator.createEnvironmentSample(environment.toReference(), user.toReference(), lab.toReference(), s -> {
s.setSampleDateTime(DateHelper.subtractDays(new Date(), 10));
s.getLocation().setLatitude(3.0);
s.getLocation().setLongitude(4.0);
});

creator.createPathogenTest(
sample.toReference(),
PathogenTestType.CULTURE,
Disease.CORONAVIRUS,
DateHelper.subtractDays(new Date(), 2),
lab.toReference(),
user.toReference(),
PathogenTestResultType.POSITIVE,
null);

SampleDashboardCriteria criteria = new SampleDashboardCriteria();
criteria.dateBetween(DateHelper.subtractDays(new Date(), 5), new Date());
criteria.sampleDateType(SampleDashboardFilterDateType.MOST_RELEVANT);
assertEquals(1, getSampleDashboardFacade().countEnvironmentalSamplesForMap(criteria));
assertEquals(1, getSampleDashboardFacade().getEnvironmentalSamplesForMap(criteria).size());
}

public SampleDto createSampleByResultType(
CaseDataDto caze,
Date sampleDateTime,
Expand Down

0 comments on commit 2bfab27

Please sign in to comment.