use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testCreateCaseWithoutUuid.
@Test
public void testCreateCaseWithoutUuid() {
RDCF rdcf = creator.createRDCF();
CaseDataDto caze = new CaseDataDto();
caze.setReportDate(new Date());
caze.setReportingUser(creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference());
caze.setCaseClassification(CaseClassification.PROBABLE);
caze.setInvestigationStatus(InvestigationStatus.PENDING);
caze.setDisease(Disease.CORONAVIRUS);
caze.setPerson(creator.createPerson().toReference());
caze.setResponsibleRegion(rdcf.region);
caze.setResponsibleDistrict(rdcf.district);
caze.setFacilityType(FacilityType.HOSPITAL);
caze.setHealthFacility(rdcf.facility);
caze.setTherapy(new TherapyDto());
caze.setSymptoms(new SymptomsDto());
EpiDataDto epiData = new EpiDataDto();
ExposureDto exposure = new ExposureDto();
exposure.setExposureType(ExposureType.WORK);
epiData.setExposures(Collections.singletonList(exposure));
caze.setEpiData(epiData);
CaseDataDto savedCaze = getCaseFacade().save(caze);
MatcherAssert.assertThat(savedCaze.getUuid(), not(isEmptyOrNullString()));
MatcherAssert.assertThat(savedCaze.getTherapy().getUuid(), not(isEmptyOrNullString()));
MatcherAssert.assertThat(savedCaze.getSymptoms().getUuid(), not(isEmptyOrNullString()));
MatcherAssert.assertThat(savedCaze.getEpiData().getUuid(), not(isEmptyOrNullString()));
MatcherAssert.assertThat(savedCaze.getEpiData().getExposures().get(0).getUuid(), not(isEmptyOrNullString()));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testSearchByFacilityTypeAndGroup.
@Test
public void testSearchByFacilityTypeAndGroup() {
RDCF rdcf = creator.createRDCF();
PersonReferenceDto personDto = creator.createPerson().toReference();
CaseDataDto savedCaze1 = createCaseOfFacilityType(rdcf, personDto, FacilityType.HOSPITAL);
CaseDataDto savedCaze2 = createCaseOfFacilityType(rdcf, personDto, FacilityType.MATERNITY_FACILITY);
CaseDataDto savedCaze3 = createCaseOfFacilityType(rdcf, personDto, FacilityType.HOTEL);
CaseDataDto savedCaze4 = createCaseOfFacilityType(rdcf, personDto, FacilityType.REFUGEE_ACCOMMODATION);
MatcherAssert.assertThat(getCaseFacade().getIndexList(new CaseCriteria(), 0, 100, null), hasSize(4));
final CaseCriteria facilityTypeGroupFilter = new CaseCriteria();
facilityTypeGroupFilter.setFacilityTypeGroup(FacilityTypeGroup.MEDICAL_FACILITY);
MatcherAssert.assertThat(getCaseFacade().getIndexList(facilityTypeGroupFilter, 0, 100, null), hasSize(2));
final CaseCriteria facilityTypeAndGroupFilter = new CaseCriteria();
facilityTypeAndGroupFilter.setFacilityTypeGroup(FacilityTypeGroup.MEDICAL_FACILITY);
facilityTypeAndGroupFilter.setFacilityType(FacilityType.HOSPITAL);
MatcherAssert.assertThat(getCaseFacade().getIndexList(facilityTypeAndGroupFilter, 0, 100, null), hasSize(1));
final CaseCriteria facilityTypeFilter = new CaseCriteria();
facilityTypeFilter.setFacilityType(FacilityType.HOTEL);
final List<CaseIndexDto> indexListByFacilityTYpe = getCaseFacade().getIndexList(facilityTypeFilter, 0, 100, null);
MatcherAssert.assertThat(indexListByFacilityTYpe, hasSize(1));
Assert.assertEquals(indexListByFacilityTYpe.get(0).getUuid(), savedCaze3.getUuid());
final CaseCriteria facilityTypeAndGroupNonMatchingFilter = new CaseCriteria();
facilityTypeAndGroupNonMatchingFilter.setFacilityTypeGroup(FacilityTypeGroup.MEDICAL_FACILITY);
facilityTypeAndGroupNonMatchingFilter.setFacilityType(FacilityType.HOTEL);
MatcherAssert.assertThat(getCaseFacade().getIndexList(facilityTypeAndGroupNonMatchingFilter, 0, 100, null), hasSize(0));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetExportList.
@Test
public void testGetExportList() {
RDCFEntities rdcfEntities = creator.createRDCFEntities("Region", "District", "Community", "Facility");
RDCF rdcf = new RDCF(rdcfEntities);
UserDto user = creator.createUser(rdcfEntities.region.getUuid(), rdcfEntities.district.getUuid(), rdcfEntities.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(), rdcfEntities);
cazePerson.getAddress().setCity("City");
getPersonFacade().savePerson(cazePerson);
ExposureDto exposure = ExposureDto.build(ExposureType.TRAVEL);
exposure.getLocation().setDetails("Ghana");
exposure.setStartDate(new Date());
exposure.setEndDate(new Date());
caze.getEpiData().getExposures().add(exposure);
caze.getSymptoms().setAbdominalPain(SymptomState.YES);
caze = getCaseFacade().save(caze);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
creator.createSample(caze.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcfEntities.facility);
creator.createSample(caze.toReference(), cal.getTime(), cal.getTime(), user.toReference(), SampleMaterial.CRUST, rdcfEntities.facility);
creator.createPathogenTest(caze, PathogenTestType.ANTIGEN_DETECTION, PathogenTestResultType.POSITIVE);
creator.createPrescription(caze);
ImmunizationDto immunization = creator.createImmunization(caze.getDisease(), caze.getPerson(), caze.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 10), DateHelper.subtractDays(new Date(), 5), DateHelper.subtractDays(new Date(), 1), null);
creator.createImmunization(caze.getDisease(), caze.getPerson(), caze.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 8), DateHelper.subtractDays(new Date(), 7), null, null);
VaccinationDto firstVaccination = creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 7), Vaccine.OXFORD_ASTRA_ZENECA, VaccineManufacturer.ASTRA_ZENECA);
creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 4), Vaccine.MRNA_1273, VaccineManufacturer.MODERNA);
VaccinationDto thirdVaccination = creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), new Date(), Vaccine.COMIRNATY, VaccineManufacturer.BIONTECH_PFIZER);
final String primaryPhone = "0000444888";
final String primaryEmail = "primary@email.com";
cazePerson = getPersonFacade().getPersonByUuid(cazePerson.getUuid());
cazePerson.setPhone(primaryPhone);
cazePerson.setEmailAddress(primaryEmail);
cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.PHONE, PhoneNumberType.LANDLINE, "", "0265590500", "", false, "", ""));
cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.EMAIL, null, "", "secondary@email.com", "", false, "", ""));
cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.OTHER, null, "SkypeID", "personSkype", "", false, "", ""));
getPersonFacade().savePerson(cazePerson);
List<CaseExportDto> results = getCaseFacade().getExportList(new CaseCriteria(), Collections.emptySet(), CaseExportType.CASE_SURVEILLANCE, 0, 100, null, Language.EN);
// List should have one entry
assertEquals(1, results.size());
assertTrue(results.get(0).getSampleDateTime2().after(results.get(0).getSampleDateTime3()));
// Make sure that everything that is added retrospectively (symptoms, sample
// dates, lab results, address, travel history) is present
CaseExportDto exportDto = results.get(0);
assertNotNull(exportDto.getSymptoms());
// assertNotNull(exportDto.getSampleDateTime1());
// assertNotNull(exportDto.getSampleLab1());
// assertTrue(StringUtils.isNotEmpty(exportDto.getAddress()));
// assertTrue(StringUtils.isNotEmpty(exportDto.getTravelHistory()));
assertEquals(primaryPhone, exportDto.getPhone());
assertEquals(primaryEmail, exportDto.getEmailAddress());
final String otherContactDetails = exportDto.getOtherContactDetails();
assertTrue(otherContactDetails.contains("0265590500 (PHONE)"));
assertTrue(otherContactDetails.contains("secondary@email.com (EMAIL)"));
assertTrue(otherContactDetails.contains("personSkype (SkypeID)"));
assertEquals(VaccinationStatus.VACCINATED, exportDto.getVaccinationStatus());
assertEquals(thirdVaccination.getVaccineName(), exportDto.getVaccineName());
assertEquals(firstVaccination.getVaccinationDate(), exportDto.getFirstVaccinationDate());
assertEquals(thirdVaccination.getVaccinationDate(), exportDto.getLastVaccinationDate());
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testSymptomsUpdatedByVisit.
@Test
public void testSymptomsUpdatedByVisit() {
RDCF rdcf = creator.createRDCF();
UserReferenceDto user = creator.createUser(rdcf).toReference();
PersonReferenceDto cazePerson = creator.createPerson("Foo", "Bar").toReference();
CaseDataDto caze = creator.createCase(user, cazePerson, Disease.CORONAVIRUS, CaseClassification.NOT_CLASSIFIED, InvestigationStatus.PENDING, new Date(), rdcf);
caze.getSymptoms().setChestPain(SymptomState.YES);
// Add a new visit to the case
VisitDto visit = creator.createVisit(caze.getDisease(), caze.getPerson(), caze.getReportDate(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
visit.getSymptoms().setAbdominalPain(SymptomState.YES);
visit.getSymptoms().setChestPain(SymptomState.NO);
getCaseFacade().save(caze);
getVisitFacade().saveVisit(visit);
CaseDataDto updatedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
assertEquals(SymptomState.YES, updatedCase.getSymptoms().getChestPain());
assertEquals(SymptomState.YES, updatedCase.getSymptoms().getAbdominalPain());
// Update an existing visit
visit.getSymptoms().setAcuteRespiratoryDistressSyndrome(SymptomState.YES);
getVisitFacade().saveVisit(visit);
updatedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
assertEquals(SymptomState.YES, updatedCase.getSymptoms().getChestPain());
assertEquals(SymptomState.YES, updatedCase.getSymptoms().getAbdominalPain());
assertEquals(SymptomState.YES, updatedCase.getSymptoms().getAcuteRespiratoryDistressSyndrome());
assertTrue(updatedCase.getSymptoms().getSymptomatic());
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testCaseCriteriaSharedWithReportingTool.
@Test
public void testCaseCriteriaSharedWithReportingTool() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
CaseDataDto sharedCase = creator.createCase(user.toReference(), creator.createPerson().toReference(), rdcf);
ExternalShareInfo shareInfo = new ExternalShareInfo();
shareInfo.setCaze(getCaseService().getByUuid(sharedCase.getUuid()));
shareInfo.setSender(getUserService().getByUuid(user.getUuid()));
shareInfo.setStatus(ExternalShareStatus.SHARED);
getExternalShareInfoService().ensurePersisted(shareInfo);
CaseDataDto notSharedCase = creator.createCase(user.toReference(), creator.createPerson().toReference(), rdcf);
CaseCriteria caseCriteriaForShared = new CaseCriteria();
caseCriteriaForShared.setOnlyEntitiesSharedWithExternalSurvTool(true);
List<CaseIndexDto> indexList = getCaseFacade().getIndexList(caseCriteriaForShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedCase.getUuid()));
CaseCriteria caseCriteriaForNotShared = new CaseCriteria();
caseCriteriaForNotShared.setOnlyEntitiesNotSharedWithExternalSurvTool(true);
indexList = getCaseFacade().getIndexList(caseCriteriaForNotShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(notSharedCase.getUuid()));
}
Aggregations