use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.
the class PageProcessor method getEventsTable.
private String getEventsTable(String resource) throws Exception {
List<String> codes = new ArrayList<String>();
codes.addAll(definitions.getEvents().keySet());
Collections.sort(codes);
StringBuilder s = new StringBuilder();
s.append("<table class=\"grid\">\r\n");
s.append(" <tr><th>Code</th><th>Category</th><th>Description</th><th>Request Resources</th><th>Response Resources</th><th>Notes</th></tr>\r\n");
for (String c : codes) {
EventDefn e = definitions.getEvents().get(c);
if (e.getUsages().size() == 1) {
EventUsage u = e.getUsages().get(0);
s.append(" <tr><td>" + e.getCode() + "<a name=\"" + e.getCode() + "\"> </a></td><td>" + (e.getCategory() == null ? "??" : e.getCategory().toString()) + "</td><td>" + e.getDefinition() + "</td>");
s.append("<td>" + describeMsg(u.getRequestResources(), u.getRequestAggregations()) + "</td><td>" + describeMsg(u.getResponseResources(), u.getResponseAggregations()) + "</td><td>" + combineNotes(resource, e.getFollowUps(), u.getNotes(), "") + "</td></tr>\r\n");
} else {
boolean first = true;
for (EventUsage u : e.getUsages()) {
if (first)
s.append(" <tr><td rowspan=\"" + Integer.toString(e.getUsages().size()) + "\">" + e.getCode() + "</td><td rowspan=\"" + Integer.toString(e.getUsages().size()) + "\">" + e.getDefinition() + "</td>");
else
s.append(" <tr>");
first = false;
s.append("<td>" + describeMsg(u.getRequestResources(), u.getRequestAggregations()) + "</td><td>" + describeMsg(u.getResponseResources(), u.getResponseAggregations()) + "</td><td>" + combineNotes(resource, e.getFollowUps(), u.getNotes(), "") + "</td></tr>\r\n");
}
}
}
s.append("</table>\r\n");
return s.toString();
}
use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.
the class ValueSetGenerator method genMessageEvents.
private void genMessageEvents(ValueSet vs) {
if (!vs.hasCompose())
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/message-events");
vs.setUserData("filename", "valueset-" + vs.getId());
if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
} else {
String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
if (!ec.equals("fhir"))
System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 10: is " + ec + ", want to set to " + "fhir");
}
vs.setUserData("path", "valueset-" + vs.getId() + ".html");
CodeSystem cs = new CodeSystem();
CodeSystemConvertor.populate(cs, vs);
cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
cs.setUrl("http://hl7.org/fhir/message-events");
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
definitions.getCodeSystems().see(cs, packageInfo);
List<String> codes = new ArrayList<String>();
codes.addAll(definitions.getEvents().keySet());
Collections.sort(codes);
for (String s : codes) {
ConceptDefinitionComponent c = cs.addConcept();
EventDefn e = definitions.getEvents().get(s);
c.setCode(s);
c.setDisplay(transform(e.getCode(), e.getTitle()));
c.setDefinition(e.getDefinition());
}
markSpecialStatus(vs, cs, false);
}
use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.
the class SourceParser method processEvent.
private void processEvent(EventDefn defn, ElementDefn root) throws Exception {
// Exception("Event "+defn.getCode()+" has a mismatched request resource - should be "+root.getName()+", is "+defn.getUsages().get(0).getRequestResources().get(0));
if (definitions.getEvents().containsKey(defn.getCode())) {
EventDefn master = definitions.getEvents().get(defn.getCode());
master.getUsages().add(defn.getUsages().get(0));
if (!defn.getDefinition().startsWith("(see"))
master.setDefinition(defn.getDefinition());
} else
definitions.getEvents().put(defn.getCode(), defn);
}
use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.
the class OldSpreadsheetParser method readEvents.
private void readEvents(Sheet sheet, ResourceDefn root) throws Exception {
if (sheet != null) {
for (int row = 0; row < sheet.rows.size(); row++) {
String code = sheet.getColumn(row, "Event Code");
if (code != null && !code.equals("") && !code.startsWith("!")) {
System.out.print("!!Lloyd Look at me! - event " + code + " on resource " + root.getName());
EventDefn e = new EventDefn();
events.add(e);
e.setCode(code);
e.setTitle(sheet.getColumn(row, "Title"));
e.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Description")));
e.setCategory(readCategory(sheet.getColumn(row, "Category")));
EventUsage u = new EventUsage();
e.getUsages().add(u);
u.setNotes(sheet.getColumn(row, "Notes"));
for (String s : sheet.getColumn(row, "Request Resources").split(",")) {
s = s.trim();
if (!s.isEmpty())
u.getRequestResources().add(s);
}
for (String s : sheet.getColumn(row, "Request Aggregations").split("\n")) {
s = s.trim();
if (!s.isEmpty())
u.getRequestAggregations().add(s);
}
for (String s : sheet.getColumn(row, "Response Resources").split(",")) {
s = s.trim();
if (!s.isEmpty())
u.getResponseResources().add(s);
}
for (String s : sheet.getColumn(row, "Response Aggregations").split("\n")) {
s = s.trim();
if (!s.isEmpty())
u.getResponseAggregations().add(s);
}
for (String s : sheet.getColumn(row, "Follow Ups").split(",")) {
s = s.trim();
if (!s.isEmpty())
e.getFollowUps().add(s);
}
}
}
}
}
use of org.hl7.fhir.definitions.model.EventDefn 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