Search in sources :

Example 21 with CapabilityStatementComparison

use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareRestResources.

private void compareRestResources(CapabilityStatementRestComponent left, CapabilityStatementRestComponent right, StructuralMatch<Element> combined, CapabilityStatementRestComponent union, CapabilityStatementRestComponent intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
    List<CapabilityStatementRestResourceComponent> matchR = new ArrayList<>();
    for (CapabilityStatementRestResourceComponent l : left.getResource()) {
        CapabilityStatementRestResourceComponent r = findInList(right.getResource(), l);
        if (r == null) {
            union.getResource().add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
        } else {
            matchR.add(r);
            CapabilityStatementRestResourceComponent cdM = mergeRestResource(l, r);
            CapabilityStatementRestResourceComponent cdI = intersectRestResource(l, r);
            union.getResource().add(cdM);
            intersection.getResource().add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compareRestResource(sm, l, r, path, res, cdM, cdI);
            combined.getChildren().add(sm);
        }
    }
    for (CapabilityStatementRestResourceComponent r : right.getResource()) {
        if (!matchR.contains(r)) {
            union.getResource().add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
        }
    }
}
Also used : BackboneElement(org.hl7.fhir.r5.model.BackboneElement) Element(org.hl7.fhir.r5.model.Element) ArrayList(java.util.ArrayList) CapabilityStatementRestResourceComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent)

Example 22 with CapabilityStatementComparison

use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareOperations.

private void compareOperations(StructuralMatch<Element> combined, List<CapabilityStatementRestResourceOperationComponent> left, List<CapabilityStatementRestResourceOperationComponent> right, String path, CapabilityStatementComparison res, List<CapabilityStatementRestResourceOperationComponent> union, List<CapabilityStatementRestResourceOperationComponent> intersection) {
    List<CapabilityStatementRestResourceOperationComponent> matchR = new ArrayList<>();
    for (CapabilityStatementRestResourceOperationComponent l : left) {
        CapabilityStatementRestResourceOperationComponent r = findInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this Search Parameter", path)));
        } else {
            matchR.add(r);
            CapabilityStatementRestResourceOperationComponent cdM = mergeOperations(l, r);
            CapabilityStatementRestResourceOperationComponent cdI = intersectOperations(l, r);
            union.add(cdM);
            intersection.add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compareStrings(path, sm.getMessages(), l.getDocumentation(), r.getDocumentation(), "documentation", IssueSeverity.INFORMATION, res);
            compareItemProperty(sm, "definition", l.getDefinitionElement(), r.getDefinitionElement(), path, res, cdM.getDefinitionElement(), cdI.getDefinitionElement(), IssueSeverity.ERROR);
            compareExpectations(sm, l, r, path, res, cdM, cdI);
            combined.getChildren().add(sm);
        }
    }
    for (CapabilityStatementRestResourceOperationComponent r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this Search Parameter", path), r));
        }
    }
}
Also used : BackboneElement(org.hl7.fhir.r5.model.BackboneElement) Element(org.hl7.fhir.r5.model.Element) ArrayList(java.util.ArrayList) CapabilityStatementRestResourceOperationComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent)

Example 23 with CapabilityStatementComparison

use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareRestSecurity.

private void compareRestSecurity(CapabilityStatementRestComponent l, CapabilityStatementRestComponent r, StructuralMatch<Element> smp, CapabilityStatementRestSecurityComponent merge, CapabilityStatementRestSecurityComponent intersect, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
    CapabilityStatementRestSecurityComponent ls = l.hasSecurity() ? l.getSecurity() : null;
    CapabilityStatementRestSecurityComponent rs = r.hasSecurity() ? r.getSecurity() : null;
    StructuralMatch<Element> sm = new StructuralMatch<Element>(ls, rs);
    smp.getChildren().add(sm);
    compareBooleans(path, sm.getMessages(), l.getSecurity().getCorsElement(), r.getSecurity().getCorsElement(), "security.cors", IssueSeverity.WARNING, res);
    compareStrings(path, sm.getMessages(), l.getSecurity().getDescription(), r.getSecurity().getDescription(), "security.description", IssueSeverity.INFORMATION, res);
    compareRestSecurityService(ls, rs, sm, merge, intersect, csU, csI, res, path + ".security");
}
Also used : CapabilityStatementRestSecurityComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestSecurityComponent) BackboneElement(org.hl7.fhir.r5.model.BackboneElement) Element(org.hl7.fhir.r5.model.Element)

