Search in sources :

Example 6 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class VisitFacadeEjbTest method testGetIndexList.

@Test
public void testGetIndexList() {
    UserDto user = creator.createUser(creator.createRDCF(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto person = creator.createPerson();
    PersonDto person2 = creator.createPerson();
    PersonDto person3 = creator.createPerson();
    PersonDto person4 = creator.createPerson();
    PersonDto person5 = creator.createPerson();
    ContactDto contact = creator.createContact(user.toReference(), person.toReference());
    creator.createContact(user.toReference(), person2.toReference());
    ContactDto contact2 = creator.createContact(user.toReference(), person3.toReference());
    CaseDataDto caze = creator.createCase(user.toReference(), person5.toReference(), creator.createRDCF());
    creator.createCase(user.toReference(), person4.toReference(), creator.createRDCF());
    CaseDataDto caze2 = creator.createCase(user.toReference(), person3.toReference(), creator.createRDCF());
    creator.createVisit(person.toReference());
    creator.createVisit(person.toReference());
    creator.createVisit(person3.toReference());
    creator.createVisit(person3.toReference());
    creator.createVisit(person3.toReference());
    creator.createVisit(person5.toReference());
    VisitDto otherVisit = creator.createVisit(person2.toReference());
    VisitDto otherVisit2 = creator.createVisit(person4.toReference());
    List<VisitIndexDto> indexVisits = getVisitFacade().getIndexList(new VisitCriteria().contact(contact.toReference()), null, null, null);
    assertThat(indexVisits, hasSize(2));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
    indexVisits = getVisitFacade().getIndexList(new VisitCriteria().caze(caze.toReference()), null, null, null);
    assertThat(indexVisits, hasSize(1));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
    indexVisits = getVisitFacade().getIndexList(new VisitCriteria().contact(contact2.toReference()), null, null, null);
    assertThat(indexVisits, hasSize(3));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
    assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
    List<VisitIndexDto> indexVisits2 = getVisitFacade().getIndexList(new VisitCriteria().caze(caze2.toReference()), null, null, null);
    assertEquals(indexVisits.size(), indexVisits2.size());
    for (int i = 0; i < indexVisits.size(); ++i) {
        assertEquals(indexVisits.get(i).getUuid(), indexVisits2.get(i).getUuid());
    }
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) VisitIndexDto(de.symeda.sormas.api.visit.VisitIndexDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) VisitCriteria(de.symeda.sormas.api.visit.VisitCriteria) ExternalVisitDto(de.symeda.sormas.api.visit.ExternalVisitDto) VisitDto(de.symeda.sormas.api.visit.VisitDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 7 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class VisitFacadeEjbTest method testCreateExternalVisit.

@Test
public void testCreateExternalVisit() {
    TestDataCreator.RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Ext", "Vis", UserRole.REST_EXTERNAL_VISITS_USER);
    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);
    final ExternalVisitDto externalVisitDto = new ExternalVisitDto();
    externalVisitDto.setPersonUuid(contactPerson.getUuid());
    externalVisitDto.setDisease(contact.getDisease());
    externalVisitDto.setVisitDateTime(new Date());
    externalVisitDto.setVisitStatus(VisitStatus.COOPERATIVE);
    final String visitRemarks = "Everything good";
    externalVisitDto.setVisitRemarks(visitRemarks);
    final ExternalVisitDto externalVisitDto2 = new ExternalVisitDto();
    externalVisitDto2.setPersonUuid(cazePerson.getUuid());
    externalVisitDto2.setDisease(caze.getDisease());
    externalVisitDto2.setVisitDateTime(new Date());
    externalVisitDto2.setVisitStatus(VisitStatus.COOPERATIVE);
    final String visitRemarks2 = "Everything good 2";
    externalVisitDto2.setVisitRemarks(visitRemarks2);
    final VisitFacade visitFacade = getVisitFacade();
    visitFacade.saveExternalVisit(externalVisitDto);
    visitFacade.saveExternalVisit(externalVisitDto2);
    final VisitCriteria visitCriteria = new VisitCriteria();
    final List<VisitIndexDto> visitIndexList = visitFacade.getIndexList(visitCriteria.contact(new ContactReferenceDto(contact.getUuid())), 0, 100, null);
    assertNotNull(visitIndexList);
    assertEquals(1, visitIndexList.size());
    VisitIndexDto visitIndexDto = visitIndexList.get(0);
    assertNotNull(visitIndexDto.getVisitDateTime());
    assertEquals(VisitStatus.COOPERATIVE, visitIndexDto.getVisitStatus());
    assertEquals(visitRemarks, visitIndexDto.getVisitRemarks());
    assertEquals(VisitOrigin.EXTERNAL_JOURNAL, visitIndexDto.getOrigin());
    final VisitCriteria visitCriteria2 = new VisitCriteria();
    final List<VisitIndexDto> visitIndexList2 = visitFacade.getIndexList(visitCriteria2.caze(new CaseReferenceDto(caze.getUuid())), 0, 100, null);
    assertNotNull(visitIndexList2);
    assertEquals(1, visitIndexList2.size());
    VisitIndexDto visitIndexDto2 = visitIndexList2.get(0);
    assertNotNull(visitIndexDto2.getVisitDateTime());
    assertEquals(VisitStatus.COOPERATIVE, visitIndexDto2.getVisitStatus());
    assertEquals(visitRemarks2, visitIndexDto2.getVisitRemarks());
    assertEquals(VisitOrigin.EXTERNAL_JOURNAL, visitIndexDto.getOrigin());
}
Also used : ExternalVisitDto(de.symeda.sormas.api.visit.ExternalVisitDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Date(java.util.Date) VisitIndexDto(de.symeda.sormas.api.visit.VisitIndexDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) VisitCriteria(de.symeda.sormas.api.visit.VisitCriteria) VisitFacade(de.symeda.sormas.api.visit.VisitFacade) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 8 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class CaseImportEntities method createCase.

public static CaseDataDto createCase(PersonDto person, UserReferenceDto reportingUser) {
    CaseDataDto caze = CaseDataDto.build(person.toReference(), null);
    caze.setReportingUser(reportingUser);
    return caze;
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto)

Example 9 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class EntityDtoAccessHelperTest method setup.

@Before
public void setup() {
    caseDataDto = new CaseDataDto();
    caseDataDto.setDisease(Disease.DENGUE);
    caseDataDto.setUuid("ABCDEF");
    hospitalizationDto = new HospitalizationDto();
    hospitalizationDto.setDischargeDate(new Date(1600387200000L));
    hospitalizationDto.setIsolated(YesNoUnknown.NO);
    personReferenceDto = new PersonReferenceDto();
    personReferenceDto.setUuid("GHIJKL");
    personDto = new PersonDto();
    personDto.setUuid("GHIJKL");
    personDto.setFirstName("Tenzing");
    personDto.setLastName("Mike");
    personDto.setBirthdateDD(26);
    personDto.setBirthdateMM(11);
    personDto.setBirthdateYYYY(1973);
    personDto.setPhone("+49 681 1234");
    LocationDto address = new LocationDto();
    address.setStreet("Elm Street");
    personDto.setAddress(address);
    referenceDtoResolver = new IReferenceDtoResolver() {

        @Override
        public EntityDto resolve(ReferenceDto referenceDto) {
            if (referenceDto != null && "GHIJKL".equals(referenceDto.getUuid())) {
                return personDto;
            }
            return null;
        }
    };
}
Also used : PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) IReferenceDtoResolver(de.symeda.sormas.api.EntityDtoAccessHelper.IReferenceDtoResolver) Date(java.util.Date) LocationDto(de.symeda.sormas.api.location.LocationDto) Before(org.junit.Before)

Example 10 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjb method onCaseSampleChanged.

public void onCaseSampleChanged(Case associatedCase) {
    // Update case classification if the feature is enabled
    if (configFacade.isFeatureAutomaticCaseClassification()) {
        if (associatedCase.getCaseClassification() != CaseClassification.NO_CASE) {
            Long pathogenTestsCount = pathogenTestService.countByCase(associatedCase);
            if (pathogenTestsCount == 0) {
                return;
            }
            // calculate classification
            CaseDataDto newCaseDto = toDto(associatedCase);
            CaseClassification classification = caseClassificationFacade.getClassification(newCaseDto);
            // only update when classification by system changes - user may overwrite this
            if (classification != associatedCase.getSystemCaseClassification()) {
                associatedCase.setSystemCaseClassification(classification);
                // really a change? (user may have already set it)
                if (classification != associatedCase.getCaseClassification()) {
                    associatedCase.setCaseClassification(classification);
                    associatedCase.setClassificationUser(null);
                    associatedCase.setClassificationDate(new Date());
                }
            }
        }
    }
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) AtomicLong(java.util.concurrent.atomic.AtomicLong) Date(java.util.Date) LocalDate(java.time.LocalDate) ExternalShareInfoCountAndLatestDate(de.symeda.sormas.backend.share.ExternalShareInfoCountAndLatestDate)

Aggregations

CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)395 Test (org.junit.Test)287 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)239 PersonDto (de.symeda.sormas.api.person.PersonDto)174 Date (java.util.Date)159 UserDto (de.symeda.sormas.api.user.UserDto)140 ContactDto (de.symeda.sormas.api.contact.ContactDto)102 SampleDto (de.symeda.sormas.api.sample.SampleDto)74 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)62 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)58 LocalDate (java.time.LocalDate)57 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)43 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)43 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)43 List (java.util.List)42 Disease (de.symeda.sormas.api.Disease)40 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)36 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)36 ArrayList (java.util.ArrayList)35 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)34