Search in sources :

Example 31 with HierarchicalTableGenerator

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

the class ProfileComparer method spacers.

private List<Cell> spacers(Row row, int count, HierarchicalTableGenerator gen) {
    List<Cell> res = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        Cell c = gen.new Cell();
        res.add(c);
        row.getCells().add(c);
    }
    return res;
}
Also used : ArrayList(java.util.ArrayList) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 32 with HierarchicalTableGenerator

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

the class ProfileUtilities method genTargetLink.

public void genTargetLink(HierarchicalTableGenerator gen, String profileBaseFileName, String corePath, Cell c, TypeRefComponent t, String u) {
    if (u.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
        StructureDefinition sd = context.fetchResource(StructureDefinition.class, u);
        if (sd != null) {
            String disp = sd.hasTitle() ? sd.getTitle() : sd.getName();
            c.addPiece(checkForNoChange(t, gen.new Piece(checkPrepend(corePath, sd.getUserString("path")), disp, null)));
        } else {
            String rn = u.substring(40);
            c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, rn), rn, null)));
        }
    } else if (Utilities.isAbsoluteUrl(u)) {
        StructureDefinition sd = context.fetchResource(StructureDefinition.class, u);
        if (sd != null) {
            String disp = sd.hasTitle() ? sd.getTitle() : sd.getName();
            String ref = pkp.getLinkForProfile(null, sd.getUrl());
            if (ref != null && ref.contains("|"))
                ref = ref.substring(0, ref.indexOf("|"));
            c.addPiece(checkForNoChange(t, gen.new Piece(ref, disp, null)));
        } else
            c.addPiece(checkForNoChange(t, gen.new Piece(null, u, null)));
    } else if (t.hasTargetProfile() && u.startsWith("#"))
        c.addPiece(checkForNoChange(t, gen.new Piece(corePath + profileBaseFileName + "." + u.substring(1).toLowerCase() + ".html", u, null)));
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)

Example 33 with HierarchicalTableGenerator

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

the class ProfileUtilities method genSpanEntry.

private void genSpanEntry(HierarchicalTableGenerator gen, List<Row> rows, SpanEntry span) throws IOException {
    Row row = gen.new Row();
    rows.add(row);
    row.setAnchor(span.getId());
    // row.setColor(..?);
    if (span.isProfile()) {
        row.setIcon("icon_profile.png", HierarchicalTableGenerator.TEXT_ICON_PROFILE);
    } else {
        row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
    }
    row.getCells().add(gen.new Cell(null, null, span.getName(), null, null));
    row.getCells().add(gen.new Cell(null, null, span.getCardinality(), null, null));
    row.getCells().add(gen.new Cell(null, span.getProfileLink(), span.getType(), null, null));
    row.getCells().add(gen.new Cell(null, null, span.getDescription(), null, null));
    for (SpanEntry child : span.getChildren()) {
        genSpanEntry(gen, row.getSubRows(), child);
    }
}
Also used : Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 34 with HierarchicalTableGenerator

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

the class ProfileUtilities method makeChoiceRows.

