Search in sources :

Example 96 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class PersonFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(PersonCriteria criteria) {
    final UserDto user = currentUserDto();
    final JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
    final ComboBox districtFilter = getField(PersonCriteria.DISTRICT);
    final ComboBox communityFilter = getField(PersonCriteria.COMMUNITY);
    // Get initial field values according to user and criteria
    final RegionReferenceDto region = user.getRegion() == null ? criteria.getRegion() : user.getRegion();
    final DistrictReferenceDto district = user.getDistrict() == null ? criteria.getDistrict() : user.getDistrict();
    final CommunityReferenceDto community = user.getCommunity() == null ? criteria.getCommunity() : user.getCommunity();
    // district
    if (region != null) {
        enableFields(districtFilter);
        districtFilter.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        // community
        if (district != null) {
            districtFilter.setValue(district);
            communityFilter.addItems(FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
            enableFields(communityFilter);
            if (community != null) {
                communityFilter.setValue(community);
            }
        } else {
            clearAndDisableFields(communityFilter);
        }
    } else {
        clearAndDisableFields(districtFilter, communityFilter);
    }
    // Disable fields according to user & jurisdiction
    if (userJurisdictionLevel == JurisdictionLevel.DISTRICT) {
        clearAndDisableFields(districtFilter);
    } else if (userJurisdictionLevel == JurisdictionLevel.COMMUNITY) {
        clearAndDisableFields(districtFilter, communityFilter);
    } else if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
        clearAndDisableFields(districtFilter, communityFilter);
    }
    ComboBox birthDateDD = getField(PersonCriteria.BIRTHDATE_DD);
    if (getField(PersonCriteria.BIRTHDATE_YYYY).getValue() != null && getField(PersonCriteria.BIRTHDATE_MM).getValue() != null) {
        birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(PersonCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(PersonCriteria.BIRTHDATE_YYYY).getValue()));
        birthDateDD.setEnabled(true);
    } else {
        birthDateDD.clear();
        birthDateDD.setEnabled(false);
    }
}
Also used : CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 97 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class PersonFilterForm method addFields.

@Override
protected void addFields() {
    final ComboBox birthDateYYYY = addField(getContent(), PersonCriteria.BIRTHDATE_YYYY, ComboBox.class);
    birthDateYYYY.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_YYYY));
    birthDateYYYY.setWidth(140, Unit.PIXELS);
    birthDateYYYY.addItems(DateHelper.getYearsToNow());
    birthDateYYYY.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ID_TOSTRING);
    final ComboBox birthDateMM = addField(getContent(), PersonCriteria.BIRTHDATE_MM, ComboBox.class);
    birthDateMM.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_MM));
    birthDateMM.setWidth(140, Unit.PIXELS);
    birthDateMM.addItems(DateHelper.getMonthsInYear());
    final ComboBox birthDateDD = addField(getContent(), PersonCriteria.BIRTHDATE_DD, ComboBox.class);
    birthDateDD.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_DD));
    birthDateDD.setWidth(140, Unit.PIXELS);
    final TextField searchField = addField(FieldConfiguration.withCaptionAndPixelSized(PersonCriteria.NAME_ADDRESS_PHONE_EMAIL_LIKE, I18nProperties.getString(Strings.promptPersonsSearchField), 200));
    searchField.setNullRepresentation("");
    final ComboBox presentConditionField = addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.PRESENT_CONDITION, 140));
    presentConditionField.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION));
    UserDto user = currentUserDto();
    ComboBox regionField = null;
    if (user.getRegion() == null) {
        regionField = addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.REGION, 140));
        regionField.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    }
    final ComboBox districtFilter = addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.DISTRICT, 140));
    districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
    addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.COMMUNITY, 140));
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) TextField(com.vaadin.v7.ui.TextField)

Example 98 with UserDto

use of de.symeda.sormas.api.user.UserDto 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.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) Before(org.junit.Before)

Example 99 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantFacadeEjbTest method testCreateWithoutUuid.

@Test
public void testCreateWithoutUuid() {
    TestDataCreator.RDCF rdcf = creator.createRDCF();
    UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER);
    EventParticipantDto eventParticipant = new EventParticipantDto();
    eventParticipant.setEvent(creator.createEvent(user.toReference()).toReference());
    eventParticipant.setPerson(creator.createPerson());
    eventParticipant.setReportingUser(user.toReference());
    EventParticipantDto savedEventParticipant = getEventParticipantFacade().saveEventParticipant(eventParticipant);
    MatcherAssert.assertThat(savedEventParticipant.getUuid(), not(isEmptyOrNullString()));
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 100 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantFacadeEjbTest method testGetExportList.

@Test
public void testGetExportList() {
    TestDataCreator.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);
    EventDto event = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
    PersonDto eventPerson = creator.createPerson("Event", "Organizer");
    creator.createEventParticipant(event.toReference(), eventPerson, "event Director", user.toReference());
    PersonDto eventPerson1 = creator.createPerson("Event", "Participant");
    creator.createEventParticipant(event.toReference(), eventPerson1, "event fan", user.toReference());
    ImmunizationDto immunization = creator.createImmunization(event.getDisease(), eventPerson.toReference(), event.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 10), DateHelper.subtractDays(new Date(), 5), DateHelper.subtractDays(new Date(), 1), null);
    creator.createImmunization(event.getDisease(), eventPerson.toReference(), event.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 8), DateHelper.subtractDays(new Date(), 7), null, null);
    VaccinationDto firstVaccination = creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 7), Vaccine.OXFORD_ASTRA_ZENECA, VaccineManufacturer.ASTRA_ZENECA);
    creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 4), Vaccine.MRNA_1273, VaccineManufacturer.MODERNA);
    VaccinationDto thirdVaccination = creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), new Date(), Vaccine.COMIRNATY, VaccineManufacturer.BIONTECH_PFIZER);
    EventParticipantCriteria eventParticipantCriteria = new EventParticipantCriteria();
    eventParticipantCriteria.withEvent(event.toReference());
    List<EventParticipantExportDto> results = getEventParticipantFacade().getExportList(eventParticipantCriteria, Collections.emptySet(), 0, 100, Language.EN, null);
    // List should have two entries
    assertThat(results, Matchers.hasSize(2));
    assertEquals(VaccinationStatus.VACCINATED, results.get(0).getVaccinationStatus());
    assertEquals(thirdVaccination.getVaccineName(), results.get(0).getVaccineName());
    assertEquals(firstVaccination.getVaccinationDate(), results.get(0).getFirstVaccinationDate());
    assertEquals(thirdVaccination.getVaccinationDate(), results.get(0).getLastVaccinationDate());
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) EventParticipantExportDto(de.symeda.sormas.api.event.EventParticipantExportDto) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

UserDto (de.symeda.sormas.api.user.UserDto)274 Test (org.junit.Test)210 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)160 PersonDto (de.symeda.sormas.api.person.PersonDto)142 Date (java.util.Date)138 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)121 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)64 ContactDto (de.symeda.sormas.api.contact.ContactDto)57 LocalDate (java.time.LocalDate)57 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)56 EventDto (de.symeda.sormas.api.event.EventDto)52 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)47 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)43 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)43 SampleDto (de.symeda.sormas.api.sample.SampleDto)41 File (java.io.File)41 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)31 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)30 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)27 ImportResultStatus (de.symeda.sormas.ui.importer.ImportResultStatus)27