Example 24 with CapabilityStatementComparison

use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method addRestSecurityServiceRow.

private Row addRestSecurityServiceRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, CapabilityStatementComparison comparison) {
    Row r = gen.new Row();
    rows.add(r);
    r.getCells().add(gen.new Cell(null, null, "service", null, null));
    CodeableConcept left = t.hasLeft() ? (CodeableConcept) t.getLeft() : null;
    CodeableConcept right = t.hasRight() ? (CodeableConcept) t.getRight() : null;
    r.getCells().add(style(gen.new Cell(null, null, left != null ? gen(left) : "", null, null), left != null ? gen(left) : null, right != null ? gen(right) : null, true));
    r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getText() : "", null, null), left != null ? left.getText() : null, right != null ? right.getText() : null, true));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? gen(right) : "", null, null), left != null ? gen(left) : null, right != null ? gen(right) : null, false));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getText() : "", null, null), left != null ? left.getText() : null, right != null ? right.getText() : null, true));
    r.getCells().add(cellForMessages(gen, t.getMessages()));
    return r;
}
Also used : Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept)

Example 25 with CapabilityStatementComparison

use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareExpectations.

private void compareExpectations(StructuralMatch<Element> combined, Element left, Element right, String path, CapabilityStatementComparison res, Element union, Element intersection) {
    Extension l = left.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation");
    Extension r = right.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation");
    if (l != null || r != null) {
        if (l == null) {
            union.addExtension(r.copy());
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this expectation", path), r));
        } else if (r == null) {
            union.addExtension(l.copy());
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this expectation", path)));
        } else {
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            combined.getChildren().add(sm);
            String ls = l.getValue().primitiveValue();
            String rs = r.getValue().primitiveValue();
            if (ls.equals(rs)) {
                union.addExtension(l.copy());
                intersection.addExtension(l.copy());
            } else {
                sm.getMessages().add(new ValidationMessage(Source.ProfileComparer, IssueType.INFORMATIONAL, path + ".extension('http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation')", "Changed value for expectation: '" + ls + "' vs '" + rs + "'", IssueSeverity.WARNING));
                String lowest = lower(ls, rs) ? ls : rs;
                String highest = lower(ls, rs) ? rs : ls;
                union.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation", new CodeType(lowest));
                intersection.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation", new CodeType(highest));
            }
        }
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) BackboneElement(org.hl7.fhir.r5.model.BackboneElement) Element(org.hl7.fhir.r5.model.Element) CodeType(org.hl7.fhir.r5.model.CodeType)

Aggregations

Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)18 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)18 ArrayList (java.util.ArrayList)14 BackboneElement (org.hl7.fhir.r4b.model.BackboneElement)10 Element (org.hl7.fhir.r4b.model.Element)10 BackboneElement (org.hl7.fhir.r5.model.BackboneElement)10 Element (org.hl7.fhir.r5.model.Element)10 Date (java.util.Date)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 CapabilityStatementRestComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent)2 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent)2 CapabilityStatementRestResourceOperationComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent)2 CapabilityStatementRestResourceSearchParamComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent)2 CapabilityStatementRestSecurityComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestSecurityComponent)2 ResourceInteractionComponent (org.hl7.fhir.r4b.model.CapabilityStatement.ResourceInteractionComponent)2 CodeableConcept (org.hl7.fhir.r4b.model.CodeableConcept)2 Extension (org.hl7.fhir.r4b.model.Extension)2 CapabilityStatement (org.hl7.fhir.r5.model.CapabilityStatement)2 CapabilityStatementRestResourceComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent)2 ResourceInteractionComponent (org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent)2