Search in sources :

Example 1 with HealthConditionsDto

use of de.symeda.sormas.api.clinicalcourse.HealthConditionsDto in project SORMAS-Project by hzi-braunschweig.

the class DtoHelperTest method testFillDto.

@Test
public void testFillDto() {
    RDCFEntities rdcf = creator.createRDCFEntities();
    RDCFEntities rdcf2 = creator.createRDCFEntities();
    rdcf2.facility.setType(FacilityType.LABORATORY);
    UserDto user = creator.createUser(rdcf, UserRole.ADMIN);
    // Test simple values
    {
        HealthConditionsDto targetDto = new HealthConditionsDto();
        HealthConditionsDto sourceDto = new HealthConditionsDto();
        // lead and other have different values
        targetDto.setTuberculosis(YesNoUnknown.YES);
        sourceDto.setTuberculosis(YesNoUnknown.NO);
        // lead has value, other has not
        targetDto.setAsplenia(YesNoUnknown.YES);
        // lead has no value, other has
        sourceDto.setDiabetes(YesNoUnknown.YES);
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        // Check no values
        assertNull(targetDto.getHiv());
        // Check 'lead and other have different values'
        assertNotEquals(sourceDto.getTuberculosis(), targetDto.getTuberculosis());
        // Check 'lead has value, other has not'
        assertEquals(YesNoUnknown.YES, targetDto.getAsplenia());
        assertNull(sourceDto.getAsplenia());
        // Check 'lead has no value, other has'
        assertEquals(sourceDto.getDiabetes(), targetDto.getDiabetes());
    }
    // Test complex subDto
    {
        PersonDto person = creator.createPerson("First", "Last");
        CaseDataDto targetDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        CaseDataDto sourceDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        SymptomsDto targetSymptomsDto = targetDto.getSymptoms();
        SymptomsDto sourceSymptomsDto = sourceDto.getSymptoms();
        // lead and other have different values
        SymptomState abdominalPain = SymptomState.NO;
        targetSymptomsDto.setAbdominalPain(abdominalPain);
        sourceSymptomsDto.setAbdominalPain(SymptomState.UNKNOWN);
        // lead has value, other has not
        SymptomState alteredConsciousness = SymptomState.YES;
        targetSymptomsDto.setAlteredConsciousness(alteredConsciousness);
        // lead has no value, other has
        SymptomState anorexiaAppetiteLoss = SymptomState.UNKNOWN;
        sourceSymptomsDto.setAnorexiaAppetiteLoss(anorexiaAppetiteLoss);
        targetDto.setSymptoms(targetSymptomsDto);
        sourceDto.setSymptoms(sourceSymptomsDto);
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        // Check no values
        assertNull(targetDto.getSymptoms().getBackache());
        // Check 'lead and other have different values'
        assertEquals(abdominalPain, targetDto.getSymptoms().getAbdominalPain());
        // Check 'lead has value, other has not'
        assertEquals(alteredConsciousness, targetDto.getSymptoms().getAlteredConsciousness());
        // Check 'lead has no value, other has'
        assertEquals(anorexiaAppetiteLoss, targetDto.getSymptoms().getAnorexiaAppetiteLoss());
    }
    // Test List
    {
        PersonDto person = creator.createPerson("First", "Last");
        CaseDataDto targetDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        CaseDataDto sourceDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        ExposureDto subDto1 = ExposureDto.build(ExposureType.TRAVEL);
        ExposureDto subDto2 = ExposureDto.build(ExposureType.TRAVEL);
        // lead and other have different values
        ArrayList<ExposureDto> targetList1 = new ArrayList<>();
        targetList1.add(subDto1);
        ArrayList<ExposureDto> sourceList1 = new ArrayList<>();
        sourceList1.add(subDto2);
        // lead has values, other has not
        ArrayList<ExposureDto> targetList2 = new ArrayList<>();
        targetList2.add(subDto1);
        targetList2.add(subDto2);
        // lead has no values, other has
        ArrayList<ExposureDto> sourceList2 = new ArrayList<>();
        sourceList2.add(subDto1);
        sourceList2.add(subDto2);
        // Check no values
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        assertTrue(targetDto.getEpiData().getExposures().isEmpty());
        // Check 'lead has still same entries'
        targetDto.getEpiData().setExposures(targetList1);
        sourceDto.getEpiData().setExposures(sourceList1);
        String existingUuid = targetList1.get(0).getUuid();
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        assertEquals(targetList1.size(), targetDto.getEpiData().getExposures().size());
        assertNotNull(targetDto.getEpiData().getExposures().get(0).getUuid());
        assertEquals(existingUuid, targetDto.getEpiData().getExposures().get(0).getUuid());
        assertNotEquals(existingUuid, sourceDto.getEpiData().getExposures().get(0).getUuid());
        // Check 'lead has value, other has not'
        targetDto.getEpiData().setExposures(targetList2);
        sourceDto.getEpiData().setExposures(null);
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        assertNotNull(targetDto.getEpiData().getExposures().get(0).getUuid());
        assertEquals(targetList2.size(), targetDto.getEpiData().getExposures().size());
        assertEquals(targetList2.get(0).getUuid(), targetDto.getEpiData().getExposures().get(0).getUuid());
        assertEquals(targetList2.get(1).getUuid(), targetDto.getEpiData().getExposures().get(1).getUuid());
        // Check 'lead has no value, other has'
        targetDto.getEpiData().setExposures(null);
        sourceDto.getEpiData().setExposures(sourceList2);
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        assertNotNull(targetDto.getEpiData().getExposures().get(0).getUuid());
        assertEquals(sourceList2.size(), targetDto.getEpiData().getExposures().size());
        assertNotEquals(sourceList2.get(0).getUuid(), targetDto.getEpiData().getExposures().get(0).getUuid());
        assertNotEquals(sourceList2.get(1).getUuid(), targetDto.getEpiData().getExposures().get(1).getUuid());
    }
    // test non-entity list
    {
        PersonDto person = creator.createPerson("First", "Last");
        CaseDataDto targetCaseDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        CaseDataDto sourceCaseDto = creator.createCase(user.toReference(), person.toReference(), rdcf);
        SampleDto sourceDto = creator.createSample(sourceCaseDto.toReference(), user.toReference(), rdcf2.facility);
        sourceDto.setPathogenTestingRequested(true);
        sourceDto.getRequestedPathogenTests().add(PathogenTestType.ANTIGEN_DETECTION);
        sourceDto.getRequestedPathogenTests().add(PathogenTestType.NEUTRALIZING_ANTIBODIES);
        SampleDto targetDto = SampleDto.build(user.toReference(), targetCaseDto.toReference());
        DtoHelper.copyDtoValues(targetDto, sourceDto, false);
        assertEquals(2, targetDto.getRequestedPathogenTests().size());
    }
    // test map
    {
        TestDataCreator.RDCF caseRdcf = creator.createRDCF();
        Map<ReinfectionDetail, Boolean> map1 = new EnumMap<>(ReinfectionDetail.class);
        map1.put(ReinfectionDetail.GENOME_SEQUENCE_CURRENT_INFECTION_KNOWN, true);
        map1.put(ReinfectionDetail.PREVIOUS_ASYMPTOMATIC_INFECTION, true);
        map1.put(ReinfectionDetail.LAST_PCR_DETECTION_NOT_RECENT, false);
        PersonDto person = creator.createPerson();
        CaseDataDto sourceCase = creator.createCase(user.toReference(), person.toReference(), caseRdcf);
        CaseDataDto targetCase = creator.createCase(user.toReference(), person.toReference(), caseRdcf);
        // Map must not be persisted because H2 can't map it to JSON
        sourceCase.setReinfectionDetails(map1);
        DtoHelper.copyDtoValues(targetCase, sourceCase, false);
        assertEquals(3, targetCase.getReinfectionDetails().size());
        sourceCase.getReinfectionDetails().put(ReinfectionDetail.PREVIOUS_ASYMPTOMATIC_INFECTION, false);
        sourceCase.getReinfectionDetails().put(ReinfectionDetail.TESTED_NEGATIVE_AFTER_PREVIOUS_INFECTION, true);
        DtoHelper.copyDtoValues(targetCase, sourceCase, false);
        assertEquals(4, targetCase.getReinfectionDetails().size());
        assertTrue(targetCase.getReinfectionDetails().get(ReinfectionDetail.PREVIOUS_ASYMPTOMATIC_INFECTION));
        DtoHelper.copyDtoValues(targetCase, sourceCase, true);
        assertEquals(4, targetCase.getReinfectionDetails().size());
        assertFalse(targetCase.getReinfectionDetails().get(ReinfectionDetail.PREVIOUS_ASYMPTOMATIC_INFECTION));
        sourceCase.setReinfectionDetails(null);
        DtoHelper.copyDtoValues(targetCase, sourceCase, false);
        assertEquals(4, targetCase.getReinfectionDetails().size());
        DtoHelper.copyDtoValues(targetCase, sourceCase, true);
        assertEquals(4, targetCase.getReinfectionDetails().size());
    }
}
Also used : SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) SymptomState(de.symeda.sormas.api.symptoms.SymptomState) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ReinfectionDetail(de.symeda.sormas.api.caze.ReinfectionDetail) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ArrayList(java.util.ArrayList) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Map(java.util.Map) EnumMap(java.util.EnumMap) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with HealthConditionsDto

