Class ParserOptions
parser
instances
created by a given FhirContext
. It is accessed using FhirContext.getParserOptions()
and FhirContext.setParserOptions(ParserOptions)
.
It is fine to share a ParserOptions instances across multiple context instances.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the value supplied toIParser.setDontStripVersionsFromReferencesAtPaths(String...)
boolean
If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly inIBaseReference.setReference(String)
and the parser will automatically locate it and insert it intoResource.contained
when serializing.boolean
If set totrue
(which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined.boolean
If set totrue
(which is the default), resource references containing a version will have the version removed when the resource is encoded.
void
setAutoContainReferenceTargetsWithNoId
(boolean theAllowAutoContainedReferences) If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly inIBaseReference.setReference(String)
and the parser will automatically locate it and insert it intoResource.contained
when serializing.setDontEncodeElementsForSummaryMode
(String... theEncodeElements) This option specifies one or more elements that should be excluded when the parser is encoding a resource insummary mode
, even if the element is a part of the base FHIR specification's list of summary elements.setDontEncodeElementsForSummaryMode
(Collection<String> theDontEncodeElements) This option specifies one or more elements that should be excluded when the parser is encoding a resource insummary mode
, even if the element is a part of the base FHIR specification's list of summary elements.setDontStripVersionsFromReferencesAtPaths
(String... thePaths) If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process.If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process.setEncodeElementsForSummaryMode
(String... theEncodeElements) This option specifies one or more elements that should be included when the parser is encoding a resource insummary mode
, even if the element is not a part of the base FHIR specification's list of summary elements.setEncodeElementsForSummaryMode
(Collection<String> theEncodeElements) This option specifies one or more elements that should be included when the parser is encoding a resource insummary mode
, even if the element is not a part of the base FHIR specification's list of summary elements.setOverrideResourceIdWithBundleEntryFullUrl
(boolean theOverrideResourceIdWithBundleEntryFullUrl) If set totrue
(which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined.setStripVersionsFromReferences
(boolean theStripVersionsFromReferences) If set totrue
(which is the default), resource references containing a version will have the version removed when the resource is encoded.
-
Constructor Details
-
ParserOptions
public ParserOptions()
-
-
Method Details
-
isAutoContainReferenceTargetsWithNoId
If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly inIBaseReference.setReference(String)
and the parser will automatically locate it and insert it intoResource.contained
when serializing. This is convenient, but also imposes a performance cost when serializing large numbers of resources, so this can be disabled if it is not needed.If disabled, only resources that are directly placed in
Resource.contained
will be serialized.- Since:
- 5.7.0
-
setAutoContainReferenceTargetsWithNoId
If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly inIBaseReference.setReference(String)
and the parser will automatically locate it and insert it intoResource.contained
when serializing. This is convenient, but also imposes a performance cost when serializing large numbers of resources, so this can be disabled if it is not needed.If disabled, only resources that are directly placed in
Resource.contained
will be serialized.- Since:
- 5.7.0
-
isStripVersionsFromReferences
If set totrue
(which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situations, references from one resource to another should be to the resource by ID, not by ID and version. In some cases though, it may be desirable to preserve the version in resource links. In that case, this value should be set to
false
.- Returns:
- Returns the parser instance's configuration setting for stripping versions from resource references when
encoding. Default is
true
.
-
setStripVersionsFromReferences
If set totrue
(which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situations, references from one resource to another should be to the resource by ID, not by ID and version. In some cases though, it may be desirable to preserve the version in resource links. In that case, this value should be set to
false
.This method provides the ability to globally disable reference encoding. If finer-grained control is needed, use
setDontStripVersionsFromReferencesAtPaths(String...)
- Parameters:
theStripVersionsFromReferences
- Set this tofalse
to prevent the parser from removing resource versions from references.
- Returns:
- Returns a reference to
this
parser so that method calls can be chained together - See Also:
-
getDontStripVersionsFromReferencesAtPaths
Returns the value supplied toIParser.setDontStripVersionsFromReferencesAtPaths(String...)
-
setDontStripVersionsFromReferencesAtPaths
If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has no effect on the parsing process.This method provides a finer-grained level of control than
setStripVersionsFromReferences(boolean)
and any paths specified by this method will be encoded even ifsetStripVersionsFromReferences(boolean)
has been set totrue
(which is the default)- Parameters:
thePaths
- A collection of paths for which the resource versions will not be removed automatically when serializing, e.g. "Patient.managingOrganization" or "AuditEvent.object.reference". Note that only resource name and field names with dots separating is allowed here (no repetition indicators, FluentPath expressions, etc.)- Returns:
- Returns a reference to
this
parser so that method calls can be chained together - See Also:
-
setDontStripVersionsFromReferencesAtPaths
If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has no effect on the parsing process.This method provides a finer-grained level of control than
setStripVersionsFromReferences(boolean)
and any paths specified by this method will be encoded even ifsetStripVersionsFromReferences(boolean)
has been set totrue
(which is the default)- Parameters:
thePaths
- A collection of paths for which the resource versions will not be removed automatically when serializing, e.g. "Patient.managingOrganization" or "AuditEvent.object.reference". Note that only resource name and field names with dots separating is allowed here (no repetition indicators, FluentPath expressions, etc.)- Returns:
- Returns a reference to
this
parser so that method calls can be chained together - See Also:
-
isOverrideResourceIdWithBundleEntryFullUrl
If set totrue
(which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this tofalse
if this is not the desired behavior (e.g. the client code wishes to perform additional validation checks between the fullUrl and the resource id).- Returns:
- Returns the parser instance's configuration setting for overriding resource ids with Bundle.entry.fullUrl when
parsing the source data into a Bundle object. Default is
true
.
-
setOverrideResourceIdWithBundleEntryFullUrl
public ParserOptions setOverrideResourceIdWithBundleEntryFullUrl(boolean theOverrideResourceIdWithBundleEntryFullUrl) If set totrue
(which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this tofalse
if this is not the desired behavior (e.g. the client code wishes to perform additional validation checks between the fullUrl and the resource id).- Parameters:
theOverrideResourceIdWithBundleEntryFullUrl
- Set this tofalse
to prevent the parser from overriding resource ids with the Bundle.entry.fullUrl- Returns:
- Returns a reference to
this
parser so that method calls can be chained together
-
setEncodeElementsForSummaryMode
This option specifies one or more elements that should be included when the parser is encoding a resource insummary mode
, even if the element is not a part of the base FHIR specification's list of summary elements. Examples of valid values include:- Patient.maritalStatus - Encode the entire maritalStatus CodeableConcept, even though Patient.maritalStatus is not a summary element
- Patient.maritalStatus.text - Encode only the text component of the patient's maritalStatus
- *.text - Encode the text element on any resource (only the very first position may contain a wildcard)
-
setEncodeElementsForSummaryMode
@Nonnull public ParserOptions setEncodeElementsForSummaryMode(@Nullable Collection<String> theEncodeElements) This option specifies one or more elements that should be included when the parser is encoding a resource insummary mode
, even if the element is not a part of the base FHIR specification's list of summary elements. Examples of valid values include:- Patient.maritalStatus - Encode the entire maritalStatus CodeableConcept, even though Patient.maritalStatus is not a summary element
- Patient.maritalStatus.text - Encode only the text component of the patient's maritalStatus
- *.text - Encode the text element on any resource (only the very first position may contain a wildcard)
-
getEncodeElementsForSummaryMode
- Returns:
- Returns the values provided to
setEncodeElementsForSummaryMode(Collection)
ornull
- Since:
- 7.4.0
-
setDontEncodeElementsForSummaryMode
@Nonnull public ParserOptions setDontEncodeElementsForSummaryMode(@Nonnull String... theEncodeElements) This option specifies one or more elements that should be excluded when the parser is encoding a resource insummary mode
, even if the element is a part of the base FHIR specification's list of summary elements. Examples of valid values include:- Patient.name - Do not include the patient's name
- Patient.name.family - Do not include the patient's family name
- *.name - Do not include the name element on any resource type
-
setDontEncodeElementsForSummaryMode
@Nonnull public ParserOptions setDontEncodeElementsForSummaryMode(@Nullable Collection<String> theDontEncodeElements) This option specifies one or more elements that should be excluded when the parser is encoding a resource insummary mode
, even if the element is a part of the base FHIR specification's list of summary elements. Examples of valid values include:- Patient.name - Do not include the patient's name
- Patient.name.family - Do not include the patient's family name
- *.name - Do not include the name element on any resource type
-
getDontEncodeElementsForSummaryMode
- Returns:
- Returns the values provided to
setDontEncodeElementsForSummaryMode(Collection)
ornull
- Since:
- 7.4.0
-