use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class MappingsGenerator method generate.
public void generate(List<ElementDefn> elements) {
StringBuilder s = new StringBuilder();
List<String> maps = new ArrayList<String>();
for (ElementDefn e : elements) listKnownMappings(e, maps);
Collections.sort(maps);
StringBuilder list = new StringBuilder();
for (String m : maps) {
list.append("|" + definitions.getMapTypes().get(m).getTitle() + "#" + m);
s.append("<a name=\"" + m + "\"> </a>\r\n");
s.append("<a name=\"" + definitions.getMapTypes().get(m).getId() + "\"> </a>\r\n");
s.append("<h3>" + definitions.getMapTypes().get(m).getTitle() + " (" + m + ")</h3>\r\n");
s.append("<table class=\"grid\">\r\n");
for (ElementDefn e : elements) if (elementHasMapping(e, m)) {
genElement(s, 0, e, m, ALL, true, definitions.getMapTypes().get(m).isSparse());
}
s.append("</table>\r\n");
}
mappings = s.toString();
if (list.toString().length() > 1)
mappingsList = list.toString().substring(1);
else
mappingsList = list.toString();
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class ProfileGenerator method createBaseDefinition.
private ElementDefinition createBaseDefinition(StructureDefinition p, String path, ElementDefn src) throws Exception {
ElementDefinition ce = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
ce.setId(path + "." + src.getName());
ce.setPath(path + "." + src.getName());
ce.setShort(src.getShortDefn());
ce.setDefinition(preProcessMarkdown(src.getDefinition(), "ELement Definition"));
ce.setComment(preProcessMarkdown(src.getComments(), "Element Comments"));
ce.setRequirements(preProcessMarkdown(src.getRequirements(), "Element Reqiurements"));
for (String a : src.getAliases()) ce.addAlias(a);
ce.setMin(src.getMinCardinality());
if (src.getMaxCardinality() != null)
ce.setMax(src.getMaxCardinality() == Integer.MAX_VALUE ? "*" : src.getMaxCardinality().toString());
ce.getType(src.typeCode());
// this one should never be used
if (!Utilities.noString(src.getTypes().get(0).getProfile())) {
if (ce.getType().equals("Reference") || ce.getType().equals("canonical") || ce.getType().equals("CodeableReference"))
throw new Error("Should not happen");
ce.getType().get(0).addProfile(src.getTypes().get(0).getProfile());
}
// todo? conditions, constraints, binding, mapping
if (src.hasModifier())
ce.setIsModifier(src.isModifier());
if (ce.getIsModifier())
ce.setIsModifierReason(src.getModifierReason());
if (src.hasSummaryItem())
ce.setIsSummaryElement(Factory.newBoolean(src.isSummary()));
for (Invariant id : src.getStatedInvariants()) ce.addCondition(id.getId());
return ce;
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class DictHTMLGenerator method patternAnalysis.
private String patternAnalysis(ElementDefn e) {
StringBuilder b = new StringBuilder();
boolean first = true;
for (TypeRef tr : e.getTypes()) {
if (tr.getPatterns() != null) {
if (first)
first = false;
else
b.append("<br/>\r\n");
if (tr.getPatterns().isEmpty())
b.append(tr.summary() + ": No common pattern");
else {
CommaSeparatedStringBuilder cb = new CommaSeparatedStringBuilder();
for (String s : tr.getPatterns()) {
cb.append("<a href=\"" + s.toLowerCase() + ".html#" + s + "\">" + s + "</a>");
}
if (tr.getPatterns().size() == 0)
b.append(tr.summary() + ": Common pattern = " + cb.toString());
else
b.append(tr.summary() + ": Common patterns = " + cb.toString());
}
}
}
return b.toString();
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class DictHTMLGenerator method describeBinding.
private String describeBinding(String path, ElementDefn e) throws Exception {
if (!e.hasBinding())
return null;
// name (description): [[ValueSet]], Strength = [[]]
StringBuilder b = new StringBuilder();
BindingSpecification cd = e.getBinding();
if (cd.getValueSet() == null) {
if (!Utilities.noString(cd.getReference()))
b.append("<a href=\"" + prefix + cd.getReference() + "\">" + e.getBinding().getName() + "</a>: ");
else
b.append("<a href=\"" + prefix + "terminologies.html#unbound\">" + e.getBinding().getName() + "</a>: ");
} else
b.append(TerminologyNotesGenerator.describeBinding(prefix, cd, page));
// "<a href=\"terminologies.html#conformance\">"+(cd.getBindingStrength() == null ? "--" : cd.getBindingStrength().toString().toLowerCase())+"</a>)");
return b.toString();
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class JsonSpecGenerator method generateCoreElem.
private void generateCoreElem(ElementDefn elem, int indent, String rootName, String pathName, boolean backbone, boolean last) throws Exception {
// base pattern: "name" : "value" // optionality documentation
int width = 0;
// If this is an unrolled element, show its profile name
if (elem.getProfileName() != null && !elem.getProfileName().equals("")) {
for (int i = 0; i < indent; i++) write(" ");
write("<span style=\"color: Gray\">// </span><span style=\"color: blue\">\"" + elem.getProfileName() + "\":</span>\r\n");
}
if (elem.getMaxCardinality() != null && elem.getMaxCardinality() == 0)
write("<span style=\"text-decoration: line-through\">");
String en = elem.getName();
if (en.contains("[x]") && elem.getTypes().size() == 1 && !elem.getTypes().get(0).isWildcardType())
en = en.replace("[x]", elem.typeCode());
if (en.contains("[x]")) {
// 1. name
for (int i = 0; i < indent; i++) {
write(" ");
}
if (elem.getTypes().size() > 1) {
write("<span style=\"color: Gray\">// " + en + ": <span style=\"color: navy; opacity: 0.8\">" + docPrefix(width, indent, elem) + Utilities.escapeXml(elem.getShortDefn()) + "</span>. One of these " + Integer.toString(elem.getTypes().size()) + ":</span>\r\n");
for (TypeRef t : elem.getTypes()) generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en.replace("[x]", nameForType(t.getName())), t, false);
} else {
List<WildcardInformation> tr = TypesUtilities.wildcards(version);
write("<span style=\"color: Gray\">// " + en + ": <span style=\"color: navy; opacity: 0.8\">" + docPrefix(width, indent, elem) + Utilities.escapeXml(elem.getShortDefn()) + "</span>. One of these " + Integer.toString(tr.size()) + ":</span>\r\n");
for (WildcardInformation t : tr) generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en.replace("[x]", upFirst(t.getTypeName())), toTypeRef(t), false);
}
} else {
generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en, elem.getTypes().isEmpty() ? null : elem.getTypes().get(0), true);
}
}
Aggregations