use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetIndexList.
@Test
public void testGetIndexList() {
String districtName = "District";
RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility");
useSurveillanceOfficerLogin(rdcf);
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
String lastName = "Person";
PersonDto cazePerson = creator.createPerson("Case", lastName);
creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf, c -> c.setHealthFacilityDetails("abc"));
creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf, c -> c.setHealthFacilityDetails("xyz"));
List<CaseIndexDto> results = getCaseFacade().getIndexList(null, 0, 100, Arrays.asList(new SortProperty(CaseIndexDto.DISEASE), new SortProperty(CaseIndexDto.PERSON_FIRST_NAME), new SortProperty(CaseIndexDto.RESPONSIBLE_DISTRICT_NAME), new SortProperty(CaseIndexDto.HEALTH_FACILITY_NAME, false), new SortProperty(CaseIndexDto.SURVEILLANCE_OFFICER_UUID)));
// List should have one entry
assertEquals(3, results.size());
assertEquals(districtName, results.get(0).getResponsibleDistrictName());
assertEquals(lastName, results.get(0).getPersonLastName());
assertEquals("Facility - xyz", results.get(0).getHealthFacilityName());
assertEquals("Facility - abc", results.get(1).getHealthFacilityName());
assertEquals("Facility", results.get(2).getHealthFacilityName());
}
use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetDuplicateCasesOfDifferentSexAndSameBirthDateIsEmpty.
@Test
public void testGetDuplicateCasesOfDifferentSexAndSameBirthDateIsEmpty() {
final Date today = new Date();
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);
creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, today, rdcf);
PersonDto cazePerson2 = creator.createPerson("Case", "Person", Sex.FEMALE, 1980, 1, 1);
creator.createCase(user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateUtils.addMinutes(today, -3), rdcf);
Assert.assertEquals(0, getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(today).creationDateTo(today), true).size());
}
use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetIndexListByEventFreeText.
@Test
public void testGetIndexListByEventFreeText() {
String districtName = "District";
RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility");
useSurveillanceOfficerLogin(rdcf);
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person1 = creator.createPerson();
PersonDto person2 = creator.createPerson();
EventDto event1 = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Signal foo", "A long description for this event", user.toReference(), eventDto -> {
});
EventParticipantDto event1Participant1 = creator.createEventParticipant(event1.toReference(), person1, user.toReference());
EventParticipantDto event1Participant2 = creator.createEventParticipant(event1.toReference(), person2, user.toReference());
CaseDataDto case1 = creator.createCase(user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
CaseDataDto case2 = creator.createCase(user.toReference(), person2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
event1Participant1.setResultingCase(case1.toReference());
getEventParticipantFacade().saveEventParticipant(event1Participant1);
Assert.assertEquals(2, getCaseFacade().getIndexList(null, 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal"), 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike(event1.getUuid()), 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal description"), 0, 100, null).size());
}
use of de.symeda.sormas.api.person.PersonDto 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.person.PersonDto 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));
}
}
Aggregations