Search in sources :

Example 16 with CapabilityStatementRestComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementRenderer method render.

public boolean render(XhtmlNode x, CapabilityStatement conf) throws FHIRFormatError, DefinitionException, IOException {
    x.h2().addText(conf.getName());
    addMarkdown(x, conf.getDescription());
    if (conf.getRest().size() > 0) {
        CapabilityStatementRestComponent rest = conf.getRest().get(0);
        XhtmlNode t = x.table(null);
        addTableRow(t, "Mode", rest.getMode().toString());
        addMarkdown(addTableRow(t, "Description"), rest.getDocumentation());
        addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION));
        addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM));
        addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM));
        boolean hasVRead = false;
        boolean hasPatch = false;
        boolean hasDelete = false;
        boolean hasHistory = false;
        boolean hasUpdates = false;
        for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
            hasVRead = hasVRead || hasOp(r, TypeRestfulInteraction.VREAD);
            hasPatch = hasPatch || hasOp(r, TypeRestfulInteraction.PATCH);
            hasDelete = hasDelete || hasOp(r, TypeRestfulInteraction.DELETE);
            hasHistory = hasHistory || hasOp(r, TypeRestfulInteraction.HISTORYTYPE);
            hasUpdates = hasUpdates || hasOp(r, TypeRestfulInteraction.HISTORYINSTANCE);
        }
        t = x.table(null);
        XhtmlNode tr = t.tr();
        tr.th().b().tx("Resource Type");
        tr.th().b().tx("Profile");
        tr.th().b().attribute("title", "GET a resource (read interaction)").tx("Read");
        if (hasVRead)
            tr.th().b().attribute("title", "GET past versions of resources (vread interaction)").tx("V-Read");
        tr.th().b().attribute("title", "GET all set of resources of the type (search interaction)").tx("Search");
        tr.th().b().attribute("title", "PUT a new resource version (update interaction)").tx("Update");
        if (hasPatch)
            tr.th().b().attribute("title", "PATCH a new resource version (patch interaction)").tx("Patch");
        tr.th().b().attribute("title", "POST a new resource (create interaction)").tx("Create");
        if (hasDelete)
            tr.th().b().attribute("title", "DELETE a resource (delete interaction)").tx("Delete");
        if (hasUpdates)
            tr.th().b().attribute("title", "GET changes to a resource (history interaction on instance)").tx("Updates");
        if (hasHistory)
            tr.th().b().attribute("title", "GET changes for all resources of the type (history interaction on type)").tx("History");
        XhtmlNode profCell = null;
        boolean hasProf = false;
        boolean hasSupProf = false;
        for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
            tr = t.tr();
            tr.td().addText(r.getType());
            // Show profiles
            profCell = tr.td();
            hasProf = r.hasProfile();
            hasSupProf = r.hasSupportedProfile();
            if ((!hasProf) && (!hasSupProf)) {
                profCell.nbsp();
            } else if (hasProf) {
                profCell.ah(r.getProfile()).addText(r.getProfile());
                if (hasSupProf) {
                    profCell.br();
                    profCell.addText("Additional supported profiles:");
                    for (CanonicalType sp : r.getSupportedProfile()) {
                        profCell.br();
                        profCell.nbsp().nbsp();
                        profCell.ah(sp.getValue()).addText(sp.getValue());
                    }
                }
            } else {
                // Case of only supported profiles
                profCell.addText("Supported profiles:");
                for (CanonicalType sp : r.getSupportedProfile()) {
                    profCell.br();
                    profCell.nbsp().nbsp();
                    profCell.ah(sp.getValue()).addText(sp.getValue());
                }
            }
            // Show capabilities
            tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
            if (hasVRead)
                tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
            tr.td().addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
            tr.td().addText(showOp(r, TypeRestfulInteraction.UPDATE));
            if (hasPatch)
                tr.td().addText(showOp(r, TypeRestfulInteraction.PATCH));
            tr.td().addText(showOp(r, TypeRestfulInteraction.CREATE));
            if (hasDelete)
                tr.td().addText(showOp(r, TypeRestfulInteraction.DELETE));
            if (hasUpdates)
                tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
            if (hasHistory)
                tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
        }
    }
    return true;
}
Also used : CapabilityStatementRestComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent) CapabilityStatementRestResourceComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 17 with CapabilityStatementRestComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent in project org.hl7.fhir.core by hapifhir.

