Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13029 - Search by NationalID is not consistently working in all loca… #13036

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sormas-api/src/main/resources/doc/SORMAS_Data_Dictionary.xlsx
Binary file not shown.
Binary file modified sormas-api/src/main/resources/doc/SORMAS_User_Roles.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
import de.symeda.sormas.backend.common.AbstractDomainObject;
import de.symeda.sormas.backend.common.ChangeDateBuilder;
import de.symeda.sormas.backend.common.ChangeDateFilterBuilder;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.common.CriteriaBuilderHelper;
import de.symeda.sormas.backend.common.DeletableAdo;
import de.symeda.sormas.backend.contact.Contact;
Expand Down Expand Up @@ -854,7 +855,8 @@ public <T extends AbstractDomainObject> Predicate createCriteriaFilter(CaseCrite
CriteriaBuilderHelper
.unaccentedIlike(cb, personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_PRIMARY_OTHER_SUBQUERY), textFilter),
CriteriaBuilderHelper.unaccentedIlike(cb, joins.getPersonAddress().get(Location.CITY), textFilter),
CriteriaBuilderHelper.ilike(cb, joins.getPersonAddress().get(Location.POSTAL_CODE), textFilter)));
CriteriaBuilderHelper.ilike(cb, joins.getPersonAddress().get(Location.POSTAL_CODE), textFilter),
CriteriaBuilderHelper.ilike(cb, joins.getPerson().get(Person.NATIONAL_HEALTH_ID), textFilter)));

filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,8 @@ public Predicate buildCriteriaFilter(ContactCriteria contactCriteria, ContactQue
CriteriaBuilderHelper
.unaccentedIlike(cb, personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_PRIMARY_OTHER_SUBQUERY), textFilter),
CriteriaBuilderHelper.unaccentedIlike(cb, location.get(Location.CITY), textFilter),
CriteriaBuilderHelper.ilike(cb, location.get(Location.POSTAL_CODE), textFilter)));
CriteriaBuilderHelper.ilike(cb, location.get(Location.POSTAL_CODE), textFilter),
CriteriaBuilderHelper.ilike(cb, joins.getPerson().get(Person.NATIONAL_HEALTH_ID), textFilter)));

filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ public Predicate buildCriteriaFilter(EventCriteria eventCriteria, EventQueryCont
CriteriaBuilderHelper.unaccentedIlike(cb, personJoin.get(Person.FIRST_NAME), textFilter),
CriteriaBuilderHelper.unaccentedIlike(cb, personJoin.get(Person.LAST_NAME), textFilter),
CriteriaBuilderHelper.ilike(cb, personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_PHONE_SUBQUERY), textFilter),
CriteriaBuilderHelper.ilike(cb, personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_EMAIL_SUBQUERY), textFilter));
CriteriaBuilderHelper.ilike(cb, personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_EMAIL_SUBQUERY), textFilter),
CriteriaBuilderHelper.ilike(cb, personJoin.get(Person.NATIONAL_HEALTH_ID), textFilter));
filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
}
filter = CriteriaBuilderHelper.and(cb, filter, cb.isFalse(eventParticipantJoin.get(EventParticipant.DELETED)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.Tuple;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
Expand All @@ -37,12 +36,12 @@
import de.symeda.sormas.api.immunization.ImmunizationIndexDto;
import de.symeda.sormas.api.immunization.ImmunizationManagementStatus;
import de.symeda.sormas.api.person.PersonAssociation;
import de.symeda.sormas.api.person.PersonCriteria;
import de.symeda.sormas.api.person.PersonIndexDto;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.DateHelper;
import de.symeda.sormas.api.utils.SortProperty;
import de.symeda.sormas.backend.common.AbstractDeletableAdoService;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.common.CriteriaBuilderHelper;
import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal;
import de.symeda.sormas.backend.immunization.entity.DirectoryImmunization;
Expand Down Expand Up @@ -305,6 +304,7 @@ private Predicate buildCriteriaFilter(ImmunizationCriteria criteria, DirectoryIm
CriteriaBuilderHelper.ilike(cb, person.get(Person.INTERNAL_TOKEN), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.EXTERNAL_ID), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.EXTERNAL_TOKEN), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.NATIONAL_HEALTH_ID), textFilter),
CriteriaBuilderHelper.unaccentedIlike(cb, lastVaccineType.get(LastVaccineType.VACCINE_TYPE), textFilter));
filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
}
Expand Down Expand Up @@ -406,7 +406,7 @@ private Predicate createUserFilter(DirectoryImmunizationQueryContext qc) {
final CriteriaBuilder cb = qc.getCriteriaBuilder();
Predicate filter = null;

filter = isInJurisdictionOrOwned(qc);
filter = isInJurisdictionOrOwned(qc);

From<?, DirectoryImmunization> root = qc.getRoot();
DirectoryImmunizationJoins joins = qc.getJoins();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ private Predicate buildCriteriaFilter(TravelEntryCriteria criteria, TravelEntryQ
CriteriaBuilderHelper.ilike(cb, from.get(TravelEntry.UUID), textFilter),
CriteriaBuilderHelper.ilike(cb, from.get(TravelEntry.EXTERNAL_ID), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.UUID), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.EXTERNAL_ID), textFilter)));
CriteriaBuilderHelper.ilike(cb, person.get(Person.EXTERNAL_ID), textFilter),
CriteriaBuilderHelper.ilike(cb, person.get(Person.NATIONAL_HEALTH_ID), textFilter)));
filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.mockito.Mockito;

