Search in sources :

Example 1 with ResourceWrapperDirect

use of org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method renderCanonical.

public void renderCanonical(Resource res, XhtmlNode x, String url) throws UnsupportedEncodingException, IOException {
    ResourceWrapper rw = new ResourceWrapperDirect(this.context, res);
    renderCanonical(rw, x, url);
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper) ResourceWrapperDirect(org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect)

Example 2 with ResourceWrapperDirect

use of org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method renderReference.

public void renderReference(Resource res, XhtmlNode x, Reference r) throws UnsupportedEncodingException, IOException {
    ResourceWrapper rw = new ResourceWrapperDirect(this.context, res);
    renderReference(rw, x, r);
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper) ResourceWrapperDirect(org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect)

Example 3 with ResourceWrapperDirect

use of org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect 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;
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) ResourceWrapperMetaElement(org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement) Element(org.hl7.fhir.r5.elementmodel.Element) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) DomainResource(org.hl7.fhir.r5.model.DomainResource) Resource(org.hl7.fhir.r5.model.Resource) ResourceWithReference(org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference) ResourceWrapperDirect(org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect) Element(org.hl7.fhir.r5.elementmodel.Element) ResourceWrapperMetaElement(org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement)

Example 4 with ResourceWrapperDirect

use of org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method renderReference.

public void renderReference(Resource res, XhtmlNode x, Reference r) throws UnsupportedEncodingException, IOException {
    ResourceWrapper rw = new ResourceWrapperDirect(this.context, res);
    renderReference(rw, x, r);
}
Also used : ResourceWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper) ResourceWrapperDirect(org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect)

Example 5 with ResourceWrapperDirect

use of org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect 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;
}
Also used : ResourceWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper) Element(org.hl7.fhir.r4b.elementmodel.Element) BundleEntryComponent(org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent) Element(org.hl7.fhir.r4b.elementmodel.Element) ResourceWrapperMetaElement(org.hl7.fhir.r4b.renderers.utils.ElementWrappers.ResourceWrapperMetaElement) CanonicalResource(org.hl7.fhir.r4b.model.CanonicalResource) Resource(org.hl7.fhir.r4b.model.Resource) DomainResource(org.hl7.fhir.r4b.model.DomainResource) ResourceWithReference(org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceWithReference) ResourceWrapperDirect(org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect) ResourceWrapperMetaElement(org.hl7.fhir.r4b.renderers.utils.ElementWrappers.ResourceWrapperMetaElement)

Aggregations

ResourceWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper)3 ResourceWrapperDirect (org.hl7.fhir.r4b.renderers.utils.DirectWrappers.ResourceWrapperDirect)3 ResourceWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper)3 ResourceWrapperDirect (org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect)3 Element (org.hl7.fhir.r4b.elementmodel.Element)1 BundleEntryComponent (org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent)1 CanonicalResource (org.hl7.fhir.r4b.model.CanonicalResource)1 DomainResource (org.hl7.fhir.r4b.model.DomainResource)1 Resource (org.hl7.fhir.r4b.model.Resource)1 ResourceWrapperMetaElement (org.hl7.fhir.r4b.renderers.utils.ElementWrappers.ResourceWrapperMetaElement)1 ResourceWithReference (org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceWithReference)1 Element (org.hl7.fhir.r5.elementmodel.Element)1 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)1 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)1 DomainResource (org.hl7.fhir.r5.model.DomainResource)1 Resource (org.hl7.fhir.r5.model.Resource)1 ResourceWrapperMetaElement (org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement)1 ResourceWithReference (org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference)1