Updated identifier matcher to only match on non-empty values
This commit is contained in:
parent
af44b9c7a0
commit
dc89a4abd7
|
@ -23,11 +23,11 @@ package ca.uhn.fhir.mdm.rules.matcher;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.mdm.util.CanonicalIdentifier;
|
import ca.uhn.fhir.mdm.util.CanonicalIdentifier;
|
||||||
import ca.uhn.fhir.mdm.util.IdentifierUtil;
|
import ca.uhn.fhir.mdm.util.IdentifierUtil;
|
||||||
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
public class IdentifierMatcher implements IMdmFieldMatcher {
|
public class IdentifierMatcher implements IMdmFieldMatcher {
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return true if the two fhir identifiers are the same. If @param theIdentifierSystem is not null, then the
|
* @return true if the two fhir identifiers are the same. If @param theIdentifierSystem is not null, then the
|
||||||
* matcher only returns true if the identifier systems also match this system.
|
* matcher only returns true if the identifier systems also match this system.
|
||||||
* @throws UnsupportedOperationException if either Base is not an Identifier instance
|
* @throws UnsupportedOperationException if either Base is not an Identifier instance
|
||||||
|
@ -41,6 +41,16 @@ public class IdentifierMatcher implements IMdmFieldMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CanonicalIdentifier right = IdentifierUtil.identifierDtFromIdentifier(theRightBase);
|
CanonicalIdentifier right = IdentifierUtil.identifierDtFromIdentifier(theRightBase);
|
||||||
|
if (isEmpty(left.getValueElement()) || isEmpty(right.getValueElement())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return left.equals(right);
|
return left.equals(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEmpty(StringDt theValue) {
|
||||||
|
if (theValue == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return theValue.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,17 @@ public class IdentifierMatcherR4Test extends BaseMatcherR4Test {
|
||||||
assertFalse(fieldMatch.match(ourFhirContext, rightNoValue, left).match);
|
assertFalse(fieldMatch.match(ourFhirContext, rightNoValue, left).match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIdentifierMatchWithNoValues() {
|
||||||
|
Identifier left = new Identifier().setSystem(MATCHING_SYSTEM);
|
||||||
|
Identifier right = new Identifier().setSystem(MATCHING_SYSTEM);
|
||||||
|
|
||||||
|
MdmMatcherJson matcher = new MdmMatcherJson().setAlgorithm(MdmMatcherEnum.IDENTIFIER).setIdentifierSystem(MATCHING_SYSTEM);
|
||||||
|
MdmFieldMatchJson fieldMatch = new MdmFieldMatchJson().setMatcher(matcher);
|
||||||
|
|
||||||
|
assertFalse(fieldMatch.match(ourFhirContext, left, right).match);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdentifierNamedSystemMatch() {
|
public void testIdentifierNamedSystemMatch() {
|
||||||
Identifier left = new Identifier().setSystem(MATCHING_SYSTEM).setValue(MATCHING_VALUE);
|
Identifier left = new Identifier().setSystem(MATCHING_SYSTEM).setValue(MATCHING_VALUE);
|
||||||
|
|
Loading…
Reference in New Issue