Merge branch 'gg_20201105-remove-person-references' of github.com:jamesagnew/hapi-fhir into gg_20201105-remove-person-references

This commit is contained in:
Nick Goupinets 2020-11-16 19:00:33 -05:00
commit 406bbafafe
12 changed files with 71 additions and 34 deletions

View File

@ -39,4 +39,6 @@ public class EmpiConstants {
public static final String CODE_GOLDEN_RECORD_REDIRECTED = "REDIRECTED";
public static final String DISPLAY_GOLDEN_RECORD = "Golden Record";
public static final String DISPLAY_GOLDEN_REDIRECT = "This resource was found to be a duplicate and has been redirected.";
public static final String UNKNOWN_MDM_TYPES = "Unknown Resource Types";
}

View File

@ -21,7 +21,6 @@ package ca.uhn.fhir.empi.provider;
*/
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.empi.api.EmpiLinkJson;
import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
import ca.uhn.fhir.empi.model.MdmTransactionContext;
@ -30,10 +29,8 @@ import ca.uhn.fhir.rest.server.TransactionLogMessages;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
import ca.uhn.fhir.util.ParametersUtil;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import java.util.stream.Stream;
@ -82,10 +79,6 @@ public abstract class BaseEmpiProvider {
validateNotNull(ProviderConstants.MDM_UPDATE_LINK_RESOURCE_ID, theResourceId);
}
protected String getResourceType(String theParamName, String theResourceId) {
IIdType idType = EmpiControllerUtil.getGoldenIdDtOrThrowException(theParamName, theResourceId);
return idType.getResourceType();
}
protected MdmTransactionContext createMdmContext(RequestDetails theRequestDetails, MdmTransactionContext.OperationType theOperationType, String theResourceType) {
TransactionLogMessages transactionLogMessages = TransactionLogMessages.createFromTransactionGuid(theRequestDetails.getTransactionGuid());

View File

@ -44,12 +44,12 @@ import org.hl7.fhir.dstu3.model.DecimalType;
import org.hl7.fhir.dstu3.model.InstantType;
import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Person;
import org.hl7.fhir.dstu3.model.Practitioner;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.codesystems.MatchGrade;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import javax.annotation.Nonnull;
@ -109,59 +109,59 @@ public class EmpiProviderDstu3 extends BaseEmpiProvider {
return searchComponent;
}
@Operation(name = ProviderConstants.MDM_MERGE_GOLDEN_RESOURCES, type = Person.class)
public Person mergePerson(@OperationParam(name=ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theFromPersonId,
@OperationParam(name=ProviderConstants.MDM_MERGE_GR_TO_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theToPersonId,
RequestDetails theRequestDetails) {
validateMergeParameters(theFromPersonId, theToPersonId);
@Operation(name = ProviderConstants.MDM_MERGE_GOLDEN_RESOURCES)
public IBaseResource mergeGoldenResource(@OperationParam(name=ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theFromGoldenResourceId,
@OperationParam(name=ProviderConstants.MDM_MERGE_GR_TO_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theToGoldenResourceId,
RequestDetails theRequestDetails) {
validateMergeParameters(theFromGoldenResourceId, theToGoldenResourceId);
String resourceType = getResourceType(ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, theFromPersonId.getValue());
String resourceType = getResourceType(ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, theFromGoldenResourceId);
return (Person) myEmpiControllerSvc.mergeGoldenResources(theFromPersonId.getValue(), theToPersonId.getValue(),
return myEmpiControllerSvc.mergeGoldenResources(theFromGoldenResourceId.getValue(), theToGoldenResourceId.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.MERGE_PERSONS, resourceType));
}
@Operation(name = ProviderConstants.MDM_UPDATE_LINK, type = Person.class)
public Person updateLink(@OperationParam(name=ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType thePersonId,
@Operation(name = ProviderConstants.MDM_UPDATE_LINK)
public IBaseResource updateLink(@OperationParam(name=ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theGoldenResourceId,
@OperationParam(name=ProviderConstants.MDM_UPDATE_LINK_RESOURCE_ID, min = 1, max = 1) StringType theTargetId,
@OperationParam(name=ProviderConstants.MDM_UPDATE_LINK_MATCH_RESULT, min = 1, max = 1) StringType theMatchResult,
ServletRequestDetails theRequestDetails) {
validateUpdateLinkParameters(thePersonId, theTargetId, theMatchResult);
validateUpdateLinkParameters(theGoldenResourceId, theTargetId, theMatchResult);
return (Person) myEmpiControllerSvc.updateLink(thePersonId.getValue(), theTargetId.getValue(), theMatchResult.getValue(),
return myEmpiControllerSvc.updateLink(theGoldenResourceId.getValue(), theTargetId.getValue(), theMatchResult.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.UPDATE_LINK,
getResourceType(ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, thePersonId.getValue())));
getResourceType(ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, theGoldenResourceId)));
}
@Operation(name = ProviderConstants.MDM_QUERY_LINKS)
public Parameters queryLinks(@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, min = 0, max = 1) StringType thePersonId,
@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, min = 0, max = 1) StringType theTargetId,
public Parameters queryLinks(@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, min = 0, max = 1) StringType theGoldenResourceId,
@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, min = 0, max = 1) StringType theTargetResourceId,
@OperationParam(name=ProviderConstants.EMPI_QUERY_LINKS_MATCH_RESULT, min = 0, max = 1) StringType theMatchResult,
@OperationParam(name=ProviderConstants.EMPI_QUERY_LINKS_MATCH_RESULT, min = 0, max = 1) StringType theLinkSource,
ServletRequestDetails theRequestDetails) {
Stream<EmpiLinkJson> empiLinkJson = myEmpiControllerSvc.queryLinks(extractStringOrNull(thePersonId), extractStringOrNull(theTargetId),
Stream<EmpiLinkJson> empiLinkJson = myEmpiControllerSvc.queryLinks(extractStringOrNull(theGoldenResourceId), extractStringOrNull(theTargetResourceId),
extractStringOrNull(theMatchResult), extractStringOrNull(theLinkSource), createMdmContext(theRequestDetails,
MdmTransactionContext.OperationType.QUERY_LINKS, getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, thePersonId.getValue())));
MdmTransactionContext.OperationType.QUERY_LINKS, getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId)));
return (Parameters) parametersFromEmpiLinks(empiLinkJson, true);
}
@Operation(name = ProviderConstants.MDM_DUPLICATE_GOLDEN_RESOURCES)
public Parameters getDuplicatePersons(ServletRequestDetails theRequestDetails) {
public Parameters getDuplicateGoldenResources(ServletRequestDetails theRequestDetails) {
Stream<EmpiLinkJson> possibleDuplicates = myEmpiControllerSvc.getDuplicateGoldenResources(createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.QUERY_LINKS, (String) null));
return (Parameters) parametersFromEmpiLinks(possibleDuplicates, false);
}
@Operation(name = ProviderConstants.MDM_NOT_DUPLICATE)
// TODO KHS can this return void?
public Parameters notDuplicate(@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType thePersonId,
@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, min = 1, max = 1) StringType theTargetId,
public Parameters notDuplicate(@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, min = 1, max = 1) StringType theGoldenResourceId,
@OperationParam(name=ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, min = 1, max = 1) StringType theTargetResourceId,
ServletRequestDetails theRequestDetails) {
validateNotDuplicateParameters(thePersonId, theTargetId);
myEmpiControllerSvc.notDuplicateGoldenResource(thePersonId.getValue(), theTargetId.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.NOT_DUPLICATE, thePersonId.fhirType()));
validateNotDuplicateParameters(theGoldenResourceId, theTargetResourceId);
myEmpiControllerSvc.notDuplicateGoldenResource(theGoldenResourceId.getValue(), theTargetResourceId.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.NOT_DUPLICATE, theGoldenResourceId.fhirType()));
Parameters retval = (Parameters) ParametersUtil.newInstance(myFhirContext);
ParametersUtil.addParameterToParametersBoolean(myFhirContext, retval, "success", true);
@ -287,4 +287,13 @@ public class EmpiProviderDstu3 extends BaseEmpiProvider {
}
return matchGrade;
}
protected String getResourceType(String theParamName, StringType theResourceId) {
if (theResourceId != null) {
IIdType idType = EmpiControllerUtil.getGoldenIdDtOrThrowException(theParamName, theResourceId.getValueNotNull());
return idType.getResourceType();
} else {
return EmpiConstants.UNKNOWN_MDM_TYPES;
}
}
}

