Merge pull request #2679 from hapifhir/2678_mdm_identifier
Updated identifier matcher to only match on non-empty values
This commit is contained in:
commit
52ce8e35a7
|
@ -23,11 +23,11 @@ package ca.uhn.fhir.mdm.rules.matcher;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.mdm.util.CanonicalIdentifier;
|
||||
import ca.uhn.fhir.mdm.util.IdentifierUtil;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
public class IdentifierMatcher implements IMdmFieldMatcher {
|
||||
/**
|
||||
*
|
||||
* @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.
|
||||
* @throws UnsupportedOperationException if either Base is not an Identifier instance
|
||||
|
@ -41,6 +41,16 @@ public class IdentifierMatcher implements IMdmFieldMatcher {
|
|||
}
|
||||
}
|
||||
CanonicalIdentifier right = IdentifierUtil.identifierDtFromIdentifier(theRightBase);
|
||||
if (isEmpty(left.getValueElement()) || isEmpty(right.getValueElement())) {
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
public void testIdentifierNamedSystemMatch() {
|
||||
Identifier left = new Identifier().setSystem(MATCHING_SYSTEM).setValue(MATCHING_VALUE);
|
||||
|
|
Loading…
Reference in New Issue