use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project kindling by HL7.
the class Publisher method generateConceptMap.
private void generateConceptMap(ConceptMap cm) throws Exception {
String filename = cm.getUserString("path");
RenderingContext lrc = page.getRc().copy().setLocalPrefix("").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cm, lrc).render(cm);
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".json"));
json.compose(s, cm);
s.close();
json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.json"));
json.compose(s, cm);
s.close();
String n = Utilities.changeFileExt(filename, "");
jsonToXhtml(n, cm.getName(), resource2Json(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
ttlToXhtml(n, cm.getName(), resource2Ttl(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
IParser xml = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".xml"));
xml.compose(s, cm);
s.close();
xml = new XmlParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.xml"));
xml.compose(s, cm);
s.close();
cloneToXhtml(n, cm.getName(), false, "conceptmap-instance", "Concept Map", null, wg("vocab"));
// now, we create an html page from the narrative
String narrative = new XhtmlComposer(XhtmlComposer.HTML).compose(cm.getText().getDiv());
String html = TextFile.fileToString(page.getFolders().templateDir + "template-example.html").replace("<%example%>", narrative);
html = page.processPageIncludes(Utilities.changeFileExt(filename, ".html"), html, "conceptmap-instance", null, null, null, "Concept Map", null, null, wg("vocab"));
TextFile.stringToFile(html, page.getFolders().dstDir + Utilities.changeFileExt(filename, ".html"));
conceptMapsFeed.getEntry().add(new BundleEntryComponent().setResource(cm).setFullUrl("http://hl7.org/fhir/" + cm.fhirType() + "/" + cm.getId()));
page.getConceptMaps().see(cm, page.packageInfo());
page.getHTMLChecker().registerFile(n + ".html", cm.getName(), HTMLLinkChecker.XHTML_TYPE, false);
}
use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project kindling by HL7.
the class Publisher method checkBundleURLs.
/**
* This is not true of bundles generally, but it is true of all the
* conformance bundles produced by the spec:
*
* all entries must have a fullUrl, and it must equal http://hl7.org/fhir/[type]/[id]
*
* @param bnd - the bundle to check
*/
private void checkBundleURLs(Bundle bnd) {
int i = 0;
for (BundleEntryComponent e : bnd.getEntry()) {
i++;
if (!e.getResource().hasUserData("external.url")) {
if (!e.hasFullUrl())
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "Bundle " + bnd.getId(), "no Full URL on entry " + Integer.toString(i), IssueSeverity.ERROR));
else if (!e.getFullUrl().endsWith("/" + e.getResource().getResourceType().toString() + "/" + e.getResource().getId()) && e.getResource().getResourceType() != ResourceType.CodeSystem)
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "Bundle " + bnd.getId(), "URL doesn't match resource and id on entry " + Integer.toString(i) + " : " + e.getFullUrl() + " should end with /" + e.getResource().getResourceType().toString() + "/" + e.getResource().getId(), IssueSeverity.ERROR));
else if (!e.getFullUrl().equals("http://hl7.org/fhir/" + e.getResource().getResourceType().toString() + "/" + e.getResource().getId()) && e.getResource().getResourceType() != ResourceType.CodeSystem)
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "Bundle " + bnd.getId(), "URL is non-FHIR " + Integer.toString(i) + " : " + e.getFullUrl() + " should start with http://hl7.org/fhir/ for HL7-defined artifacts", IssueSeverity.WARNING));
if (e.getResource() instanceof CanonicalResource) {
CanonicalResource m = (CanonicalResource) e.getResource();
String url = m.getUrl();
if (url != null && url.startsWith("http://hl7.org/fhir") && !SIDUtilities.isKnownSID(url)) {
if (!page.getVersion().toCode().equals(m.getVersion()))
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "Bundle " + bnd.getId(), "definitions in FHIR space should have the correct version (url = " + url + ", version = " + m.getVersion() + ")", IssueSeverity.ERROR));
}
}
}
}
}
use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project kindling by HL7.
the class SourceParser method loadCommonSearchParameters.
private void loadCommonSearchParameters() throws FHIRFormatError, FileNotFoundException, IOException {
Bundle bnd = (Bundle) new XmlParser().parse(new CSFileInputStream(Utilities.path(srcDir, "searchparameter", "common-search-parameters.xml")));
for (BundleEntryComponent be : bnd.getEntry()) {
SearchParameter sp = (SearchParameter) be.getResource();
CommonSearchParameter csp = new CommonSearchParameter();
csp.setId(sp.getId());
csp.setCode(sp.getCode());
for (CodeType ct : sp.getBase()) {
csp.getResources().add(ct.asStringValue());
definitions.getCommonSearchParameters().put(ct.asStringValue() + "::" + sp.getCode(), csp);
}
}
}
use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project kindling by HL7.
the class SpreadSheetCreator method addSearchParams.
private void addSearchParams(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
Bundle bnd = (Bundle) parseXml(fnSP());
XSSFSheet sheet = excel.createSheet(SN_SEARCH);
addSearchColumns(sheet);
int rowCount = 0;
for (BundleEntryComponent be : bnd.getEntry()) {
rowCount++;
addSearchParam(sheet, (SearchParameter) be.getResource(), rowCount);
}
}
use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project kindling by HL7.
the class Publisher method addToResourceFeed.
private void addToResourceFeed(CapabilityStatement cs, Bundle dest) throws Exception {
if (cs.getId() == null)
throw new Exception("Resource has no id");
if (ResourceUtilities.getById(dest, ResourceType.ValueSet, cs.getId()) != null)
throw new Exception("Attempt to add duplicate Conformance " + cs.getId());
if (!cs.hasText() || !cs.getText().hasDiv()) {
RendererFactory.factory(cs, page.getRc().copy()).render(cs);
}
if (!cs.hasText() || cs.getText().getDiv() == null)
System.out.println("WARNING: Example CapabilityStatement " + cs.getId() + " does not have any narrative");
// Changed this from an exception to a warning because generateConformanceStatement doesn't produce narrative if
// "register" is 'false'
ResourceUtilities.meta(cs).setLastUpdated(page.getGenDate().getTime());
if (!cs.getUrl().equals("http://hl7.org/fhir/" + cs.getResourceType().toString() + "/" + cs.getId()))
throw new Exception("URL mismatch on CapabilityStatement");
dest.getEntry().add(new BundleEntryComponent().setResource(cs).setFullUrl("http://hl7.org/fhir/" + cs.fhirType() + "/" + cs.getId()));
}
Aggregations