Package com.ibm.fhir.search.util
Class ReferenceUtil
- java.lang.Object
- 
- com.ibm.fhir.search.util.ReferenceUtil
 
- 
 public class ReferenceUtil extends java.lang.ObjectEncapsulates utility functions used when processing model Reference elements from a FHIR resource
- 
- 
Constructor SummaryConstructors Constructor Description ReferenceUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static ReferenceValuecreateReferenceValueFrom(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.0static ReferenceValuecreateReferenceValueFrom(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.0static java.lang.StringgetBaseUrl(Bundle.Entry entry)Extract the base URL from the bundle entry if one is given, otherwise use the service base URL.static java.lang.StringgetBaseUrlFromBundle(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.StringgetServiceBaseUrl()Get the service base URL using the originalRequestUri currently set in the FHIRRequestContextstatic java.lang.StringgetServiceBaseUrl(java.lang.String uri)Get the service base URL from the given uri
 
- 
- 
- 
Method Detail- 
createReferenceValueFrompublic 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.0Absolute 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: - LITERAL_RELATIVE: the id of the referenced resource
- LITERAL_ABSOLUTE: the full URI of the reference
- LOGICAL: the Identifier.value (Identifier.system is not presently stored)
- DISPLAY_ONLY: null
- 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
 
 - 
createReferenceValueFrompublic 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.0Absolute 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: - LITERAL_RELATIVE: the id of the referenced resource
- LITERAL_ABSOLUTE: the full URI of the reference
- 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
 
 - 
getBaseUrlpublic 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
 
 - 
getBaseUrlFromBundlepublic 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
 
 - 
getServiceBaseUrlpublic static java.lang.String getServiceBaseUrl() throws FHIRSearchExceptionGet the service base URL using the originalRequestUri currently set in the FHIRRequestContext- Parameters:
- bundle-
- Returns:
- the base url
- Throws:
- FHIRSearchException
 
 - 
getServiceBaseUrlpublic static java.lang.String getServiceBaseUrl(java.lang.String uri) throws FHIRSearchExceptionGet the service base URL from the given uri- Parameters:
- uri-
- Returns:
- Throws:
- FHIRSearchException
 
 
- 
 
-