Search in sources :

Example 11 with LocationDto

use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.

the class QuarantineOrderFacadeEjbTest method setup.

@Before
public void setup() throws URISyntaxException {
    TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility", "PointOfEntry");
    UserDto userDto = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    loginWith(userDto);
    quarantineOrderFacadeEjb = getQuarantineOrderFacade();
    reset();
    LocationDto locationDto = new LocationDto();
    locationDto.setStreet("Nauwieserstraße");
    locationDto.setHouseNumber("7");
    locationDto.setCity("Saarbrücken");
    locationDto.setPostalCode("66111");
    PersonDto personDto = PersonDto.build();
    personDto.setFirstName("Guy");
    personDto.setLastName("Debord");
    personDto.setSex(Sex.UNKNOWN);
    personDto.setBirthdateYYYY(1931);
    personDto.setBirthdateMM(12);
    personDto.setBirthdateDD(28);
    personDto.setAddress(locationDto);
    personDto.setPhone("+49 681 1234");
    getPersonFacade().savePerson(personDto);
    caseDataDto = creator.createCase(userDto.toReference(), rdcf, (c) -> {
        c.setDisease(Disease.CORONAVIRUS);
        c.setPerson(personDto.toReference());
        c.setQuarantineFrom(parseDate("10/09/2020"));
        c.setQuarantineTo(parseDate("24/09/2020"));
        c.setQuarantineOrderedOfficialDocumentDate(parseDate("09/09/2020"));
    });
    contactDto = creator.createContact(userDto.toReference(), personDto.toReference());
    contactDto.setCaze(caseDataDto.toReference());
    contactDto.setQuarantineFrom(parseDate("10/09/2020"));
    contactDto.setQuarantineTo(parseDate("24/09/2020"));
    contactDto.setQuarantineOrderedOfficialDocumentDate(parseDate("09/09/2020"));
    getContactFacade().save(contactDto);
    eventDto = creator.createEvent(userDto.toReference());
    eventDto.setEventTitle("An event");
    getEventFacade().save(eventDto);
    eventParticipantDto = creator.createEventParticipant(eventDto.toReference(), personDto, "participated", userDto.toReference());
    sampleDto = SampleDto.build(userDto.toReference(), caseDataDto.toReference());
    sampleDto.setSampleDateTime(parseDate("11/09/2020"));
    sampleDto.setSampleMaterial(SampleMaterial.NASAL_SWAB);
    sampleDto.setPathogenTestResult(PathogenTestResultType.NEGATIVE);
    sampleDto.setSamplePurpose(SamplePurpose.EXTERNAL);
    sampleDto = getSampleFacade().saveSample(sampleDto);
    pathogenTestDto = PathogenTestDto.build(sampleDto.toReference(), userDto.toReference());
    pathogenTestDto.setTestDateTime(parseDate("12/09/2020"));
    pathogenTestDto.setTestedDisease(Disease.CORONAVIRUS);
    pathogenTestDto.setTestResult(PathogenTestResultType.POSITIVE);
    pathogenTestDto.setTestResultVerified(false);
    pathogenTestDto.setTestType(PathogenTestType.ANTIBODY_DETECTION);
    pathogenTestDto = getPathogenTestFacade().savePathogenTest(pathogenTestDto);
    travelEntryDto = TravelEntryDto.build(personDto.toReference());
    travelEntryDto.setUuid("VQCJU2-DZPOBO-7FWMLV-G3F3SACI");
    travelEntryDto.setReportDate(parseDate("09/01/2021"));
    travelEntryDto.setReportingUser(userDto.toReference());
    travelEntryDto.setDateOfArrival(new Date());
    travelEntryDto.setPointOfEntry(rdcf.pointOfEntry);
    // To survive validation:
    travelEntryDto.setDisease(Disease.CORONAVIRUS);
    travelEntryDto.setResponsibleRegion(rdcf.region);
    travelEntryDto.setResponsibleDistrict(rdcf.district);
    travelEntryDto = getTravelEntryFacade().save(travelEntryDto);
}
Also used : Arrays(java.util.Arrays) XWPFDocument(org.apache.poi.xwpf.usermodel.XWPFDocument) Date(java.util.Date) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) URISyntaxException(java.net.URISyntaxException) ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) PersonDto(de.symeda.sormas.api.person.PersonDto) QuarantineOrderFacade(de.symeda.sormas.api.docgeneneration.QuarantineOrderFacade) XWPFWordExtractor(org.apache.poi.xwpf.extractor.XWPFWordExtractor) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) UserRole(de.symeda.sormas.api.user.UserRole) ParseException(java.text.ParseException) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) DocumentTemplateException(de.symeda.sormas.api.docgeneneration.DocumentTemplateException) DocumentVariables(de.symeda.sormas.api.docgeneneration.DocumentVariables) Sex(de.symeda.sormas.api.person.Sex) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) ContactDto(de.symeda.sormas.api.contact.ContactDto) PathogenTestReferenceDto(de.symeda.sormas.api.sample.PathogenTestReferenceDto) SamplePurpose(de.symeda.sormas.api.sample.SamplePurpose) MockProducer(de.symeda.sormas.backend.MockProducer) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) Before(org.junit.Before) ConfigFacadeEjb(de.symeda.sormas.backend.common.ConfigFacadeEjb) LocationDto(de.symeda.sormas.api.location.LocationDto) Properties(java.util.Properties) UserDto(de.symeda.sormas.api.user.UserDto) StringWriter(java.io.StringWriter) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) TravelEntryReferenceDto(de.symeda.sormas.api.travelentry.TravelEntryReferenceDto) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) TemplateTestUtil.cleanLineSeparators(de.symeda.sormas.backend.docgeneration.TemplateTestUtil.cleanLineSeparators) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) LocationDto(de.symeda.sormas.api.location.LocationDto) Date(java.util.Date) Before(org.junit.Before)

