Replaced removed code

This commit is contained in:
Lloyd McKenzie 2024-06-06 09:57:55 -06:00
parent ca97ce2aaa
commit 3b2434781d
3 changed files with 318 additions and 0 deletions

View File

@ -1279,6 +1279,83 @@ public class ProfileUtilities {
return false; return false;
} }
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder,
boolean inlineGraphics, boolean full, String corePath, Set<String> outputTracker)
throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
boolean deep = false;
boolean vdeep = false;
for (ElementDefinition eld : ed.getSnapshot().getElement()) {
deep = deep || eld.getPath().contains("Extension.extension.");
vdeep = vdeep || eld.getPath().contains("Extension.extension.extension.");
}
Row r = gen.new Row();
model.getRows().add(r);
r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile + "-definitions.html#extension." + ed.getName(),
ed.getSnapshot().getElement().get(0).getIsModifier() ? "modifierExtension" : "extension", null, null));
r.getCells().add(gen.new Cell());
r.getCells().add(gen.new Cell(null, null,
describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null));
if (full || vdeep) {
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon(deep ? "icon_extension_complex.png" : "icon_extension_simple.png",
deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX
: HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(),
ed.getSnapshot().getElement().get(0));
for (ElementDefinition child : children)
if (!child.getPath().endsWith(".id"))
genElement(defFile == null ? "" : defFile + "-definitions.html#extension.", gen, r.getSubRows(), child,
ed.getSnapshot().getElement(), null, true, defFile, true, full, corePath);
} else if (deep) {
List<ElementDefinition> children = new ArrayList<ElementDefinition>();
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().equals("Extension.extension"))
children.add(ted);
}
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon("icon_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
for (ElementDefinition c : children) {
ElementDefinition ved = getValueFor(ed, c);
ElementDefinition ued = getUrlFor(ed, c);
if (ved != null && ued != null) {
Row r1 = gen.new Row();
r.getSubRows().add(r1);
r1.getCells()
.add(gen.new Cell(null, defFile == null ? "" : defFile + "-definitions.html#extension." + ed.getName(),
((UriType) ued.getFixed()).getValue(), null, null));
r1.getCells().add(gen.new Cell());
r1.getCells().add(gen.new Cell(null, null, describeCardinality(c, null, new UnusedTracker()), null, null));
genTypes(gen, r1, ved, defFile, ed, corePath);
r1.getCells().add(gen.new Cell(null, null, c.getDefinition(), null, null));
r1.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
}
} else {
ElementDefinition ved = null;
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().startsWith("Extension.value"))
ved = ted;
}
genTypes(gen, r, ved, defFile, ed, corePath);
r.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
Cell c = gen.new Cell("", "", "URL = " + ed.getUrl(), null, null);
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, ed.getName() + ": " + ed.getDescription(), null));
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, describeExtensionContext(ed), null));
r.getCells().add(c);
return gen.generate(model, corePath, 0, outputTracker);
}
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) { private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
int i = ed.getSnapshot().getElement().indexOf(c) + 1; int i = ed.getSnapshot().getElement().indexOf(c) + 1;
while (i < ed.getSnapshot().getElement().size() while (i < ed.getSnapshot().getElement().size()
@ -1486,6 +1563,21 @@ public class ProfileUtilities {
return piece; return piece;
} }
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 {
assert (diff != snapshot);// check it's ok to get rid of one of these
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId() + (diff ? "d" : "s"), false,
TableGenerationMode.XML);
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);
}
private void genElement(String defPath, HierarchicalTableGenerator gen, List<Row> rows, ElementDefinition element, private void genElement(String defPath, HierarchicalTableGenerator gen, List<Row> rows, ElementDefinition element,
List<ElementDefinition> all, List<StructureDefinition> profiles, boolean showMissing, String profileBaseFileName, List<ElementDefinition> all, List<StructureDefinition> profiles, boolean showMissing, String profileBaseFileName,
Boolean extensions, boolean snapshot, String corePath) throws IOException { Boolean extensions, boolean snapshot, String corePath) throws IOException {

View File

@ -1281,6 +1281,87 @@ public class ProfileUtilities {
return false; return false;
} }
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder,
boolean inlineGraphics, boolean full, String corePath, Set<String> outputTracker)
throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
boolean deep = false;
boolean vdeep = false;
for (ElementDefinition eld : ed.getSnapshot().getElement()) {
deep = deep || eld.getPath().contains("Extension.extension.");
vdeep = vdeep || eld.getPath().contains("Extension.extension.extension.");
}
Row r = gen.new Row();
model.getRows().add(r);
r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile + "-definitions.html#extension." + ed.getName(),
ed.getSnapshot().getElement().get(0).getIsModifier() ? "modifierExtension" : "extension", null, null));
r.getCells().add(gen.new Cell());
r.getCells().add(gen.new Cell(null, null,
describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null));
if (full || vdeep) {
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon(deep ? "icon_extension_complex.png" : "icon_extension_simple.png",
deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX
: HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(),
ed.getSnapshot().getElement().get(0));
for (ElementDefinition child : children)
if (!child.getPath().endsWith(".id"))
genElement(defFile == null ? "" : defFile + "-definitions.html#extension.", gen, r.getSubRows(), child,
ed.getSnapshot().getElement(), null, true, defFile, true, full, corePath, true, false);
} else if (deep) {
List<ElementDefinition> children = new ArrayList<ElementDefinition>();
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().equals("Extension.extension"))
children.add(ted);
}
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon("icon_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
for (ElementDefinition c : children) {
ElementDefinition ved = getValueFor(ed, c);
ElementDefinition ued = getUrlFor(ed, c);
if (ved != null && ued != null) {
Row r1 = gen.new Row();
r.getSubRows().add(r1);
r1.getCells()
.add(gen.new Cell(null, defFile == null ? "" : defFile + "-definitions.html#extension." + ed.getName(),
((UriType) ued.getFixed()).getValue(), null, null));
r1.getCells().add(gen.new Cell());
r1.getCells().add(gen.new Cell(null, null, describeCardinality(c, null, new UnusedTracker()), null, null));
genTypes(gen, r1, ved, defFile, ed, corePath);
r1.getCells().add(gen.new Cell(null, null, c.getDefinition(), null, null));
r1.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
}
} else {
ElementDefinition ved = null;
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().startsWith("Extension.value"))
ved = ted;
}
genTypes(gen, r, ved, defFile, ed, corePath);
r.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
Cell c = gen.new Cell("", "", "URL = " + ed.getUrl(), null, null);
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, ed.getName() + ": " + ed.getDescription(), null));
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, describeExtensionContext(ed), null));
r.getCells().add(c);
try {
return gen.generate(model, corePath, 0, outputTracker);
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
}
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) { private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
int i = ed.getSnapshot().getElement().indexOf(c) + 1; int i = ed.getSnapshot().getElement().indexOf(c) + 1;
while (i < ed.getSnapshot().getElement().size() while (i < ed.getSnapshot().getElement().size()
@ -1481,6 +1562,25 @@ public class ProfileUtilities {
return piece; return piece;
} }
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder,
boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, boolean logicalModel,
Set<String> outputTracker) throws IOException, FHIRException {
assert (diff != snapshot);// check it's ok to get rid of one of these
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId() + (diff ? "d" : "s"), false,
TableGenerationMode.XML);
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, true, logicalModel);
try {
return gen.generate(model, corePath, 0, outputTracker);
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
}
private void genElement(String defPath, HierarchicalTableGenerator gen, List<Row> rows, ElementDefinition element, private void genElement(String defPath, HierarchicalTableGenerator gen, List<Row> rows, ElementDefinition element,
List<ElementDefinition> all, List<StructureDefinition> profiles, boolean showMissing, String profileBaseFileName, List<ElementDefinition> all, List<StructureDefinition> profiles, boolean showMissing, String profileBaseFileName,
Boolean extensions, boolean snapshot, String corePath, boolean root, boolean logicalModel) throws IOException { Boolean extensions, boolean snapshot, String corePath, boolean root, boolean logicalModel) throws IOException {

View File

@ -1620,6 +1620,91 @@ public class ProfileUtilities extends TranslatingUtilities {
return !p.contains("."); return !p.contains(".");
} }
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
boolean deep = false;
String m = "";
boolean vdeep = false;
if (ed.getSnapshot().getElementFirstRep().getIsModifier())
m = "modifier_";
for (ElementDefinition eld : ed.getSnapshot().getElement()) {
deep = deep || eld.getPath().contains("Extension.extension.");
vdeep = vdeep || eld.getPath().contains("Extension.extension.extension.");
}
Row r = gen.new Row();
model.getRows().add(r);
r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#extension."+ed.getName(), ed.getSnapshot().getElement().get(0).getIsModifier() ? "modifierExtension" : "extension", null, null));
r.getCells().add(gen.new Cell());
r.getCells().add(gen.new Cell(null, null, describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null));
ElementDefinition ved = null;
if (full || vdeep) {
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon(deep ? "icon_"+m+"extension_complex.png" : "icon_extension_simple.png", deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX : HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0));
for (ElementDefinition child : children)
if (!child.getPath().endsWith(".id"))
genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), null, true, defFile, true, full, corePath, imagePath, true, false, false, false);
} else if (deep) {
List<ElementDefinition> children = new ArrayList<ElementDefinition>();
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().equals("Extension.extension"))
children.add(ted);
}
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
r.setIcon("icon_"+m+"extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
for (ElementDefinition c : children) {
ved = getValueFor(ed, c);
ElementDefinition ued = getUrlFor(ed, c);
if (ved != null && ued != null) {
Row r1 = gen.new Row();
r.getSubRows().add(r1);
r1.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#extension."+ed.getName(), ((UriType) ued.getFixed()).getValue(), null, null));
r1.getCells().add(gen.new Cell());
r1.getCells().add(gen.new Cell(null, null, describeCardinality(c, null, new UnusedTracker()), null, null));
genTypes(gen, r1, ved, defFile, ed, corePath, imagePath);
r1.getCells().add(gen.new Cell(null, null, c.getDefinition(), null, null));
r1.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
}
} else {
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
if (ted.getPath().startsWith("Extension.value"))
ved = ted;
}
genTypes(gen, r, ved, defFile, ed, corePath, imagePath);
r.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
}
Cell c = gen.new Cell("", "", "URL = "+ed.getUrl(), null, null);
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, ed.getName()+": "+ed.getDescription(), null));
if (!full && !(deep || vdeep) && ved != null && ved.hasBinding()) {
c.addPiece(gen.new Piece("br"));
BindingResolution br = pkp.resolveBinding(ed, ved.getBinding(), ved.getPath());
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, translate("sd.table", "Binding")+": ", null).addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null)));
if (ved.getBinding().hasStrength()) {
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, " (", null)));
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(corePath+"terminologies.html#"+ved.getBinding().getStrength().toCode(), egt(ved.getBinding().getStrengthElement()), ved.getBinding().getStrength().getDefinition())));
c.getPieces().add(gen.new Piece(null, ")", null));
}
}
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, describeExtensionContext(ed), null));
r.getCells().add(c);
try {
return gen.generate(model, corePath, 0, outputTracker);
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
}
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) { private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
int i = ed.getSnapshot().getElement().indexOf(c) + 1; int i = ed.getSnapshot().getElement().indexOf(c) + 1;
while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) { while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) {
@ -1902,6 +1987,37 @@ public class ProfileUtilities extends TranslatingUtilities {
return piece; return piece;
} }
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean logicalModel, boolean allInvariants, Set<String> outputTracker) throws IOException, FHIRException {
assert(diff != snapshot);// check it's ok to get rid of one of these
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false, TableGenerationMode.XML);
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
profiles.add(profile);
genElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath, imagePath, true, logicalModel, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list), allInvariants);
try {
return gen.generate(model, imagePath, 0, outputTracker);
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
}
public XhtmlNode generateGrid(String defFile, StructureDefinition profile, String imageFolder, boolean inlineGraphics, String profileBaseFileName, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, inlineGraphics);
TableModel model = gen.initGridTable(corePath, profile.getId());
List<ElementDefinition> list = profile.getSnapshot().getElement();
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
profiles.add(profile);
genGridElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, true, profileBaseFileName, null, corePath, imagePath, true, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list));
try {
return gen.generate(model, imagePath, 1, outputTracker);
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), e);
}
}
private boolean usesMustSupport(List<ElementDefinition> list) { private boolean usesMustSupport(List<ElementDefinition> list) {
for (ElementDefinition ed : list) for (ElementDefinition ed : list)
if (ed.hasMustSupport() && ed.getMustSupport()) if (ed.hasMustSupport() && ed.getMustSupport())
@ -3363,6 +3479,16 @@ public class ProfileUtilities extends TranslatingUtilities {
} }
public XhtmlNode generateSpanningTable(StructureDefinition profile, String imageFolder, boolean onlyConstraints, String constraintPrefix, Set<String> outputTracker) throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(new RenderingI18nContext(), imageFolder, false);
TableModel model = initSpanningTable(gen, "", false, profile.getId());
Set<String> processed = new HashSet<String>();
SpanEntry span = buildSpanningTable("(focus)", "", profile, processed, onlyConstraints, constraintPrefix);
genSpanEntry(gen, model.getRows(), span);
return gen.generate(model, "", 0, outputTracker);
}
private SpanEntry buildSpanningTable(String name, String cardinality, StructureDefinition profile, Set<String> processed, boolean onlyConstraints, String constraintPrefix) throws IOException { private SpanEntry buildSpanningTable(String name, String cardinality, StructureDefinition profile, Set<String> processed, boolean onlyConstraints, String constraintPrefix) throws IOException {
SpanEntry res = buildSpanEntryFromProfile(name, cardinality, profile); SpanEntry res = buildSpanEntryFromProfile(name, cardinality, profile);
boolean wantProcess = !processed.contains(profile.getUrl()); boolean wantProcess = !processed.contains(profile.getUrl());