Search in sources :

Example 11 with OperationDefinitionParameterComponent

use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class OperationDefinitionRenderer method genOpParam.

private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode tr;
    tr = tbl.tr();
    tr.td().addText(p.getUse().toString());
    tr.td().addText(path + p.getName());
    tr.td().addText(Integer.toString(p.getMin()) + ".." + p.getMax());
    XhtmlNode td = tr.td();
    StructureDefinition sd = p.getType() != null ? context.getWorker().fetchTypeDefinition(p.getType().toCode()) : null;
    if (sd == null)
        td.tx(p.hasType() ? p.getType().toCode() : "");
    else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) {
        boolean first = true;
        for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) {
            if (first)
                first = false;
            else
                td.tx(" | ");
            String s = ex.getValue().primitiveValue();
            StructureDefinition sdt = context.getWorker().fetchTypeDefinition(s);
            if (sdt == null)
                td.tx(p.hasType() ? p.getType().toCode() : "");
            else
                td.ah(sdt.getUserString("path")).tx(s);
        }
    } else
        td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType().toCode() : "");
    if (p.hasSearchType()) {
        td.br();
        td.tx("(");
        td.ah(context.getSpecificationLink() == null ? "search.html#" + p.getSearchType().toCode() : Utilities.pathURL(context.getSpecificationLink(), "search.html#" + p.getSearchType().toCode())).tx(p.getSearchType().toCode());
        td.tx(")");
    }
    td = tr.td();
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
        AddVsRef(p.getBinding().getValueSet(), td);
        td.tx(" (" + p.getBinding().getStrength().getDisplay() + ")");
    }
    addMarkdown(tr.td(), p.getDocumentation());
    if (!p.hasType()) {
        for (OperationDefinitionParameterComponent pp : p.getPart()) {
            genOpParam(tbl, path + p.getName() + ".", pp);
        }
    }
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.r4b.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 12 with OperationDefinitionParameterComponent

use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class OperationDefinitionRenderer method genOpParam.

