Search in sources :

Example 21 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class CanonicalResourceComparer method comparePrimitives.

@SuppressWarnings("rawtypes")
protected void comparePrimitives(String name, PrimitiveType l, PrimitiveType r, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res) {
    StructuralMatch<String> match = null;
    if (l.isEmpty() && r.isEmpty()) {
        match = new StructuralMatch<>(null, null, null);
    } else if (l.isEmpty()) {
        match = new StructuralMatch<>(null, r.primitiveValue(), vmI(IssueSeverity.INFORMATION, "Added the item '" + r.primitiveValue() + "'", fhirType() + "." + name));
    } else if (r.isEmpty()) {
        match = new StructuralMatch<>(l.primitiveValue(), null, vmI(IssueSeverity.INFORMATION, "Removed the item '" + l.primitiveValue() + "'", fhirType() + "." + name));
    } else if (!l.hasValue() && !r.hasValue()) {
        match = new StructuralMatch<>(null, null, vmI(IssueSeverity.INFORMATION, "No Value", fhirType() + "." + name));
    } else if (!l.hasValue()) {
        match = new StructuralMatch<>(null, r.primitiveValue(), vmI(IssueSeverity.INFORMATION, "No Value on Left", fhirType() + "." + name));
    } else if (!r.hasValue()) {
        match = new StructuralMatch<>(l.primitiveValue(), null, vmI(IssueSeverity.INFORMATION, "No Value on Right", fhirType() + "." + name));
    } else if (l.getValue().equals(r.getValue())) {
        match = new StructuralMatch<>(l.primitiveValue(), r.primitiveValue(), null);
    } else {
        match = new StructuralMatch<>(l.primitiveValue(), r.primitiveValue(), vmI(level, "Values Differ", fhirType() + "." + name));
        if (level != IssueSeverity.NULL) {
            res.getMessages().add(new ValidationMessage(Source.ProfileComparer, IssueType.INFORMATIONAL, fhirType() + "." + name, "Values for " + name + " differ: '" + l.primitiveValue() + "' vs '" + r.primitiveValue() + "'", level));
        }
    }
    comp.put(name, match);
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage)

Example 22 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class ParserBase method logError.

// FIXME: i18n should be done here
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
    if (errors != null) {
        if (policy == ValidationPolicy.EVERYTHING) {
            ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
            errors.add(msg);
        } else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
            throw new FHIRFormatError(message + String.format(" at line %d col %d", line, col));
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 23 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class CanonicalResourceComparer method compareCodeList.

protected void compareCodeList(String name, List<CodeType> left, List<CodeType> right, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res, List<CodeType> union, List<CodeType> intersection) {
    List<CodeType> matchR = new ArrayList<>();
    StructuralMatch<String> combined = new StructuralMatch<String>();
    for (CodeType l : left) {
        CodeType r = findCodeInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<String>(l.getValue(), vm(IssueSeverity.INFORMATION, "Removed the item '" + l.getValue() + "'", fhirType() + "." + name, res.getMessages())));
        } else {
            matchR.add(r);
            union.add(r);
            intersection.add(r);
            StructuralMatch<String> sm = new StructuralMatch<String>(l.getValue(), r.getValue());
            combined.getChildren().add(sm);
        }
    }
    for (CodeType r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<String>(vm(IssueSeverity.INFORMATION, "Added the item '" + r.getValue() + "'", fhirType() + "." + name, res.getMessages()), r.getValue()));
        }
    }
    comp.put(name, combined);
}
Also used : ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r4b.model.CodeType)

Example 24 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class CanonicalResourceComparer method comparePrimitives.

@SuppressWarnings("rawtypes")
protected void comparePrimitives(String name, PrimitiveType l, PrimitiveType r, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res) {
    StructuralMatch<String> match = null;
    if (l.isEmpty() && r.isEmpty()) {
        match = new StructuralMatch<>(null, null, null);
    } else if (l.isEmpty()) {
        match = new StructuralMatch<>(null, r.primitiveValue(), vmI(IssueSeverity.INFORMATION, "Added the item '" + r.primitiveValue() + "'", fhirType() + "." + name));
    } else if (r.isEmpty()) {
        match = new StructuralMatch<>(l.primitiveValue(), null, vmI(IssueSeverity.INFORMATION, "Removed the item '" + l.primitiveValue() + "'", fhirType() + "." + name));
    } else if (!l.hasValue() && !r.hasValue()) {
        match = new StructuralMatch<>(null, null, vmI(IssueSeverity.INFORMATION, "No Value", fhirType() + "." + name));
    } else if (!l.hasValue()) {
        match = new StructuralMatch<>(null, r.primitiveValue(), vmI(IssueSeverity.INFORMATION, "No Value on Left", fhirType() + "." + name));
    } else if (!r.hasValue()) {
        match = new StructuralMatch<>(l.primitiveValue(), null, vmI(IssueSeverity.INFORMATION, "No Value on Right", fhirType() + "." + name));
    } else if (l.getValue().equals(r.getValue())) {
        match = new StructuralMatch<>(l.primitiveValue(), r.primitiveValue(), null);
    } else {
        match = new StructuralMatch<>(l.primitiveValue(), r.primitiveValue(), vmI(level, "Values Differ", fhirType() + "." + name));
        if (level != IssueSeverity.NULL) {
            res.getMessages().add(new ValidationMessage(Source.ProfileComparer, IssueType.INFORMATIONAL, fhirType() + "." + name, "Values for " + name + " differ: '" + l.primitiveValue() + "' vs '" + r.primitiveValue() + "'", level));
        }
    }
    comp.put(name, match);
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage)

Example 25 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class CanonicalResourceComparer method compareCanonicalList.

protected void compareCanonicalList(String name, List<CanonicalType> left, List<CanonicalType> right, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res, List<CanonicalType> union, List<CanonicalType> intersection) {
    List<CanonicalType> matchR = new ArrayList<>();
    StructuralMatch<String> combined = new StructuralMatch<String>();
    for (CanonicalType l : left) {
        CanonicalType r = findCanonicalInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<String>(l.getValue(), vm(IssueSeverity.INFORMATION, "Removed the item '" + l.getValue() + "'", fhirType() + "." + name, res.getMessages())));
        } else {
            matchR.add(r);
            union.add(r);
            intersection.add(r);
            StructuralMatch<String> sm = new StructuralMatch<String>(l.getValue(), r.getValue());
            combined.getChildren().add(sm);
        }
    }
    for (CanonicalType r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<String>(vm(IssueSeverity.INFORMATION, "Added the item '" + r.getValue() + "'", fhirType() + "." + name, res.getMessages()), r.getValue()));
        }
    }
    comp.put(name, combined);
}
Also used : ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType)

Aggregations

ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)12 ArrayList (java.util.ArrayList)9 IssueSeverity (org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)9 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 JsonObject (com.google.gson.JsonObject)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)2 ValidationResult (org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult)2 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)2 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)2 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)2 TextFile (org.hl7.fhir.utilities.TextFile)2 JsonNull (com.google.gson.JsonNull)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Meta (org.hl7.fhir.dstu3.model.Meta)1 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)1 UriType (org.hl7.fhir.dstu3.model.UriType)1