the class OpenApiGenerator method generate.

public void generate(String license, String url) {
    dest.info().title(source.present()).description(source.getDescription()).license(license, url).version(source.getVersion());
    for (ContactDetail cd : source.getContact()) {
        dest.info().contact(cd.getName(), email(cd.getTelecom()), url(cd.getTelecom()));
    }
    if (source.hasPublisher())
        dest.info().contact(source.getPublisher(), null, null);
    if (source.hasImplementation()) {
        dest.server(source.getImplementation().getUrl()).description(source.getImplementation().getDescription());
    }
    dest.externalDocs().url(source.getUrl()).description("FHIR CapabilityStatement");
    for (CapabilityStatementRestComponent csr : source.getRest()) {
        if (csr.getMode() == org.hl7.fhir.r4b.model.CapabilityStatement.RestfulCapabilityMode.SERVER) {
            generatePaths(csr);
        }
    }
    writeBaseParameters(dest.components());
}
Also used : ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) CapabilityStatementRestComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent)

Example 18 with CapabilityStatementRestComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent 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 19 with CapabilityStatementRestComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent 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 20 with CapabilityStatementRestComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareRests.

private void compareRests(List<CapabilityStatementRestComponent> left, List<CapabilityStatementRestComponent> right, StructuralMatch<Element> combined, List<CapabilityStatementRestComponent> union, List<CapabilityStatementRestComponent> intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
    List<CapabilityStatementRestComponent> matchR = new ArrayList<>();
    for (CapabilityStatementRestComponent l : left) {
        CapabilityStatementRestComponent r = findInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
        } else {
            matchR.add(r);
            CapabilityStatementRestComponent cdM = merge(l, r, res);
            CapabilityStatementRestComponent cdI = intersect(l, r, res);
            union.add(cdM);
            intersection.add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compare(sm, l, r, path + ".where(mode='" + l.getMode() + "')", res);
            combined.getChildren().add(sm);
            compareRestSecurity(l, r, sm, cdM.getSecurity(), cdI.getSecurity(), csU, csI, res, path + ".security");
            compareRestResources(l, r, sm, cdM, cdI, csU, csI, res, path + ".resource");
            compareSearchParams(combined, l.getSearchParam(), r.getSearchParam(), path, res, cdM.getSearchParam(), cdI.getSearchParam());
            compareOperations(combined, l.getOperation(), r.getOperation(), path, res, cdM.getOperation(), cdI.getOperation());
            compareItemPropertyList(sm, "compartment", l.getCompartment(), r.getCompartment(), path, res, cdM.getCompartment(), cdI.getCompartment(), IssueSeverity.ERROR);
        }
    }
    for (CapabilityStatementRestComponent r : right) {
        if (!matchR.contains(r)) {
            union.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) CapabilityStatementRestComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent)

Aggregations

CapabilityStatementRestComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent)7 ArrayList (java.util.ArrayList)5 CapabilityStatementRestResourceComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent)5 CapabilityStatementRestComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent)4 CapabilityStatementRestComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent)3 BackboneElement (org.hl7.fhir.r4b.model.BackboneElement)3 Element (org.hl7.fhir.r4b.model.Element)3 BackboneElement (org.hl7.fhir.r5.model.BackboneElement)3 Element (org.hl7.fhir.r5.model.Element)3 HashSet (java.util.HashSet)2 CapabilityStatementRestComponent (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent)2 CapabilityStatementRestResourceComponent (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent)2 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent)2 CapabilityStatementRestSecurityComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestSecurityComponent)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 VersionUtil (ca.uhn.fhir.util.VersionUtil)1