Search in sources :

Example 86 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderLogicItem.

private boolean renderLogicItem(HierarchicalTableGenerator gen, List<Row> rows, Questionnaire q, QuestionnaireItemComponent i) throws IOException {
    Row r = gen.new Row();
    rows.add(r);
    boolean hasExt = false;
    r.setIcon("icon-q-" + i.getType().toCode().toLowerCase() + ".png", i.getType().getDisplay());
    r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + i.getLinkId(), i.getLinkId(), null, null));
    Cell defn = gen.new Cell();
    r.getCells().add(defn);
    if (i.hasMaxLength()) {
        defn.getPieces().add(gen.new Piece(null, "Max Length: ", null));
        defn.getPieces().add(gen.new Piece(null, Integer.toString(i.getMaxLength()), null));
    }
    if (i.hasDefinition()) {
        if (!defn.getPieces().isEmpty())
            defn.addPiece(gen.new Piece("br"));
        defn.getPieces().add(gen.new Piece(null, "Definition: ", null));
        genDefinitionLink(gen, i, defn);
    }
    if (i.hasEnableWhen()) {
        if (!defn.getPieces().isEmpty())
            defn.addPiece(gen.new Piece("br"));
        defn.getPieces().add(gen.new Piece(null, "Enable When: ", null));
        defn.getPieces().add(gen.new Piece(null, "todo", null));
    }
    if (i.hasAnswerValueSet()) {
        if (!defn.getPieces().isEmpty())
            defn.addPiece(gen.new Piece("br"));
        defn.getPieces().add(gen.new Piece(null, "Value Set: ", null));
        if (Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
            ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
            if (vs == null) {
                defn.getPieces().add(gen.new Piece(null, i.getAnswerValueSet(), null));
            } else {
                defn.getPieces().add(gen.new Piece(vs.getUserString("path"), vs.present(), null));
            }
        } else {
            ValueSet vs = context.getWorker().fetchResource(ValueSet.class, i.getAnswerValueSet());
            if (vs == null || !vs.hasUserData("path")) {
                defn.getPieces().add(gen.new Piece(null, i.getAnswerValueSet(), null));
            } else {
                defn.getPieces().add(gen.new Piece(vs.getUserString("path"), vs.present(), null));
            }
        }
    }
    if (i.hasAnswerOption()) {
        if (!defn.getPieces().isEmpty())
            defn.addPiece(gen.new Piece("br"));
        defn.getPieces().add(gen.new Piece(null, "Options: ", null));
        defn.getPieces().add(gen.new Piece(context.getDefinitionsTarget() + "#item." + i.getLinkId(), Integer.toString(i.getAnswerOption().size()) + " " + Utilities.pluralize("option", i.getAnswerOption().size()), null));
    }
    if (i.hasInitial()) {
        for (QuestionnaireItemInitialComponent v : i.getInitial()) {
            if (!defn.getPieces().isEmpty())
                defn.addPiece(gen.new Piece("br"));
            defn.getPieces().add(gen.new Piece(null, "Initial Value: ", null));
            defn.getPieces().add(gen.new Piece(null, v.getValue().fhirType(), null));
            defn.getPieces().add(gen.new Piece(null, " = ", null));
            if (v.getValue().isPrimitive()) {
                defn.getPieces().add(gen.new Piece(null, v.getValue().primitiveValue(), null));
            } else {
                renderCoding(gen, defn.getPieces(), v.getValueCoding());
            }
        }
    }
    if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
        if (!defn.getPieces().isEmpty())
            defn.addPiece(gen.new Piece("br"));
        defn.getPieces().add(gen.new Piece(null, "Expressions: ", null));
        Piece p = gen.new Piece("ul");
        defn.getPieces().add(p);
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
            addExpression(p, e.getValueExpression(), "Initial Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression");
        }
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression")) {
            addExpression(p, e.getValueExpression(), "Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression");
        }
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext")) {
            addExpression(p, e.getValueExpression(), "Item Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext");
        }
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression")) {
            addExpression(p, e.getValueExpression(), "Enable When", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression");
        }
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression")) {
            addExpression(p, e.getValueExpression(), "Calculated Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression");
        }
        for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression")) {
            addExpression(p, e.getValueExpression(), "Candidates", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression");
        }
    }
    for (QuestionnaireItemComponent c : i.getItem()) {
        hasExt = renderLogicItem(gen, r.getSubRows(), q, c) || hasExt;
    }
    return hasExt;
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) QuestionnaireItemComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) QuestionnaireItemInitialComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemInitialComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) ValueSet(org.hl7.fhir.r4b.model.ValueSet)

