Package ca.uhn.fhir.util
Class TerserUtilHelper
java.lang.Object
ca.uhn.fhir.util.TerserUtilHelper
Wrapper class holding context-related instances, and the resource being operated on. Sample use case is
TerserUtilHelper helper = TerserUtilHelper.newHelper(ourFhirContext, "Patient");
helper.setField("identifier.system", "http://org.com/sys");
helper.setField("identifier.value", "123");
...
Patient patient = helper.getResource();
-
Constructor Summary
ModifierConstructorDescriptionprotected
TerserUtilHelper
(FhirContext theFhirContext, IBaseResource theResource) -
Method Summary
Modifier and TypeMethodDescriptionGets context holding resource definition.getFieldValue
(String theField) Gets first available values of the specified field.getFieldValueByFhirPath
(String theFhirPath) Gets first available value for the specified field values by FHIRPath.getFieldValues
(String theField) Gets values for the specified child field.getFieldValuesByFhirPath
(String theFhirPath) Gets values for the specified field values by FHIRPath.<T extends IBaseResource>
TGets resource that this helper operates onGets runtime definition for the resourceGets the terser instance, creating one if necessary.newElement
(String theElementName) Creates a new elementprotected IBase
newElement
(String theElementType, Object theValue) static TerserUtilHelper
newHelper
(FhirContext theFhirContext, String theResourceName) Factory method for creating a new instance of the wrapperstatic TerserUtilHelper
newHelper
(FhirContext theFhirContext, IBaseResource theResource) Factory method for creating a new instance of the wrapperprotected IBase
newStringElement
(String theValue) Sets string field at the specified FHIR pathSets field at the specified FHIR path
-
Constructor Details
-
TerserUtilHelper
-
-
Method Details
-
newHelper
Factory method for creating a new instance of the wrapper- Parameters:
theFhirContext
- FHIR Context to be used for all further operationstheResourceName
- Name of the resource type- Returns:
- Returns a new helper instance
-
newHelper
Factory method for creating a new instance of the wrapper- Parameters:
theFhirContext
- FHIR Context to be used for all further operationstheResource
- The resource to operate on- Returns:
- Returns a new helper instance
-
setField
Sets string field at the specified FHIR path- Parameters:
theField
- The FHIR Path to set the values attheValue
- The string value to be set- Returns:
- Returns current instance
-
setField
Sets field at the specified FHIR path- Parameters:
theField
- The FHIR Path to set the values attheValue
- The value to be set- Returns:
- Returns current instance
-
newStringElement
-
newElement
-
getFieldValues
Gets values for the specified child field.- Parameters:
theField
- The field to get values from- Returns:
- Returns a list of retrieved values or null if the specified field doesn't exist
-
getFieldValuesByFhirPath
Gets values for the specified field values by FHIRPath.- Parameters:
theFhirPath
- The FHIR path expression to get the values from- Returns:
- Returns a collection of values or null if the specified field doesn't exist
-
getFieldValueByFhirPath
Gets first available value for the specified field values by FHIRPath.- Parameters:
theFhirPath
- The FHIR path expression to get the values from- Returns:
- Returns the value or null if the specified field doesn't exist or is empty
-
getFieldValue
Gets first available values of the specified field.- Parameters:
theField
- The field to get values from- Returns:
- Returns the first available value for the field name or null if the specified field doesn't exist or has no values
-
getTerser
Gets the terser instance, creating one if necessary.- Returns:
- Returns the terser
-
getResource
Gets resource that this helper operates on- Type Parameters:
T
- Instance type of the resource- Returns:
- Returns the resources
-
getResourceDefinition
Gets runtime definition for the resource- Returns:
- Returns resource definition.
-
newElement
Creates a new element- Parameters:
theElementName
- Name of the element to create- Returns:
- Returns a new element
-
getContext
Gets context holding resource definition.- Returns:
- Returns the current FHIR context.
-