use of org.hl7.fhir.r4.model.DomainResource in project kindling by HL7.
the class PageProcessor method genAllSearchParams.
private String genAllSearchParams() throws Exception {
List<SearchParameter> splist = new ArrayList<SearchParameter>();
for (ResourceDefn rd : getDefinitions().getBaseResources().values()) addSearchParams(splist, rd);
for (ResourceDefn rd : getDefinitions().getResources().values()) addSearchParams(splist, rd);
for (Profile cp : getDefinitions().getPackList()) {
addSearchParams(splist, cp);
}
StringBuilder b = new StringBuilder();
genSearchParams(b, splist, "Resource");
genSearchParams(b, splist, "DomainResource");
genCommonSearchParams(b, splist);
for (String n : definitions.sortedResourceNames()) genSearchParams(b, splist, n);
return b.toString();
}
use of org.hl7.fhir.r4.model.DomainResource in project kindling by HL7.
the class PageProcessor method dictForDt.
// private boolean notime;
private String dictForDt(String dt) throws Exception {
File tmp = Utilities.createTempFile("tmp", ".tmp");
DictHTMLGenerator gen = new DictHTMLGenerator(new FileOutputStream(tmp), this, "");
TypeParser tp = new TypeParser(version.toCode());
TypeRef t = tp.parse(dt, false, null, workerContext, true).get(0);
ElementDefn e;
if (t.getName().equals("Resource"))
e = definitions.getBaseResources().get("DomainResource").getRoot();
else
e = definitions.getElementDefn(t.getName());
if (e == null) {
gen.close();
throw new Exception("unable to find definition for " + dt);
} else {
gen.generate(e);
gen.close();
}
String val = TextFile.fileToString(tmp.getAbsolutePath()) + "\r\n";
tmp.delete();
return val;
}
use of org.hl7.fhir.r4.model.DomainResource in project kindling by HL7.
the class PageProcessor method produceRefExtensions.
private String produceRefExtensions(ResourceDefn resource) {
int count = 0;
Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean refers = false;
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
for (TypeRefComponent tr : ed.getType()) {
for (UriType u : tr.getTargetProfile()) if (u.getValue().endsWith("/" + resource.getName()))
refers = true;
}
if (refers)
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(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 colspan=\"\3\">No Extensions refer to this resource</td></tr>");
map.clear();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean refers = false;
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
for (TypeRefComponent tr : ed.getType()) {
for (UriType u : tr.getTargetProfile()) if (u.getValue().endsWith("/Any") || u.getValue().endsWith("/Resource") || u.getValue().endsWith("/DomainResource"))
refers = true;
}
if (refers)
map.put(sd.getId(), sd);
}
}
b.append("<tr><td colspan=\"\3\">Extensions that refer to Any resource</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><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.DomainResource in project kindling by HL7.
the class PageProcessor method genExample.
private String genExample(Example example, int headerLevelContext, String genlevel) throws IOException, EOperationOutcome, FHIRException {
String xml = XMLUtil.elementToString(example.getXml().getDocumentElement());
Resource res = new XmlParser().parse(xml);
if (!(res instanceof DomainResource))
return "";
DomainResource dr = (DomainResource) res;
if (!dr.hasText() || !dr.getText().hasDiv()) {
RenderingContext lrc = rc.copy().setHeaderLevelContext(headerLevelContext);
RendererFactory.factory(dr, lrc).render(dr);
}
return new XhtmlComposer(XhtmlComposer.HTML).compose(dr.getText().getDiv());
}
use of org.hl7.fhir.r4.model.DomainResource in project kindling by HL7.
the class SourceParser method loadResource.
private ResourceDefn loadResource(String n, Map<String, ResourceDefn> map, boolean isAbstract, boolean isTemplate, String t, boolean isInterface) throws Exception {
String folder = n;
WorkGroup wg = definitions.getWorkgroups().get(ini.getStringProperty("workgroups", n));
if (wg == null)
throw new Exception("No Workgroup found for resource " + n + ": '" + ini.getStringProperty("workgroups", n) + "'");
File f = new File(Utilities.path(srcDir, folder, n + ".svg"));
if (isTemplate) {
File spreadsheet = new CSFile((srcDir) + folder + File.separatorChar + n + "-spreadsheet.xml");
OldSpreadsheetParser sparser = new OldSpreadsheetParser("core", new CSFileInputStream(spreadsheet), spreadsheet.getName(), spreadsheet.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, false, ini, wg, definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
ResourceDefn root;
try {
root = sparser.parseResource(isTemplate);
} catch (Exception e) {
throw new Exception("Error Parsing Resource " + n + ": " + e.getMessage(), e);
}
root.setAbstract(isAbstract);
root.setInterface(isInterface);
errors.addAll(sparser.getErrors());
setResourceProps(n, wg, root);
String sc = ini.getStringProperty("security-categorization", root.getName().toLowerCase());
if (sc != null) {
root.setSecurityCategorization(SecurityCategorization.fromCode(sc));
} else if (!Utilities.existsInList(root.getName(), "Resource", "DomainResource", "CanonicalResource", "MetadataResource", "MetadataPattern"))
throw new Exception("Must have an entry in the security-categorization section of fhir.ini for the resource " + root.getName());
for (EventDefn e : sparser.getEvents()) {
processEvent(e, root.getRoot());
}
if (map != null) {
map.put(root.getName(), root);
}
if (!isTemplate) {
definitions.getKnownResources().put(root.getName(), new DefinedCode(root.getName(), root.getRoot().getDefinition(), n));
context.getResourceNames().add(root.getName());
}
if (root.getNormativeVersion() != null || root.getNormativePackage() != null) {
root.setStatus(StandardsStatus.NORMATIVE);
}
if (f.exists()) {
parseSvgFile(f, root.getLayout(), f.getName());
}
if (map != null) {
map.put(root.getName(), root);
}
return root;
} else {
try {
new SpreadSheetReloader(context, srcDir, t, version.toCode()).process();
} catch (Exception e) {
System.out.println("Error loading spreadsheet for resource " + t + ": " + e.getMessage());
}
new SpreadSheetCreator(context, srcDir, t).generateSpreadsheet();
ResourceDefn rootNew = new ResourceParser(srcDir, definitions, context, wg, registry, version.toCode(), page.getConceptMaps()).parse(n, t);
if (f.exists()) {
parseSvgFile(f, rootNew.getLayout(), f.getName());
}
if (!isTemplate) {
definitions.getKnownResources().put(rootNew.getName(), new DefinedCode(rootNew.getName(), rootNew.getRoot().getDefinition(), n));
context.getResourceNames().add(rootNew.getName());
}
setResourceProps(n, wg, rootNew);
if (map != null) {
map.put(rootNew.getName(), rootNew);
}
return rootNew;
}
}
Aggregations