Example 87 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderRootDefinition.

private boolean renderRootDefinition(XhtmlNode tbl, Questionnaire q, List<QuestionnaireItemComponent> parents) throws IOException {
    boolean ext = false;
    XhtmlNode td = tbl.tr().td("structure").colspan("2").span(null, null).attribute("class", "self-link-parent");
    td.an(q.getId());
    td.img(Utilities.path(context.getLocalPrefix(), "icon_q_root.gif"));
    td.tx(" Questionnaire ");
    td.b().tx(q.getId());
    // general information
    defn(tbl, "URL", q.getUrl());
    defn(tbl, "Version", q.getVersion());
    defn(tbl, "Name", q.getName());
    defn(tbl, "Title", q.getTitle());
    if (q.hasDerivedFrom()) {
        td = defn(tbl, "Derived From");
        boolean first = true;
        for (CanonicalType c : q.getDerivedFrom()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            // todo: make these a reference
            td.tx(c.asStringValue());
        }
    }
    defn(tbl, "Status", q.getStatus().getDisplay());
    defn(tbl, "Experimental", q.getExperimental());
    defn(tbl, "Publication Date", q.getDateElement().primitiveValue());
    defn(tbl, "Approval Date", q.getApprovalDateElement().primitiveValue());
    defn(tbl, "Last Review Date", q.getLastReviewDateElement().primitiveValue());
    if (q.hasEffectivePeriod()) {
        renderPeriod(defn(tbl, "Effective Period"), q.getEffectivePeriod());
    }
    if (q.hasSubjectType()) {
        td = defn(tbl, "Subject Type");
        boolean first = true;
        for (CodeType c : q.getSubjectType()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            td.tx(c.asStringValue());
        }
    }
    defn(tbl, "Description", q.getDescription());
    defn(tbl, "Purpose", q.getPurpose());
    defn(tbl, "Copyright", q.getCopyright());
    if (q.hasCode()) {
        td = defn(tbl, Utilities.pluralize("Code", q.getCode().size()));
        boolean first = true;
        for (Coding c : q.getCode()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            renderCodingWithDetails(td, c);
        }
    }
    return false;
}
Also used : Coding(org.hl7.fhir.r4b.model.Coding) CodeType(org.hl7.fhir.r4b.model.CodeType) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 88 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderFormItem.

