use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project kindling by HL7.
the class Publisher method insertSectionNumbers.
private String insertSectionNumbers(String src, SectionTracker st, String link, int level, DocumentHolder doch) throws Exception {
try {
// TextFile.stringToFile(src, "c:\\temp\\text.html");
XhtmlDocument doc = new XhtmlParser().parse(src, "html");
insertSectionNumbersInNode(doc, st, link, level, new BooleanHolder(), null);
if (doch != null)
doch.doc = doc;
return new XhtmlComposer(XhtmlComposer.HTML).compose(doc);
} catch (Exception e) {
System.out.println(e.getMessage());
// TextFile.stringToFile(src, "c:\\temp\\dump.html");
TextFile.stringToFile(src, Utilities.appendSlash(System.getProperty("user.dir")) + "fhir-error-dump.html");
throw new Exception("Exception inserting section numbers in " + link + ": " + e.getMessage(), e);
}
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCompositionSectionComponent.
protected void composeCompositionSectionComponent(Complex parent, String parentType, String name, Composition.SectionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "section", name, element, index);
if (element.hasTitleElement())
composeString(t, "Composition", "title", element.getTitleElement(), -1);
if (element.hasCode())
composeCodeableConcept(t, "Composition", "code", element.getCode(), -1);
if (element.hasText())
composeNarrative(t, "Composition", "text", element.getText(), -1);
if (element.hasModeElement())
composeCode(t, "Composition", "mode", element.getModeElement(), -1);
if (element.hasOrderedBy())
composeCodeableConcept(t, "Composition", "orderedBy", element.getOrderedBy(), -1);
for (int i = 0; i < element.getEntry().size(); i++) composeReference(t, "Composition", "entry", element.getEntry().get(i), i);
if (element.hasEmptyReason())
composeCodeableConcept(t, "Composition", "emptyReason", element.getEmptyReason(), -1);
for (int i = 0; i < element.getSection().size(); i++) composeCompositionSectionComponent(t, "Composition", "section", element.getSection().get(i), i);
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class TurtleParser method composeElement.
private void composeElement(Section section, Complex ctxt, Element element, Element parent) throws FHIRException {
// "Extension".equals(element.getType())?
// (element.getProperty().getDefinition().getIsModifier()? "modifierExtension" : "extension") ;
String en = getFormalName(element);
Complex t;
if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY && parent != null && parent.getNamedChildValue("fullUrl") != null) {
String url = "<" + parent.getNamedChildValue("fullUrl") + ">";
ctxt.linkedPredicate("fhir:" + en, url, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
t = section.subject(url);
} else {
t = ctxt.linkedPredicate("fhir:" + en, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
}
if (element.getSpecial() != null)
t.linkedPredicate("a", "fhir:" + element.fhirType(), linkResolver == null ? null : linkResolver.resolveType(element.fhirType()));
if (element.hasValue())
t.linkedPredicate("fhir:value", ttlLiteral(element.getValue(), element.getType()), linkResolver == null ? null : linkResolver.resolveType(element.getType()));
if (element.getProperty().isList() && (!element.isResource() || element.getSpecial() == SpecialElement.CONTAINED))
t.linkedPredicate("fhir:index", Integer.toString(element.getIndex()), linkResolver == null ? null : linkResolver.resolvePage("rdf.html#index"));
if ("Coding".equals(element.getType()))
decorateCoding(t, element, section);
if (Utilities.existsInList(element.getType(), "Reference"))
decorateReference(t, element);
else if (Utilities.existsInList(element.getType(), "canonical"))
decorateCanonical(t, element);
if ("canonical".equals(element.getType())) {
String refURI = element.primitiveValue();
if (refURI != null) {
String uriType = getURIType(refURI);
if (uriType != null && !section.hasSubject(refURI))
section.triple(refURI, "a", "fhir:" + uriType);
}
}
if ("Reference".equals(element.getType())) {
String refURI = getReferenceURI(element.getChildValue("reference"));
if (refURI != null) {
String uriType = getURIType(refURI);
if (uriType != null && !section.hasSubject(refURI))
section.triple(refURI, "a", "fhir:" + uriType);
}
}
for (Element child : element.getChildren()) {
if ("xhtml".equals(child.getType())) {
String childfn = getFormalName(child);
t.predicate("fhir:" + childfn, ttlLiteral(child.getValue(), child.getType()));
} else
composeElement(section, t, child, element);
}
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class TurtleParser method compose.
public void compose(Element e, Turtle ttl, String base) throws FHIRException {
ttl.prefix("fhir", FHIR_URI_BASE);
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");
ttl.prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
Section section = ttl.section("resource");
String subjId = genSubjectId(e);
String ontologyId = subjId.replace(">", ".ttl>");
Section ontology = ttl.section("ontology header");
ontology.triple(ontologyId, "a", "owl:Ontology");
ontology.triple(ontologyId, "owl:imports", "fhir:fhir.ttl");
if (ontologyId.startsWith("<" + FHIR_URI_BASE))
ontology.triple(ontologyId, "owl:versionIRI", ontologyId.replace(FHIR_URI_BASE, FHIR_VERSION_BASE));
Subject subject = section.triple(subjId, "a", "fhir:" + e.getType());
subject.linkedPredicate("fhir:nodeRole", "fhir:treeRoot", linkResolver == null ? null : linkResolver.resolvePage("rdf.html#tree-root"));
for (Element child : e.getChildren()) {
composeElement(section, subject, child, null);
}
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class BundleRenderer method renderDocument.
private boolean renderDocument(XhtmlNode x, ResourceWrapper b, List<BaseWrapper> entries) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
// from the spec:
//
// When the document is presented for human consumption, applications SHOULD present the collated narrative portions in order:
// * The subject resource Narrative
// * The Composition resource Narrative
// * The section.text Narratives
ResourceWrapper comp = (ResourceWrapper) entries.get(0).getChildByName("resource").getAsResource();
ResourceWrapper subject = resolveReference(entries, comp.get("subject"));
if (subject != null) {
if (subject.hasNarrative()) {
x.addChildren(subject.getNarrative());
} else {
RendererFactory.factory(subject, context).render(x, subject);
}
}
x.hr();
if (comp.hasNarrative()) {
x.addChildren(comp.getNarrative());
x.hr();
}
List<BaseWrapper> sections = comp.children("section");
for (BaseWrapper section : sections) {
addSection(x, section, 2, false);
}
return false;
}
Aggregations