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, Bundle b) 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
Composition comp = (Composition) b.getEntry().get(0).getResource();
Resource subject = resolveReference(b, comp.getSubject());
if (subject != null) {
XhtmlNode nx = (subject instanceof DomainResource) ? ((DomainResource) subject).getText().getDiv() : null;
if (nx != null) {
x.addChildren(nx);
} else {
RendererFactory.factory(subject, context).render(x, subject);
}
}
x.hr();
if (comp.getText().hasDiv()) {
x.addChildren(comp.getText().getDiv());
x.hr();
}
for (SectionComponent section : comp.getSection()) {
addSection(x, section, 2, false);
}
return false;
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class Turtle method section.
public Section section(String sn) {
if (hasSection(sn))
throw new Error("Duplicate section name " + sn);
Section s = new Section();
s.name = sn;
sections.add(s);
return s;
}
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 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 Turtle method section.
public Section section(String sn) {
if (hasSection(sn))
throw new Error("Duplicate section name " + sn);
Section s = new Section();
s.name = sn;
sections.add(s);
return s;
}
Aggregations