Class FHIRResponseImpl

  • All Implemented Interfaces:
    FHIRResponse

    public class FHIRResponseImpl
    extends java.lang.Object
    implements FHIRResponse
    An implementation of the FHIRResponse interface which exposes the results of a FHIR REST API operation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getETag()
      This method is used to retrieve the value of the ETag response HTTP header.
      java.time.Instant getLastModified()
      This method is used to retrieve the Last-Modified response HTTP header.
      java.lang.String getLocation()
      This method is used to retrieve the value of the Location response HTTP header as a String.
      java.net.URI getLocationURI()
      This method is used to retrieve the value of the Location response HTTP header as a URI.
      <T> T getResource​(java.lang.Class<T> type)
      This method is used to retrieve the resource returned in a FHIR REST API response.
      javax.ws.rs.core.Response getResponse()
      Returns the underlying JAX-RS 2.0 Response object associated with this FHIRResponse.
      int getStatus()
      This method is used to retrieve the numeric HTTP status code associated with a FHIR REST API response.
      boolean isEmpty()
      Returns whether the response contains a FHIR Resource entity.
      java.lang.String[] parseLocation​(java.lang.String location)
      This function will parse the specified location value into its constituent parts and return a String array containing the individual parts.
      • Methods inherited from class java.lang.Object

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

      • FHIRResponseImpl

        protected FHIRResponseImpl()
      • FHIRResponseImpl

        public FHIRResponseImpl​(javax.ws.rs.core.Response response)
    • Method Detail

      • getStatus

        public int getStatus()
        Description copied from interface: FHIRResponse
        This method is used to retrieve the numeric HTTP status code associated with a FHIR REST API response.
        Specified by:
        getStatus in interface FHIRResponse
        Returns:
        the HTTP status code
      • getLocationURI

        public java.net.URI getLocationURI()
                                    throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This method is used to retrieve the value of the Location response HTTP header as a URI.
        Specified by:
        getLocationURI in interface FHIRResponse
        Returns:
        the Location response header value as a URI
        Throws:
        java.lang.Exception
      • getLocation

        public java.lang.String getLocation()
                                     throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This method is used to retrieve the value of the Location response HTTP header as a String.
        Specified by:
        getLocation in interface FHIRResponse
        Returns:
        the Location response header value as a String
        Throws:
        java.lang.Exception
      • getLastModified

        public java.time.Instant getLastModified()
                                          throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This method is used to retrieve the Last-Modified response HTTP header.
        Specified by:
        getLastModified in interface FHIRResponse
        Returns:
        Throws:
        java.lang.Exception
      • getETag

        public java.lang.String getETag()
                                 throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This method is used to retrieve the value of the ETag response HTTP header.
        Specified by:
        getETag in interface FHIRResponse
        Returns:
        the ETag response header value
        Throws:
        java.lang.Exception
      • getResource

        public <T> T getResource​(java.lang.Class<T> type)
                          throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This method is used to retrieve the resource returned in a FHIR REST API response.
        Specified by:
        getResource in interface FHIRResponse
        Parameters:
        type - this should be a java.lang.Class value which indicates the type of return value expected
        Returns:
        Throws:
        java.lang.Exception
      • getResponse

        public javax.ws.rs.core.Response getResponse()
                                              throws java.lang.Exception
        Description copied from interface: FHIRResponse
        Returns the underlying JAX-RS 2.0 Response object associated with this FHIRResponse.
        Specified by:
        getResponse in interface FHIRResponse
        Returns:
        the JAX-RS Response
        Throws:
        java.lang.Exception
      • parseLocation

        public java.lang.String[] parseLocation​(java.lang.String location)
                                         throws java.lang.Exception
        Description copied from interface: FHIRResponse
        This function will parse the specified location value into its constituent parts and return a String array containing the individual parts. The resulting String array returned by this function will contain the following values:
        • Index 0 - the resource type
        • Index 1 - the resource id
        • Index 2 - the version id (optional)
        Examples:
        1. If you call parseLocation with the value "http://localhost:9080/fhir-server/api/v4/Patient/23/_history/2", then you should receive this String array:
          • [0] - "Patient"
          • [1] - "23"
          • [2] - "2"
        2. If you call parseLocation with the value "http://localhost:9080/fhir-server/api/v4/Observation/38", then you should receive this String array:
          • [0] - "Observation"
          • [1] - "38"
        Specified by:
        parseLocation in interface FHIRResponse
        Parameters:
        location - a resource's location URI as a string; this will typically be the value returned by the getLocation() method.
        Returns:
        a String array containing the individual parts of the location string or null if the specified location value could not be parsed or was passed in as null.
        Throws:
        java.lang.Exception
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: FHIRResponse
        Returns whether the response contains a FHIR Resource entity.
        Specified by:
        isEmpty in interface FHIRResponse
        Returns:
        true if the response body is empty, otherwise false