use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetIndexListWithLabUser.
@Test
public void testGetIndexListWithLabUser() {
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);
PersonDto contactPerson = creator.createPerson("Contact", "Person");
ContactDto contact = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
UserDto labUser = creator.createUser(null, null, null, "Lab", "Off", UserRole.LAB_USER);
FacilityReferenceDto laboratory = new FacilityReferenceDto(rdcf.facility.getUuid(), rdcf.facility.toString(), rdcf.facility.getExternalID());
labUser.setLaboratory(laboratory);
getUserFacade().saveUser(labUser);
loginWith(labUser);
assertEquals(0, getContactFacade().getIndexList(null, 0, 100, null).size());
loginWith(user);
creator.createSample(contact.toReference(), user.toReference(), laboratory, s -> {
s.setSampleDateTime(new Date());
s.setComment("Test contact sample");
});
loginWith(labUser);
assertEquals(1, getContactFacade().getIndexList(null, 0, 100, null).size());
}
use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetIndexDetailedList.
@Test
public void testGetIndexDetailedList() {
ContactCriteria contactCriteria = new ContactCriteria();
contactCriteria.setIncludeContactsFromOtherJurisdictions(true);
List<SortProperty> sortProperties = Collections.emptyList();
List<ContactIndexDetailedDto> result;
// 0. No data: empty list
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, is(empty()));
// Create needed structural data
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);
UserReferenceDto reportingUser = new UserReferenceDto(user.getUuid());
EventDto event1 = creator.createEvent(reportingUser, DateHelper.subtractDays(new Date(), 1));
EventDto event2 = creator.createEvent(reportingUser, new Date());
PersonDto contactPerson = creator.createPerson("Contact", "Person");
ContactDto contact1 = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
// 1a. one Contact without Event
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(0L));
assertNull(dto.getLatestEventId());
assertNull(dto.getLatestEventTitle());
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1b. one Contact with one Event
creator.createEventParticipant(new EventReferenceDto(event1.getUuid()), contactPerson, reportingUser);
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(1L));
assertThat(dto.getLatestEventId(), equalTo(event1.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event1.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1c. one Contact with two Events, second is leading
creator.createEventParticipant(new EventReferenceDto(event2.getUuid()), contactPerson, reportingUser);
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1d. one Contact with two Events and one visit
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(1));
}
// 1e. one Contact with two Events and three visits
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(3));
}
}
use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetIndexList.
@Test
public void testGetIndexList() {
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);
PersonDto contactPerson = creator.createPerson("Contact", "Person");
creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
// Database should contain one contact, associated visit and task
assertEquals(1, getContactFacade().getIndexList(null, 0, 100, null).size());
}
use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testMapContactListCreation.
@Test
public void testMapContactListCreation() {
TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = useSurveillanceOfficerLogin(rdcf);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
PersonDto contactPerson = creator.createPerson("Contact", "Person", p -> {
p.getAddress().setLatitude(0.0);
p.getAddress().setLongitude(0.0);
});
creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), caze.getDisease(), rdcf);
Long count = getContactFacade().countContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
List<MapContactDto> mapContactDtos = getContactFacade().getContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
// List should have one entry
assertEquals((long) count, mapContactDtos.size());
assertEquals((long) 1, mapContactDtos.size());
}
use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testCountMaximumFollowUpDays.
@Test
public void testCountMaximumFollowUpDays() {
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);
PersonDto contactPerson = creator.createPerson("Contact", "Person");
creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
visit.getSymptoms().setAbdominalPain(SymptomState.YES);
getVisitFacade().saveVisit(visit);
PersonDto contactPerson2 = creator.createPerson("Contact2", "Person2");
creator.createContact(user.toReference(), user.toReference(), contactPerson2.toReference(), caze, new Date(), new Date(), null);
VisitDto visit21 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
visit21.getSymptoms().setAbdominalPain(SymptomState.YES);
getVisitFacade().saveVisit(visit21);
VisitDto visit22 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
visit22.getSymptoms().setAgitation(SymptomState.YES);
getVisitFacade().saveVisit(visit22);
PersonDto contactPerson3 = creator.createPerson("Contact3", "Person3");
creator.createContact(user.toReference(), user.toReference(), contactPerson3.toReference(), caze, new Date(), new Date(), null);
for (int i = 0; i < 10; i++) {
creator.createVisit(caze.getDisease(), contactPerson3.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
}
assertEquals(10, getContactFacade().countMaximumFollowUpDays(null));
}
Aggregations