use of de.symeda.sormas.api.immunization.ImmunizationReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class VaccinationFacadeEjbTest method testSave.
@Test
public void testSave() {
loginWith(nationalUser);
PersonDto person = creator.createPerson("John", "Doe");
ImmunizationDto immunizationDto = creator.createImmunization(Disease.CORONAVIRUS, person.toReference(), nationalUser.toReference(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf1);
HealthConditionsDto healthConditions = new HealthConditionsDto();
healthConditions.setOtherConditions("PEBMAC");
VaccinationDto vaccinationDto = creator.createVaccination(nationalUser.toReference(), new ImmunizationReferenceDto(immunizationDto.getUuid(), immunizationDto.toString(), immunizationDto.getExternalId()), healthConditions);
Vaccination actualVaccination = getVaccinationService().getByUuid(vaccinationDto.getUuid());
assertThat(actualVaccination.getUuid(), equalTo(vaccinationDto.getUuid()));
assertThat(vaccinationDto.getHealthConditions().getOtherConditions(), equalTo("PEBMAC"));
ImmunizationDto actualImmunization = getImmunizationFacade().getByUuid(immunizationDto.getUuid());
assertThat(actualImmunization.getVaccinations(), hasSize(1));
assertThat(actualImmunization.getVaccinations().get(0).getUuid(), equalTo(vaccinationDto.getUuid()));
}
use of de.symeda.sormas.api.immunization.ImmunizationReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class VaccinationFacadeEjbTest method testCreate.
@Test
public void testCreate() {
loginWith(nationalUser);
PersonDto person1 = creator.createPerson("John", "Doe");
PersonDto person2 = creator.createPerson("Jane", "Doe");
Disease disease1 = Disease.CORONAVIRUS;
Disease disease2 = Disease.CHOLERA;
// Immunization association case 1 covered
VaccinationDto vaccination11 = VaccinationDto.build(nationalUser.toReference());
vaccination11 = getVaccinationFacade().createWithImmunization(vaccination11, rdcf1.region, rdcf1.district, person1.toReference(), disease1);
ImmunizationReferenceDto immunization11 = vaccination11.getImmunization();
assertNotNull(immunization11);
VaccinationDto vaccination12 = VaccinationDto.build(nationalUser.toReference());
vaccination12 = getVaccinationFacade().createWithImmunization(vaccination12, rdcf1.region, rdcf1.district, person1.toReference(), disease1);
ImmunizationReferenceDto immunization12 = vaccination12.getImmunization();
assertEquals(immunization11, immunization12);
VaccinationDto vaccination13 = VaccinationDto.build(nationalUser.toReference());
vaccination13 = getVaccinationFacade().createWithImmunization(vaccination13, rdcf1.region, rdcf1.district, person1.toReference(), disease2);
ImmunizationReferenceDto immunization13 = vaccination13.getImmunization();
assertNotEquals(immunization11, immunization13);
VaccinationDto vaccination21 = VaccinationDto.build(nationalUser.toReference());
vaccination21 = getVaccinationFacade().createWithImmunization(vaccination21, rdcf1.region, rdcf1.district, person2.toReference(), disease1);
ImmunizationReferenceDto immunization21 = vaccination21.getImmunization();
assertNotEquals(immunization11, immunization21);
VaccinationDto vaccination22 = VaccinationDto.build(nationalUser.toReference());
vaccination22 = getVaccinationFacade().createWithImmunization(vaccination22, rdcf1.region, rdcf1.district, person2.toReference(), disease2);
ImmunizationReferenceDto immunization22 = vaccination22.getImmunization();
assertNotEquals(immunization21, immunization22);
// Test correct association based on dates
PersonDto person3 = creator.createPerson("James", "Doe");
Date referenceDate = new Date();
ImmunizationDto immunizationStartEnd = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
i.setStartDate(DateHelper.subtractDays(referenceDate, 400));
i.setEndDate(DateHelper.subtractDays(referenceDate, 380));
});
ImmunizationDto immunizationStart = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
i.setStartDate(DateHelper.subtractDays(referenceDate, 420));
});
creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
i.setEndDate(DateHelper.subtractDays(referenceDate, 390));
});
ImmunizationDto immunizationReport = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1);
ImmunizationDto immunizationReport2 = creator.createImmunization(disease2, person3.toReference(), nationalUser.toReference(), rdcf1);
// Immunization association case 2 covered
VaccinationDto vaccination31 = VaccinationDto.build(nationalUser.toReference());
vaccination31.setVaccinationDate(DateHelper.subtractDays(referenceDate, 390));
vaccination31 = getVaccinationFacade().createWithImmunization(vaccination31, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
assertEquals(vaccination31.getImmunization(), immunizationStartEnd.toReference());
// Immunization association case 3 covered
VaccinationDto vaccination32 = VaccinationDto.build(nationalUser.toReference());
vaccination32.setVaccinationDate(DateHelper.subtractDays(referenceDate, 415));
vaccination32 = getVaccinationFacade().createWithImmunization(vaccination32, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
assertEquals(vaccination32.getImmunization(), immunizationStart.toReference());
// Immunization association case 3 covered
VaccinationDto vaccination33 = VaccinationDto.build(nationalUser.toReference());
vaccination33.setVaccinationDate(DateHelper.subtractDays(referenceDate, 0));
vaccination33 = getVaccinationFacade().createWithImmunization(vaccination33, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
assertEquals(vaccination33.getImmunization(), immunizationStartEnd.toReference());
// Immunization association case 4 covered
VaccinationDto vaccination34 = VaccinationDto.build(nationalUser.toReference());
vaccination34.setVaccinationDate(DateHelper.subtractDays(referenceDate, 100));
vaccination34 = getVaccinationFacade().createWithImmunization(vaccination34, rdcf1.region, rdcf1.district, person3.toReference(), disease2);
assertEquals(vaccination34.getImmunization(), immunizationReport2.toReference());
// Immunization association case 4 covered
VaccinationDto vaccination35 = VaccinationDto.build(nationalUser.toReference());
vaccination35 = getVaccinationFacade().createWithImmunization(vaccination35, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
assertThat(vaccination35.getImmunization(), anyOf(is(immunizationReport.toReference()), is(immunizationReport2.toReference())));
// Ignore immunizations with a means of immunization that does not include vaccination
PersonDto person4 = creator.createPerson("Johanna", "Doe");
ImmunizationDto recoveryImmunization = creator.createImmunization(disease1, person4.toReference(), nationalUser.toReference(), rdcf1, i -> i.setMeansOfImmunization(MeansOfImmunization.RECOVERY));
VaccinationDto vaccination41 = VaccinationDto.build(nationalUser.toReference());
vaccination41 = getVaccinationFacade().createWithImmunization(vaccination41, rdcf1.region, rdcf1.district, person4.toReference(), disease1);
assertNotEquals(vaccination41.getImmunization(), recoveryImmunization.toReference());
}
Aggregations