Skip to content

Commit

Permalink
Merge pull request #13169 from SORMAS-Foundation/change-#13168-automa…
Browse files Browse the repository at this point in the history
…tic-message-processing-person-matching

#13168 Normalization of Automatic Processing for Name, Birthdate, and…
  • Loading branch information
leventegal-she authored Oct 23, 2024
2 parents 6dda78d + 8bb7730 commit 9d73733
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package de.symeda.sormas.backend.externalmessage.labmessage;

import java.text.Collator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -316,5 +317,20 @@ private <T> boolean unsetOrMatches(T personValue, T messageValue) {

return personValue.equals(messageValue);
}

private boolean unsetOrMatches(String personValue, String messageValue) {
if (personValue == null || messageValue == null) {
return true;
}

Collator collator = Collator.getInstance();
collator.setStrength(Collator.PRIMARY);

return collator.compare(normalizatString(personValue), normalizatString(messageValue)) == 0;
}

private String normalizatString(String string) {
return string.replaceAll("[\\s-,;:]", "");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import de.symeda.sormas.api.externalmessage.processing.ExternalMessageProcessingResult;
import de.symeda.sormas.api.infrastructure.facility.FacilityDto;
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.api.person.PersonCriteria;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.Sex;
import de.symeda.sormas.api.sample.PathogenTestDto;
Expand Down Expand Up @@ -310,6 +311,29 @@ public void testProcessWithExistingPersonWithSameNationalHealthIdButDifferentDet
assertThat(getPathogenTestFacade().getAllActiveUuids(), hasSize(0));
}

@Test
public void testProcessWithExistingPersonWithSameNationalHealthIdAndPersonDetailsNormalizedCheck()
throws ExecutionException, InterruptedException {
ExternalMessageDto externalMessage = createExternalMessage(m -> {
m.setPersonFirstName("john vander");
m.setPersonLastName("DOÉ");
m.setPersonCity(" PERSON city \n");
m.setPersonStreet(" person STREET 12A");
});

creator.createPerson("John Van Der", "Doe", Sex.MALE, p -> {
p.setNationalHealthId(externalMessage.getPersonNationalHealthId());
p.getAddress().setCity("person city");
p.getAddress().setStreet("PERSON STREET, 12a");
});

ProcessingResult<ExternalMessageProcessingResult> result = runFlow(externalMessage);
assertThat(result.getStatus(), is(DONE));
assertThat(externalMessage.getStatus(), is(ExternalMessageStatus.PROCESSED));
assertThat(getExternalMessageFacade().getByUuid(externalMessage.getUuid()).getStatus(), is(ExternalMessageStatus.PROCESSED));
assertThat(getPersonFacade().count(new PersonCriteria()), is(1L));
}

@Test
public void testProcessWithExistingSimilarPerson() throws ExecutionException, InterruptedException {
ExternalMessageDto externalMessage = createExternalMessage(m -> m.setPersonNationalHealthId(null));
Expand Down

0 comments on commit 9d73733

Please sign in to comment.