Search in sources :

Example 86 with HierarchicalTableGenerator

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

the class ValueSetRenderer method renderExpandGroup.

private void renderExpandGroup(HierarchicalTableGenerator gen, TableModel model, Extension ext, ConceptSetComponent inc, Map<String, ConceptDefinitionComponent> definitions) {
    Row row = gen.new Row();
    model.getRows().add(row);
    row.setIcon("icon_entry_blue.png", "entry");
    String code = ext.getExtensionString("code");
    if (code != null) {
        row.getCells().add(gen.new Cell(null, null, code, null, null));
        row.getCells().add(gen.new Cell(null, null, getDisplayForCode(inc, code, definitions), null, null));
    } else if (ext.hasId()) {
        row.getCells().add(gen.new Cell(null, null, "(#" + ext.getId() + ")", null, null));
        row.getCells().add(gen.new Cell(null, null, ext.getExtensionString("display"), null, null));
    } else {
        row.getCells().add(gen.new Cell(null, null, null, null, null));
        row.getCells().add(gen.new Cell(null, null, ext.getExtensionString("display"), null, null));
    }
    for (Extension member : ext.getExtensionsByUrl("member")) {
        Row subRow = gen.new Row();
        row.getSubRows().add(subRow);
        subRow.setIcon("icon_entry_blue.png", "entry");
        String mc = member.getValue().primitiveValue();
        // mc might be a reference to another expansion group - we check that first, or to a code in the compose
        if (mc.startsWith("#")) {
            // it's a reference by id
            subRow.getCells().add(gen.new Cell(null, null, "(" + mc + ")", null, null));
            subRow.getCells().add(gen.new Cell(null, null, "group reference by id", null, null));
        } else {
            Extension tgt = findTargetByCode(inc, mc);
            if (tgt != null) {
                subRow.getCells().add(gen.new Cell(null, null, mc, null, null));
                subRow.getCells().add(gen.new Cell(null, null, "group reference by code", null, null));
            } else {
                subRow.getCells().add(gen.new Cell(null, null, mc, null, null));
                subRow.getCells().add(gen.new Cell(null, null, getDisplayForCode(inc, mc, definitions), null, null));
            }
        }
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)

Example 87 with HierarchicalTableGenerator

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

the class QuestionnaireResponseRenderer method renderAnswer.

public void renderAnswer(HierarchicalTableGenerator gen, ResourceWrapper q, Row r, BaseWrapper ans) throws UnsupportedEncodingException, IOException {
    List<BaseWrapper> items;
    Base b = ans.get("value[x]");
    if (b == null) {
        r.getCells().add(gen.new Cell(null, null, "null!", null, null));
    } else if (b.isPrimitive()) {
        r.getCells().add(gen.new Cell(null, null, b.primitiveValue(), null, null));
    } else {
        XhtmlNode x = new XhtmlNode(NodeType.Element, "span");
        Cell cell = gen.new Cell(null, null, null, null, null);
        Piece p = gen.new Piece("span");
        p.getChildren().add(x);
        cell.addPiece(p);
        render(x, (DataType) b);
        r.getCells().add(cell);
    }
    items = ans.children("item");
    for (BaseWrapper si : items) {
        renderTreeItem(gen, r.getSubRows(), q, si);
    }
}
Also used : BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) DataType(org.hl7.fhir.r5.model.DataType) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) Base(org.hl7.fhir.r5.model.Base) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 88 with HierarchicalTableGenerator

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

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

the class QuestionnaireResponseRenderer method addTreeRoot.

private Row addTreeRoot(HierarchicalTableGenerator gen, List<Row> rows, ResourceWrapper q) throws IOException {
    Row r = gen.new Row();
    rows.add(r);
    r.setIcon("icon_q_root.gif", "QuestionnaireResponseRoot");
    r.getCells().add(gen.new Cell(null, null, q.getId(), null, null));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    r.getCells().add(gen.new Cell(null, null, "QuestionnaireResponse", null, null));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    return r;
}
Also used : Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 90 with HierarchicalTableGenerator

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

the class QuestionnaireResponseRenderer method addTreeRoot.

private Row addTreeRoot(HierarchicalTableGenerator gen, List<Row> rows, QuestionnaireResponse q) throws IOException {
    Row r = gen.new Row();
    rows.add(r);
    r.setIcon("icon_q_root.gif", "QuestionnaireResponseRoot");
    r.getCells().add(gen.new Cell(null, null, q.getId(), null, null));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    r.getCells().add(gen.new Cell(null, null, "QuestionnaireResponse", null, null));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    return r;
}
Also used : Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Aggregations

Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)99 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)83 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)67 TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)51 HierarchicalTableGenerator (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator)45 ArrayList (java.util.ArrayList)25 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)17 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)10 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)9 StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)9 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)9 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)8 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)7 HashSet (java.util.HashSet)6 List (java.util.List)6 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)6 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)5