Class ReferenceUtil


  • public class ReferenceUtil
    extends java.lang.Object
    Encapsulates utility functions used when processing model Reference elements from a FHIR resource
    • Constructor Summary

      Constructors 
      Constructor Description
      ReferenceUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ReferenceValue createReferenceValueFrom​(Reference ref, java.lang.String baseUrl)
      Processes a Reference value from the FHIR model and interprets it according to https://www.hl7.org/fhir/references.html#2.3.0
      static ReferenceValue createReferenceValueFrom​(java.lang.String refValue, java.lang.String refType, java.lang.String baseUrl)
      Processes the string value of a Reference object from the FHIR model and interprets it according to https://www.hl7.org/fhir/references.html#2.3.0
      static java.lang.String getBaseUrl​(Bundle.Entry entry)
      Extract the base URL from the bundle entry if one is given, otherwise use the service base URL.
      static java.lang.String getBaseUrlFromBundle​(Bundle.Entry entry)
      https://www.hl7.org/fhir/references.html#literal See: a relative URL, which is relative to the Service Base URL, or, if processing a resource from a bundle, which is relative to the base URL implied by the Bundle.entry.fullUrl (see Resolving References in Bundles) If the fullUrl looks like this "fullUrl": "https://localhost:9443/fhir-server/api/v4/Observation/17546b5a5a9-872ecfe4-cb5e-4f8c-a381-5b13df536f87" then the returned String will look like this: "https://localhost:9443/fhir-server/api/v4/"
      static java.lang.String getServiceBaseUrl()
      Get the service base URL using the originalRequestUri currently set in the FHIRRequestContext
      static java.lang.String getServiceBaseUrl​(java.lang.String uri)
      Get the service base URL from the given uri
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReferenceUtil

        public ReferenceUtil()
    • Method Detail

      • createReferenceValueFrom

        public static ReferenceValue createReferenceValueFrom​(Reference ref,
                                                              java.lang.String baseUrl)
        Processes a Reference value from the FHIR model and interprets it according to https://www.hl7.org/fhir/references.html#2.3.0

        Absolute literal references will be converted to relative references if their base matches baseUrl.

        The resulting ReferenceValue will contained an inferred ReferenceType and the structure of the ReferenceValue.value will vary accordingly:

        1. LITERAL_RELATIVE: the id of the referenced resource
        2. LITERAL_ABSOLUTE: the full URI of the reference
        3. LOGICAL: the Identifier.value (Identifier.system is not presently stored)
        4. DISPLAY_ONLY: null
        5. INVALID: null
        Parameters:
        ref - a non-null FHIR Reference object
        baseUrl - the base URL used to determine whether to convert absolute references to relative references
        Returns:
        a structured representation of the reference value that varies by its inferred reference type
      • createReferenceValueFrom

        public static ReferenceValue createReferenceValueFrom​(java.lang.String refValue,
                                                              java.lang.String refType,
                                                              java.lang.String baseUrl)
        Processes the string value of a Reference object from the FHIR model and interprets it according to https://www.hl7.org/fhir/references.html#2.3.0

        Absolute literal references will be converted to relative references if their base matches baseUrl.

        The resulting ReferenceValue will contain an inferred ReferenceType and the structure of the ReferenceValue.value will vary accordingly:

        1. LITERAL_RELATIVE: the id of the referenced resource
        2. LITERAL_ABSOLUTE: the full URI of the reference
        3. INVALID: null
        Parameters:
        refValue - a reference value string
        refType - a reference resource type (used for LITERAL_ABSOLUTE only)
        baseUrl - the base URL used to determine whether to convert absolute references to relative references
        Returns:
        a structured representation of the reference value that varies by its inferred reference type
      • getBaseUrl

        public static java.lang.String getBaseUrl​(Bundle.Entry entry)
                                           throws FHIRSearchException
        Extract the base URL from the bundle entry if one is given, otherwise use the service base URL.
        Parameters:
        entry - , can be null
        Returns:
        the base URL for use in interpreting references
        Throws:
        FHIRSearchException
      • getBaseUrlFromBundle

        public static java.lang.String getBaseUrlFromBundle​(Bundle.Entry entry)
                                                     throws FHIRSearchException
        https://www.hl7.org/fhir/references.html#literal See: a relative URL, which is relative to the Service Base URL, or, if processing a resource from a bundle, which is relative to the base URL implied by the Bundle.entry.fullUrl (see Resolving References in Bundles) If the fullUrl looks like this "fullUrl": "https://localhost:9443/fhir-server/api/v4/Observation/17546b5a5a9-872ecfe4-cb5e-4f8c-a381-5b13df536f87" then the returned String will look like this: "https://localhost:9443/fhir-server/api/v4/"
        Parameters:
        entry -
        Returns:
        Throws:
        FHIRSearchException
      • getServiceBaseUrl

        public static java.lang.String getServiceBaseUrl()
                                                  throws FHIRSearchException
        Get the service base URL using the originalRequestUri currently set in the FHIRRequestContext
        Parameters:
        bundle -
        Returns:
        the base url
        Throws:
        FHIRSearchException
      • getServiceBaseUrl

        public static java.lang.String getServiceBaseUrl​(java.lang.String uri)
                                                  throws FHIRSearchException
        Get the service base URL from the given uri
        Parameters:
        uri -
        Returns:
        Throws:
        FHIRSearchException