use of org.hl7.fhir.definitions.model.W5Entry in project kindling by HL7.
the class OldSpreadsheetParser method checkW5.
private String checkW5(String value, String path) throws Exception {
if (Utilities.noString(value))
return null;
if (!definitions.getW5s().containsKey(value)) {
if (!value.contains(".")) {
throw new Exception("Unknown w5 value " + value + " at " + path);
} else {
String[] vs = value.split("\\.");
if (vs.length != 2)
throw new Exception("improper w5 value " + value + " at " + path);
if (!definitions.getW5s().containsKey(vs[0]))
throw new Exception("Unknown w5 value " + value + " at " + path);
W5Entry w5 = definitions.getW5s().get(vs[0]);
if (!w5.getSubClasses().contains(vs[1]))
throw new Exception("Unknown w5 value " + value + " at " + path);
}
}
return value;
}
use of org.hl7.fhir.definitions.model.W5Entry in project kindling by HL7.
the class SourceParser method loadW5s.
private void loadW5s() throws IOException {
if (new File(Utilities.path(srcDir, "w5.ini")).exists()) {
IniFile w5 = new IniFile(Utilities.path(srcDir, "w5.ini"));
for (String n : w5.getPropertyNames("names")) {
W5Entry w5o = new W5Entry(n, w5.getStringProperty("names", n), w5.getBooleanProperty("display", n), w5.getStringProperty("subclasses", n), w5.getStringProperty("fivews", n));
definitions.getW5list().add(w5o);
definitions.getW5s().put(n, w5o);
}
}
}
use of org.hl7.fhir.definitions.model.W5Entry in project kindling by HL7.
the class W5TurtleGenerator method executeMain.
public void executeMain() throws Exception {
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.setNsPrefix(RDFNamespace.W5.getPrefix(), RDFNamespace.W5.getURI());
model.setNsPrefix(RDFNamespace.FHIR.getPrefix(), RDFNamespace.FHIR.getURI());
Ontology w5 = model.createOntology("http://hl7.org/fhir/w5.ttl");
w5.addProperty(RDFS.label, "W5 Categorization");
w5.addProperty(RDFS.comment, "FHIR W5 categorization is a preliminary classification of the fhir property");
w5.addVersionInfo("FHIR W5 categorization (Preliminary)");
w5.addProperty(OWL2.versionIRI, "http://build.fhir.org/w5.ttl");
// The only way to differentiate predicates from classes is the existence of subclasses -- if something
// has subclasses or is a subclass then it is a class. Otherwise it is a predicate...
Set<String> w5classes = new HashSet<String>();
for (W5Entry e : definitions.getW5list()) {
Set<String> escs = e.getSubClasses();
if (!escs.isEmpty()) {
w5classes.add(e.getCode());
for (String s : e.getSubClasses()) {
if (!s.contains("."))
s = e.getCode() + '.' + s;
w5classes.add(s);
}
}
}
// TODO: Temporary fix -- add 'when' element
OntProperty wp = model.createObjectProperty(RDFNamespace.W5.uriFor("when"));
wp.addLabel("when", null);
wp.addComment("point in time", null);
for (W5Entry e : definitions.getW5list()) {
String es = e.getCode();
if (w5classes.contains(es)) {
OntClass ec = model.createClass(RDFNamespace.W5.uriFor(es));
ec.addLabel(es, null);
ec.addComment(e.getDescription(), null);
for (String s : e.getSubClasses()) {
String s_uri = RDFNamespace.W5.uriFor(s.contains(".") ? s : e.getCode() + "." + s);
OntClass c = model.createClass(s_uri);
c.addSuperClass(ec);
c.addLabel(s, null);
}
} else {
OntProperty ep = model.createObjectProperty(RDFNamespace.W5.uriFor(es));
ep.addLabel(es, null);
ep.addComment(e.getDescription(), null);
String esroot = es;
while (esroot.contains(".")) {
esroot = esroot.substring(0, esroot.lastIndexOf('.'));
ep.addSuperProperty(model.createProperty(RDFNamespace.W5.uriFor(esroot)));
}
}
}
commit(model, true);
}
use of org.hl7.fhir.definitions.model.W5Entry in project kindling by HL7.
the class PageProcessor method genW5.
private String genW5(boolean types) throws Exception {
StringBuilder b = new StringBuilder();
b.append("<table border=\"1\">\r\n<tr>\r\n");
List<W5Entry> items = new ArrayList<W5Entry>();
for (W5Entry e : definitions.getW5list()) if (e.isDisplay())
items.add(e);
b.append("<td>Resource</td>");
for (W5Entry e : items) {
b.append("<td><span title=\"").append(Utilities.escapeXml(definitions.getW5s().get(e.getCode()).getDescription())).append("\">").append(e.getCode()).append("</span></td>");
}
b.append("</tr>\r\n");
processW5(b, items, "clinical", types);
processW5(b, items, "administrative", types);
processW5(b, items, "workflow", types);
processW5(b, items, "infrastructure", types);
processW5(b, items, "conformance", types);
processW5(b, items, "financial", types);
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.definitions.model.W5Entry in project kindling by HL7.
the class PageProcessor method processW5.
private void processW5(StringBuilder b, List<W5Entry> items, String cat, boolean types) throws Exception {
b.append("<tr><td colspan=\"").append(Integer.toString(items.size() + 1)).append("\"><b>").append(Utilities.escapeXml(definitions.getW5s().get(cat).getDescription())).append("</b></td></tr>\r\n");
for (String rn : definitions.sortedResourceNames()) {
ResourceDefn r = definitions.getResourceByName(rn);
if (r.getRoot().getW5().startsWith(cat)) {
b.append("<tr>\r\n <td>").append(rn).append(" (").append(r.getFmmLevel()).append(")").append("</td>\r\n");
for (W5Entry e : items) {
b.append(" <td>");
addMatchingFields(b, r.getRoot().getElements(), r.getRoot().getName(), e.getCode(), true, types);
b.append("</td>\r\n");
}
b.append("</tr>\r\n");
}
}
}
Aggregations