import de.symeda.sormas.api.CaseMeasure;
import de.symeda.sormas.api.CountryHelper;
import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.Language;
import de.symeda.sormas.api.VisitOrigin;
Expand Down Expand Up @@ -183,6 +184,7 @@
import de.symeda.sormas.backend.MockProducer;
import de.symeda.sormas.backend.TestDataCreator;
import de.symeda.sormas.backend.TestDataCreator.RDCF;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.infrastructure.district.District;
import de.symeda.sormas.backend.infrastructure.region.Region;
import de.symeda.sormas.backend.share.ExternalShareInfo;
Expand Down Expand Up @@ -3112,6 +3114,43 @@ public void searchCasesByPersonOtherDetail() {
assertEquals(0, caseIndexDetailedDtos.size());
}

@Test
public void testGetCasesByPersonNationalHealthId() {
MockProducer.getProperties().setProperty(ConfigFacadeEjb.COUNTRY_LOCALE, CountryHelper.COUNTRY_CODE_LUXEMBOURG);
PersonReferenceDto person1 = creator.createPerson().toReference();
PersonDto personDto1 = getPersonFacade().getByUuid(person1.getUuid());
personDto1.setNationalHealthId("firstNationalId");
getPersonFacade().save(personDto1);
CaseDataDto case1 = getCaseFacade().save(creator.createCase(surveillanceOfficer.toReference(), person1, rdcf));

PersonReferenceDto person2 = creator.createPerson().toReference();
PersonDto personDto2 = getPersonFacade().getByUuid(person2.getUuid());
personDto2.setNationalHealthId("secondNationalId");
getPersonFacade().save(personDto2);
getCaseFacade().save(creator.createCase(surveillanceOfficer.toReference(), person2, rdcf));

PersonReferenceDto person3 = creator.createPerson().toReference();
PersonDto personDto3 = getPersonFacade().getByUuid(person3.getUuid());
personDto3.setNationalHealthId("third");
getPersonFacade().save(personDto3);
getCaseFacade().save(creator.createCase(surveillanceOfficer.toReference(), person3, rdcf));

CaseCriteria caseCriteria = new CaseCriteria();
caseCriteria.setPersonLike("firstNationalId");

List<CaseIndexDto> caseIndexDtos1 = getCaseFacade().getIndexList(caseCriteria, 0, 100, null);
assertEquals(1, caseIndexDtos1.size());
assertEquals(case1.getUuid(), caseIndexDtos1.get(0).getUuid());

caseCriteria.setPersonLike("National");
List<CaseIndexDto> caseIndexDtosNational = getCaseFacade().getIndexList(caseCriteria, 0, 100, null);
assertEquals(2, caseIndexDtosNational.size());

caseCriteria.setPersonLike(null);
List<CaseIndexDto> caseIndexDtosAll = getCaseFacade().getIndexList(caseCriteria, 0, 100, null);
assertEquals(3, caseIndexDtosAll.size());
}

@Test
public void testArchiveAllArchivableCases() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.commons.lang3.time.DateUtils;
import org.junit.jupiter.api.Test;

import de.symeda.sormas.api.CountryHelper;
import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.Language;
import de.symeda.sormas.api.VisitOrigin;
Expand Down Expand Up @@ -133,8 +134,10 @@
import de.symeda.sormas.api.visit.VisitSummaryExportDetailsDto;
import de.symeda.sormas.api.visit.VisitSummaryExportDto;
import de.symeda.sormas.backend.AbstractBeanTest;
import de.symeda.sormas.backend.MockProducer;
import de.symeda.sormas.backend.TestDataCreator;
import de.symeda.sormas.backend.TestDataCreator.RDCF;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.contact.ContactFacadeEjb.ContactFacadeEjbLocal;
import de.symeda.sormas.backend.infrastructure.community.Community;
import de.symeda.sormas.backend.infrastructure.district.District;
Expand Down Expand Up @@ -2216,6 +2219,46 @@ public void searchContactsByPersonOtherDetail() {
assertEquals(0, contactIndexDetailedDtos.size());
}

