more fixing rendering

This commit is contained in:
Grahame Grieve 2024-03-18 14:35:59 +11:00
parent c221488463
commit 413c047b56
4 changed files with 25 additions and 0 deletions

View File

@ -62,6 +62,7 @@ public class BaseWrappers {
public interface BaseWrapper extends WrapperBase {
public Base getBase() throws UnsupportedEncodingException, IOException, FHIRException;
public ResourceWrapper getResource() throws UnsupportedEncodingException, IOException, FHIRException; // for contained, etc
public PropertyWrapper getChildByName(String tail);
public String fhirType();
}

View File

@ -102,6 +102,19 @@ public class DOMWrappers {
return type;
}
@Override
public ResourceWrapper getResource() throws UnsupportedEncodingException, IOException, FHIRException {
Element r = XMLUtil.getFirstChild(element);
StructureDefinition sd = getContext().getContext().fetchTypeDefinition(r.getLocalName());
if (sd == null) {
throw new FHIRException("Unable to find definition for type "+type+" @ "+definition.getPath());
}
if (sd.getKind() != StructureDefinitionKind.RESOURCE) {
throw new FHIRException("Definition for type "+type+" is not for a resource @ "+definition.getPath());
}
return new ResourceWrapperElement(context, r, sd);
}
}
public static class PropertyWrapperElement extends RendererWrapperImpl implements PropertyWrapper {

View File

@ -5,6 +5,7 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.DomainResource;
@ -164,6 +165,11 @@ public class DirectWrappers {
return wrapped.fhirType();
}
@Override
public ResourceWrapper getResource() throws UnsupportedEncodingException, IOException, FHIRException {
return new DirectWrappers.ResourceWrapperDirect(getContext(), (Resource) wrapped);
}
}
public static class ResourceWrapperDirect extends WrapperBaseImpl implements ResourceWrapper {

View File

@ -109,6 +109,11 @@ public class ElementWrappers {
return element.fhirType();
}
@Override
public ResourceWrapper getResource() throws UnsupportedEncodingException, IOException, FHIRException {
return new ElementWrappers.ResourceWrapperMetaElement(getContext(), element);
}
}
public static class ResourceWrapperMetaElement extends WrapperBaseImpl implements ResourceWrapper {