use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.
the class PageProcessor method profileHeader.
// private String resourcesHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span> </span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("definitions".equals(mode))
// b.append("<li class=\"selected\"><span>Detailed Descriptions</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-definitions.html\">Detailed Descriptions</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 270px\"><span> </span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
// private String formatsHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span> </span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("examples".equals(mode))
// b.append("<li class=\"selected\"><span>Examples</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-examples.html\">Examples</a></span></li>");
// if ("definitions".equals(mode))
// b.append("<li class=\"selected\"><span>Detailed Descriptions</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-definitions.html\">Detailed Descriptions</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 270px\"><span> </span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
private String profileHeader(String n, String mode, boolean hasExamples) {
StringBuilder b = new StringBuilder();
if (n.endsWith(".xml"))
n = n.substring(0, n.length() - 4);
b.append("<ul class=\"nav nav-tabs\">");
b.append(makeHeaderTab("Content", n + ".html", mode == null || "base".equals(mode)));
if (hasExamples)
b.append(makeHeaderTab("Examples", n + "-examples.html", mode == null || "examples".equals(mode)));
b.append(makeHeaderTab("Detailed Descriptions", n + "-definitions.html", "definitions".equals(mode)));
b.append(makeHeaderTab("Mappings", n + "-mappings.html", "mappings".equals(mode)));
// if (!isDict && !n.equals("elementdefinition-de")) // todo: do this properly
// b.append(makeHeaderTab("HTML Form", n+"-questionnaire.html", "questionnaire".equals(mode)));
b.append(makeHeaderTab("XML", n + ".profile.xml.html", "xml".equals(mode)));
b.append(makeHeaderTab("JSON", n + ".profile.json.html", "json".equals(mode)));
b.append("</ul>\r\n");
return b.toString();
}
use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.
the class TypeParser method convert.
public List<TypeRefComponent> convert(IWorkerContext context, String path, List<TypeRef> types, boolean resource, ElementDefinition ed) throws Exception {
List<TypeRefComponent> list = new ArrayList<TypeRefComponent>();
for (TypeRef t : types) {
// Expand any Resource(A|B|C) references
if (t.hasParams() && !("Reference".equals(t.getName()) || "canonical".equals(t.getName()))) {
throw new Exception("Only resource references can specify parameters. Path " + path);
}
if (t.getParams().size() > 0) {
if (t.getProfile() != null && t.getParams().size() != 1) {
throw new Exception("Cannot declare profile on a resource reference declaring multiple resource types. Path " + path);
}
if (t.getProfile() != null) {
TypeRefComponent childType = getTypeComponent(list, t.getName());
if (t.getVersioning() != null)
childType.setVersioning(t.getVersioning());
if (t.getName().equals("Reference") || t.getName().equals("canonical"))
childType.addTargetProfile(t.getProfile());
else
childType.addProfile(t.getProfile());
} else
for (String param : t.getParams()) {
TypeRefComponent childType = getTypeComponent(list, t.getName());
if (t.getVersioning() != null)
childType.setVersioning(t.getVersioning());
String p = "Any".equals(param) ? "Resource" : param;
if (t.getName().equals("Reference") || t.getName().equals("canonical"))
childType.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + p);
else
childType.addProfile("http://hl7.org/fhir/StructureDefinition/" + p);
}
} else if (t.isWildcardType()) {
// this list is filled out manually because it may be running before the types referred to have been loaded
for (String n : TypesUtilities.wildcardTypes(version)) {
TypeRefComponent tc = new TypeRefComponent().setCode(n);
if (t.getVersioning() != null)
tc.setVersioning(t.getVersioning());
list.add(tc);
}
} else if (Utilities.noString(t.getName()) && t.getProfile() != null) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, t.getProfile());
TypeRefComponent tc = getTypeComponent(list, sd != null ? sd.getType() : t.getName());
if (t.getVersioning() != null)
tc.setVersioning(t.getVersioning());
if (t.getName().equals("Reference"))
tc.addTargetProfile(t.getProfile());
else
tc.addProfile(t.getProfile());
} else if (t.getName().startsWith("=")) {
if (resource)
list.add(new TypeRefComponent().setCode("BackboneElement"));
else
list.add(new TypeRefComponent().setCode("Element"));
ToolingExtensions.addStringExtension(ed, "http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name", t.getName().substring(1));
} else {
StructureDefinition sd = context.fetchTypeDefinition(t.getName());
if (sd == null)
throw new Exception("Unknown type '" + t.getName() + "'");
TypeRefComponent tc = getTypeComponent(list, sd.getType());
if (t.getVersioning() != null)
tc.setVersioning(t.getVersioning());
if (t.getName().equals("Reference")) {
if (t.hasProfile())
tc.addTargetProfile(t.getProfile());
} else if (t.hasProfile())
tc.addProfile(t.getProfile());
}
}
// no duplicates
for (TypeRefComponent tr1 : list) {
for (TypeRefComponent tr2 : list) {
if (tr1 != tr2) {
if (tr1.getWorkingCode().equals(tr2.getWorkingCode()))
throw new Exception("duplicate code " + tr1.getWorkingCode());
}
}
}
return list;
}
use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.
the class SpreadSheetReloader method parseUml.
private void parseUml(ElementDefinition ed, String value, XSSFSheet bindings) {
ed.removeExtension(BuildExtensions.EXT_UML_BREAK);
ed.removeExtension(BuildExtensions.EXT_UML_DIR);
if (!Utilities.noString(value)) {
if (value.contains("|")) {
String[] p = value.split("\\|");
if (Utilities.noString(p[0].trim())) {
ed.addExtension(BuildExtensions.EXT_UML_BREAK, new CodeType(p[1].trim()));
} else {
ed.addExtension(BuildExtensions.EXT_UML_DIR, new CodeType(p[0].trim()));
ed.addExtension(BuildExtensions.EXT_UML_BREAK, new CodeType(p[1].trim()));
}
} else {
ed.addExtension(BuildExtensions.EXT_UML_DIR, new CodeType(value));
}
}
sortExtensions(ed);
}
use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.
the class SpreadSheetReloader method processResource.
private void processResource(XSSFWorkbook excel) throws Exception {
StructureDefinition sd = (StructureDefinition) parseXml(fnSD());
XSSFSheet res = getSheet(excel, SN_RESOURCE);
XSSFSheet bindings = getSheet(excel, SN_BINDINGS);
XSSFSheet invariants = getSheet(excel, SN_INVARIANTS);
List<ElementDefinition> oldElements = sd.getDifferential().getElement();
sd.getDifferential().setElement(new ArrayList<ElementDefinition>());
XSSFRow cols = res.getRow(0);
for (int i = 1; i <= res.getLastRowNum(); i++) {
XSSFRow row = res.getRow(i);
if (row != null && hasValue(row, cols, "Path")) {
String p = getValue(row, cols, "Path");
ElementDefinition ed = getED(oldElements, p);
sd.getDifferential().getElement().add(ed);
readElementDefinition(row, cols, ed, bindings, invariants);
}
}
saveXml(fnSD(), sd);
}
use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.
the class SpreadSheetReloader method parseType.
private void parseType(ElementDefinition ed, String value, String hierarchy) throws Exception {
ed.getType().clear();
ed.setContentReferenceElement(null);
if (ed.getPath().equals("Resource.id")) {
ed.addType().setCode("http://hl7.org/fhirpath/System.String").addExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type", new UriType("id"));
} else {
if (Utilities.noString(value)) {
if (ed.getPath().contains(".")) {
ed.addType().setCode("BackboneElement");
}
} else if (value.startsWith("#")) {
ed.setContentReference(value);
} else {
List<TypeRef> tl = new TypeParser(version).parse(value, false, null, context, false);
for (TypeRef tr : tl) {
TypeRefComponent t = ed.addType().setCode(tr.getName());
if ("SimpleQuantity".equals(t.getCode())) {
t.setCode("Quantity");
t.addProfile("http://hl7.org/fhir/StructureDefinition/SimpleQuantity");
}
for (String p : tr.getParams()) {
if (p.equals("Definition")) {
t.addExtension(BuildExtensions.EXT_PATTERN, new CanonicalType("http://hl7.org/fhir/StructureDefinition/Definition"));
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/ActivityDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EventDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EvidenceVariable");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Measure");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/OperationDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/PlanDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Questionnaire");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/SubscriptionTopic");
} else {
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + p);
}
}
if (Utilities.existsInList(tr.getName(), "canonical", "Reference") && !Utilities.noString(hierarchy)) {
t.addExtension(BuildExtensions.EXT_HIERARCHY, new BooleanType(Utilities.existsInList(hierarchy, "true", "True", "TRUE", "1", "y", "Y")));
}
}
}
}
}
Aggregations