use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class PageProcessor method produceExtensions.
private String produceExtensions(ResourceDefn resource) {
int count = 0;
Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) {
if (ec.getType() == ExtensionContextType.ELEMENT) {
inc = inc || (ec.getExpression().equals(resource.getName()) || ec.getExpression().startsWith(resource.getName() + "."));
}
if (inc)
map.put(sd.getId(), sd);
}
}
StringBuilder b = new StringBuilder();
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(presentContext(cs, resource.getName())).append("</td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId().toLowerCase() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Extensions defined for this resource</td></tr>");
map.clear();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) inc = inc || (ec.getExpression().equals("Resource") || ec.getExpression().equals("DomainResource") || ec.getExpression().equals("Any"));
if (inc)
map.put(sd.getId(), sd);
}
b.append("<tr><td colspan=\"4\">Extensions for all resources or elements</td></tr>");
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td colspan=\"2\"><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
return b.toString();
}
use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class Publisher method getIgProfile.
public StructureDefinition getIgProfile(String base) throws Exception {
String[] parts = base.split("#");
StructureDefinition p = getIGProfileByURL(parts[0]);
if (p == null)
return null;
// this is recursive, but will terminate at the root
processProfile(p);
if (parts.length == 1) {
if (p.getSnapshot() == null)
// or else we could fill it in?
throw new Exception("StructureDefinition " + base + " has no snapshot");
return p;
}
for (Resource r : p.getContained()) {
if (r instanceof StructureDefinition && r.getId().equals(parts[1])) {
StructureDefinition pc = (StructureDefinition) r;
if (pc.getSnapshot() == null) {
StructureDefinition ps = getSnapShotForProfile(pc.getBaseDefinition());
processProfile(pc);
}
return pc;
}
}
throw new Exception("Unable to find snapshot for " + base);
}
use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class Publisher method resource2Ttl.
private String resource2Ttl(Resource r) throws Exception {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
IParser rdf = new RdfParser().setOutputStyle(OutputStyle.PRETTY);
rdf.setSuppressXhtml("Snipped for Brevity");
rdf.compose(bytes, r);
bytes.close();
return new String(bytes.toByteArray());
}
use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class Publisher method stripJson.
private InputStream stripJson(InputStream source) throws Exception {
JsonParser p = new JsonParser();
Resource r = p.parse(source);
minify(r);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
p.compose(bo, r);
bo.close();
return new ByteArrayInputStream(bo.toByteArray());
}
use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class PageProcessor method resourcesHeader.
private String resourcesHeader(String mode) {
StringBuilder b = new StringBuilder();
b.append("<ul class=\"nav nav-tabs\">");
b.append(makeHeaderTab("Resource Definitions", "resource.html", mode == null || "base".equals(mode)));
b.append(makeHeaderTab("Examples", "resources-examples.html", mode == null || "examples".equals(mode)));
b.append(makeHeaderTab("Detailed Descriptions", "resources-definitions.html", mode == null || "definitions".equals(mode)));
b.append("</ul>\r\n");
return b.toString();
}
Aggregations