Fix validator error messages
This commit is contained in:
parent
dae587912d
commit
511696bd84
|
@ -72,6 +72,9 @@ public class EmpiRuleValidator implements IEmpiRuleValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateMdmTypes(EmpiRulesJson theEmpiRulesJson) {
|
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()) {
|
for (String resourceType: theEmpiRulesJson.getMdmTypes()) {
|
||||||
validateTypeHasIdentifier(resourceType);
|
validateTypeHasIdentifier(resourceType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package ca.uhn.fhir.empi.rules.config;
|
package ca.uhn.fhir.empi.rules.config;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
import ca.uhn.fhir.empi.BaseR4Test;
|
import ca.uhn.fhir.empi.BaseR4Test;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
import org.springframework.core.io.Resource;
|
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.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
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 {
|
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
|
@Test
|
||||||
public void testValidate() throws IOException {
|
public void testValidate() throws IOException {
|
||||||
try {
|
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
|
@Test
|
||||||
public void testMatcherduplicateName() throws IOException {
|
public void testMatcherduplicateName() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class EmpiResourceFieldMatcherR4Test extends BaseEmpiRulesR4Test {
|
||||||
super.before();
|
super.before();
|
||||||
|
|
||||||
ArrayList<String> myLegalMdmTypes = new ArrayList<>();
|
ArrayList<String> myLegalMdmTypes = new ArrayList<>();
|
||||||
myLegalMdmTypes.add("Patient");
|
//myLegalMdmTypes.add("Patient");
|
||||||
myEmpiRulesJson.setMdmTypes(myLegalMdmTypes);
|
myEmpiRulesJson.setMdmTypes(myLegalMdmTypes);
|
||||||
myComparator = new EmpiResourceFieldMatcher(ourFhirContext, myGivenNameMatchField, myEmpiRulesJson);
|
myComparator = new EmpiResourceFieldMatcher(ourFhirContext, myGivenNameMatchField, myEmpiRulesJson);
|
||||||
myJohn = buildJohn();
|
myJohn = buildJohn();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"resourcePath" : "name.given",
|
"resourcePath" : "name.given",
|
||||||
"similarity" : {
|
"similarity" : {
|
||||||
"algorithm": "COSINE",
|
"algorithm": "COSINE",
|
||||||
"threshold": 0.8
|
"matchThreshold": 0.8
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"matchResultMap" : {
|
"matchResultMap" : {
|
||||||
|
|
Loading…
Reference in New Issue