Accidentally reverted a fix in InstanceValidator
@@ -105,7 +105,6 @@ import org.w3c.dom.Node;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-import com.google.gson.stream.JsonWriter;
import ca.uhn.fhir.util.ObjectUtil;
@@ -293,6 +292,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
source = Source.InstanceValidator;
}
+
+
@Override
public boolean isNoInvariantChecks() {
return noInvariantChecks;
@@ -1357,17 +1358,31 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
checkFixedValue(errors, path + ".denominator", focus.getNamedChild("denominator"), fixed.getDenominator(), "denominator", focus);
}
+ private Reference readAsReference(Element item) {
+ Reference r = new Reference();
+ r.setDisplay(item.getNamedChildValue("display"));
+ r.setReference(item.getNamedChildValue("reference"));
+ List<Element> identifier = item.getChildrenByName("identifier");
+ if (identifier.isEmpty() == false) {
+ r.setIdentifier(readAsIdentifier(identifier.get(0)));
+ }
+ return r;
+ }
+ private Identifier readAsIdentifier(Element item) {
+ Identifier r = new Identifier();
+ r.setSystem(item.getNamedChildValue("system"));
+ r.setValue(item.getNamedChildValue("value"));
+ return r;
+ }
+
private void checkReference(Object appContext, List<ValidationMessage> errors, String path, Element element, StructureDefinition profile, ElementDefinition container, String parentType, NodeStack stack) throws FHIRException, IOException {
- String ref = null;
- try {
- // Do this inside a try because invalid instances might provide more than one reference.
- ref = element.getNamedChildValue("reference");
- } catch (Error e) {
+ Reference reference = readAsReference(element);
- }
+ String ref = reference.getReference();
if (Utilities.noString(ref)) {
- // todo - what should we do in this case?
- warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference should have a display");
+ if (Utilities.noString(reference.getIdentifier().getSystem()) && Utilities.noString(reference.getIdentifier().getValue())) {
+ warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference or identifier should have a display");
+ }
return;
}