use of de.symeda.sormas.api.clinicalcourse.HealthConditionsDto 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()));
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ImmunizationReferenceDto(de.symeda.sormas.api.immunization.ImmunizationReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 3 with HealthConditionsDto

use of de.symeda.sormas.api.clinicalcourse.HealthConditionsDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFacadeEjbTest method testNoImmunizationStatusUpdateWhenExpired.

@Test
public void testNoImmunizationStatusUpdateWhenExpired() {
    loginWith(nationalUser);
    final PersonDto person = creator.createPerson("John", "Doe");
    final ImmunizationDto immunization = creator.createImmunizationDto(Disease.DENGUE, person.toReference(), nationalUser.toReference(), ImmunizationStatus.EXPIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.SCHEDULED, rdcf1);
    immunization.setNumberOfDoses(2);
    immunization.setStartDate(DateHelper.subtractDays(new Date(), 1));
    immunization.setVaccinations(Arrays.asList(creator.createVaccinationDto(nationalUser.toReference(), immunization.toReference(), new HealthConditionsDto()), creator.createVaccinationDto(nationalUser.toReference(), immunization.toReference(), new HealthConditionsDto())));
    getImmunizationFacade().save(immunization);
    final ImmunizationDto immWithTwoVac = getImmunizationFacade().getByUuid(immunization.getUuid());
    Assert.assertEquals(2, immWithTwoVac.getVaccinations().size());
    Assert.assertEquals(ImmunizationManagementStatus.SCHEDULED, immWithTwoVac.getImmunizationManagementStatus());
    Assert.assertEquals(ImmunizationStatus.EXPIRED, immWithTwoVac.getImmunizationStatus());
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 4 with HealthConditionsDto

use of de.symeda.sormas.api.clinicalcourse.HealthConditionsDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFacadeEjbTest method testUpdateImmunizationStatusBasedOnVaccinationsOngoing.

@Test
public void testUpdateImmunizationStatusBasedOnVaccinationsOngoing() {
    loginWith(nationalUser);
    final PersonDto person = creator.createPerson("John", "Doe");
    final ImmunizationDto immunization = creator.createImmunizationDto(Disease.DENGUE, person.toReference(), nationalUser.toReference(), ImmunizationStatus.PENDING, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.SCHEDULED, rdcf1);
    immunization.setNumberOfDoses(2);
    immunization.setStartDate(DateHelper.subtractDays(new Date(), 1));
    immunization.setVaccinations(Arrays.asList(creator.createVaccinationDto(nationalUser.toReference(), immunization.toReference(), new HealthConditionsDto())));
    getImmunizationFacade().save(immunization);
    final ImmunizationDto immWithOneVac = getImmunizationFacade().getByUuid(immunization.getUuid());
    Assert.assertEquals(1, immWithOneVac.getVaccinations().size());
    Assert.assertEquals(ImmunizationManagementStatus.ONGOING, immWithOneVac.getImmunizationManagementStatus());
    Assert.assertEquals(ImmunizationStatus.PENDING, immWithOneVac.getImmunizationStatus());
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with HealthConditionsDto

use of de.symeda.sormas.api.clinicalcourse.HealthConditionsDto in project SORMAS-Project by hzi-braunschweig.

the class CaseClassificationLogicTest method createImmunizationWithVaccination.

private void createImmunizationWithVaccination(CaseDataDto caze, Date vaccinationDate) {
    ImmunizationDto immunization = creator.createImmunization(caze.getDisease(), caze.getPerson(), caze.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, new TestDataCreator.RDCF(caze.getRegion(), caze.getDistrict(), caze.getCommunity(), caze.getHealthFacility()));
    VaccinationDto vaccination = creator.createVaccination(caze.getReportingUser(), immunization.toReference(), new HealthConditionsDto());
    vaccination.setVaccinationDate(vaccinationDate);
    getVaccinationFacade().save(vaccination);
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)

Aggregations

HealthConditionsDto (de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)9 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)7 Test (org.junit.Test)7 ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)6 PersonDto (de.symeda.sormas.api.person.PersonDto)6 Date (java.util.Date)5 VaccinationDto (de.symeda.sormas.api.vaccination.VaccinationDto)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 ReinfectionDetail (de.symeda.sormas.api.caze.ReinfectionDetail)1 ContactDto (de.symeda.sormas.api.contact.ContactDto)1 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)1 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)1 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)1 ImmunizationReferenceDto (de.symeda.sormas.api.immunization.ImmunizationReferenceDto)1 SampleDto (de.symeda.sormas.api.sample.SampleDto)1 SymptomState (de.symeda.sormas.api.symptoms.SymptomState)1 SymptomsDto (de.symeda.sormas.api.symptoms.SymptomsDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)1 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)1