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();
}
use of org.hl7.fhir.r4.model.Resource in project kindling by HL7.
the class PageProcessor method buildIgRegistry.
private String buildIgRegistry(ImplementationGuideDefn ig, String types) throws Exception {
StringBuilder b = new StringBuilder();
b.append("<table class=\"codes\">\r\n");
b.append("<tr><td><b>Id</b></td><td><b>Name</b></td><td><b>Description</b></td></tr>\r\n");
// examples second:
boolean example = false;
while (true) {
boolean usedPurpose = false;
for (String type : types.split("\\,")) {
List<String> ids = new ArrayList<String>();
Map<String, ImplementationGuideDefinitionResourceComponent> map = new HashMap<String, ImplementationGuideDefinitionResourceComponent>();
for (ImplementationGuideDefinitionResourceComponent r : ig.getIg().getDefinition().getResource()) {
Resource ar = (Resource) r.getUserData(ToolResourceUtilities.RES_ACTUAL_RESOURCE);
if (ar != null && ar.getResourceType().toString().equals(type) && r.hasExample() == example) {
String id = ar.getId();
ids.add(id);
map.put(id, r);
}
Example ex = (Example) r.getUserData(ToolResourceUtilities.NAME_RES_EXAMPLE);
if (ex != null && ex.getResourceName().equals(type) && r.hasExample() == example) {
String id = ex.getId();
ids.add(id);
map.put(id, r);
}
}
if (ids.size() > 0) {
if (!usedPurpose) {
b.append("<tr><td colspan=\"3\" style=\"background: #DFDFDF\"><b>" + (example ? "Specification" : "Example") + "</b> </td></tr>\r\n");
usedPurpose = true;
}
Collections.sort(ids);
b.append("<tr><td colspan=\"3\" style=\"background: #EFEFEF\">" + getTypePluralDesc(type) + "</td></tr>\r\n");
for (String id : ids) {
ImplementationGuideDefinitionResourceComponent r = map.get(id);
b.append("<tr><td><a href=\"" + Utilities.changeFileExt(r.getReference().getReference(), ".html") + "\">" + id + "</a></td><td>" + Utilities.escapeXml(r.getName()) + "</td><td>" + Utilities.escapeXml(r.getDescription()) + "</td></tr>\r\n");
}
}
}
if (example)
break;
else
example = true;
}
b.append("</table>\r\n");
return b.toString();
}
Aggregations