use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetAllActiveCasesIncludeExtendedChangeDateFiltersLocationTest.
@Test
public void testGetAllActiveCasesIncludeExtendedChangeDateFiltersLocationTest() throws InterruptedException {
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = useSurveillanceOfficerLogin(rdcf);
CaseDataDto caze = creator.createCase(user.toReference(), creator.createPerson("Case", "Person").toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
Date date = new Date();
// the delay is needed in order to ensure the time difference between the date and the case dependent objects update
Thread.sleep(10L);
PersonDto cazePerson = getPersonFacade().getPersonByUuid(caze.getPerson().getUuid());
cazePerson.getAddress().setStreet("new Street");
cazePerson.getAddress().setHouseNumber("new Number");
cazePerson.getAddress().setAdditionalInformation("new Information");
getPersonFacade().savePerson(cazePerson);
assertEquals(0, getCaseFacade().getAllActiveCasesAfter(date).size());
assertEquals(1, getCaseFacade().getAllActiveCasesAfter(date, true).size());
}
use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetCasesForDuplicateMerging.
@Test
public void testGetCasesForDuplicateMerging() {
final Date today = new Date();
final Date threeDaysAgo = DateUtils.addDays(today, -3);
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 1);
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, today, rdcf);
SessionImpl em = (SessionImpl) getEntityManager();
QueryImplementor query = em.createQuery("select c from cases c where c.uuid=:uuid");
query.setParameter("uuid", caze.getUuid());
Case singleResult = (Case) query.getSingleResult();
singleResult.setCreationDate(new Timestamp(threeDaysAgo.getTime()));
singleResult.setReportDate(threeDaysAgo);
em.save(singleResult);
PersonDto cazePerson2 = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 1);
CaseDataDto case2 = creator.createCase(user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateUtils.addMinutes(today, -3), rdcf);
final List<CaseIndexDto[]> casesForDuplicateMergingToday = getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(today).creationDateTo(today), true);
final List<CaseIndexDto[]> casesForDuplicateMergingThreeDaysAgo = getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(threeDaysAgo).creationDateTo(threeDaysAgo), true);
Assert.assertEquals(1, casesForDuplicateMergingToday.size());
Assert.assertEquals(1, casesForDuplicateMergingThreeDaysAgo.size());
}
use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testMapCaseListCreation.
@Test
public void testMapCaseListCreation() {
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person", p -> {
p.getAddress().setLatitude(0.0);
p.getAddress().setLongitude(0.0);
});
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
Long count = getCaseFacade().countCasesForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1), null);
List<MapCaseDto> mapCaseDtos = getCaseFacade().getCasesForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1), null);
// List should have one entry
assertEquals((long) count, mapCaseDtos.size());
assertEquals(1, mapCaseDtos.size());
}
use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testOutcomePersonConditionUpdateForAppSync.
@Test
public void testOutcomePersonConditionUpdateForAppSync() throws InterruptedException {
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto firstCase = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
// simulate short delay between transmissions
Thread.sleep(DtoHelper.CHANGE_DATE_TOLERANCE_MS + 1);
// set person to dead so that case will be updated automatically
cazePerson.setPresentCondition(PresentCondition.DEAD);
cazePerson.setDeathDate(new Date());
cazePerson.setCauseOfDeath(CauseOfDeath.EPIDEMIC_DISEASE);
cazePerson.setCauseOfDeathDisease(firstCase.getDisease());
getPersonFacade().savePerson(cazePerson);
// this should throw an exception
exception.expect(OutdatedEntityException.class);
getCaseFacade().save(firstCase);
}
use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testArchiveAndDearchiveCase.
@Test
public void testArchiveAndDearchiveCase() {
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
Date testStartDate = new Date();
// getAllActiveCases and getAllUuids should return length 1
assertEquals(1, getCaseFacade().getAllActiveCasesAfter(null).size());
assertEquals(1, getCaseFacade().getAllActiveUuids().size());
getCaseFacade().archive(caze.getUuid(), null);
// getAllActiveCases and getAllUuids should return length 0
assertEquals(0, getCaseFacade().getAllActiveCasesAfter(null).size());
assertEquals(0, getCaseFacade().getAllActiveUuids().size());
// getArchivedUuidsSince should return length 1
assertEquals(1, getCaseFacade().getArchivedUuidsSince(testStartDate).size());
getCaseFacade().dearchive(Collections.singletonList(caze.getUuid()), null);
// getAllActiveCases and getAllUuids should return length 1
assertEquals(1, getCaseFacade().getAllActiveCasesAfter(null).size());
assertEquals(1, getCaseFacade().getAllActiveUuids().size());
// getArchivedUuidsSince should return length 0
assertEquals(0, getCaseFacade().getArchivedUuidsSince(testStartDate).size());
}
Aggregations