Package com.ibm.fhir.search.util
Class ReferenceUtil
- java.lang.Object
-
- com.ibm.fhir.search.util.ReferenceUtil
-
public class ReferenceUtil extends 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, 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 String
getBaseUrl(Bundle.Entry entry)
Extract the base URL from the bundle entry if one is given, otherwise use the service base URL.static 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 String
getServiceBaseUrl()
Get the service base URL using the originalRequestUri currently set in the FHIRRequestContextstatic String
getServiceBaseUrl(String uri)
Get the service base URL from the given uri
-
-
-
Method Detail
-
createReferenceValueFrom
public static ReferenceValue createReferenceValueFrom(Reference ref, 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 objectbaseUrl
- 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 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 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 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 String getServiceBaseUrl(String uri) throws FHIRSearchException
Get the service base URL from the given uri- Parameters:
uri
-- Returns:
- Throws:
FHIRSearchException
-
-