Search in sources :

Example 16 with OperationDefinitionParameterComponent

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

the class SpreadSheetReloader method processOperationParameter.

private void processOperationParameter(XSSFRow row, XSSFRow cols, String name, OperationDefinition opd, Map<String, OperationDefinitionParameterComponent> params, XSSFSheet bindings) {
    String pname = name.substring(name.lastIndexOf(".") + 1);
    String context = name.substring(0, name.lastIndexOf("."));
    OperationParameterUse use = OperationParameterUse.fromCode(getValue(row, cols, CN_USE));
    OperationDefinitionParameterComponent param = params.get(pname + (use != null ? ":" + use : ""));
    if (param == null) {
        param = new OperationDefinitionParameterComponent().setName(pname).setUse(use);
    }
    OperationDefinitionParameterComponent ctxt = findParam(opd, context);
    if (ctxt == null) {
        opd.getParameter().add(param);
    } else {
        ctxt.getPart().add(param);
    }
    param.setMinElement(null);
    param.setMaxElement(null);
    String[] card = splitValue(row, cols, CN_CARD, "\\.\\.");
    if (card.length == 2) {
        param.setMin(Integer.parseInt(card[0]));
        param.setMax(card[1]);
    }
    String t = getValue(row, cols, CN_TYPE);
    if (!Utilities.noString(t)) {
        if (t.contains(" | ")) {
            param.setType(FHIRAllTypes.ELEMENT);
            for (String s : t.split("\\|")) {
                param.addExtension(BuildExtensions.EXT_ALLOWED_TYPE, new UriType(s.trim()));
            }
        } else {
            if (t.contains("/")) {
                param.setSearchType(SearchParamType.fromCode(t.substring(t.lastIndexOf("/") + 1).trim()));
                t = t.substring(0, t.indexOf("/")).trim();
            }
            param.setType(FHIRAllTypes.fromCode(t));
        }
    }
    parseBinding(param, getValue(row, cols, CN_BINDING), bindings);
    param.setDocumentation(getValue(row, cols, CN_DOCUMENTATION));
    parseStatus(param, getValue(row, cols, CN_STATUS));
    readExt(param, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.String);
}
Also used : OperationParameterUse(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent) UriType(org.hl7.fhir.r5.model.UriType)

Example 17 with OperationDefinitionParameterComponent

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

the class SpreadSheetReloader method moveParams.

private void moveParams(OperationDefinition opd, Map<String, OperationDefinitionParameterComponent> params) {
    params.clear();
    for (OperationDefinitionParameterComponent p : opd.getParameter()) {
        String path = p.getName() + (p.hasUse() ? ":" + p.getUse() : "");
        params.put(path, p);
        moveParts(path, p, params);
        p.getPart().clear();
    }
    opd.getParameter().clear();
}
Also used : OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 18 with OperationDefinitionParameterComponent

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

the class SpreadSheetReloader method findParam.

private OperationDefinitionParameterComponent findParam(OperationDefinition opd, String context) {
    if (opd.getCode().equals(context)) {
        return null;
    }
    for (int i = opd.getParameter().size() - 1; i >= 0; i--) {
        OperationDefinitionParameterComponent p = opd.getParameter().get(i);
        String path = opd.getCode() + "." + p.getName();
        if (path.equals(context)) {
            return p;
        }
        if (context.startsWith(path)) {
            return findParam(path, 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)

Example 19 with OperationDefinitionParameterComponent

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

the class ResourceParser method convertOperation.

private Operation convertOperation(OperationDefinition src) throws FileNotFoundException, FHIRException, IOException, Exception {
    List<OperationExample> examples = new ArrayList<>();
    List<OperationExample> examples2 = new ArrayList<>();
    for (Extension ex : src.getExtensionsByUrl(BuildExtensions.EXT_OP_EXAMPLE)) {
        if ("2".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))) {
            processExample(examples2, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
        } else {
            processExample(examples, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
        }
    }
    Operation op = new Operation(src.getName(), src.getSystem(), src.getType(), src.getInstance(), src.getKind().toCode(), src.getTitle(), src.getDescription(), BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER), examples, !src.getAffectsState());
    op.getExamples2().addAll(examples2);
    op.setResource(src);
    op.setStandardsStatus(StandardsStatus.fromCode(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_STANDARDS_STATUS)));
    op.setFmm(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FMM_LEVEL));
    op.setFooter2(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER2));
    for (OperationDefinitionParameterComponent psrc : src.getParameter()) {
        op.getParameters().add(convertOperationParameter(psrc, false));
    }
    return op;
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ArrayList(java.util.ArrayList) Operation(org.hl7.fhir.definitions.model.Operation) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 20 with OperationDefinitionParameterComponent

use of org.hl7.fhir.r4.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.getNotes());
    inject(opd, x, NarrativeStatus.GENERATED);
}
Also used : CodeType(org.hl7.fhir.dstu2.model.CodeType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2.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