Search in sources :

Example 21 with VisitDto

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

the class VisitController method editVisit.

public void editVisit(String visitUuid, ContactReferenceDto contactRef, CaseReferenceDto caseRef, Consumer<VisitReferenceDto> doneConsumer) {
    VisitDto visit = FacadeProvider.getVisitFacade().getVisitByUuid(visitUuid);
    VisitEditForm editForm;
    if (contactRef != null) {
        ContactDto contact = FacadeProvider.getContactFacade().getByUuid(contactRef.getUuid());
        PersonDto visitPerson = FacadeProvider.getPersonFacade().getPersonByUuid(visit.getPerson().getUuid());
        editForm = new VisitEditForm(visit.getDisease(), contact, visitPerson, false, !contact.isPseudonymized());
    } else if (caseRef != null) {
        CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
        PersonDto visitPerson = FacadeProvider.getPersonFacade().getPersonByUuid(visit.getPerson().getUuid());
        editForm = new VisitEditForm(visit.getDisease(), caze, visitPerson, false, !caze.isPseudonymized());
    } else {
        throw new IllegalArgumentException("Cannot edit a visit without contact nor case");
    }
    editForm.setValue(visit);
    boolean canEdit = VisitOrigin.USER.equals(visit.getOrigin());
    editVisit(editForm, visit.toReference(), doneConsumer, canEdit);
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) VisitDto(de.symeda.sormas.api.visit.VisitDto)

Example 22 with VisitDto

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

the class TestDataCreator method createVisit.

public VisitDto createVisit(Disease disease, PersonReferenceDto contactPerson, Date visitDateTime, VisitStatus visitStatus) {
    VisitDto visit = VisitDto.build(contactPerson, disease, VisitOrigin.USER);
    visit.setVisitDateTime(visitDateTime);
    visit.setVisitStatus(visitStatus);
    visit = FacadeProvider.getVisitFacade().saveVisit(visit);
    return visit;
}
Also used : VisitDto(de.symeda.sormas.api.visit.VisitDto)

Example 23 with VisitDto

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

the class VisitFacadeEjb method convertToDto.

public VisitDto convertToDto(Visit source, Pseudonymizer pseudonymizer) {
    VisitDto visitDto = toDto(source);
    pseudonymizeDto(source, visitDto, pseudonymizer);
    return visitDto;
}
Also used : ExternalVisitDto(de.symeda.sormas.api.visit.ExternalVisitDto) VisitDto(de.symeda.sormas.api.visit.VisitDto)

Example 24 with VisitDto

use of de.symeda.sormas.api.visit.VisitDto 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)

Example 25 with VisitDto

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

the class ContactFacadeEjbTest method testContactDeletion.

@Test
public void testContactDeletion() {
    Date since = new Date();
    RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    UserDto admin = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Another", "Admin", UserRole.ADMIN);
    String adminUuid = admin.getUuid();
    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);
    VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), DateUtils.addDays(new Date(), 21), VisitStatus.UNAVAILABLE, VisitOrigin.USER);
    TaskDto task = creator.createTask(TaskContext.CONTACT, TaskType.CONTACT_INVESTIGATION, TaskStatus.PENDING, null, contact.toReference(), null, new Date(), user.toReference());
    SampleDto sample = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    SampleDto sample2 = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    sample2.setAssociatedCase(new CaseReferenceDto(caze.getUuid()));
    getSampleFacade().saveSample(sample2);
    // Database should contain the created contact, visit and task
    assertNotNull(getContactFacade().getByUuid(contact.getUuid()));
    assertNotNull(getTaskFacade().getByUuid(task.getUuid()));
    assertNotNull(getVisitFacade().getVisitByUuid(visit.getUuid()));
    assertNotNull(getSampleFacade().getSampleByUuid(sample.getUuid()));
    getContactFacade().deleteContact(contact.getUuid());
    // Deleted flag should be set for contact; Task should be deleted
    assertTrue(getContactFacade().getDeletedUuidsSince(since).contains(contact.getUuid()));
    // Can't delete visit because it might be associated with other contacts as well
    // assertNull(getVisitFacade().getVisitByUuid(visit.getUuid()));
    assertNull(getTaskFacade().getByUuid(task.getUuid()));
    assertTrue(getSampleFacade().getDeletedUuidsSince(since).contains(sample.getUuid()));
    assertFalse(getSampleFacade().getDeletedUuidsSince(since).contains(sample2.getUuid()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) VisitDto(de.symeda.sormas.api.visit.VisitDto) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) TaskDto(de.symeda.sormas.api.task.TaskDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) LocalDate(java.time.LocalDate) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

VisitDto (de.symeda.sormas.api.visit.VisitDto)44 PersonDto (de.symeda.sormas.api.person.PersonDto)27 Test (org.junit.Test)25 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)24 Date (java.util.Date)24 ContactDto (de.symeda.sormas.api.contact.ContactDto)22 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)20 UserDto (de.symeda.sormas.api.user.UserDto)19 ExternalVisitDto (de.symeda.sormas.api.visit.ExternalVisitDto)14 LocalDate (java.time.LocalDate)11 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)10 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)8 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)7 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)7 VisitCriteria (de.symeda.sormas.api.visit.VisitCriteria)7 ArrayList (java.util.ArrayList)7 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)6 ClinicalVisitDto (de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto)5 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)5 SampleDto (de.symeda.sormas.api.sample.SampleDto)4