Example 12 with LocationDto

use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.

the class EpiDataPseudonymizationTest method createCaseWEpiData.

private CaseDataDto createCaseWEpiData(UserDto user, TestDataCreator.RDCF rdcf) {
    CaseDataDto caze = creator.createCase(user.toReference(), rdcf, c -> {
        EpiDataDto epiData = c.getEpiData();
        ExposureDto exposure = ExposureDto.build(ExposureType.ANIMAL_CONTACT);
        exposure.setAnimalCondition(AnimalCondition.DEAD);
        exposure.setDescription("Test description");
        exposure.getLocation().setDetails("Test location details");
        epiData.getExposures().add(exposure);
        ExposureDto exposure2 = ExposureDto.build(ExposureType.ANIMAL_CONTACT);
        exposure2.setTypeOfAnimal(TypeOfAnimal.OTHER);
        exposure2.setTypeOfAnimalDetails("Test other animal details");
        epiData.getExposures().add(exposure2);
        ExposureDto exposure3 = ExposureDto.build(ExposureType.TRAVEL);
        exposure3.setBodyOfWater(YesNoUnknown.YES);
        exposure3.setWaterSource(WaterSource.OTHER);
        exposure3.setWaterSourceDetails("Test water source details");
        epiData.getExposures().add(exposure3);
        ExposureDto exposure4 = ExposureDto.build(ExposureType.ANIMAL_CONTACT);
        exposure4.setAnimalContactType(AnimalContactType.OTHER);
        exposure4.setAnimalContactTypeDetails("Test animal contact type details");
        epiData.getExposures().add(exposure4);
        ExposureDto burial = ExposureDto.build(ExposureType.BURIAL);
        burial.setDeceasedPersonName("John Smith");
        burial.setDeceasedPersonRelation("Test burial relation");
        LocationDto address = new LocationDto();
        address.setRegion(rdcf.region);
        address.setDistrict(rdcf.district);
        address.setCommunity(rdcf.community);
        address.setCity("Test City");
        burial.setLocation(address);
        epiData.getExposures().add(burial);
        ExposureDto travel = ExposureDto.build(ExposureType.TRAVEL);
        travel.getLocation().setDetails("Test travel destination");
        epiData.getExposures().add(travel);
        ExposureDto gathering = ExposureDto.build(ExposureType.GATHERING);
        gathering.setLocation(address);
        gathering.setDescription("Test gathering description");
        epiData.getExposures().add(gathering);
    });
    return caze;
}
Also used : EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) LocationDto(de.symeda.sormas.api.location.LocationDto)

Example 13 with LocationDto

use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.

the class EpiDataPseudonymizationTest method getEpiDataInJurisdiction.

