Search in sources :

Example 21 with OperationDefinitionParameterComponent

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

the class NarrativeGenerator method genOpParam.

private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode tr;
    tr = tbl.addTag("tr");
    tr.addTag("td").addText(p.getUse().toString());
    tr.addTag("td").addText(path + p.getName());
    tr.addTag("td").addText(Integer.toString(p.getMin()) + ".." + p.getMax());
    tr.addTag("td").addText(p.hasType() ? p.getType() : "");
    XhtmlNode td = tr.addTag("td");
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
        if (p.getBinding().getValueSet() instanceof Reference)
            AddVsRef(p.getBinding().getValueSetReference().getReference(), td);
        else
            td.addTag("a").setAttribute("href", p.getBinding().getValueSetUriType().getValue()).addText("External Reference");
        td.addText(" (" + p.getBinding().getStrength().getDisplay() + ")");
    }
    addMarkdown(tr.addTag("td"), p.getDocumentation());
    if (!p.hasType()) {
        for (OperationDefinitionParameterComponent pp : p.getPart()) {
            genOpParam(tbl, path + p.getName() + ".", pp);
        }
    }
}
Also used : Reference(org.hl7.fhir.dstu2.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 22 with OperationDefinitionParameterComponent

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

the class OperationDefinition method setProperty.

@Override
public Base setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url")) {
        // UriType
        this.url = castToUri(value);
    } else if (name.equals("version")) {
        // StringType
        this.version = castToString(value);
    } else if (name.equals("name")) {
        // StringType
        this.name = castToString(value);
    } else if (name.equals("status")) {
        value = new PublicationStatusEnumFactory().fromType(castToCode(value));
        // Enumeration<PublicationStatus>
        this.status = (Enumeration) value;
    } else if (name.equals("kind")) {
        value = new OperationKindEnumFactory().fromType(castToCode(value));
        // Enumeration<OperationKind>
        this.kind = (Enumeration) value;
    } else if (name.equals("experimental")) {
        // BooleanType
        this.experimental = castToBoolean(value);
    } else if (name.equals("date")) {
        // DateTimeType
        this.date = castToDateTime(value);
    } else if (name.equals("publisher")) {
        // StringType
        this.publisher = castToString(value);
    } else if (name.equals("contact")) {
        this.getContact().add(castToContactDetail(value));
    } else if (name.equals("description")) {
        // MarkdownType
        this.description = castToMarkdown(value);
    } else if (name.equals("useContext")) {
        this.getUseContext().add(castToUsageContext(value));
    } else if (name.equals("jurisdiction")) {
        this.getJurisdiction().add(castToCodeableConcept(value));
    } else if (name.equals("purpose")) {
        // MarkdownType
        this.purpose = castToMarkdown(value);
    } else if (name.equals("idempotent")) {
        // BooleanType
        this.idempotent = castToBoolean(value);
    } else if (name.equals("code")) {
        // CodeType
        this.code = castToCode(value);
    } else if (name.equals("comment")) {
        // StringType
        this.comment = castToString(value);
    } else if (name.equals("base")) {
        // Reference
        this.base = castToReference(value);
    } else if (name.equals("resource")) {
        this.getResource().add(castToCode(value));
    } else if (name.equals("system")) {
        // BooleanType
        this.system = castToBoolean(value);
    } else if (name.equals("type")) {
        // BooleanType
        this.type = castToBoolean(value);
    } else if (name.equals("instance")) {
        // BooleanType
        this.instance = castToBoolean(value);
    } else if (name.equals("parameter")) {
        this.getParameter().add((OperationDefinitionParameterComponent) value);
    } else if (name.equals("overload")) {
        this.getOverload().add((OperationDefinitionOverloadComponent) value);
    } else
        return super.setProperty(name, value);
    return value;
}
Also used : PublicationStatusEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)

Example 23 with OperationDefinitionParameterComponent

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

