use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processVitalSignsSection.
protected SectionComponent processVitalSignsSection(Element section) throws Exception {
ListResource list = new ListResource();
for (Element entry : cda.getChildren(section, "entry")) {
Element organizer = cda.getlastChild(entry);
if (cda.hasTemplateId(organizer, "2.16.840.1.113883.10.20.22.4.26")) {
processVitalSignsOrganizer(list, organizer);
} else
throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(organizer));
}
// todo: text
SectionComponent s = new Composition.SectionComponent();
s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
// todo: check subject
s.addEntry(Factory.makeReference(addReference(list, "Vital Signs", makeUUIDReference())));
return s;
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method convert.
public Bundle convert(InputStream stream) throws Exception {
cda = new CDAUtilities(stream);
doc = cda.getElement();
cda.checkTemplateId(doc, "2.16.840.1.113883.10.20.22.1.1");
convert = new Convert(cda, ucumSvc, "Z");
// check it's a CDA/CCD
feed = new Bundle();
feed.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
feed.setId(makeUUIDReference());
// todo-bundle ("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/document", "Document"));
feed.getMeta().getTag().add(new Coding());
// process the header
makeDocument();
composition.setSubject(Factory.makeReference(makeSubject()));
for (Element e : cda.getChildren(doc, "author")) composition.getAuthor().add(Factory.makeReference(makeAuthor(e)));
// todo: data enterer & informant goes in provenance
composition.setCustodian(Factory.makeReference(makeOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), "Custodian")));
// todo: informationRecipient
for (Element e : cda.getChildren(doc, "legalAuthenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.LEGAL, "Legal Authenticator"));
for (Element e : cda.getChildren(doc, "authenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.PROFESSIONAL, "Authenticator"));
// process the contents
// we do this by section - keep the original section order
Element body = cda.getDescendent(doc, "component/structuredBody");
processComponentSections(composition.getSection(), body);
return feed;
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processAdverseReactionsSection.
protected SectionComponent processAdverseReactionsSection(Element section) throws Exception {
ListResource list = new ListResource();
for (Element entry : cda.getChildren(section, "entry")) {
Element concern = cda.getChild(entry, "act");
if (cda.hasTemplateId(concern, "2.16.840.1.113883.10.20.22.4.30")) {
processAllergyProblemAct(list, concern);
} else
throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(concern));
}
// todo: text
SectionComponent s = new Composition.SectionComponent();
s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
// todo: check subject
s.addEntry(Factory.makeReference(addReference(list, "Allergies, Adverse Reactions, Alerts", makeUUIDReference())));
return s;
}
use of org.hl7.fhir.utilities.turtle.Turtle.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)" : ""));
}
}
for (ElementDefinition child : children) {
String name = tail(child.getPath());
generateForChildren(sch, xpath + "/f:" + name, child, structure, base);
}
}
use of org.hl7.fhir.utilities.turtle.Turtle.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) {
// "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 ("Reference".equals(element.getType()))
decorateReference(t, element);
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);
}
}
Aggregations