Fix build

This commit is contained in:
James Agnew 2016-06-08 15:35:08 -07:00
parent cf1ea276c9
commit 338e83e4e8
2 changed files with 67 additions and 54 deletions

View File

@ -187,8 +187,9 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
@Override
public Set<String> typeTails() {
return new HashSet<String>(Arrays.asList("Integer", "UnsignedInt", "PositiveInt", "Decimal", "DateTime", "Date", "Time", "Instant", "String", "Uri", "Oid", "Uuid", "Id", "Boolean", "Code", "Markdown", "Base64Binary", "Coding", "CodeableConcept", "Attachment", "Identifier", "Quantity",
"SampledData", "Range", "Period", "Ratio", "HumanName", "Address", "ContactPoint", "Timing", "Reference", "Annotation", "Signature", "Meta"));
return new HashSet<String>(Arrays.asList("Integer", "UnsignedInt", "PositiveInt", "Decimal", "DateTime", "Date", "Time", "Instant", "String", "Uri", "Oid", "Uuid", "Id", "Boolean", "Code",
"Markdown", "Base64Binary", "Coding", "CodeableConcept", "Attachment", "Identifier", "Quantity", "SampledData", "Range", "Period", "Ratio", "HumanName", "Address", "ContactPoint",
"Timing", "Reference", "Annotation", "Signature", "Meta"));
}
@Override
@ -229,7 +230,8 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
public ValidationResult validateCode(String theSystem, String theCode, String theDisplay, ValueSet theVs) {
ValueSetExpansionOutcome expandedValueSet = expand(theVs);
for (ValueSetExpansionContainsComponent next : expandedValueSet.getValueset().getExpansion().getContains()) {
if (next.getSystem().equals(theSystem) && next.getCode().equals(theCode)) {
if (next.getCode().equals(theCode)) {
if (theSystem == null || next.getSystem().equals(theSystem)) {
ConceptDefinitionComponent definition = new ConceptDefinitionComponent();
definition.setCode(next.getCode());
definition.setDisplay(next.getDisplay());
@ -237,32 +239,33 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
return retVal;
}
}
}
// for (UriType nextComposeImport : theVs.getCompose().getImport()) {
// if (isNotBlank(nextComposeImport.getValue())) {
// aaa
// }
// }
// for (ConceptSetComponent nextComposeConceptSet : theVs.getCompose().getInclude()) {
// if (theSystem == null || StringUtils.equals(theSystem, nextComposeConceptSet.getSystem())) {
// if (nextComposeConceptSet.getConcept().isEmpty()) {
// ValidationResult retVal = validateCode(nextComposeConceptSet.getSystem(), theCode, theDisplay);
// if (retVal != null && retVal.isOk()) {
// return retVal;
// }
// } else {
// for (ConceptReferenceComponent nextComposeCode : nextComposeConceptSet.getConcept()) {
// ConceptDefinitionComponent conceptDef = new ConceptDefinitionComponent();
// conceptDef.setCode(nextComposeCode.getCode());
// conceptDef.setDisplay(nextComposeCode.getDisplay());
// ValidationResult retVal = validateCodeSystem(theCode, conceptDef);
// if (retVal != null && retVal.isOk()) {
// return retVal;
// }
// }
// }
// }
// }
// for (UriType nextComposeImport : theVs.getCompose().getImport()) {
// if (isNotBlank(nextComposeImport.getValue())) {
// aaa
// }
// }
// for (ConceptSetComponent nextComposeConceptSet : theVs.getCompose().getInclude()) {
// if (theSystem == null || StringUtils.equals(theSystem, nextComposeConceptSet.getSystem())) {
// if (nextComposeConceptSet.getConcept().isEmpty()) {
// ValidationResult retVal = validateCode(nextComposeConceptSet.getSystem(), theCode, theDisplay);
// if (retVal != null && retVal.isOk()) {
// return retVal;
// }
// } else {
// for (ConceptReferenceComponent nextComposeCode : nextComposeConceptSet.getConcept()) {
// ConceptDefinitionComponent conceptDef = new ConceptDefinitionComponent();
// conceptDef.setCode(nextComposeCode.getCode());
// conceptDef.setDisplay(nextComposeCode.getDisplay());
// ValidationResult retVal = validateCodeSystem(theCode, conceptDef);
// if (retVal != null && retVal.isOk()) {
// return retVal;
// }
// }
// }
// }
// }
return new ValidationResult(IssueSeverity.ERROR, "Unknown code[" + theCode + "] in system[" + theSystem + "]");
}

View File

@ -5,32 +5,27 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hl7.fhir.dstu3.exceptions.DefinitionException;
import org.hl7.fhir.dstu3.exceptions.FHIRException;
import org.hl7.fhir.dstu3.formats.FormatUtilities;
import org.hl7.fhir.dstu3.metamodel.Element;
import org.hl7.fhir.dstu3.metamodel.Element.SpecialElement;
import org.hl7.fhir.dstu3.metamodel.JsonParser;
import org.hl7.fhir.dstu3.metamodel.Manager;
import org.hl7.fhir.dstu3.metamodel.Manager.FhirFormat;
import org.hl7.fhir.dstu3.metamodel.ParserBase.ValidationPolicy;
import org.hl7.fhir.dstu3.metamodel.ParserBase;
import org.hl7.fhir.dstu3.metamodel.ParserBase.ValidationPolicy;
import org.hl7.fhir.dstu3.metamodel.XmlParser;
import org.hl7.fhir.dstu3.metamodel.Element.SpecialElement;
import org.hl7.fhir.dstu3.model.Address;
import org.hl7.fhir.dstu3.model.Attachment;
import org.hl7.fhir.dstu3.model.Base;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.ContactPoint;
@ -50,7 +45,6 @@ import org.hl7.fhir.dstu3.model.IntegerType;
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueType;
import org.hl7.fhir.dstu3.model.Period;
import org.hl7.fhir.dstu3.model.Property;
import org.hl7.fhir.dstu3.model.Quantity;
import org.hl7.fhir.dstu3.model.Questionnaire;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent;
@ -60,7 +54,6 @@ import org.hl7.fhir.dstu3.model.Range;
import org.hl7.fhir.dstu3.model.Ratio;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.ResourceType;
import org.hl7.fhir.dstu3.model.SampledData;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.StructureDefinition;
@ -73,7 +66,6 @@ import org.hl7.fhir.dstu3.model.Timing;
import org.hl7.fhir.dstu3.model.Type;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
import org.hl7.fhir.dstu3.utils.IWorkerContext;
@ -413,6 +405,19 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "No code provided, and a code should be provided from the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl());
} else {
long t = System.nanoTime();
boolean atLeastOneSystemIsSupported = false;
for (Coding nextCoding : cc.getCoding()) {
String nextSystem = nextCoding.getSystem();
if (isNotBlank(nextSystem) && context.supportsSystem(nextSystem)) {
atLeastOneSystemIsSupported = true;
break;
}
}
if (!atLeastOneSystemIsSupported && binding.getStrength() == BindingStrength.EXAMPLE) {
// ignore this since we can't validate but it doesn't matter..
} else {
ValidationResult vr = context.validateCode(cc, valueset);
txTime = txTime + (System.nanoTime() - t);
if (!vr.isOk()) {
@ -424,6 +429,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is recommended to come from this value set");
}
}
}
} catch (Exception e) {
warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept");
}
@ -470,6 +476,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(system), "Coding.system must be an absolute reference, not a local reference");
if (system != null && code != null) {
try {
if (checkCode(errors, element, path, code, system, display))
if (theElementCntext != null && theElementCntext.getBinding() != null) {
ElementDefinitionBindingComponent binding = theElementCntext.getBinding();
@ -501,6 +508,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
}
}
} catch (Exception e) {
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept");
}
}
}