private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode tr;
    tr = tbl.tr();
    tr.td().addText(p.getUse().toString());
    tr.td().addText(path + p.getName());
    tr.td().addText(Integer.toString(p.getMin()) + ".." + p.getMax());
    XhtmlNode td = tr.td();
    StructureDefinition sd = p.getType() != null ? context.getWorker().fetchTypeDefinition(p.getType().toCode()) : null;
    if (sd == null)
        td.tx(p.hasType() ? p.getType().toCode() : "");
    else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) {
        boolean first = true;
        for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) {
            if (first)
                first = false;
            else
                td.tx(" | ");
            String s = ex.getValue().primitiveValue();
            StructureDefinition sdt = context.getWorker().fetchTypeDefinition(s);
            if (sdt == null)
                td.tx(p.hasType() ? p.getType().toCode() : "");
            else
                td.ah(sdt.getUserString("path")).tx(s);
        }
    } else
        td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType().toCode() : "");
    if (p.hasSearchType()) {
        td.br();
        td.tx("(");
        td.ah(context.getSpecificationLink() == null ? "search.html#" + p.getSearchType().toCode() : Utilities.pathURL(context.getSpecificationLink(), "search.html#" + p.getSearchType().toCode())).tx(p.getSearchType().toCode());
        td.tx(")");
    }
    td = tr.td();
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
        AddVsRef(p.getBinding().getValueSet(), td);
        td.tx(" (" + p.getBinding().getStrength().getDisplay() + ")");
    }
    addMarkdown(tr.td(), p.getDocumentation());
    if (!p.hasType()) {
        for (OperationDefinitionParameterComponent pp : p.getPart()) {
            genOpParam(tbl, path + p.getName() + ".", pp);
        }
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 13 with OperationDefinitionParameterComponent

use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.h2().addText(opd.getName());
    x.para().addText(Utilities.capitalize(opd.getKind().toString()) + ": " + opd.getName());
    x.para().tx("The official URL for this operation definition is: ");
    x.pre().tx(opd.getUrl());
    addMarkdown(x, opd.getDescription());
    if (opd.getSystem())
        x.para().tx("URL: [base]/$" + opd.getCode());
    for (CodeType c : opd.getResource()) {
        if (opd.getType())
            x.para().tx("URL: [base]/" + c.getValue() + "/$" + opd.getCode());
        if (opd.getInstance())
            x.para().tx("URL: [base]/" + c.getValue() + "/[id]/$" + opd.getCode());
    }
    x.para().tx("Parameters");
    XhtmlNode tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    tr.td().b().tx("Use");
    tr.td().b().tx("Name");
    tr.td().b().tx("Cardinality");
    tr.td().b().tx("Type");
    tr.td().b().tx("Binding");
    tr.td().b().tx("Documentation");
    for (OperationDefinitionParameterComponent p : opd.getParameter()) {
        genOpParam(rcontext, tbl, "", p);
    }
    addMarkdown(x, opd.getComment());
    inject(opd, x, NarrativeStatus.GENERATED);
    return true;
}
Also used : CodeType(org.hl7.fhir.dstu3.model.CodeType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 14 with OperationDefinitionParameterComponent

use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.h2().addText(opd.getName());
    x.para().addText(Utilities.capitalize(opd.getKind().toString()) + ": " + opd.getName());
    x.para().tx("The official URL for this operation definition is: ");
    x.pre().tx(opd.getUrl());
    addMarkdown(x, opd.getDescription());
    if (opd.getSystem())
        x.para().tx("URL: [base]/$" + opd.getCode());
    for (CodeType c : opd.getResource()) {
        if (opd.getType())
            x.para().tx("URL: [base]/" + c.getValue() + "/$" + opd.getCode());
        if (opd.getInstance())
            x.para().tx("URL: [base]/" + c.getValue() + "/[id]/$" + opd.getCode());
    }
    x.para().tx("Parameters");
    XhtmlNode tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    tr.td().b().tx("Use");
    tr.td().b().tx("Name");
    tr.td().b().tx("Cardinality");
    tr.td().b().tx("Type");
    tr.td().b().tx("Binding");
    tr.td().b().tx("Documentation");
    for (OperationDefinitionParameterComponent p : opd.getParameter()) {
        genOpParam(rcontext, tbl, "", p);
    }
    addMarkdown(x, opd.getComment());
    inject(opd, x, NarrativeStatus.GENERATED);
    return true;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 15 with OperationDefinitionParameterComponent

use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.

the class SpreadSheetReloader method findParam.

private OperationDefinitionParameterComponent findParam(String path, OperationDefinitionParameterComponent pp, String context) {
    for (int i = pp.getPart().size() - 1; i >= 0; i--) {
        OperationDefinitionParameterComponent p = pp.getPart().get(i);
        String npath = path + "." + p.getName();
        if (npath.equals(context)) {
            return p;
        }
        if (context.startsWith(npath)) {
            return findParam(npath, p, context);
        }
    }
    throw new Error("Unable to find parameter " + context);
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Aggregations

OperationDefinitionParameterComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)13 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)12 Row (org.apache.poi.ss.usermodel.Row)3 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)3 Extension (org.hl7.fhir.r5.model.Extension)3 OperationDefinitionParameterBindingComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent)3 ArrayList (java.util.ArrayList)2 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)2 OperationParameter (org.hl7.fhir.definitions.model.OperationParameter)2 OperationDefinitionParameterComponent (org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent)2 OperationDefinitionParameterComponent (org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent)2 OperationDefinitionParameterComponent (org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 OperationDefinitionParameterComponent (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent)2 OperationDefinitionParameterComponent (org.hl7.fhir.r4b.model.OperationDefinition.OperationDefinitionParameterComponent)2 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)2 UriType (org.hl7.fhir.r5.model.UriType)2 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1