use of org.hl7.fhir.r4b.model.ElementDefinition in project kindling by HL7.
the class DictHTMLGenerator method invariants.
//
//
// for (String id : ids) {
// ElementDefinitionConstraintComponent inv = getConstraint(constraints, id);
// s.append("<tr><td><b title=\"Formal Invariant Identifier\">"+inv.getId()+"</b></td><td>"+presentLevel(inv)+"</td><td>(base)</td><td>"+Utilities.escapeXml(inv.getHuman())+"</td><td><span style=\"font-family: Courier New, monospace\">"+Utilities.escapeXml(inv.getExpression())+"</span>");
// if (inv.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice"))
// s.append("<br/>This is (only) a best practice guideline because: <blockquote>"+page.processMarkdown("best practice guideline", inv.getExtensionString("http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice-explanation"), prefix)+"</blockquote>");
// s.append("</td></tr>");
// }
// }
private String invariants(Map<String, Invariant> invariants, List<Invariant> stated) throws Exception {
List<String> done = new ArrayList<String>();
StringBuilder s = new StringBuilder();
if (invariants.size() + stated.size() > 0) {
s.append("<table class=\"dict\">\r\n");
if (invariants.size() > 0) {
s.append("<tr><td colspan=\"4\"><b>Defined on this element</b></td></tr>\r\n");
List<String> ids = new ArrayList<String>();
for (String id : invariants.keySet()) ids.add(id);
Collections.sort(ids, new ConstraintsSorter());
for (String i : ids) {
Invariant inv = invariants.get(i);
done.add(inv.getId());
s.append("<tr><td width=\"60px\"><b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b></td><td>" + presentLevel(inv) + "</td><td>" + Utilities.escapeXml(inv.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>");
if (!Utilities.noString(inv.getExplanation()))
s.append("<br/>This is (only) a best practice guideline because: <blockquote>" + page.processMarkdown("best practice guideline", inv.getExplanation(), prefix) + "</blockquote>");
s.append("</td></tr>");
}
}
if (stated.size() > 0) {
s.append("<tr><td colspan=\"4\"><b>Affect this element</b></td></tr>\r\n");
boolean b = false;
for (Invariant id : stated) {
if (!done.contains(id.getId())) {
s.append("<tr><td width=\"60px\"><b title=\"Formal Invariant Identifier\">" + id.getId() + "</b></td><td>" + presentLevel(id) + "</td><td>" + Utilities.escapeXml(id.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(id.getExpression()) + "</span>");
if (!Utilities.noString(id.getExplanation()))
s.append("<br/>This is (only) a best practice guideline because: <blockquote>" + page.processMarkdown("best practice guideline", id.getExplanation(), prefix) + "</blockquote>");
s.append("</td></tr>");
}
}
}
s.append("</table>\r\n");
}
return s.toString();
}
use of org.hl7.fhir.r4b.model.ElementDefinition in project kindling by HL7.
the class ReviewSpreadsheetGenerator method processRows.
private int processRows(HSSFWorkbook workbook, String path, StructureDefinition profile, List<ElementDefinition> list, int i, HSSFSheet sheet, String indent) throws FHIRException {
ElementDefinition ed = list.get(i);
HSSFFont font = workbook.createFont();
font.setFontName("Calibri");
HSSFCellStyle style = workbook.createCellStyle();
style.setFont(font);
while (i < list.size() && ed.getPath().startsWith(path + ".")) {
HSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows());
int c = 0;
HSSFRichTextString richString;
if (ed.getType().size() == 0) {
richString = new HSSFRichTextString(indent + ed.getPath().substring(path.length() + 1) + " [" + describeCardinality(ed) + "]");
} else if (ed.getType().size() == 1) {
richString = new HSSFRichTextString(indent + ed.getPath().substring(path.length() + 1) + " : " + ed.getType().get(0).getWorkingCode() + " [" + describeCardinality(ed) + "]");
HSSFFont fontBlue = workbook.createFont();
fontBlue.setFontName("Calibri");
fontBlue.setColor(IndexedColors.DARK_BLUE.getIndex());
richString.applyFont(indent.length() + ed.getPath().length() - (path.length() + 1), richString.length() - describeCardinality(ed).length() - 3, fontBlue);
} else {
richString = new HSSFRichTextString(indent + ed.getPath().substring(path.length() + 1) + " : * [" + describeCardinality(ed) + "]");
}
HSSFCell cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue(richString);
if (ed.getType().size() == 0) {
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue(ed.getSliceName());
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue("");
i++;
if (i < list.size())
i = processRows(workbook, ed.getPath(), profile, list, i, sheet, indent + " ");
} else if (ed.getType().size() == 1) {
cell = row.createCell(c++);
cell.setCellStyle(style);
if (ed.getType().get(0).hasProfile())
cell.setCellValue(ed.getType().get(0).getProfile().get(0).getValue());
if (ed.getType().get(0).hasTargetProfile())
cell.setCellValue(ed.getType().get(0).getTargetProfile().get(0).getValue());
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue(describeBinding(profile, ed));
i++;
} else {
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue(ed.getSliceName());
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue(describeBinding(profile, ed));
i++;
}
cell = row.createCell(c++);
cell.setCellStyle(style);
cell = row.createCell(c++);
cell.setCellStyle(style);
cell.setCellValue("");
if (i < list.size())
ed = list.get(i);
}
return i;
}
use of org.hl7.fhir.r4b.model.ElementDefinition in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method analyseTypes.
private void analyseTypes(JsonObject element, ElementDefinition rev, ElementDefinition orig) {
JsonArray oa = new JsonArray();
JsonArray ra = new JsonArray();
if (rev.getType().size() == 1 && orig.getType().size() == 1) {
String r = describeType(rev.getType().get(0));
if (Utilities.noString(r) && Utilities.existsInList(rev.getId(), "Element.id", "Extension.url"))
r = "string";
String o = describeType(orig.getType().get(0));
if (Utilities.noString(o) && Utilities.existsInList(orig.getId(), "Element.id", "Extension.url"))
o = "string";
if (!o.equals(r)) {
oa.add(new JsonPrimitive(o));
ra.add(new JsonPrimitive(r));
}
} else {
for (TypeRefComponent tr : orig.getType()) {
if (!hasType(rev.getType(), tr))
oa.add(new JsonPrimitive(describeType(tr)));
}
for (TypeRefComponent tr : rev.getType()) {
if (!hasType(orig.getType(), tr) && !isAbstractType(tr.getWorkingCode()))
ra.add(new JsonPrimitive(describeType(tr)));
}
for (TypeRefComponent tr : rev.getType()) {
TypeRefComponent tm = getType(rev.getType(), tr);
if (tm != null) {
compareParameters(element, tr, tm);
}
}
}
if (oa.size() > 0)
element.add("removed-types", oa);
if (ra.size() > 0)
element.add("added-types", ra);
}
use of org.hl7.fhir.r4b.model.ElementDefinition in project org.hl7.fhir.core by hapifhir.
the class ExtensionDefinitionGenerator method buildExtensions.
private void buildExtensions(StructureDefinition type, List<StructureDefinition> list) throws FHIRException {
for (ElementDefinition ed : type.getDifferential().getElement()) {
if (ed.getPath().contains(".")) {
if (!ed.getPath().endsWith(".extension") && !ed.getPath().endsWith(".modifierExtension")) {
StructureDefinition ext = generateExtension(type, ed);
if (ext != null) {
list.add(ext);
context.cacheResource(ext);
}
}
}
}
}
use of org.hl7.fhir.r4b.model.ElementDefinition in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method compare.
private void compare(StructureDefinition orig, StructureDefinition rev) {
moves.clear();
XhtmlNode tr = tbl.addTag("tr").setAttribute("class", "diff-item");
XhtmlNode left = tr.addTag("td").setAttribute("class", "diff-left");
String link = linker == null ? null : linker.getLink(rev.getName());
if (link != null)
left.addTag("a").setAttribute("href", link).addText(rev.getName());
else
left.addText(rev.getName());
XhtmlNode right = tr.addTag("td").setAttribute("class", "diff-right");
// first, we must match revision elements to old elements
boolean changed = false;
if (!orig.getName().equals(rev.getName())) {
changed = true;
right.ul().li().addText("Name Changed from " + orig.getName() + " to " + rev.getName());
}
for (ElementDefinition ed : rev.getDifferential().getElement()) {
ElementDefinition oed = getMatchingElement(rev.getName(), orig.getDifferential().getElement(), ed);
if (oed != null) {
ed.setUserData("match", oed);
oed.setUserData("match", ed);
}
}
for (ElementDefinition ed : rev.getDifferential().getElement()) {
ElementDefinition oed = (ElementDefinition) ed.getUserData("match");
if (oed == null) {
changed = true;
markNew(ed.getPath(), false, false, ed.getMin() > 0);
} else
changed = compareElement(ed, oed) || changed;
}
List<String> dels = new ArrayList<String>();
for (ElementDefinition ed : orig.getDifferential().getElement()) {
if (ed.getUserData("match") == null) {
changed = true;
boolean marked = false;
for (String s : dels) if (ed.getPath().startsWith(s + "."))
marked = true;
if (!marked) {
dels.add(ed.getPath());
markDeleted(ed.getPath(), false);
}
}
}
if (!changed)
right.ul().li().addText("No Changes");
for (ElementDefinition ed : rev.getDifferential().getElement()) ed.clearUserData("match");
for (ElementDefinition ed : orig.getDifferential().getElement()) ed.clearUserData("match");
}
Aggregations