@Test
public void testGetContactsByPersonNationalHealthId() {
MockProducer.getProperties().setProperty(ConfigFacadeEjb.COUNTRY_LOCALE, CountryHelper.COUNTRY_CODE_LUXEMBOURG);
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createSurveillanceSupervisor(rdcf);

PersonReferenceDto person1 = creator.createPerson().toReference();
PersonDto personDto1 = getPersonFacade().getByUuid(person1.getUuid());
personDto1.setNationalHealthId("firstNationalId");
getPersonFacade().save(personDto1);
ContactDto contact1 = getContactFacade().save(creator.createContact(user.toReference(), person1));

PersonReferenceDto person2 = creator.createPerson().toReference();
PersonDto personDto2 = getPersonFacade().getByUuid(person2.getUuid());
personDto2.setNationalHealthId("secondNationalId");
getPersonFacade().save(personDto2);
getContactFacade().save(creator.createContact(user.toReference(), person2));

PersonReferenceDto person3 = creator.createPerson().toReference();
PersonDto personDto3 = getPersonFacade().getByUuid(person3.getUuid());
personDto3.setNationalHealthId("third");
getPersonFacade().save(personDto3);
getContactFacade().save(creator.createContact(user.toReference(), person3));

ContactCriteria contactCriteria = new ContactCriteria();
contactCriteria.setPersonLike("firstNationalId");

List<ContactIndexDto> contactIndexDtos1 = getContactFacade().getIndexList(contactCriteria, 0, 100, null);
assertEquals(1, contactIndexDtos1.size());
assertEquals(contact1.getUuid(), contactIndexDtos1.get(0).getUuid());

contactCriteria.setPersonLike("National");
List<ContactIndexDto> contactIndexDtosNational = getContactFacade().getIndexList(contactCriteria, 0, 100, null);
assertEquals(2, contactIndexDtosNational.size());

contactCriteria.setPersonLike(null);
List<ContactIndexDto> contactIndexDtosAll = getContactFacade().getIndexList(contactCriteria, 0, 100, null);
assertEquals(3, contactIndexDtosAll.size());
}

@Test
public void testContactsForDashboard() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;

import de.symeda.sormas.api.CountryHelper;
import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.action.ActionDto;
import de.symeda.sormas.api.common.DeletionDetails;
Expand All @@ -56,6 +57,7 @@
import de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolRuntimeException;
import de.symeda.sormas.api.location.LocationDto;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.share.ExternalShareStatus;
import de.symeda.sormas.api.user.DefaultUserRole;
import de.symeda.sormas.api.user.UserDto;
Expand All @@ -65,7 +67,9 @@
import de.symeda.sormas.api.utils.ValidationRuntimeException;
import de.symeda.sormas.api.utils.criteria.ExternalShareDateType;
import de.symeda.sormas.backend.AbstractBeanTest;
import de.symeda.sormas.backend.MockProducer;
import de.symeda.sormas.backend.TestDataCreator.RDCF;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.event.EventFacadeEjb.EventFacadeEjbLocal;
import de.symeda.sormas.backend.share.ExternalShareInfo;

Expand Down Expand Up @@ -607,4 +611,47 @@ public void testGetEventUsersWithoutUsesLimitedToOthersDiseses() {
assertTrue(userReferenceDtos.contains(limitedCovidNationalUser));
assertFalse(userReferenceDtos.contains(limitedDengueNationalUser));
}

