Fix validator error messages

This commit is contained in:
Tadgh 2020-11-16 19:11:19 -05:00
parent dae587912d
commit 511696bd84
4 changed files with 27 additions and 2 deletions

View File

@ -72,6 +72,9 @@ public class EmpiRuleValidator implements IEmpiRuleValidator {
}
public void validateMdmTypes(EmpiRulesJson theEmpiRulesJson) {
if (theEmpiRulesJson.getMdmTypes() == null) {
throw new ConfigurationException("mdmTypes must be set to a list of resource types.");
}
for (String resourceType: theEmpiRulesJson.getMdmTypes()) {
validateTypeHasIdentifier(resourceType);
}

View File

@ -1,9 +1,11 @@
package ca.uhn.fhir.empi.rules.config;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.empi.BaseR4Test;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@ -14,8 +16,18 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class EmpiRuleValidatorTest extends BaseR4Test {
@BeforeEach
public void before() {
when(mySearchParamRetriever.getActiveSearchParam("Patient", "identifier")).thenReturn(mock(RuntimeSearchParam.class));
when(mySearchParamRetriever.getActiveSearchParam("Practitioner", "identifier")).thenReturn(mock(RuntimeSearchParam.class));
when(mySearchParamRetriever.getActiveSearchParam("Medication", "identifier")).thenReturn(mock(RuntimeSearchParam.class));
when(mySearchParamRetriever.getActiveSearchParam("AllergyIntolerance", "identifier")).thenReturn(null);
}
@Test
public void testValidate() throws IOException {
try {
@ -76,6 +88,16 @@ public class EmpiRuleValidatorTest extends BaseR4Test {
}
}
@Test
public void testInvalidMdmType() throws IOException {
try {
setEmpiRuleJson("bad-rules-missing-mdm-types.json");
fail();
} catch (ConfigurationException e) {
assertThat(e.getMessage(), startsWith("mdmTypes must be set to a list of resource types."));
}
}
@Test
public void testMatcherduplicateName() throws IOException {
try {

View File

@ -31,7 +31,7 @@ public class EmpiResourceFieldMatcherR4Test extends BaseEmpiRulesR4Test {
super.before();
ArrayList<String> myLegalMdmTypes = new ArrayList<>();
myLegalMdmTypes.add("Patient");
//myLegalMdmTypes.add("Patient");
myEmpiRulesJson.setMdmTypes(myLegalMdmTypes);
myComparator = new EmpiResourceFieldMatcher(ourFhirContext, myGivenNameMatchField, myEmpiRulesJson);
myJohn = buildJohn();

View File

@ -8,7 +8,7 @@
"resourcePath" : "name.given",
"similarity" : {
"algorithm": "COSINE",
"threshold": 0.8
"matchThreshold": 0.8
}
}],
"matchResultMap" : {