the class OperationDefinitionRenderer method render.

public boolean render(XhtmlNode x, OperationDefinition opd) throws IOException, FHIRException, EOperationOutcome {
    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());
    }
    if (opd.hasInputProfile()) {
        XhtmlNode p = x.para();
        p.tx("Input parameters Profile: ");
        StructureDefinition sd = context.getContext().fetchResource(StructureDefinition.class, opd.getInputProfile());
        if (sd == null) {
            p.pre().tx(opd.getInputProfile());
        } else {
            p.ah(sd.getUserString("path")).tx(sd.present());
        }
    }
    if (opd.hasOutputProfile()) {
        XhtmlNode p = x.para();
        p.tx("Output parameters Profile: ");
        StructureDefinition sd = context.getContext().fetchResource(StructureDefinition.class, opd.getOutputProfile());
        if (sd == null) {
            p.pre().tx(opd.getOutputProfile());
        } else {
            p.ah(sd.getUserString("path")).tx(sd.present());
        }
    }
    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(tbl, "", p);
    }
    addMarkdown(x, opd.getComment());
    return true;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CodeType(org.hl7.fhir.r5.model.CodeType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 24 with OperationDefinitionParameterComponent

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

the class NarrativeGenerator method genOpParam.

private void genOpParam(ResourceContext rcontext, 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 = context.fetchTypeDefinition(p.getType());
    if (sd == null)
        td.tx(p.hasType() ? p.getType() : "");
    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.fetchTypeDefinition(s);
            if (sdt == null)
                td.tx(p.hasType() ? p.getType() : "");
            else
                td.ah(sdt.getUserString("path")).tx(s);
        }
    } else
        td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType() : "");
    if (p.hasSearchType()) {
        td.br();
        td.tx("(");
        td.ah(corePath == null ? "search.html#" + p.getSearchType().toCode() : Utilities.pathURL(corePath, "search.html#" + p.getSearchType().toCode())).tx(p.getSearchType().toCode());
        td.tx(")");
    }
    td = tr.td();
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
        AddVsRef(rcontext, p.getBinding().getValueSet(), td);
        td.tx(" (" + p.getBinding().getStrength().getDisplay() + ")");
    }
    addMarkdown(tr.td(), p.getDocumentation());
    if (!p.hasType()) {
        for (OperationDefinitionParameterComponent pp : p.getPart()) {
            genOpParam(rcontext, tbl, path + p.getName() + ".", pp);
        }
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 25 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 void generate(OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.addTag("h2").addText(opd.getName());
    x.addTag("p").addText(Utilities.capitalize(opd.getKind().toString()) + ": " + opd.getName());
    addMarkdown(x, opd.getDescription());
    if (opd.getSystem())
        x.addTag("p").addText("URL: [base]/$" + opd.getCode());
    for (CodeType c : opd.getType()) {
        x.addTag("p").addText("URL: [base]/" + c.getValue() + "/$" + opd.getCode());
        if (opd.getInstance())
            x.addTag("p").addText("URL: [base]/" + c.getValue() + "/[id]/$" + opd.getCode());
    }
    x.addTag("p").addText("Parameters");
    XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
    XhtmlNode tr = tbl.addTag("tr");
    tr.addTag("td").addTag("b").addText("Use");
    tr.addTag("td").addTag("b").addText("Name");
    tr.addTag("td").addTag("b").addText("Cardinality");
    tr.addTag("td").addTag("b").addText("Type");
    tr.addTag("td").addTag("b").addText("Binding");
    tr.addTag("td").addTag("b").addText("Documentation");
    for (OperationDefinitionParameterComponent p : opd.getParameter()) {
        genOpParam(tbl, "", p);
    }
    addMarkdown(x, opd.getComment());
    inject(opd, x, NarrativeStatus.GENERATED);
}
Also used : CodeType(org.hl7.fhir.dstu2016may.model.CodeType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2016may.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