Class FHIRPersistenceSupport


  • public class FHIRPersistenceSupport
    extends java.lang.Object
    Collection of helper methods related to the persistence of FHIR resource payload data
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Instant getCurrentInstant()
      Get the current time which can be used for the lastUpdated field
      static java.time.Instant getLastUpdatedFromResource​(Resource resource)
      Get the lastUpdated value from a Resource as a Instant.
      static int getMetaVersionId​(Resource resource)
      Obtain the versionId value from the Resource meta element, converting to an int for use by the persistence layer
      static Instant getNewLastUpdatedInstant​(java.time.Instant currentLastUpdated)
      Get the lastUpdated time to use for the next version of a resource.
      static <T extends Resource>
      T
      parse​(java.lang.Class<T> resourceType, java.io.InputStream in, java.util.List<java.lang.String> elements, boolean uncompress)
      Parse the given stream, using elements if needed
      static InputOutputByteStream render​(Resource resource, boolean compress)
      Render the payload
      • Methods inherited from class java.lang.Object

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

      • FHIRPersistenceSupport

        public FHIRPersistenceSupport()
    • Method Detail

      • parse

        public static <T extends Resource> T parse​(java.lang.Class<T> resourceType,
                                                   java.io.InputStream in,
                                                   java.util.List<java.lang.String> elements,
                                                   boolean uncompress)
                                            throws FHIRParserException,
                                                   java.io.IOException
        Parse the given stream, using elements if needed
        Type Parameters:
        T -
        Parameters:
        resourceType -
        in -
        elements -
        uncompress -
        Returns:
        Throws:
        FHIRParserException
        java.io.IOException
      • getCurrentInstant

        public static Instant getCurrentInstant()
        Get the current time which can be used for the lastUpdated field
        Returns:
        current time in UTC
      • getMetaVersionId

        public static int getMetaVersionId​(Resource resource)
                                    throws FHIRPersistenceException
        Obtain the versionId value from the Resource meta element, converting to an int for use by the persistence layer
        Parameters:
        resource -
        Returns:
        Throws:
        FHIRPersistenceException
      • getLastUpdatedFromResource

        public static java.time.Instant getLastUpdatedFromResource​(Resource resource)
        Get the lastUpdated value from a Resource as a Instant.
        Parameters:
        resource -
        Returns:
      • getNewLastUpdatedInstant

        public static Instant getNewLastUpdatedInstant​(java.time.Instant currentLastUpdated)
                                                throws FHIRPersistenceException
        Get the lastUpdated time to use for the next version of a resource. If a current version of the resource exists, pass its lastUpdated time as the currenLastUpdated parameter (all times should be UTC). If the gap falls within a grace period of 2 seconds, then we make the new lastUpdated time equal the current time + 1 ms to maintain consistent ordering. Clusters should easily be able to maintain clocks synchronized within 2 seconds if they are configured with a reliable network time service.
        Parameters:
        currentLastUpdated -
        Returns:
        Throws:
        FHIRPersistenceException - if current time is 2 or more seconds before currentLastUpdated