-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CND-94 pt 2 - Feature flag modernized deduplication (#259)
* Add api call for matching * Fix code smell / bug * Update PatientMatchingService with feature flag to use new deduplication check. Default: false * Remove possible null * Fix bug * Split deduplication call into service to ease testing. Add additional unit tests for modernized matching * More testing * Response test * Clean up some awkward logic * Improved test coverage * Fix jurisdiction code lookup --------- Co-authored-by: Michael Peels <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,348 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
491 changes: 260 additions & 231 deletions
491
...ain/java/gov/cdc/dataprocessing/service/implementation/person/PatientMatchingService.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...va/gov/cdc/dataprocessing/service/implementation/person/matching/DeduplicationClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestClient; | ||
|
||
@Configuration | ||
public class DeduplicationClient { | ||
|
||
@Bean("deduplicationRestClient") | ||
public RestClient restClient(@Value("${features.modernizedMatching.url}") String modernizedMatchingUrl) { | ||
return RestClient.builder().baseUrl(modernizedMatchingUrl).build(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...a/gov/cdc/dataprocessing/service/implementation/person/matching/DeduplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.RestClient; | ||
|
||
@Component | ||
public class DeduplicationService { | ||
|
||
private RestClient restClient; | ||
|
||
public DeduplicationService( | ||
@Qualifier("deduplicationRestClient") RestClient restClient) { | ||
this.restClient = restClient; | ||
} | ||
|
||
public MatchResponse match(PersonMatchRequest request) { | ||
return restClient.post() | ||
.uri("/match") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.body(request) | ||
.retrieve() | ||
.body(MatchResponse.class); | ||
} | ||
|
||
public void relate(RelateRequest relateRequest) { | ||
restClient.post() | ||
.uri("/relate") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.body(relateRequest) | ||
.retrieve() | ||
.body(Void.class); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/java/gov/cdc/dataprocessing/service/implementation/person/matching/LinkResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
import java.util.List; | ||
|
||
public record LinkResponse( | ||
String patient_reference_id, | ||
String person_reference_id, | ||
String prediction, // match, possible_match, no_match | ||
List<Results> results) { | ||
public record Results( | ||
String person_reference_id, | ||
Double belongingness_ratio) { | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ain/java/gov/cdc/dataprocessing/service/implementation/person/matching/MatchResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
public record MatchResponse( | ||
Long match, | ||
MatchType matchType, | ||
LinkResponse linkResponse) { | ||
|
||
public enum MatchType { | ||
EXACT, | ||
POSSIBLE, | ||
NONE | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ava/gov/cdc/dataprocessing/service/implementation/person/matching/PersonMatchRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import gov.cdc.dataprocessing.model.container.model.PersonContainer; | ||
import gov.cdc.dataprocessing.model.dto.entity.EntityIdDto; | ||
import gov.cdc.dataprocessing.model.dto.entity.EntityLocatorParticipationDto; | ||
import gov.cdc.dataprocessing.model.dto.locator.PostalLocatorDto; | ||
import gov.cdc.dataprocessing.model.dto.locator.TeleLocatorDto; | ||
import gov.cdc.dataprocessing.model.dto.person.PersonDto; | ||
import gov.cdc.dataprocessing.model.dto.person.PersonNameDto; | ||
import gov.cdc.dataprocessing.model.dto.person.PersonRaceDto; | ||
|
||
public record PersonMatchRequest( | ||
PersonDto personDto, | ||
Collection<PersonNameDto> names, | ||
Collection<PersonRaceDto> races, | ||
Collection<PostalLocatorDto> postalLocators, | ||
Collection<TeleLocatorDto> teleLocators, | ||
Collection<EntityIdDto> identifications) { | ||
public PersonMatchRequest(PersonContainer personContainer) { | ||
this( | ||
personContainer.getThePersonDto(), | ||
personContainer.getThePersonNameDtoCollection(), | ||
personContainer.getThePersonRaceDtoCollection(), | ||
Optional.of(personContainer.getTheEntityLocatorParticipationDtoCollection()) | ||
.orElseGet(ArrayList::new) | ||
.stream() | ||
.map(EntityLocatorParticipationDto::getThePostalLocatorDto) | ||
.filter(Objects::nonNull) | ||
.toList(), | ||
Optional.of(personContainer.getTheEntityLocatorParticipationDtoCollection()) | ||
.orElseGet(ArrayList::new) | ||
.stream() | ||
.map(EntityLocatorParticipationDto::getTheTeleLocatorDto) | ||
.filter(Objects::nonNull) | ||
.toList(), | ||
personContainer.getTheEntityIdDtoCollection()); | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ain/java/gov/cdc/dataprocessing/service/implementation/person/matching/RelateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package gov.cdc.dataprocessing.service.implementation.person.matching; | ||
|
||
import gov.cdc.dataprocessing.service.implementation.person.matching.MatchResponse.MatchType; | ||
|
||
public record RelateRequest( | ||
Long nbsPerson, | ||
Long nbsPersonParent, | ||
MatchType matchType, | ||
LinkResponse linkResponse) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.