@Test
public void testGetEventsByPersonNationalHealthId() {
MockProducer.getProperties().setProperty(ConfigFacadeEjb.COUNTRY_LOCALE, CountryHelper.COUNTRY_CODE_LUXEMBOURG);
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createSurveillanceSupervisor(rdcf);

EventDto event1 = creator.createEvent(user.toReference(), Disease.CORONAVIRUS);
PersonReferenceDto person1 = creator.createPerson().toReference();
PersonDto personDto1 = getPersonFacade().getByUuid(person1.getUuid());
personDto1.setNationalHealthId("firstNationalId");
getPersonFacade().save(personDto1);
creator.createEventParticipant(event1.toReference(), personDto1, "firstPerson", user.toReference());

EventDto event2 = creator.createEvent(user.toReference(), Disease.CORONAVIRUS);
PersonReferenceDto person2 = creator.createPerson().toReference();
PersonDto personDto2 = getPersonFacade().getByUuid(person2.getUuid());
personDto2.setNationalHealthId("secondNationalId");
getPersonFacade().save(personDto2);
creator.createEventParticipant(event2.toReference(), personDto2, "secondPerson", user.toReference());

EventDto event3 = creator.createEvent(user.toReference(), Disease.CORONAVIRUS);
PersonReferenceDto person3 = creator.createPerson().toReference();
PersonDto personDto3 = getPersonFacade().getByUuid(person3.getUuid());
personDto3.setNationalHealthId("third");
getPersonFacade().save(personDto3);
creator.createEventParticipant(event3.toReference(), personDto3, "thirdPerson", user.toReference());

EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setFreeTextEventParticipants("firstNationalId");

List<EventIndexDto> eventIndexDtos1 = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(1, eventIndexDtos1.size());
assertEquals(event1.getUuid(), eventIndexDtos1.get(0).getUuid());

eventCriteria.setFreeTextEventParticipants("National");
List<EventIndexDto> eventIndexDtosNational = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(2, eventIndexDtosNational.size());

eventCriteria.setFreeTextEventParticipants(null);
List<EventIndexDto> eventIndexDtosAll = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(3, eventIndexDtosAll.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.junit.jupiter.api.Test;

import de.symeda.sormas.api.CountryHelper;
import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.EntityDto;
import de.symeda.sormas.api.clinicalcourse.HealthConditionsDto;
Expand All @@ -43,13 +44,16 @@
import de.symeda.sormas.api.person.PersonContactDetailDto;
import de.symeda.sormas.api.person.PersonContactDetailType;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.user.DefaultUserRole;
import de.symeda.sormas.api.user.UserDto;
import de.symeda.sormas.api.utils.DateHelper;
import de.symeda.sormas.api.utils.UtilDate;
import de.symeda.sormas.api.utils.ValidationRuntimeException;
import de.symeda.sormas.backend.AbstractBeanTest;
import de.symeda.sormas.backend.MockProducer;
import de.symeda.sormas.backend.TestDataCreator;
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
import de.symeda.sormas.backend.immunization.entity.Immunization;

public class ImmunizationFacadeEjbTest extends AbstractBeanTest {
Expand Down Expand Up @@ -777,4 +781,42 @@ public void testGetIndexListFilterByCriteria() {
assertEquals(1, immunizationIndexDtos.size());
assertEquals(immunizationDto2.getUuid(), immunizationIndexDtos.get(0).getUuid());
}

@Test
public void testGetCasesByPersonNationalHealthId() {
MockProducer.getProperties().setProperty(ConfigFacadeEjb.COUNTRY_LOCALE, CountryHelper.COUNTRY_CODE_LUXEMBOURG);
PersonReferenceDto person1 = creator.createPerson().toReference();
PersonDto personDto1 = getPersonFacade().getByUuid(person1.getUuid());
personDto1.setNationalHealthId("firstNationalId");
getPersonFacade().save(personDto1);
final ImmunizationDto immunization1 =
getImmunizationFacade().save(creator.createImmunization(Disease.CORONAVIRUS, person1, districtUser1.toReference(), rdcf1));

PersonReferenceDto person2 = creator.createPerson().toReference();
PersonDto personDto2 = getPersonFacade().getByUuid(person2.getUuid());
personDto2.setNationalHealthId("secondNationalId");
getPersonFacade().save(personDto2);
getImmunizationFacade().save(creator.createImmunization(Disease.CORONAVIRUS, person2, districtUser1.toReference(), rdcf1));

PersonReferenceDto person3 = creator.createPerson().toReference();
PersonDto personDto3 = getPersonFacade().getByUuid(person3.getUuid());
personDto3.setNationalHealthId("third");
getPersonFacade().save(personDto3);
getImmunizationFacade().save(creator.createImmunization(Disease.CORONAVIRUS, person3, districtUser1.toReference(), rdcf1));

ImmunizationCriteria immunizationCriteria = new ImmunizationCriteria();
immunizationCriteria.setNameAddressPhoneEmailLike("firstNationalId");

List<ImmunizationIndexDto> immunizationIndexDtos1 = getImmunizationFacade().getIndexList(immunizationCriteria, 0, 100, null);
assertEquals(1, immunizationIndexDtos1.size());
assertEquals(immunization1.getUuid(), immunizationIndexDtos1.get(0).getUuid());

immunizationCriteria.setNameAddressPhoneEmailLike("National");
List<ImmunizationIndexDto> immunizationIndexDtosNational = getImmunizationFacade().getIndexList(immunizationCriteria, 0, 100, null);
assertEquals(2, immunizationIndexDtosNational.size());

immunizationCriteria.setNameAddressPhoneEmailLike(null);
List<ImmunizationIndexDto> immunizationIndexDtosAll = getImmunizationFacade().getIndexList(immunizationCriteria, 0, 100, null);
assertEquals(3, immunizationIndexDtosAll.size());
}
}
Loading
Loading