@Test
public void getEpiDataInJurisdiction() {
    CaseDataDto caseWEpiData = createCaseWEpiData(user2, rdcf2);
    CaseDataDto savedCase = getCaseFacade().getCaseDataByUuid(caseWEpiData.getUuid());
    EpiDataDto epiData = savedCase.getEpiData();
    assertThat(epiData.getExposures().get(0).getDescription(), is("Test description"));
    assertThat(epiData.getExposures().get(0).getLocation().getDetails(), is("Test location details"));
    assertThat(epiData.getExposures().get(1).getTypeOfAnimalDetails(), is("Test other animal details"));
    assertThat(epiData.getExposures().get(2).getWaterSourceDetails(), is("Test water source details"));
    assertThat(epiData.getExposures().get(3).getAnimalContactTypeDetails(), is("Test animal contact type details"));
    ExposureDto burial = epiData.getExposures().get(4);
    assertThat(burial.getDeceasedPersonName(), is("John Smith"));
    assertThat(burial.getDeceasedPersonRelation(), is("Test burial relation"));
    LocationDto burialAddress = burial.getLocation();
    assertThat(burialAddress.getCommunity(), is(rdcf2.community));
    assertThat(burialAddress.getCity(), is("Test City"));
    ExposureDto travel = epiData.getExposures().get(5);
    assertThat(travel.getLocation().getDetails(), is("Test travel destination"));
    ExposureDto gathering = epiData.getExposures().get(6);
    assertThat(gathering.getDescription(), is("Test gathering description"));
    LocationDto gatheringAddress = gathering.getLocation();
    assertThat(gatheringAddress.getCommunity(), is(rdcf2.community));
    assertThat(gatheringAddress.getCity(), is("Test City"));
}
Also used : EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) LocationDto(de.symeda.sormas.api.location.LocationDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 14 with LocationDto

use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.

the class LocationsField method createEntry.

@Override
protected LocationDto createEntry() {
    LocationDto location = LocationDto.build();
    location.setCountry(FacadeProvider.getCountryFacade().getServerCountry());
    return location;
}
Also used : LocationDto(de.symeda.sormas.api.location.LocationDto)

Example 15 with LocationDto

use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.

the class LocationsField method updateColumns.

@Override
protected void updateColumns() {
    Table table = getTable();
    table.addGeneratedColumn(STREET, (Table.ColumnGenerator) (source, itemId, columnId) -> {
        LocationDto locationDto = (LocationDto) itemId;
        if (!locationDto.isPseudonymized()) {
            StringBuilder streetBuilder = new StringBuilder();
            streetBuilder.append(locationDto.getStreet() != null ? locationDto.getStreet() + " " : "");
            streetBuilder.append(locationDto.getHouseNumber() != null ? locationDto.getHouseNumber() : "");
            return streetBuilder.toString();
        } else {
            return I18nProperties.getCaption(Captions.inaccessibleValue);
        }
    });
    table.setVisibleColumns(EDIT_COLUMN_ID, LocationDto.ADDRESS_TYPE, STREET, LocationDto.CITY, LocationDto.POSTAL_CODE, LocationDto.DISTRICT, LocationDto.COMMUNITY);
    table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
    table.setColumnExpandRatio(LocationDto.ADDRESS_TYPE, 0);
    table.setColumnExpandRatio(STREET, 0);
    table.setColumnExpandRatio(LocationDto.CITY, 0);
    table.setColumnExpandRatio(LocationDto.POSTAL_CODE, 0);
    table.setColumnExpandRatio(LocationDto.DISTRICT, 0);
    table.setColumnExpandRatio(LocationDto.COMMUNITY, 0);
    for (Object columnId : table.getVisibleColumns()) {
        if (columnId.equals(EDIT_COLUMN_ID)) {
            table.setColumnHeader(columnId, "&nbsp");
        } else {
            table.setColumnHeader(columnId, I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, (String) columnId));
        }
    }
}
Also used : LocationDto(de.symeda.sormas.api.location.LocationDto) AbstractTableField(de.symeda.sormas.ui.caze.AbstractTableField) Table(com.vaadin.v7.ui.Table) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Window(com.vaadin.ui.Window) Captions(de.symeda.sormas.api.i18n.Captions) Consumer(java.util.function.Consumer) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) Table(com.vaadin.v7.ui.Table) LocationDto(de.symeda.sormas.api.location.LocationDto)

Aggregations

LocationDto (de.symeda.sormas.api.location.LocationDto)32 PersonDto (de.symeda.sormas.api.person.PersonDto)9 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)7 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Test (org.junit.Test)7 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)6 UserDto (de.symeda.sormas.api.user.UserDto)4 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)4 ContactDto (de.symeda.sormas.api.contact.ContactDto)3 EpiDataDto (de.symeda.sormas.api.epidata.EpiDataDto)3 EventDto (de.symeda.sormas.api.event.EventDto)3 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)3 PersonContactDetailDto (de.symeda.sormas.api.person.PersonContactDetailDto)3 SampleDto (de.symeda.sormas.api.sample.SampleDto)3 LocationEditForm (de.symeda.sormas.ui.location.LocationEditForm)3 Label (com.vaadin.ui.Label)2 CheckBox (com.vaadin.v7.ui.CheckBox)2 Disease (de.symeda.sormas.api.Disease)2 BirthDateDto (de.symeda.sormas.api.caze.BirthDateDto)2