View File

@ -152,7 +152,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
return myEmpiControllerSvc.mergeGoldenResources(theFromGoldenResourceId.getValue(), theToGoldenResourceId.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.MERGE_PERSONS,
getResourceType(ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, theFromGoldenResourceId.getValue()))
getResourceType(ProviderConstants.MDM_MERGE_GR_FROM_GOLDEN_RESOURCE_ID, theFromGoldenResourceId))
);
}
@ -165,7 +165,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
return myEmpiControllerSvc.updateLink(theGoldenResourceId.getValueNotNull(), theResourceId.getValue(),
theMatchResult.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.UPDATE_LINK,
getResourceType(ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, theGoldenResourceId.getValue()))
getResourceType(ProviderConstants.MDM_UPDATE_LINK_GOLDEN_RESOURCE_ID, theGoldenResourceId))
);
}
@ -197,7 +197,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
Stream<EmpiLinkJson> empiLinkJson = myEmpiControllerSvc.queryLinks(extractStringOrNull(theGoldenResourceId),
extractStringOrNull(theResourceId), extractStringOrNull(theMatchResult), extractStringOrNull(theLinkSource),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.QUERY_LINKS,
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId.getValue()))
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId))
);
return (Parameters) parametersFromEmpiLinks(empiLinkJson, true);
}
@ -218,7 +218,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
validateNotDuplicateParameters(theGoldenResourceId, theResourceId);
myEmpiControllerSvc.notDuplicateGoldenResource(theGoldenResourceId.getValue(), theResourceId.getValue(),
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.NOT_DUPLICATE,
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId.getValue()))
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId))
);
Parameters retval = (Parameters) ParametersUtil.newInstance(myFhirContext);
@ -315,4 +315,13 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
}
return matchGrade;
}
private String getResourceType(String theParamName, StringType theResourceId) {
if (theResourceId != null) {
IIdType idType = EmpiControllerUtil.getGoldenIdDtOrThrowException(theParamName, theResourceId.getValueNotNull());
return idType.getResourceType();
} else {
return EmpiConstants.UNKNOWN_MDM_TYPES;
}
}
}

View File

@ -1,4 +1,5 @@
{
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"version": "1",
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [{

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [],
"matchFields" : [ {

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams" : [{
"resourceType" : "Patient",
"searchParams" : ["foo"]

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [],
"matchFields" : [],

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams": [],
"candidateFilterSearchParams": [],
"matchFields": [

View File

@ -0,0 +1,17 @@
{
"version": "1",
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [],
"matchFields" : [ {
"name" : "given-name",
"resourceType" : "*",
"resourcePath" : "name.given",
"similarity" : {
"algorithm": "COSINE",
"threshold": 0.8
}
}],
"matchResultMap" : {
"given-name" : "POSSIBLE_MATCH"
}
}

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [],
"matchFields" : [ {

View File

@ -1,5 +1,6 @@
{
"version": "1",
"mdmTypes": ["Patient", "Practitioner", "Medication"],
"candidateSearchParams" : [],
"candidateFilterSearchParams" : [],
"matchFields" : [ {