Search in sources :

Example 46 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method renderExpansionRules.

private void renderExpansionRules(XhtmlNode x, ConceptSetComponent inc, int index, Map<String, ConceptDefinitionComponent> definitions) throws FHIRException, IOException {
    String s = "This include specifies a heirarchy for when value sets are generated for use in a User Interface, but the rules are not properly defined";
    if (inc.hasExtension(ToolingExtensions.EXT_EXPAND_RULES)) {
        String rule = inc.getExtensionString(ToolingExtensions.EXT_EXPAND_RULES);
        if (rule != null) {
            switch(rule) {
                case "all-codes":
                    s = "This include specifies a heirarchy for when value sets are generated for use in a User Interface. The expansion contains all the codes, and also this structure:";
                case "ungrouped":
                    s = "This include specifies a heirarchy for when value sets are generated for use in a User Interface. The expansion contains this structure, and any codes not found in the structure:";
                case "groups-only":
                    s = "This include specifies a heirarchy for when value sets are generated for use in a User Interface. The expansion contains this structure:";
            }
        }
    }
    x.br();
    x.tx(s);
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
    TableModel model = gen.new TableModel("exp.h=" + index, !forResource);
    model.setAlternating(true);
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("vs.exp.header", "Code"), translate("vs.exp.hint", "The code for the item"), null, 0));
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("vs.exp.header", "Display"), translate("vs.exp.hint", "The display for the item"), null, 0));
    for (Extension ext : inc.getExtensionsByUrl(ToolingExtensions.EXT_EXPAND_GROUP)) {
        renderExpandGroup(gen, model, ext, inc, definitions);
    }
    x.br();
    x.tx("table");
    XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
    x.getChildNodes().add(xn);
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) Title(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Title) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 47 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilities method generateTable.

public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, Set<String> outputTracker) throws IOException, FHIRException {
    // check it's ok to get rid of one of these
    assert (diff != snapshot);
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
    TableModel model = gen.initNormalTable(corePath, false, true, profile.getId() + (diff ? "d" : "s"), false);
    List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
    List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
    profiles.add(profile);
    genElement(defFile == null ? null : defFile + "#" + profile.getId() + ".", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath);
    return gen.generate(model, corePath, 0, outputTracker);
}
Also used : StructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition) ArrayList(java.util.ArrayList) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)

Example 48 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireResponseRenderer method renderTree.

public boolean renderTree(XhtmlNode x, QuestionnaireResponse q) throws UnsupportedEncodingException, IOException {
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
    TableModel model = gen.new TableModel("qtree=" + q.getId(), true);
    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", "Definition"), 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", "Answer"), translate("sd.hint", "The type of the item"), null, 0));
    boolean hasExt = false;
    // first we add a root for the questionaire itself
    Row row = addTreeRoot(gen, model.getRows(), q);
    for (QuestionnaireResponseItemComponent i : q.getItem()) {
        hasExt = renderTreeItem(gen, row.getSubRows(), q, i) || hasExt;
    }
    XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
    x.getChildNodes().add(xn);
    return hasExt;
}
Also used : QuestionnaireResponseItemComponent(org.hl7.fhir.r4b.model.QuestionnaireResponse.QuestionnaireResponseItemComponent) 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 49 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel 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 50 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderLogic.

private boolean renderLogic(XhtmlNode x, Questionnaire q) throws FHIRException, IOException {
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
    TableModel model = gen.new TableModel("qtree=" + q.getId(), true);
    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", "Description & Constraints"), translate("sd.hint", "Additional information about the item"), null, 0));
    boolean hasExt = false;
    if (!q.hasItem()) {
        gen.emptyRow(model, 2);
    } else {
        for (QuestionnaireItemComponent i : q.getItem()) {
            hasExt = renderLogicItem(gen, model.getRows(), q, i) || hasExt;
        }
    }
    XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
    x.getChildNodes().add(xn);
    return hasExt;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)51 HierarchicalTableGenerator (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator)45 ArrayList (java.util.ArrayList)17 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)14 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)11 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)7 List (java.util.List)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 HashSet (java.util.HashSet)5 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)2 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)2 Element (org.hl7.fhir.r4b.model.Element)2 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)2