public class FhirTerser extends Object
| Constructor and Description |
|---|
FhirTerser(FhirContext theContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear(IBaseResource theInput)
Clear all content on a resource
|
IBase |
cloneInto(IBase theSource,
IBase theTarget,
boolean theIgnoreMissingFields)
Clones all values from a source object into the equivalent fields in a target object
|
Collection<IBaseResource> |
getAllEmbeddedResources(IBaseResource theResource,
boolean theRecurse)
Returns all embedded resources that are found embedded within
theResource. |
<T extends IBase> |
getAllPopulatedChildElementsOfType(IBaseResource theResource,
Class<T> theType)
Returns a list containing all child elements (including the resource itself) which are non-empty and are either of the exact type specified, or are a subclass of that type.
|
List<ResourceReferenceInfo> |
getAllResourceReferences(IBaseResource theResource) |
BaseRuntimeChildDefinition |
getDefinition(Class<? extends IBaseResource> theResourceType,
String thePath) |
Object |
getSingleValueOrNull(IBase theTarget,
String thePath) |
<T> T |
getSingleValueOrNull(IBase theTarget,
String thePath,
Class<T> theWantedType) |
List<Object> |
getValues(IBaseResource theResource,
String thePath)
Returns values stored in an element identified by its path.
|
List<Object> |
getValues(IBaseResource theResource,
String thePath,
boolean theCreate)
Returns values stored in an element identified by its path.
|
List<Object> |
getValues(IBaseResource theResource,
String thePath,
boolean theCreate,
boolean theAddExtension)
Returns values stored in an element identified by its path.
|
<T> List<T> |
getValues(IBaseResource theResource,
String thePath,
Class<T> theWantedClass)
Returns values stored in an element identified by its path.
|
<T> List<T> |
getValues(IBaseResource theResource,
String thePath,
Class<T> theWantedClass,
boolean theCreate)
Returns values stored in an element identified by its path.
|
<T> List<T> |
getValues(IBaseResource theResource,
String thePath,
Class<T> theWantedClass,
boolean theCreate,
boolean theAddExtension)
Returns values stored in an element identified by its path.
|
boolean |
isSourceInCompartmentForTarget(String theCompartmentName,
IBaseResource theSource,
IIdType theTarget)
Returns
true if theSource is in the compartment named theCompartmentName
belonging to resource theTarget |
void |
visit(IBaseResource theResource,
IModelVisitor theVisitor)
Visit all elements in a given resource
|
void |
visit(IBaseResource theResource,
IModelVisitor2 theVisitor)
Visit all elements in a given resource
|
public FhirTerser(FhirContext theContext)
public IBase cloneInto(IBase theSource, IBase theTarget, boolean theIgnoreMissingFields)
theSource - The source object (must not be null)theTarget - The target object to copy values into (must not be null)theIgnoreMissingFields - The ignore fields in the target which do not exist (if false, an exception will be thrown if the target is unable to accept a value from the source)public <T extends IBase> List<T> getAllPopulatedChildElementsOfType(IBaseResource theResource, Class<T> theType)
For example, specifying a type of StringDt would return all non-empty string instances within the message. Specifying a type of IResource would return the resource itself, as
well as any contained resources.
Note on scope: This method will descend into any contained resources (IResource.getContained()) as well, but will not descend into linked resources (e.g.
BaseResourceReferenceDt.getResource()) or embedded resources (e.g. Bundle.entry.resource)
theResource - The resource instance to search. Must not be null.theType - The type to search for. Must not be null.public List<ResourceReferenceInfo> getAllResourceReferences(IBaseResource theResource)
public BaseRuntimeChildDefinition getDefinition(Class<? extends IBaseResource> theResourceType, String thePath)
public Object getSingleValueOrNull(IBase theTarget, String thePath)
public <T> T getSingleValueOrNull(IBase theTarget, String thePath, Class<T> theWantedType)
public List<Object> getValues(IBaseResource theResource, String thePath)
Object.theResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.Object.public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate)
Object.theResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.theCreate - When set to true, the terser will create a null-valued element where none exists.Object.public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate, boolean theAddExtension)
Object.theResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.theCreate - When set to true, the terser will create a null-valued element where none exists.theAddExtension - When set to true, the terser will add a null-valued extension where one or more such extensions already exist.Object.public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass)
theWantedClass.T - Type declared by theWantedClasstheResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.theWantedClass - The desired class to be returned in a list.theWantedClass.public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate)
theWantedClass.T - Type declared by theWantedClasstheResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.theWantedClass - The desired class to be returned in a list.theCreate - When set to true, the terser will create a null-valued element where none exists.theWantedClass.public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate, boolean theAddExtension)
theWantedClass.T - Type declared by theWantedClasstheResource - The resource instance to be accessed. Must not be null.thePath - The path for the element to be accessed.theWantedClass - The desired class to be returned in a list.theCreate - When set to true, the terser will create a null-valued element where none exists.theAddExtension - When set to true, the terser will add a null-valued extension where one or more such extensions already exist.theWantedClass.public boolean isSourceInCompartmentForTarget(String theCompartmentName, IBaseResource theSource, IIdType theTarget)
true if theSource is in the compartment named theCompartmentName
belonging to resource theTargettheCompartmentName - The name of the compartmenttheSource - The potential member of the compartmenttheTarget - The owner of the compartment. Note that both the resource type and ID must be filled in on this IIdType or the method will throw an IllegalArgumentExceptiontrue if theSource is in the compartmentIllegalArgumentException - If theTarget does not contain both a resource type and IDpublic void visit(IBaseResource theResource, IModelVisitor theVisitor)
Note on scope: This method will descend into any contained resources (IResource.getContained()) as well, but will not descend into linked resources (e.g.
BaseResourceReferenceDt.getResource()) or embedded resources (e.g. Bundle.entry.resource)
theResource - The resource to visittheVisitor - The visitorpublic void visit(IBaseResource theResource, IModelVisitor2 theVisitor)
THIS ALTERNATE METHOD IS STILL EXPERIMENTAL! USE WITH CAUTION
Note on scope: This method will descend into any contained resources (IResource.getContained()) as well, but will not descend into linked resources (e.g.
BaseResourceReferenceDt.getResource()) or embedded resources (e.g. Bundle.entry.resource)
theResource - The resource to visittheVisitor - The visitorpublic Collection<IBaseResource> getAllEmbeddedResources(IBaseResource theResource, boolean theRecurse)
theResource.
An embedded resource is a resource that can be found as a direct child within a resource,
as opposed to being referenced by the resource.
Examples include resources found within Bundle.entry.resource
and Parameters.parameter.resource, as well as contained resources
found within Resource.contained
theRecurse - Should embedded resources be recursively scanned for further embedded
resourcespublic void clear(IBaseResource theInput)
Copyright © 2014–2019 University Health Network. All rights reserved.