use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row in project bunsen by cerner.
the class FhirEncodersTest method coding.
@Test
public void coding() {
Coding expectedCoding = condition.getSeverity().getCodingFirstRep();
Coding actualCoding = decodedCondition.getSeverity().getCodingFirstRep();
// Codings are a nested array, so we explode them into a table of the coding
// fields so we can easily select and compare individual fields.
Dataset<Row> severityCodings = conditionsDataset.select(functions.explode(conditionsDataset.col("severity.coding")).alias("coding")).select(// Pull all fields in the coding to the top level.
"coding.*").cache();
Assert.assertEquals(expectedCoding.getCode(), severityCodings.select("code").head().get(0));
Assert.assertEquals(expectedCoding.getCode(), actualCoding.getCode());
Assert.assertEquals(expectedCoding.getSystem(), severityCodings.select("system").head().get(0));
Assert.assertEquals(expectedCoding.getSystem(), actualCoding.getSystem());
Assert.assertEquals(expectedCoding.getUserSelected(), severityCodings.select("userSelected").head().get(0));
Assert.assertEquals(expectedCoding.getUserSelected(), actualCoding.getUserSelected());
Assert.assertEquals(expectedCoding.getDisplay(), severityCodings.select("display").head().get(0));
Assert.assertEquals(expectedCoding.getDisplay(), actualCoding.getDisplay());
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row in project kindling by HL7.
the class PageProcessor method genStatusCodes.
private String genStatusCodes() throws Exception {
StringBuilder b = new StringBuilder();
b.append("<table border=\"1\">\r\n");
int colcount = 0;
for (ArrayList<String> row : definitions.getStatusCodes().values()) {
int rc = 0;
for (int i = 0; i < row.size(); i++) if (!Utilities.noString(row.get(i)))
rc = i;
if (rc > colcount)
colcount = rc;
}
// b.append("<tr>");
// b.append("<td>Path</td>");
// for (int i = 0; i < colcount; i++)
// b.append("<td>c").append(Integer.toString(i + 1)).append("</td>");
// b.append("</tr>\r\n");
List<String> names = new ArrayList<String>();
for (String n : definitions.getStatusCodes().keySet()) names.add(n);
Collections.sort(names);
ArrayList<String> row = definitions.getStatusCodes().get("@code");
b.append("<tr>");
b.append("<td><b>code</b></td>");
for (int i = 0; i < colcount; i++) b.append("<td><b><a href=\"codesystem-resource-status.html#resource-status-" + row.get(i) + "\">").append(row.get(i)).append("</a></b></td>");
b.append("</tr>\r\n");
row = definitions.getStatusCodes().get("@codes");
b.append("<tr>");
b.append("<td><b>stated codes</b></td>");
for (int i = 0; i < colcount; i++) b.append("<td>").append(i < row.size() ? row.get(i) : "").append("</td>");
b.append("</tr>\r\n");
b.append("<tr>");
b.append("<td>actual codes</td>");
for (int i = 0; i < colcount; i++) {
Set<String> codeset = new HashSet<String>();
for (String n : names) {
if (!n.startsWith("@")) {
row = definitions.getStatusCodes().get(n);
String c = row.get(i);
if (!Utilities.noString(c)) {
codeset.add(c);
}
}
}
b.append("<td>").append(separated(codeset, ", ")).append("</td>");
}
b.append("</tr>\r\n");
row = definitions.getStatusCodes().get("@issues");
b.append("<tr>");
b.append("<td><b>Issues?</b></td>");
for (int i = 0; i < colcount; i++) {
String s = i < row.size() ? row.get(i) : "";
b.append("<td").append(Utilities.noString(s) ? "" : " style=\"background-color: #ffcccc\"").append(">").append(s).append("</td>");
}
b.append("</tr>\r\n");
for (String n : names) {
if (!n.startsWith("@")) {
b.append("<tr>");
ElementDefn ed = getElementDefn(n);
if (ed == null || !ed.isModifier())
b.append("<td>").append(linkToPath(n)).append("</td>");
else
b.append("<td><b>").append(linkToPath(n)).append("</b></td>");
row = definitions.getStatusCodes().get(n);
for (int i = 0; i < colcount; i++) b.append("<td>").append(i < row.size() ? row.get(i) : "").append("</td>");
b.append("</tr>\r\n");
}
}
b.append("</table>\r\n");
CodeSystem cs = getCodeSystems().get("http://hl7.org/fhir/resource-status");
row = definitions.getStatusCodes().get("@code");
for (int i = 0; i < colcount; i++) {
String code = row.get(i);
String definition = CodeSystemUtilities.getCodeDefinition(cs, code);
Set<String> dset = new HashSet<String>();
for (String n : names) {
if (!n.startsWith("@")) {
ArrayList<String> rowN = definitions.getStatusCodes().get(n);
String c = rowN.get(i);
String d = getDefinition(n, c);
if (!Utilities.noString(d))
dset.add(d);
}
}
b.append("<hr/>\r\n");
b.append("<h4>").append(code).append("</h4>\r\n");
b.append("<p>").append(Utilities.escapeXml(definition)).append("</p>\r\n");
b.append("<p>Definitions for matching codes:</p>\r\n");
b.append("<ul>\r\n");
for (String s : sorted(dset)) b.append("<li>").append(Utilities.escapeXml(s)).append("</li>\r\n");
b.append("</ul>\r\n");
}
return b.toString();
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row in project kindling by HL7.
the class PageProcessor method generateToc.
private String generateToc() throws Exception {
// return breadCrumbManager.makeToc();
List<String> entries = new ArrayList<String>();
entries.addAll(toc.keySet());
Collections.sort(entries, new SectionSorter());
Set<String> pages = new HashSet<String>();
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(folders.dstDir, false, true);
TableModel model = gen.new TableModel("toc", true);
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Table of Contents", "Table of Contents", null, 0));
Deque<TocItem> stack = new ArrayDeque<TocItem>();
for (String s : entries) {
TocEntry t = toc.get(s);
if (!t.isIg() && !s.startsWith("?")) {
String nd = s;
while (nd.endsWith(".0")) nd = nd.substring(0, nd.length() - 2);
int d = Utilities.charCount(nd, '.');
if (d < 4 && !pages.contains(t.getLink())) {
String np = getNormativePackageForPage(t.getLink());
pages.add(t.getLink());
while (!stack.isEmpty() && stack.getFirst().depth >= d) stack.pop();
Row row = gen.new Row();
row.setIcon("icon_page.gif", null);
String td = t.getText();
if (!stack.isEmpty()) {
if (td.startsWith(stack.getFirst().entry.getText() + " - "))
td = td.substring(stack.getFirst().entry.getText().length() + 3);
else if (td.startsWith(stack.getFirst().entry.getText()))
td = td.substring(stack.getFirst().entry.getText().length());
}
Cell cell = gen.new Cell(null, t.getLink(), nd + " " + td, t.getText() + " ", null);
row.getCells().add(cell);
if (np != null) {
cell.addPiece(gen.new Piece(null, " ", null));
cell.addPiece(gen.new Piece("versions.html#std-process", "basic".equals(np) ? "(Normative)" : "(Normative / " + Utilities.capitalize(np) + ")", null).addStyle("color: #008000"));
if (np.equals("infrastructure"))
row.setIcon("icon_page_n_i.gif", null);
else if (np.equals("conformance"))
row.setIcon("icon_page_n_c.gif", null);
else if (np.equals("patient"))
row.setIcon("icon_page_n_p.gif", null);
else if (np.equals("observation"))
row.setIcon("icon_page_n_o.gif", null);
else
row.setIcon("icon_page_n.gif", null);
} else {
cell.addPiece(gen.new Piece(null, " ", null));
cell.addPiece(gen.new Piece("versions.html#std-process", "(Trial Use)", null).addStyle("color: #b3b3b3"));
}
if (stack.isEmpty())
model.getRows().add(row);
else
stack.getFirst().row.getSubRows().add(row);
stack.push(new TocItem(t, row, d));
}
}
}
return new XhtmlComposer(XhtmlComposer.HTML).compose(gen.generate(model, "", 0, null));
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row in project kindling by HL7.
the class BindingsParser method parse.
public List<BindingSpecification> parse() throws Exception {
List<BindingSpecification> results = new ArrayList<BindingSpecification>();
// BindingSpecification n = new BindingSpecification();
// n.setName("*unbound*");
// n.setBinding(BindingSpecification.Binding.Unbound);
// results.add(n);
xls = new XLSXmlParser(file, filename);
new XLSXmlNormaliser(filename, exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Bindings");
for (int row = 0; row < sheet.rows.size(); row++) {
processLine(results, sheet, row);
}
return results;
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row in project kindling by HL7.
the class OldSpreadsheetParser method parseProfileSheet.
private ConstraintStructure parseProfileSheet(Definitions definitions, Profile ap, String n, List<String> namedSheets, boolean published, String usage, List<ValidationMessage> issues, WorkGroup wg, String fmm) throws Exception {
Sheet sheet;
ResourceDefn resource = new ResourceDefn();
sheet = loadSheet(n + "-Inv");
Map<String, Invariant> invariants = null;
if (sheet != null) {
invariants = readInvariants(sheet, n, n + "-Inv");
} else {
invariants = new HashMap<String, Invariant>();
}
sheet = loadSheet(n);
if (sheet == null)
throw new Exception("The StructureDefinition referred to a tab by the name of '" + n + "', but no tab by the name could be found");
for (int row = 0; row < sheet.rows.size(); row++) {
ElementDefn e = processLine(resource, sheet, row, invariants, true, ap, row == 0);
if (e != null)
for (TypeRef t : e.getTypes()) {
if (t.getProfile() != null && !t.getName().equals("Extension") && t.getProfile().startsWith("#")) {
if (!namedSheets.contains(t.getProfile().substring(1)))
namedSheets.add(t.getProfile().substring(1));
}
}
}
sheet = loadSheet(n + "-Extensions");
if (sheet != null) {
int row = 0;
while (row < sheet.rows.size()) {
if (sheet.getColumn(row, "Code").startsWith("!"))
row++;
else
row = processExtension(resource.getRoot().getElementByName(definitions, "extensions", true, false), sheet, row, definitions, ap.metadata("extension.uri"), ap, issues, invariants, wg);
}
}
sheet = loadSheet(n + "-Search");
if (sheet != null) {
readSearchParams(resource, sheet, true);
}
if (invariants != null) {
for (Invariant inv : invariants.values()) {
if (Utilities.noString(inv.getContext()))
throw new Exception("Type " + resource.getRoot().getName() + " Invariant " + inv.getId() + " has no context");
else {
ElementDefn ed = findContext(resource.getRoot(), inv.getContext(), "Type " + resource.getRoot().getName() + " Invariant " + inv.getId() + " Context");
// TODO: Need to resolve context based on element name, not just path
if (ed.getName().endsWith("[x]") && !inv.getContext().endsWith("[x]"))
inv.setFixedName(inv.getContext().substring(inv.getContext().lastIndexOf(".") + 1));
ed.getInvariants().put(inv.getId(), inv);
if (Utilities.noString(inv.getXpath())) {
throw new Exception("Type " + resource.getRoot().getName() + " Invariant " + inv.getId() + " (" + inv.getEnglish() + ") has no XPath statement");
} else if (inv.getXpath().contains("\""))
throw new Exception("Type " + resource.getRoot().getName() + " Invariant " + inv.getId() + " (" + inv.getEnglish() + ") contains a \" character");
// if (Utilities.noString(inv.getExpression()))
// throw new Exception("Type "+resource.getRoot().getName()+" Invariant "+inv.getId()+" ("+inv.getEnglish()+") has no Expression statement (in FHIRPath format)");
}
}
}
resource.getRoot().setProfileName(n);
if (n.toLowerCase().equals(ap.getId()))
throw new Exception("Duplicate Profile Name: Package id " + ap.getId() + " and profile id " + n.toLowerCase() + " are the same");
if (profileIds.containsKey(n.toLowerCase()))
throw new Exception("Duplicate Profile Name: " + n.toLowerCase() + " in " + ap.getId() + ", already registered in " + profileIds.get(n.toLowerCase()).getOwner());
ConstraintStructure p = new ConstraintStructure(n.toLowerCase(), resource.getRoot().getProfileName(), resource, ig != null ? ig : definitions.getUsageIG(usage, "Parsing " + name), wg, fmm, Utilities.existsInList(ap.metadata("Experimental"), "y", "Y", "true", "TRUE", "1"));
p.setOwner(ap.getId());
profileIds.put(n.toLowerCase(), p);
return p;
}
Aggregations