Updates to validation for DSTU2

This commit is contained in:
James 2017-08-18 08:22:17 -04:00
parent 45ddf372ce
commit 4bd1c1d0de
2 changed files with 48 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.instance.hapi.validation;
import java.util.List;
import ca.uhn.fhir.parser.DataFormatException;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.formats.IParser;
import org.hl7.fhir.instance.formats.ParserType;
@ -172,6 +173,22 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
@Override
public ValidationResult validateCode(String theSystem, String theCode, String theDisplay, ValueSet theVs) {
/*
* For some reason the built-in valueset is empty
*/
if (theVs.getIdElement().getValue().equals("http://hl7.org/fhir/ValueSet/defined-types")) {
// try {
// myCtx.getResourceDefinition(theCode);
// return new ValidationResult(new ConceptDefinitionComponent(new CodeType(theCode)));
// } catch (DataFormatException e){
// if (myCtx.getElementDefinition(theCode) != null) {
// return new ValidationResult(new ConceptDefinitionComponent(new CodeType(theCode)));
// }
// }
return new ValidationResult(new ConceptDefinitionComponent(new CodeType(theCode)));
}
if (theSystem == null || StringUtils.equals(theSystem, theVs.getCodeSystem().getSystem())) {
for (ConceptDefinitionComponent next : theVs.getCodeSystem().getConcept()) {
ValidationResult retVal = validateCodeSystem(theCode, next);
@ -210,4 +227,4 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
return null;
}
}
}
}

View File

@ -0,0 +1,30 @@
package org.hl7.fhir.instance.hapi.validation;
import ca.uhn.fhir.context.FhirContext;
import org.hl7.fhir.instance.model.ValueSet;
import org.hl7.fhir.instance.utils.IWorkerContext;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class HapiWorkerContextTest {
@Test
public void testIdTypes(){
HapiWorkerContext hwc = new HapiWorkerContext(FhirContext.forDstu2(), new DefaultProfileValidationSupport());
ValueSet vs = new ValueSet();
vs.setId("http://hl7.org/fhir/ValueSet/defined-types");
IWorkerContext.ValidationResult outcome;
outcome = hwc.validateCode(null, "Patient", null, vs);
assertTrue(outcome.isOk());
outcome = hwc.validateCode(null, "id", null, vs);
assertTrue(outcome.isOk());
}
}