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);
}
}
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));
}
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);
}
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()));
}
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());
}
Aggregations