use of org.hl7.fhir.dstu2.model.StructureDefinition in project kindling by HL7.
the class Publisher method produceProfiledTypeProfile.
private void produceProfiledTypeProfile(ProfiledType pt) throws Exception {
String fn = pt.getName().toLowerCase() + ".profile.xml";
StructureDefinition rp = pt.getProfile();
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + fn);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.xml"));
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".json"));
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.json"));
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
Utilities.copyFile(new CSFile(page.getFolders().dstDir + fn), new CSFile(Utilities.path(page.getFolders().dstDir, "examples", fn)));
addToResourceFeed(rp, page.getTypeBundle(), (fn));
cloneToXhtml(pt.getName().toLowerCase() + ".profile", "StructureDefinition for " + pt.getName(), false, "profile-instance:type:" + pt.getName(), "Type", null, wg("mnm"));
jsonToXhtml(pt.getName().toLowerCase() + ".profile", "StructureDefinition for " + pt.getName(), resource2Json(rp), "profile-instance:type:" + pt.getName(), "Type", null, wg("mnm"));
ttlToXhtml(pt.getName().toLowerCase() + ".profile", "StructureDefinition for " + pt.getName(), resource2Ttl(rp), "profile-instance:type:" + pt.getName(), "Type", null, wg("mnm"));
String shex = new ShExGenerator(page.getWorkerContext()).generate(HTMLLinkPolicy.NONE, rp);
TextFile.stringToFile(shex, Utilities.changeFileExt(page.getFolders().dstDir + fn, ".shex"));
shexToXhtml(pt.getName().toLowerCase(), "ShEx statement for " + pt.getName(), shex, "profile-instance:type:" + pt.getName(), "Type", null, wg("mnm"));
}
use of org.hl7.fhir.dstu2.model.StructureDefinition in project kindling by HL7.
the class Publisher method genXhtmlProfile.
private void genXhtmlProfile() throws Exception {
StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generateXhtml();
if (page.getProfiles().has(profile.getUrl()))
throw new Exception("Duplicate Profile URL " + profile.getUrl());
page.getProfiles().see(profile, page.packageInfo());
// DataTypeTableGenerator dtg = new DataTypeTableGenerator(page.getFolders().dstDir, page, t.getCode(), true);
// t.setProfile(profile);
// t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
// t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t));
}
use of org.hl7.fhir.dstu2.model.StructureDefinition in project kindling by HL7.
the class Publisher method produceSpecMap.
private void produceSpecMap() throws IOException {
SpecMapManager spm = new SpecMapManager("hl7.fhir.core", page.getVersion().toCode(), page.getVersion().toCode(), page.getBuildId(), page.getGenDate(), CANONICAL_BASE);
for (StructureDefinition sd : page.getWorkerContext().allStructures()) {
if (sd.hasUserData("path")) {
spm.path(sd.getUrl(), sd.getUserString("path").replace("\\", "/"));
spm.target(sd.getUserString("path").replace("\\", "/"));
}
}
for (StructureDefinition sd : page.getWorkerContext().getExtensionDefinitions()) {
if (sd.hasUserData("path")) {
spm.path(sd.getUrl(), sd.getUserString("path").replace("\\", "/"));
spm.target(sd.getUserString("path").replace("\\", "/"));
}
}
for (String s : page.getCodeSystems().keys()) {
CodeSystem cs = page.getCodeSystems().get(s);
if (cs == null && !Utilities.existsInList(s, "http://unitsofmeasure.org", "http://loinc.org", "http://fdasis.nlm.nih.gov", "http://www.nlm.nih.gov/research/umls/rxnorm", "urn:oid:1.2.36.1.2001.1005.17") && !SIDUtilities.isknownCodeSystem(s))
System.out.println("No code system resource found for " + s);
}
for (CodeSystem cs : page.getCodeSystems().getList()) {
if (cs != null && cs.hasUserData("path")) {
spm.path(cs.getUrl(), cs.getUserString("path").replace("\\", "/"));
spm.target(cs.getUserString("path").replace("\\", "/"));
}
}
for (ValueSet vs : page.getValueSets().getList()) {
if (vs.hasUserData("path")) {
spm.path(vs.getUrl(), vs.getUserString("path").replace("\\", "/"));
spm.target(vs.getUserString("path").replace("\\", "/"));
}
}
for (ConceptMap cm : page.getConceptMaps().getList()) {
if (cm.hasUserData("path")) {
spm.path(cm.getUrl(), cm.getUserString("path").replace("\\", "/"));
spm.target(cm.getUserString("path").replace("\\", "/"));
}
}
for (String s : page.getDefinitions().getPageTitles().keySet()) {
spm.page(s, page.getDefinitions().getPageTitles().get(s));
}
for (String n : page.getIni().getPropertyNames("pages")) {
spm.target(n);
}
for (ResourceDefn rd : page.getDefinitions().getResources().values()) {
spm.target(rd.getName().toLowerCase() + ".html");
spm.target(rd.getName().toLowerCase() + "-definitions.html");
spm.target(rd.getName().toLowerCase() + "-mappings.html");
spm.target(rd.getName().toLowerCase() + "-examples.html");
spm.target(rd.getName().toLowerCase() + "-profiles.html");
if (!rd.getOperations().isEmpty())
spm.target(rd.getName().toLowerCase() + "-operations.html");
for (Example ex : rd.getExamples()) {
ImplementationGuideDefn ig = ex.getIg() == null ? null : page.getDefinitions().getIgs().get(ex.getIg());
String prefix = (ig == null || ig.isCore()) ? "" : ig.getCode() + "/";
spm.target(prefix + ex.getTitle() + ".html");
}
}
for (Profile p : page.getDefinitions().getPackList()) {
spm.target(p.getId() + ".html");
}
// for (String url : page.getDefinitions().getMapTypes().keySet()) {
// spm.map(url, page.getDefinitions().getMapTypes().get(url).getPreamble());
// }
scanForImages(spm, page.getFolders().dstDir, page.getFolders().dstDir);
scanForPages(spm, page.getFolders().dstDir, page.getFolders().dstDir);
for (String url : page.getDefinitions().getRedirectList().keySet()) {
// http://hl7.org/fhir/ = 20 chars
spm.target(url.substring(20));
}
spm.save(page.getFolders().dstDir + "spec.internals");
}
use of org.hl7.fhir.dstu2.model.StructureDefinition in project kindling by HL7.
the class Publisher method generateProfile.
private StructureDefinition generateProfile(ResourceDefn root, String n, String xmlSpec, String jsonSpec, String ttlSpec, boolean gen) throws Exception, FileNotFoundException {
StructureDefinition rp = root.getProfile();
page.getProfiles().see(rp, page.packageInfo());
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + n + ".profile.xml");
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + n + ".profile.canonical.xml");
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + n + ".profile.json");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + n + ".profile.canonical.json");
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
Utilities.copyFile(new CSFile(page.getFolders().dstDir + n + ".profile.xml"), new CSFile(page.getFolders().dstDir + "examples" + File.separator + n + ".profile.xml"));
if (buildFlags.get("all")) {
addToResourceFeed(rp, page.getResourceBundle(), null);
}
if (gen) {
saveAsPureHtml(rp, new FileOutputStream(page.getFolders().dstDir + "html" + File.separator + n + ".html"));
cloneToXhtml(n + ".profile", "StructureDefinition for " + n, true, "profile-instance:resource:" + root.getName(), "Profile", root, root.getWg());
jsonToXhtml(n + ".profile", "StructureDefinition for " + n, resource2Json(rp), "profile-instance:resource:" + root.getName(), "Profile", root, root.getWg());
ttlToXhtml(n + ".profile", "StructureDefinition for " + n, resource2Ttl(rp), "profile-instance:resource:" + root.getName(), "Profile", root, root.getWg());
String shex = new ShExGenerator(page.getWorkerContext()).generate(HTMLLinkPolicy.NONE, rp);
TextFile.stringToFile(shex, page.getFolders().dstDir + n + ".shex");
shexToXhtml(n, "ShEx statement for " + n, shex, "profile-instance:type:" + root.getName(), "Type", root, root.getWg());
}
return rp;
}
use of org.hl7.fhir.dstu2.model.StructureDefinition in project kindling by HL7.
the class Publisher method producePrimitiveTypeProfile.
private void producePrimitiveTypeProfile(DefinedCode type) throws Exception {
String fn = type.getCode().toLowerCase() + ".profile.xml";
StructureDefinition rp = type.getProfile();
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + fn);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.xml"));
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".json"));
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.json"));
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
String shex = new ShExGenerator(page.getWorkerContext()).generate(HTMLLinkPolicy.NONE, rp);
TextFile.stringToFile(shex, Utilities.changeFileExt(page.getFolders().dstDir + fn, ".shex"));
Utilities.copyFile(new CSFile(page.getFolders().dstDir + fn), new CSFile(Utilities.path(page.getFolders().dstDir, "examples", fn)));
addToResourceFeed(rp, page.getTypeBundle(), (fn));
// saveAsPureHtml(rp, new FileOutputStream(page.getFolders().dstDir+ "html"
// + File.separator + "datatypes.html"));
cloneToXhtml(type.getCode().toLowerCase() + ".profile", "StructureDefinition for " + type.getCode(), false, "profile-instance:type:" + type.getCode(), "Type", null, wg("mnm"));
jsonToXhtml(type.getCode().toLowerCase() + ".profile", "StructureDefinition for " + type.getCode(), resource2Json(rp), "profile-instance:type:" + type.getCode(), "Type", null, wg("mnm"));
ttlToXhtml(type.getCode().toLowerCase() + ".profile", "StructureDefinition for " + type.getCode(), resource2Ttl(rp), "profile-instance:type:" + type.getCode(), "Type", null, wg("mnm"));
shexToXhtml(type.getCode().toLowerCase(), "ShEx statement for " + type.getCode(), shex, "profile-instance:type:" + type.getCode(), "Type", null, wg("mnm"));
}
Aggregations