private boolean renderFormItem(XhtmlNode x, Questionnaire q, QuestionnaireItemComponent i, String pfx, int indent) throws IOException {
    boolean hasExt = false;
    XhtmlNode d = x.div().style("width: " + Integer.toString(900 - indent * 10) + "px; border-top: 1px #eeeeee solid");
    if (indent > 0) {
        d.style("margin-left: " + Integer.toString(10 * indent) + "px");
    }
    XhtmlNode display = d.div().style("display: inline-block; width: " + Integer.toString(500 - indent * 10) + "px");
    XhtmlNode details = d.div().style("border: 1px #ccccff solid; padding: 2px; display: inline-block; background-color: #fefce7; width: 380px");
    XhtmlNode p = display.para();
    if (i.getType() == QuestionnaireItemType.GROUP) {
        p = p.b();
    }
    if (i.hasPrefix()) {
        p.tx(i.getPrefix());
        p.tx(": ");
    }
    p.span(null, "linkId: " + i.getLinkId()).tx(i.getText());
    if (i.getRequired()) {
        p.span("color: red", "Mandatory").tx("*");
    }
    XhtmlNode input = null;
    switch(i.getType()) {
        case STRING:
            p.tx(" ");
            input = p.input(i.getLinkId(), "text", i.getType().getDisplay(), 60);
            break;
        case ATTACHMENT:
            break;
        case BOOLEAN:
            p.tx(" ");
            input = p.input(i.getLinkId(), "checkbox", i.getType().getDisplay(), 1);
            break;
        case CHOICE:
        case OPENCHOICE:
            input = p.select(i.getLinkId());
            listOptions(q, i, input);
            break;
        case DATE:
            p.tx(" ");
            input = p.input(i.getLinkId(), "date", i.getType().getDisplay(), 10);
            break;
        case DATETIME:
            p.tx(" ");
            input = p.input(i.getLinkId(), "datetime-local", i.getType().getDisplay(), 25);
            break;
        case DECIMAL:
            p.tx(" ");
            input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 15);
            break;
        case DISPLAY:
            break;
        case GROUP:
            break;
        case INTEGER:
            p.tx(" ");
            input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 10);
            break;
        case QUANTITY:
            p.tx(" ");
            input = p.input(i.getLinkId(), "number", "value", 15);
            p.tx(" ");
            input = p.input(i.getLinkId(), "unit", "unit", 10);
            break;
        case QUESTION:
            break;
        case REFERENCE:
            break;
        case TEXT:
            break;
        case TIME:
            break;
        case URL:
            break;
        default:
            break;
    }
    if (input != null) {
        if (i.getReadOnly()) {
            input.attribute("readonly", "1");
            input.style("background-color: #eeeeee");
        }
    }
    // if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation")) {
    // String code = ToolingExtensions.readStringExtension(i,  "http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation");
    // flags.addPiece(gen.new Piece("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod", null, "Orientation: "+code).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-"+code+".png"))));
    // }
    XhtmlNode ul = details.ul();
    boolean hasFlag = false;
    XhtmlNode flags = item(ul, "Flags");
    item(ul, "linkId", i.getLinkId());
    if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject", "Can change the subject of the questionnaire").img(Utilities.path(context.getLocalPrefix(), "icon-qi-subject.png"));
    }
    if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden")) {
        hasFlag = true;
        flags.ah(Utilities.pathURL(context.getSpecificationLink(), "extension-questionnaire-hidden.html"), "Is a hidden item").img(Utilities.path(context.getLocalPrefix(), "icon-qi-hidden.png"));
        d.style("background-color: #eeeeee");
    }
    if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay", "Is optional to display").img(Utilities.path(context.getLocalPrefix(), "icon-qi-optional.png"));
    }
    if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod", "Is linked to an observation").img(Utilities.path(context.getLocalPrefix(), "icon-qi-observation.png"));
    }
    if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory")) {
        CodeableConcept cc = i.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory").getValueCodeableConcept();
        String code = cc.getCode("http://hl7.org/fhir/questionnaire-display-category");
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-displayCategory", "Category: " + code).img(Utilities.path(context.getLocalPrefix(), "icon-qi-" + code + ".png"));
    }
    if (i.hasMaxLength()) {
        item(ul, "Max Length", Integer.toString(i.getMaxLength()));
    }
    if (i.hasDefinition()) {
        genDefinitionLink(item(ul, "Definition"), i);
    }
    if (i.hasEnableWhen()) {
        item(ul, "Enable When", "todo");
    }
    if (i.hasAnswerValueSet()) {
        XhtmlNode ans = item(ul, "Answers");
        if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
            ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
            if (vs == null) {
                ans.tx(i.getAnswerValueSet());
            } else {
                ans.ah(vs.getUserString("path")).tx(vs.present());
            }
        } else {
            ValueSet vs = context.getWorker().fetchResource(ValueSet.class, i.getAnswerValueSet());
            if (vs == null || !vs.hasUserData("path")) {
                ans.tx(i.getAnswerValueSet());
            } else {
                ans.ah(vs.getUserString("path")).tx(vs.present());
            }
        }
    }
    if (i.hasAnswerOption()) {
        item(ul, "Answers", Integer.toString(i.getAnswerOption().size()) + " " + Utilities.pluralize("option", i.getAnswerOption().size()), context.getDefinitionsTarget() + "#item." + i.getLinkId());
    }
    if (i.hasInitial()) {
        XhtmlNode vi = item(ul, "Initial Values");
        boolean first = true;
        for (QuestionnaireItemInitialComponent v : i.getInitial()) {
            if (first)
                first = false;
            else
                vi.tx(", ");
            if (v.getValue().isPrimitive()) {
                vi.tx(v.getValue().primitiveValue());
            } else {
                renderCoding(vi, v.getValueCoding(), true);
            }
        }
    }
    if (!hasFlag) {
        ul.remove(flags);
    }
    // if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
    // if (!defn.getPieces().isEmpty()) defn.addPiece(gen.new Piece("br"));
    // defn.getPieces().add(gen.new Piece(null, "Expressions: ", null));
    // Piece p = gen.new Piece("ul");
    // defn.getPieces().add(p);
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
    // addExpression(p, e.getValueExpression(), "Initial Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression")) {
    // addExpression(p, e.getValueExpression(), "Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext")) {
    // addExpression(p, e.getValueExpression(), "Item Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression")) {
    // addExpression(p, e.getValueExpression(), "Enable When", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression")) {
    // addExpression(p, e.getValueExpression(), "Calculated Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression")) {
    // addExpression(p, e.getValueExpression(), "Candidates", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression");
    // }
    // }
    // 
    int t = 1;
    for (QuestionnaireItemComponent c : i.getItem()) {
        hasExt = renderFormItem(x, q, c, pfx == null ? null : pfx + "." + Integer.toString(t), indent + 1) || hasExt;
        t++;
    }
    return hasExt;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent) QuestionnaireItemInitialComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemInitialComponent) ValueSet(org.hl7.fhir.r4b.model.ValueSet) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept)

