Search in sources :

Example 6 with OperationDefinitionParameterComponent

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

the class SpreadSheetCreator method addOperation.

private int addOperation(XSSFSheet sheet, XSSFSheet bindings, OperationDefinition opd, int rowCount) {
    Row row = sheet.createRow(rowCount++);
    int columnCount = 0;
    addCell(opd.getCode(), row, columnCount++);
    addCell(use(opd), row, columnCount++);
    addCell("", row, columnCount++);
    addCell(type(opd), row, columnCount++);
    addCell("", row, columnCount++);
    addCell(opd.present(), row, columnCount++);
    addCell(opd.getDescription(), row, columnCount++);
    addCell(opd.getComment(), row, columnCount++);
    addCell(ext(opd, BuildExtensions.EXT_FOOTER), row, columnCount++);
    addCell(ext(opd, BuildExtensions.EXT_FOOTER2), row, columnCount++);
    addCell(exlist(opd, false, "1"), row, columnCount++);
    addCell(exlist(opd, true, "1"), row, columnCount++);
    addCell(exlist(opd, false, "2"), row, columnCount++);
    addCell(exlist(opd, true, "2"), row, columnCount++);
    addCell(status(opd), row, columnCount++);
    addCell(ext(opd, BuildExtensions.EXT_COMMITTEE_NOTES), row, columnCount++);
    for (OperationDefinitionParameterComponent param : opd.getParameter()) {
        rowCount = addOpParam(sheet, bindings, opd.getCode(), param, rowCount);
    }
    return rowCount;
}
Also used : Row(org.apache.poi.ss.usermodel.Row) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 7 with OperationDefinitionParameterComponent

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

the class ResourceParser method convertOperationParameter.

public OperationParameter convertOperationParameter(OperationDefinitionParameterComponent psrc, boolean part) throws IOException {
    List<String> pl = new ArrayList<>();
    for (CanonicalType u : psrc.getTargetProfile()) {
        pl.add(u.asStringValue().replace("http://hl7.org/fhir/StructureDefinition/", ""));
    }
    String t;
    if (psrc.hasExtension(BuildExtensions.EXT_ALLOWED_TYPE)) {
        for (Extension e : psrc.getExtensionsByUrl(BuildExtensions.EXT_ALLOWED_TYPE)) {
            pl.add(e.getValue().primitiveValue());
        }
        t = String.join(" | ", pl);
    } else if (psrc.hasType()) {
        t = psrc.getType().toCode();
        if (pl.size() > 0) {
            t = t + "(" + String.join("|", pl) + ")";
        }
    } else {
        t = "Tuple";
    }
    OperationParameter p = new OperationParameter(psrc.getName(), part ? null : psrc.getUse().toCode(), psrc.getDocumentation(), psrc.getMin(), psrc.getMax(), t, psrc.hasSearchType() ? psrc.getSearchType().toCode() : null, null);
    if (psrc.hasBinding()) {
        p.setBs(parseBinding(psrc.getBinding()));
    }
    for (OperationDefinitionParameterComponent pc : psrc.getPart()) {
        p.getParts().add(convertOperationParameter(pc, true));
    }
    return p;
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 8 with OperationDefinitionParameterComponent

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

the class ProfileGenerator method produceOpParam.

private void produceOpParam(String path, List<OperationDefinitionParameterComponent> opd, OperationParameter p, OperationParameterUse defUse) throws Exception {
    OperationDefinitionParameterComponent pp = new OperationDefinitionParameterComponent();
    pp.setName(p.getName());
    if (path.contains("."))
        pp.setUse(defUse);
    else if (p.getUse().equals("in"))
        pp.setUse(OperationParameterUse.IN);
    else if (p.getUse().equals("out"))
        pp.setUse(OperationParameterUse.OUT);
    else
        // but this is validated elsewhere
        throw new Exception("Unable to determine parameter use: " + p.getUse() + " at " + path + "." + p.getName());
    pp.setDocumentation(preProcessMarkdown(p.getDoc(), "Operation Parameter Doco"));
    pp.setMin(p.getMin());
    pp.setMax(p.getMax());
    if (p.getBs() != null) {
        if (p.getBs().hasMax())
            throw new Error("Max binding not handled yet");
        pp.setBinding(new OperationDefinitionParameterBindingComponent().setStrength(p.getBs().getStrength()).setValueSet(buildValueSetReference(p.getBs())));
        if (!Utilities.noString(p.getBinding().getName())) {
            pp.getBinding().addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName", new StringType(p.getBinding().getName()));
        }
    }
    if (!Utilities.noString(p.getProfile())) {
        pp.addTargetProfile(p.getProfile());
    }
    opd.add(pp);
    if (p.getFhirType().equals("Tuple")) {
        for (OperationParameter part : p.getParts()) {
            produceOpParam(path + "." + p.getName(), pp.getPart(), part, pp.getUse());
        }
    } else {
        List<TypeRef> trs = new TypeParser(version.toCode()).parse(p.getFhirType(), false, null, null, false);
        if (trs.size() > 1) {
            if (p.getSearchType() != null)
                pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
            pp.setType(Enumerations.FHIRAllTypes.fromCode("Element"));
            for (TypeRef tr : trs) {
                pp.addExtension(ToolingExtensions.EXT_ALLOWED_TYPE, new UriType(tr.getName()));
                if (tr.getParams().size() > 0)
                    throw new Error("Multiple types for an operation parameter, where one is a reference, is not supported by the build tools");
            }
        } else {
            TypeRef tr = trs.get(0);
            if (definitions.getConstraints().containsKey(tr.getName())) {
                ProfiledType pt = definitions.getConstraints().get(tr.getName());
                pp.setType(Enumerations.FHIRAllTypes.fromCode(pt.getBaseType().equals("*") ? "Type" : pt.getBaseType()));
                pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + pt.getName());
            } else {
                if (p.getSearchType() != null)
                    pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
                pp.setType(Enumerations.FHIRAllTypes.fromCode(tr.getName().equals("*") ? "Type" : tr.getName()));
                if (tr.getParams().size() == 1 && !tr.getParams().get(0).equals("Any"))
                    pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + tr.getParams().get(0));
            }
        }
    }
}
Also used : TypeParser(org.hl7.fhir.definitions.parsers.TypeParser) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) StringType(org.hl7.fhir.r5.model.StringType) TypeRef(org.hl7.fhir.definitions.model.TypeRef) OperationDefinitionParameterBindingComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent) UriType(org.hl7.fhir.r5.model.UriType)

Example 9 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.dstu2016may.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 10 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());
    tr.td().addText(p.hasType() ? p.getType() : "");
    XhtmlNode td = tr.td();
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
        if (p.getBinding().getValueSet() instanceof Reference)
            AddVsRef(rcontext, p.getBinding().getValueSetReference().getReference(), td);
        else
            td.ah(p.getBinding().getValueSetUriType().getValue()).tx("External Reference");
        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 : Reference(org.hl7.fhir.dstu3.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu3.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