Search in sources :

Example 1 with CapabilityStatementComparison

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

the class CapabilityStatementComparer method compare.

public CapabilityStatementComparison compare(CapabilityStatement left, CapabilityStatement right) {
    if (left == null)
        throw new DefinitionException("No CapabilityStatement provided (left)");
    if (right == null)
        throw new DefinitionException("No CapabilityStatement provided (right)");
    CapabilityStatementComparison res = new CapabilityStatementComparison(left, right);
    session.identify(res);
    CapabilityStatement cs = new CapabilityStatement();
    res.setUnion(cs);
    session.identify(cs);
    cs.setName("Union" + left.getName() + "And" + right.getName());
    cs.setTitle("Union of " + left.getTitle() + " And " + right.getTitle());
    cs.setStatus(left.getStatus());
    cs.setDate(new Date());
    CapabilityStatement cs1 = new CapabilityStatement();
    res.setIntersection(cs1);
    session.identify(cs1);
    cs1.setName("Intersection" + left.getName() + "And" + right.getName());
    cs1.setTitle("Intersection of " + left.getTitle() + " And " + right.getTitle());
    cs1.setStatus(left.getStatus());
    cs1.setDate(new Date());
    compareMetadata(left, right, res.getMetadata(), res);
    comparePrimitives("kind", left.getKindElement(), right.getKindElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    compareCanonicalList("instantiates", left.getInstantiates(), right.getInstantiates(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getInstantiates(), cs1.getInstantiates());
    compareCanonicalList("imports", left.getImports(), right.getImports(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImports(), cs1.getImports());
    comparePrimitives("software.name", left.getSoftware().getNameElement(), right.getSoftware().getNameElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("software.version", left.getSoftware().getVersionElement(), right.getSoftware().getVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("software.releaseDate", left.getSoftware().getReleaseDateElement(), right.getSoftware().getReleaseDateElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("implementation.description", left.getImplementation().getDescriptionElement(), right.getImplementation().getDescriptionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("implementation.url", left.getImplementation().getUrlElement(), right.getImplementation().getUrlElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("fhirVersion", left.getFhirVersionElement(), right.getFhirVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    compareCodeList("format", left.getFormat(), right.getFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getFormat(), cs1.getFormat());
    compareCodeList("patchFormat", left.getPatchFormat(), right.getPatchFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getPatchFormat(), cs1.getPatchFormat());
    compareCanonicalList("implementationGuide", left.getImplementationGuide(), right.getImplementationGuide(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImplementationGuide(), cs1.getImplementationGuide());
    compareRests(left.getRest(), right.getRest(), res.getCombined(), res.getUnion().getRest(), res.getIntersection().getRest(), res.getUnion(), res.getIntersection(), res, "CapabilityStatement.rest");
    return res;
}
Also used : CapabilityStatement(org.hl7.fhir.r4b.model.CapabilityStatement) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Date(java.util.Date)

Example 2 with CapabilityStatementComparison

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

the class CapabilityStatementComparer method addRestOperationRow.

private Row addRestOperationRow(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, "operation", null, null));
    CapabilityStatementRestResourceOperationComponent left = t.hasLeft() ? (CapabilityStatementRestResourceOperationComponent) t.getLeft() : null;
    CapabilityStatementRestResourceOperationComponent right = t.hasRight() ? (CapabilityStatementRestResourceOperationComponent) t.getRight() : null;
    r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getName() : "", null, null), left != null ? left.getName() : null, right != null ? right.getName() : null, true));
    r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getName() : "", null, null), left != null ? left.getName() : null, right != null ? right.getName() : null, false));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : 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) CapabilityStatementRestResourceOperationComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent)

Example 3 with CapabilityStatementComparison

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

the class CapabilityStatementComparer method compareRestSecurityService.

private void compareRestSecurityService(CapabilityStatementRestSecurityComponent left, CapabilityStatementRestSecurityComponent right, StructuralMatch<Element> combined, CapabilityStatementRestSecurityComponent union, CapabilityStatementRestSecurityComponent intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
    List<CodeableConcept> matchR = new ArrayList<>();
    for (CodeableConcept l : left.getService()) {
        CodeableConcept r = findInList(right.getService(), l);
        if (r == null) {
            union.getService().add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
        } else {
            matchR.add(r);
            CodeableConcept cdM = CodeableConcept.merge(l, r);
            CodeableConcept cdI = CodeableConcept.intersect(l, r);
            union.getService().add(cdM);
            intersection.getService().add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compare(sm, l, r, path, res);
            combined.getChildren().add(sm);
        }
    }
    for (CodeableConcept r : right.getService()) {
        if (!matchR.contains(r)) {
            union.getService().add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
        }
    }
}
Also used : BackboneElement(org.hl7.fhir.r4b.model.BackboneElement) Element(org.hl7.fhir.r4b.model.Element) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept)

Example 4 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.r4b.model.CapabilityStatement.CapabilityStatementRestSecurityComponent) BackboneElement(org.hl7.fhir.r4b.model.BackboneElement) Element(org.hl7.fhir.r4b.model.Element)

Example 5 with CapabilityStatementComparison

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

the class CapabilityStatementComparer method addRestRow.

private Row addRestRow(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, "mode", null, null));
    CapabilityStatementRestComponent left = t.hasLeft() ? (CapabilityStatementRestComponent) t.getLeft() : null;
    CapabilityStatementRestComponent right = t.hasRight() ? (CapabilityStatementRestComponent) t.getRight() : null;
    r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getMode().toCode() : "", null, null), left != null ? left.getMode().toCode() : null, right != null ? right.getMode().toCode() : null, true));
    r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getMode().toCode() : "", null, null), left != null ? left.getMode().toCode() : null, right != null ? right.getMode().toCode() : null, false));
    r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
    r.getCells().add(cellForMessages(gen, t.getMessages()));
    return r;
}
Also used : CapabilityStatementRestComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

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