use of org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public String generate(ResourceContext rcontext, org.hl7.fhir.r4.elementmodel.Element er, boolean showCodeDetails, ITypeParser parser) throws IOException, FHIRException {
if (rcontext == null)
rcontext = new ResourceContext(null, er);
this.parser = parser;
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.para().b().tx("Generated Narrative" + (showCodeDetails ? " with Details" : ""));
try {
ResourceWrapperMetaElement resw = new ResourceWrapperMetaElement(er);
BaseWrapperMetaElement base = new BaseWrapperMetaElement(er, null, er.getProperty().getStructure(), er.getProperty().getDefinition());
base.children();
generateByProfile(resw, er.getProperty().getStructure(), base, er.getProperty().getStructure().getSnapshot().getElement(), er.getProperty().getDefinition(), base.children, x, er.fhirType(), showCodeDetails, 0, rcontext);
} catch (Exception e) {
e.printStackTrace();
x.para().b().setAttribute("style", "color: maroon").tx("Exception generating Narrative: " + e.getMessage());
}
inject(er, x, NarrativeStatus.GENERATED);
return new XhtmlComposer(XhtmlComposer.XML, pretty).compose(x);
}
use of org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method resolveReference.
protected ResourceWithReference resolveReference(ResourceWrapper res, String url) {
if (url == null)
return null;
if (url.startsWith("#") && res != null) {
for (ResourceWrapper r : res.getContained()) {
if (r.getId().equals(url.substring(1)))
return new ResourceWithReference(null, r);
}
return null;
}
String version = null;
if (url.contains("/_history/")) {
version = url.substring(url.indexOf("/_history/") + 10);
url = url.substring(0, url.indexOf("/_history/"));
}
if (rcontext != null) {
BundleEntryComponent bundleResource = rcontext.resolve(url);
if (bundleResource != null) {
String bundleUrl = "#" + bundleResource.getResource().getResourceType().name() + "_" + bundleResource.getResource().getId();
return new ResourceWithReference(bundleUrl, new ResourceWrapperDirect(this.context, bundleResource.getResource()));
}
org.hl7.fhir.r5.elementmodel.Element bundleElement = rcontext.resolveElement(url, version);
if (bundleElement != null) {
String bundleUrl = null;
Element br = bundleElement.getNamedChild("resource");
if (br.getChildValue("id") != null) {
bundleUrl = "#" + br.fhirType() + "_" + br.getChildValue("id");
} else {
bundleUrl = "#" + fullUrlToAnchor(bundleElement.getChildValue("fullUrl"));
}
return new ResourceWithReference(bundleUrl, new ResourceWrapperMetaElement(this.context, br));
}
}
Resource ae = getContext().getWorker().fetchResource(null, url, version);
if (ae != null)
return new ResourceWithReference(url, new ResourceWrapperDirect(this.context, ae));
else if (context.getResolver() != null) {
return context.getResolver().resolve(context, url);
} else
return null;
}
use of org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement in project org.hl7.fhir.core by hapifhir.
the class ResourceRenderer method resolveReference.
protected ResourceWithReference resolveReference(ResourceWrapper res, String url) {
if (url == null)
return null;
if (url.startsWith("#") && res != null) {
for (ResourceWrapper r : res.getContained()) {
if (r.getId().equals(url.substring(1)))
return new ResourceWithReference(null, r);
}
return null;
}
String version = null;
if (url.contains("/_history/")) {
version = url.substring(url.indexOf("/_history/") + 10);
url = url.substring(0, url.indexOf("/_history/"));
}
if (rcontext != null) {
BundleEntryComponent bundleResource = rcontext.resolve(url);
if (bundleResource != null) {
String bundleUrl = "#" + bundleResource.getResource().getResourceType().name() + "_" + bundleResource.getResource().getId();
return new ResourceWithReference(bundleUrl, new ResourceWrapperDirect(this.context, bundleResource.getResource()));
}
org.hl7.fhir.r4b.elementmodel.Element bundleElement = rcontext.resolveElement(url, version);
if (bundleElement != null) {
String bundleUrl = null;
Element br = bundleElement.getNamedChild("resource");
if (br.getChildValue("id") != null) {
bundleUrl = "#" + br.fhirType() + "_" + br.getChildValue("id");
} else {
bundleUrl = "#" + fullUrlToAnchor(bundleElement.getChildValue("fullUrl"));
}
return new ResourceWithReference(bundleUrl, new ResourceWrapperMetaElement(this.context, br));
}
}
Resource ae = getContext().getWorker().fetchResource(null, url, version);
if (ae != null)
return new ResourceWithReference(url, new ResourceWrapperDirect(this.context, ae));
else if (context.getResolver() != null) {
return context.getResolver().resolve(context, url);
} else
return null;
}
Aggregations