private void makeChoiceRows(List<Row> subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName, boolean mustSupportMode) {
    // create a child for each choice
    for (TypeRefComponent tr : element.getType()) {
        if (!mustSupportMode || allTypesMustSupport(element) || isMustSupport(tr)) {
            Row choicerow = gen.new Row();
            String t = tr.getWorkingCode();
            if (isReference(t)) {
                choicerow.getCells().add(gen.new Cell(null, null, tail(element.getPath()).replace("[x]", Utilities.capitalize(t)), null, null));
                choicerow.getCells().add(gen.new Cell());
                choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
                choicerow.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
                Cell c = gen.new Cell();
                choicerow.getCells().add(c);
                if (ADD_REFERENCE_TO_TABLE) {
                    if (tr.getWorkingCode().equals("canonical"))
                        c.getPieces().add(gen.new Piece(corePath + "datatypes.html#canonical", "canonical", null));
                    else
                        c.getPieces().add(gen.new Piece(corePath + "references.html#Reference", "Reference", null));
                    if (!mustSupportMode && isMustSupportDirect(tr) && element.getMustSupport()) {
                        c.addPiece(gen.new Piece(null, " ", null));
                        c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
                    }
                    c.getPieces().add(gen.new Piece(null, "(", null));
                }
                boolean first = true;
                for (CanonicalType rt : tr.getTargetProfile()) {
                    if (!mustSupportMode || allProfilesMustSupport(tr.getTargetProfile()) || isMustSupport(rt)) {
                        if (!first)
                            c.getPieces().add(gen.new Piece(null, " | ", null));
                        genTargetLink(gen, profileBaseFileName, corePath, c, tr, rt.getValue());
                        if (!mustSupportMode && isMustSupport(rt) && element.getMustSupport()) {
                            c.addPiece(gen.new Piece(null, " ", null));
                            c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false);
                        }
                        first = false;
                    }
                }
                if (first) {
                    c.getPieces().add(gen.new Piece(null, "Any", null));
                }
                if (ADD_REFERENCE_TO_TABLE) {
                    c.getPieces().add(gen.new Piece(null, ")", null));
                }
            } else {
                StructureDefinition sd = context.fetchTypeDefinition(t);
                if (sd == null) {
                    System.out.println("Unable to find " + t);
                    sd = context.fetchTypeDefinition(t);
                } else if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE) {
                    choicerow.getCells().add(gen.new Cell(null, null, tail(element.getPath()).replace("[x]", Utilities.capitalize(t)), sd.getDescription(), null));
                    choicerow.getCells().add(gen.new Cell());
                    choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
                    choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
                    Cell c = gen.new Cell(null, corePath + "datatypes.html#" + t, sd.getType(), null, null);
                    choicerow.getCells().add(c);
                    if (!mustSupportMode && isMustSupport(tr) && element.getMustSupport()) {
                        c.addPiece(gen.new Piece(null, " ", null));
                        c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
                    }
                } else {
                    choicerow.getCells().add(gen.new Cell(null, null, tail(element.getPath()).replace("[x]", Utilities.capitalize(t)), sd.getDescription(), null));
                    choicerow.getCells().add(gen.new Cell());
                    choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
                    choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
                    Cell c = gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null);
                    choicerow.getCells().add(c);
                    if (!mustSupportMode && isMustSupport(tr) && element.getMustSupport()) {
                        c.addPiece(gen.new Piece(null, " ", null));
                        c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
                    }
                }
                if (tr.hasProfile()) {
                    Cell typeCell = choicerow.getCells().get(3);
                    typeCell.addPiece(gen.new Piece(null, "(", null));
                    boolean first = true;
                    for (CanonicalType pt : tr.getProfile()) {
                        if (!mustSupportMode || allProfilesMustSupport(tr.getProfile()) || isMustSupport(pt)) {
                            if (first)
                                first = false;
                            else
                                typeCell.addPiece(gen.new Piece(null, " | ", null));
                            StructureDefinition psd = context.fetchResource(StructureDefinition.class, pt.getValue());
                            if (psd == null)
                                typeCell.addPiece(gen.new Piece(null, "?gen-e2?", null));
                            else
                                typeCell.addPiece(gen.new Piece(psd.getUserString("path"), psd.getName(), psd.present()));
                            if (!mustSupportMode && isMustSupport(pt) && element.getMustSupport()) {
                                typeCell.addPiece(gen.new Piece(null, " ", null));
                                typeCell.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false);
                            }
                        }
                    }
                    typeCell.addPiece(gen.new Piece(null, ")", null));
                }
            }
            choicerow.getCells().add(gen.new Cell());
            subRows.add(choicerow);
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r4b.model.ElementDefinition.TypeRefComponent) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType)

Example 35 with HierarchicalTableGenerator

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

the class ProfileUtilities method genElementNameCell.

public Cell genElementNameCell(HierarchicalTableGenerator gen, ElementDefinition element, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, StructureDefinition profile, Row typesRow, Row row, boolean hasDef, boolean ext, UnusedTracker used, String ref, String sName, List<ElementDefinition> elements) throws IOException {
    String hint = "";
    hint = checkAdd(hint, (element.hasSliceName() ? translate("sd.table", "Slice") + " " + element.getSliceName() : ""));
    if (hasDef && element.hasDefinition()) {
        hint = checkAdd(hint, (hasDef && element.hasSliceName() ? ": " : ""));
        hint = checkAdd(hint, !hasDef ? null : gt(element.getDefinitionElement()));
    }
    if (element.hasSlicing() && slicesExist(elements, element)) {
        // some elements set up slicing but don't actually slice, so we don't augment the name
        sName = "Slices for " + sName;
    }
    Cell left = gen.new Cell(null, ref, sName, hint, null);
    row.getCells().add(left);
    return left;
}
Also used : 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