Search in sources :

Example 1 with ExternalVisitDto

use of de.symeda.sormas.api.visit.ExternalVisitDto 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 2 with ExternalVisitDto

use of de.symeda.sormas.api.visit.ExternalVisitDto in project SORMAS-Project by hzi-braunschweig.

the class VisitFacadeEjb method saveExternalVisit.

@Override
public ExternalVisitDto saveExternalVisit(@Valid final ExternalVisitDto dto) {
    final String personUuid = dto.getPersonUuid();
    final UserReferenceDto currentUser = new UserReferenceDto(userService.getCurrentUser().getUuid());
    final VisitDto visitDto = VisitDto.build(new PersonReferenceDto(personUuid), dto.getDisease(), dto.getVisitDateTime(), currentUser, dto.getVisitStatus(), dto.getVisitRemarks(), dto.getSymptoms(), dto.getReportLat(), dto.getReportLon(), dto.getReportLatLonAccuracy(), VisitOrigin.EXTERNAL_JOURNAL);
    saveVisit(visitDto);
    return ExternalVisitDto.build(personUuid, visitDto.getDisease(), visitDto.getVisitDateTime(), visitDto.getVisitStatus(), visitDto.getVisitRemarks(), visitDto.getSymptoms(), visitDto.getReportLat(), visitDto.getReportLon(), visitDto.getReportLatLonAccuracy());
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) ExternalVisitDto(de.symeda.sormas.api.visit.ExternalVisitDto) VisitDto(de.symeda.sormas.api.visit.VisitDto)

Aggregations

ExternalVisitDto (de.symeda.sormas.api.visit.ExternalVisitDto)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)1 ContactDto (de.symeda.sormas.api.contact.ContactDto)1 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)1 VisitCriteria (de.symeda.sormas.api.visit.VisitCriteria)1 VisitDto (de.symeda.sormas.api.visit.VisitDto)1 VisitFacade (de.symeda.sormas.api.visit.VisitFacade)1 VisitIndexDto (de.symeda.sormas.api.visit.VisitIndexDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)1 Date (java.util.Date)1 Test (org.junit.Test)1