Class ParserOptions

java.lang.Object
ca.uhn.fhir.context.ParserOptions

public class ParserOptions extends Object
This object supplies default configuration to all 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 Details

  • Method Details

    • isAutoContainReferenceTargetsWithNoId

      If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly in IBaseReference.setReference(String) and the parser will automatically locate it and insert it into Resource.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

      public void setAutoContainReferenceTargetsWithNoId(boolean theAllowAutoContainedReferences)
      If set to true (which is the default), contained resources may be specified by populating the target (contained) resource directly in IBaseReference.setReference(String) and the parser will automatically locate it and insert it into Resource.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 to true (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

      public ParserOptions setStripVersionsFromReferences(boolean theStripVersionsFromReferences)
      If set to true (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 to false 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

      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 if setStripVersionsFromReferences(boolean) has been set to true (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 if setStripVersionsFromReferences(boolean) has been set to true (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 to true (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 to false 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 to true (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 to false 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 to false 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

      @Nonnull public ParserOptions setEncodeElementsForSummaryMode(@Nonnull String... theEncodeElements)
      This option specifies one or more elements that should be included when the parser is encoding a resource in summary 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)
      Since:
      7.4.0
      See Also:
    • 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 in summary 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)
      Since:
      7.4.0
      See Also:
    • getEncodeElementsForSummaryMode

      Returns:
      Returns the values provided to setEncodeElementsForSummaryMode(Collection) or null
      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 in summary 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
      Since:
      7.4.0
      See Also:
    • 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 in summary 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
      Since:
      7.4.0
      See Also:
    • getDontEncodeElementsForSummaryMode

      Returns:
      Returns the values provided to setDontEncodeElementsForSummaryMode(Collection) or null
      Since:
      7.4.0