use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method describeCoded.
private Piece describeCoded(HierarchicalTableGenerator gen, DataType fixed) {
if (fixed instanceof Coding) {
Coding c = (Coding) fixed;
ValidationResult vr = context.validateCode(terminologyServiceOptions, c.getSystem(), c.getVersion(), c.getCode(), c.getDisplay());
if (vr.getDisplay() != null)
return gen.new Piece(null, " (" + vr.getDisplay() + ")", null).addStyle("color: darkgreen");
} else if (fixed instanceof CodeableConcept) {
CodeableConcept cc = (CodeableConcept) fixed;
for (Coding c : cc.getCoding()) {
ValidationResult vr = context.validateCode(terminologyServiceOptions, c.getSystem(), c.getVersion(), c.getCode(), c.getDisplay());
if (vr.getDisplay() != null)
return gen.new Piece(null, " (" + vr.getDisplay() + ")", null).addStyle("color: darkgreen");
}
}
return null;
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ValueSetComparer method addComposeRow.
private void addComposeRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, String name) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, name, null, null));
if (t.hasLeft() && t.hasRight()) {
ConceptSetComponent csL = (ConceptSetComponent) t.getLeft();
ConceptSetComponent csR = (ConceptSetComponent) t.getRight();
if (csL.hasSystem() && csL.getSystem().equals(csR.getSystem())) {
r.getCells().add(gen.new Cell(null, null, csL.getSystem(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getSystem(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getSystem(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
if (csL.hasVersion() && csR.hasVersion()) {
if (csL.getVersion().equals(csR.getVersion())) {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getVersion(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
} else if (csL.hasVersion()) {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null));
r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
} else if (csR.hasVersion()) {
r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
r.getCells().add(gen.new Cell(null, null, csR.getVersion(), null, null));
} else {
r.getCells().add(missingCell(gen).span(2).center());
}
} else if (t.hasLeft()) {
r.setColor(COLOR_NO_ROW_RIGHT);
ConceptSetComponent cs = (ConceptSetComponent) t.getLeft();
r.getCells().add(gen.new Cell(null, null, cs.getSystem(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasVersion() ? "Version: " + cs.getVersion() : "", null, null));
r.getCells().add(missingCell(gen));
} else {
r.setColor(COLOR_NO_ROW_LEFT);
ConceptSetComponent cs = (ConceptSetComponent) t.getRight();
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.getSystem(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasVersion() ? "Version: " + cs.getVersion() : "", null, null));
}
r.getCells().add(cellForMessages(gen, t.getMessages()));
for (StructuralMatch<Element> c : t.getChildren()) {
if (c.either() instanceof ConceptReferenceComponent) {
addSetConceptRow(gen, r.getSubRows(), c);
} else {
addSetFilterRow(gen, r.getSubRows(), c);
}
}
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ValueSetComparer method addSetConceptRow.
private void addSetConceptRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, "Concept", null, null));
if (t.hasLeft() && t.hasRight()) {
ConceptReferenceComponent csL = (ConceptReferenceComponent) t.getLeft();
ConceptReferenceComponent csR = (ConceptReferenceComponent) t.getRight();
// we assume both have codes
if (csL.getCode().equals(csR.getCode())) {
r.getCells().add(gen.new Cell(null, null, csL.getCode(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getCode(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getCode(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
if (csL.hasDisplay() && csR.hasDisplay()) {
if (csL.getDisplay().equals(csR.getDisplay())) {
r.getCells().add(gen.new Cell(null, null, csL.getDisplay(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
} else if (csL.hasDisplay()) {
r.getCells().add(gen.new Cell(null, null, csL.getDisplay(), null, null));
r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
} else if (csR.hasDisplay()) {
r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
r.getCells().add(gen.new Cell(null, null, csR.getDisplay(), null, null));
} else {
r.getCells().add(missingCell(gen).span(2).center());
}
} else if (t.hasLeft()) {
r.setColor(COLOR_NO_ROW_RIGHT);
ConceptReferenceComponent cs = (ConceptReferenceComponent) t.getLeft();
r.getCells().add(gen.new Cell(null, null, cs.getCode(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasDisplay() ? "Version: " + cs.getDisplay() : "", null, null));
r.getCells().add(missingCell(gen));
} else {
r.setColor(COLOR_NO_ROW_LEFT);
ConceptReferenceComponent cs = (ConceptReferenceComponent) t.getRight();
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.getCode(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasDisplay() ? "Version: " + cs.getDisplay() : "", null, null));
}
r.getCells().add(cellForMessages(gen, t.getMessages()));
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method renderStructure.
public XhtmlNode renderStructure(ProfileComparison comp, String id, String prefix, String corePath) throws FHIRException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "compare"), false, true);
gen.setTranslator(session.getContextRight().translator());
TableModel model = gen.initComparisonTable(corePath, id);
genElementComp(null, /* oome back to this later */
gen, model.getRows(), comp.combined, corePath, prefix, null, true);
return gen.generate(model, prefix, 0, null);
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method genElementComp.
private void genElementComp(String defPath, HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ElementDefinitionNode> combined, String corePath, String prefix, Row slicingRow, boolean root) throws IOException {
Row originalRow = slicingRow;
Row typesRow = null;
List<StructuralMatch<ElementDefinitionNode>> children = combined.getChildren();
Row row = gen.new Row();
rows.add(row);
String path = combined.either().getDef().getPath();
row.setAnchor(path);
row.setColor(utilsRight.getRowColor(combined.either().getDef(), false));
if (eitherHasSlicing(combined))
row.setLineColor(1);
else if (eitherHasSliceName(combined))
row.setLineColor(2);
else
row.setLineColor(0);
boolean ext = false;
if (tail(path).equals("extension")) {
if (elementIsComplex(combined))
row.setIcon("icon_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
else
row.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
ext = true;
} else if (tail(path).equals("modifierExtension")) {
if (elementIsComplex(combined))
row.setIcon("icon_modifier_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
else
row.setIcon("icon_modifier_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
} else if (hasChoice(combined)) {
if (allAreReference(combined))
row.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
else {
row.setIcon("icon_choice.gif", HierarchicalTableGenerator.TEXT_ICON_CHOICE);
typesRow = row;
}
} else if (combined.either().getDef().hasContentReference())
row.setIcon("icon_reuse.png", HierarchicalTableGenerator.TEXT_ICON_REUSE);
else if (isPrimitive(combined))
row.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
else if (hasTarget(combined))
row.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
else if (isDataType(combined))
row.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
else
row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
String ref = defPath == null ? null : defPath + combined.either().getDef().getId();
String sName = tail(path);
String sn = getSliceName(combined);
if (sn != null)
sName = sName + ":" + sn;
UnusedTracker used = new UnusedTracker();
Cell nc;
String leftColor = !combined.hasLeft() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null;
String rightColor = !combined.hasRight() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null;
if (combined.hasLeft()) {
nc = utilsRight.genElementNameCell(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, false, ext, used, ref, sName, null);
} else {
nc = utilsRight.genElementNameCell(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, false, ext, used, ref, sName, null);
}
if (combined.hasLeft()) {
frame(utilsRight.genElementCells(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, true, ext, used, ref, sName, nc, false, false, null), leftColor);
} else {
frame(spacers(row, 4, gen), leftColor);
}
if (combined.hasRight()) {
frame(utilsRight.genElementCells(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, true, ext, used, ref, sName, nc, false, false, null), rightColor);
} else {
frame(spacers(row, 4, gen), rightColor);
}
row.getCells().add(cellForMessages(gen, combined.getMessages()));
for (StructuralMatch<ElementDefinitionNode> child : children) {
genElementComp(defPath, gen, row.getSubRows(), child, corePath, prefix, originalRow, false);
}
}
Aggregations