Class HashMapResourceProvider<T extends org.hl7.fhir.instance.model.api.IBaseResource>

  • Type Parameters:
    T - The resource type to support
    All Implemented Interfaces:
    IResourceProvider

    public class HashMapResourceProvider<T extends org.hl7.fhir.instance.model.api.IBaseResource>
    extends Object
    implements IResourceProvider
    This class is a simple implementation of the resource provider interface that uses a HashMap to store all resources in memory.

    This class currently supports the following FHIR operations:

    • Create
    • Update existing resource
    • Update non-existing resource (e.g. create with client-supplied ID)
    • Delete
    • Search by resource type with no parameters
    • Constructor Detail

      • HashMapResourceProvider

        public HashMapResourceProvider​(ca.uhn.fhir.context.FhirContext theFhirContext,
                                       Class<T> theResourceType)
        Constructor
        Parameters:
        theFhirContext - The FHIR context
        theResourceType - The resource type to support
    • Method Detail

      • clear

        public void clear()
        Clear all data held in this resource provider
      • create

        public ca.uhn.fhir.rest.api.MethodOutcome create​(T theResource,
                                                         RequestDetails theRequestDetails)
      • delete

        public ca.uhn.fhir.rest.api.MethodOutcome delete​(org.hl7.fhir.instance.model.api.IIdType theId,
                                                         RequestDetails theRequestDetails)
      • getCountCreate

        public long getCountCreate()
        This method returns a simple operation count. This is mostly useful for testing purposes.
      • getCountDelete

        public long getCountDelete()
        This method returns a simple operation count. This is mostly useful for testing purposes.
      • getCountRead

        public long getCountRead()
        This method returns a simple operation count. This is mostly useful for testing purposes.
      • getCountSearch

        public long getCountSearch()
        This method returns a simple operation count. This is mostly useful for testing purposes.
      • getCountUpdate

        public long getCountUpdate()
        This method returns a simple operation count. This is mostly useful for testing purposes.
      • historyInstance

        public List<org.hl7.fhir.instance.model.api.IBaseResource> historyInstance​(org.hl7.fhir.instance.model.api.IIdType theId,
                                                                                   RequestDetails theRequestDetails)
      • read

        public T read​(org.hl7.fhir.instance.model.api.IIdType theId,
                      RequestDetails theRequestDetails)
      • searchById

        public List<org.hl7.fhir.instance.model.api.IBaseResource> searchById​(ca.uhn.fhir.rest.param.TokenAndListParam theIds,
                                                                              RequestDetails theRequestDetails)
      • update

        public ca.uhn.fhir.rest.api.MethodOutcome update​(T theResource,
                                                         String theConditional,
                                                         RequestDetails theRequestDetails)
        Parameters:
        theConditional - This is provided only so that subclasses can implement if they want
      • getFhirContext

        public ca.uhn.fhir.context.FhirContext getFhirContext()
      • store

        public org.hl7.fhir.instance.model.api.IIdType store​(T theResource)
        This is a utility method that can be used to store a resource without having to use the outside API. In this case, the storage happens without any interaction with interceptors, etc.
        Parameters:
        theResource - The resource to store. If the resource has an ID, that ID is updated.
        Returns:
        Return the ID assigned to the stored resource
      • getStoredResources

        public List<TgetStoredResources()
        Returns an unmodifiable list containing the current version of all resources stored in this provider
        Since:
        4.1.0