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 TurtleParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String base) throws Exception {
this.base = base;
RdfGenerator ttl = new RdfGenerator(stream);
// ttl.setFormat(FFormat);
ttl.prefix("fhir", "http://hl7.org/fhir/");
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");
ttl.prefix("xs", "http://www.w3.org/2001/XMLSchema#");
Section section = ttl.section("resource");
Subject subject;
String id = e.getChildValue("id");
if (base != null && id != null)
subject = section.triple("<" + base + "/" + e.getType() + "/" + id + ">", "a", "fhir:" + e.getType());
else
subject = section.triple("_", "a", "fhir:" + e.getType());
subject.predicate("fhir:nodeRole", "fhir:treeRoot");
for (Element child : e.getChildren()) {
composeElement(subject, child);
}
ttl.commit(false);
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeComposition.
protected void composeComposition(Complex parent, String parentType, String name, Composition element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Composition", name, element, index);
if (element.hasIdentifier())
composeIdentifier(t, "Composition", "identifier", element.getIdentifier(), -1);
if (element.hasStatusElement())
composeEnum(t, "Composition", "status", element.getStatusElement(), -1);
if (element.hasType())
composeCodeableConcept(t, "Composition", "type", element.getType(), -1);
for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "Composition", "category", element.getCategory().get(i), i);
if (element.hasSubject())
composeReference(t, "Composition", "subject", element.getSubject(), -1);
if (element.hasEncounter())
composeReference(t, "Composition", "encounter", element.getEncounter(), -1);
if (element.hasDateElement())
composeDateTime(t, "Composition", "date", element.getDateElement(), -1);
for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "Composition", "author", element.getAuthor().get(i), i);
if (element.hasTitleElement())
composeString(t, "Composition", "title", element.getTitleElement(), -1);
if (element.hasConfidentialityElement())
composeEnum(t, "Composition", "confidentiality", element.getConfidentialityElement(), -1);
for (int i = 0; i < element.getAttester().size(); i++) composeCompositionCompositionAttesterComponent(t, "Composition", "attester", element.getAttester().get(i), i);
if (element.hasCustodian())
composeReference(t, "Composition", "custodian", element.getCustodian(), -1);
for (int i = 0; i < element.getRelatesTo().size(); i++) composeCompositionCompositionRelatesToComponent(t, "Composition", "relatesTo", element.getRelatesTo().get(i), i);
for (int i = 0; i < element.getEvent().size(); i++) composeCompositionCompositionEventComponent(t, "Composition", "event", element.getEvent().get(i), i);
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 ProfileUtilities method generateForChildren.
private void generateForChildren(SchematronWriter sch, String xpath, ElementDefinition ed, StructureDefinition structure, StructureDefinition base) throws IOException {
// generateForChild(txt, structure, child);
List<ElementDefinition> children = getChildList(structure, ed);
String sliceName = null;
ElementDefinitionSlicingComponent slicing = null;
for (ElementDefinition child : children) {
String name = tail(child.getPath());
if (child.hasSlicing()) {
sliceName = name;
slicing = child.getSlicing();
} else if (!name.equals(sliceName))
slicing = null;
ElementDefinition based = getByPath(base, child.getPath());
boolean doMin = (child.getMin() > 0) && (based == null || (child.getMin() != based.getMin()));
boolean doMax = child.hasMax() && !child.getMax().equals("*") && (based == null || (!child.getMax().equals(based.getMax())));
Slicer slicer = slicing == null ? new Slicer(true) : generateSlicer(child, slicing, structure);
if (slicer.check) {
if (doMin || doMax) {
Section s = sch.section(xpath);
Rule r = s.rule(xpath);
if (doMin)
r.assrt("count(f:" + name + slicer.criteria + ") >= " + Integer.toString(child.getMin()), name + slicer.name + ": minimum cardinality of '" + name + "' is " + Integer.toString(child.getMin()));
if (doMax)
r.assrt("count(f:" + name + slicer.criteria + ") <= " + child.getMax(), name + slicer.name + ": maximum cardinality of '" + name + "' is " + child.getMax());
}
}
}
for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) {
if (inv.hasXpath()) {
Section s = sch.section(ed.getPath());
Rule r = s.rule(xpath);
r.assrt(inv.getXpath(), (inv.hasId() ? inv.getId() + ": " : "") + inv.getHuman() + (inv.hasUserData(IS_DERIVED) ? " (inherited)" : ""));
}
}
if (!ed.hasContentReference()) {
for (ElementDefinition child : children) {
String name = tail(child.getPath());
generateForChildren(sch, xpath + "/f:" + name, child, structure, base);
}
}
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class BundleValidator method validateSections.
private void validateSections(List<ValidationMessage> errors, List<Element> entries, Element focus, NodeStack stack, String fullUrl, String id) {
List<Element> sections = new ArrayList<Element>();
focus.getNamedChildren("section", sections);
int i = 1;
for (Element section : sections) {
NodeStack localStack = stack.push(section, i, null, null);
// technically R4+, but there won't be matches from before that
validateDocumentReference(errors, entries, section, stack, fullUrl, id, true, "author", "Section");
validateDocumentReference(errors, entries, section, stack, fullUrl, id, false, "focus", "Section");
List<Element> sectionEntries = new ArrayList<Element>();
section.getNamedChildren(ENTRY, sectionEntries);
int j = 1;
for (Element sectionEntry : sectionEntries) {
NodeStack localStack2 = localStack.push(sectionEntry, j, null, null);
validateBundleReference(errors, entries, sectionEntry, "Section Entry", localStack2, fullUrl, "Composition", id);
j++;
}
validateSections(errors, entries, section, localStack, fullUrl, id);
i++;
}
}
Aggregations