Example 89 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderTree.

public boolean renderTree(XhtmlNode x, Questionnaire q) throws UnsupportedEncodingException, IOException {
    boolean hasFlags = checkForFlags(q.getItem());
    boolean doOpts = context.getDefinitionsTarget() == null && hasAnyOptions(q.getItem());
    if (doOpts) {
        x.b().tx("Structure");
    }
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
    TableModel model = gen.new TableModel("qtree=" + q.getId(), !forResource);
    model.setAlternating(true);
    model.setDocoImg(context.getSpecificationLink() + "help16.png");
    model.setDocoRef(context.getSpecificationLink() + "formats.html#table");
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "LinkId"), translate("sd.hint", "The linkId for the item"), null, 0));
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Text"), translate("sd.hint", "Text for the item"), null, 0));
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Cardinality"), translate("sd.hint", "Minimum and Maximum # of times the the itemcan appear in the instance"), null, 0));
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Type"), translate("sd.hint", "The type of the item"), null, 0));
    if (hasFlags) {
        model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Flags"), translate("sd.hint", "Other attributes of the item"), null, 0));
    }
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Description & Constraints"), translate("sd.hint", "Additional information about the item"), null, 0));
    boolean hasExt = false;
    // first we add a root for the questionaire itself
    Row row = addTreeRoot(gen, model.getRows(), q, hasFlags);
    for (QuestionnaireItemComponent i : q.getItem()) {
        hasExt = renderTreeItem(gen, row.getSubRows(), q, i, hasFlags) || hasExt;
    }
    XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
    x.getChildNodes().add(xn);
    if (doOpts) {
        renderOptions(q, x);
    }
    return hasExt;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 90 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderItemOptions.

public void renderItemOptions(XhtmlNode x, QuestionnaireItemComponent i) {
    if (i.hasAnswerOption()) {
        boolean useSelect = false;
        for (QuestionnaireItemAnswerOptionComponent opt : i.getAnswerOption()) {
            useSelect = useSelect || opt.getInitialSelected();
        }
        x.an("opt-item." + i.getLinkId());
        x.para().b().tx("Answer options for " + i.getLinkId());
        XhtmlNode ul = x.ul();
        for (QuestionnaireItemAnswerOptionComponent opt : i.getAnswerOption()) {
            XhtmlNode li = ul.li();
            li.style("font-size: 11px");
            if (useSelect) {
                if (opt.getInitialSelected()) {
                    li.img("icon-selected.png");
                } else {
                    li.img("icon-not-selected.png");
                }
            }
            if (opt.getValue().isPrimitive()) {
                li.tx(opt.getValue().primitiveValue());
            } else if (opt.getValue() instanceof Coding) {
                Coding c = (Coding) opt.getValue();
                String link = c.hasSystem() ? context.getWorker().getLinkForUrl(context.getSpecificationLink(), c.getSystem()) : null;
                if (link == null) {
                    li.tx(c.getSystem() + "#" + c.getCode());
                } else {
                    li.ah(link).tx(describeSystem(c.getSystem()));
                    li.tx(": " + c.getCode());
                }
                if (c.hasDisplay()) {
                    li.tx(" (\"" + c.getDisplay() + "\")");
                }
            } else {
                li.tx("??");
            }
        }
    }
}
Also used : QuestionnaireItemAnswerOptionComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemAnswerOptionComponent) Coding(org.hl7.fhir.r4b.model.Coding) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

ArrayList (java.util.ArrayList)32 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)16 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)15 QuestionnaireItemComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)11 Element (org.hl7.fhir.r5.elementmodel.Element)9 NodeStack (org.hl7.fhir.validation.instance.utils.NodeStack)9 QuestionnaireItemComponent (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent)7 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)7 QuestionnaireResponse (org.hl7.fhir.r4b.model.QuestionnaireResponse)7 QuestionnaireItemAnswerOptionComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent)7 QuestionnaireResponse (org.hl7.fhir.r5.model.QuestionnaireResponse)7 QuestionnaireItemComponent (org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)6 ValueSet (org.hl7.fhir.r4b.model.ValueSet)6 ValueSet (org.hl7.fhir.r5.model.ValueSet)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)6 QuestionnaireResponse (org.hl7.fhir.dstu2016may.model.QuestionnaireResponse)5 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)5