Package ca.uhn.fhir.jpa.api.svc
Interface IIdHelperService<T extends ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId>
public interface IIdHelperService<T extends ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId>
This interface is used to translate between
IResourcePersistentId
and actual resource IDs.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addResolvedPidToForcedId
(T theResourcePersistentId, RequestPartitionId theRequestPartitionId, String theResourceType, String theForcedId, Date theDeletedAt) Pre-cache a PID-to-Resource-ID mapping for later retrieval bytranslatePidsToForcedIds(Set)
and related methodsgetPidOrNull
(RequestPartitionId theRequestPartitionId, org.hl7.fhir.instance.model.api.IBaseResource theResource) getPidOrThrowException
(RequestPartitionId theRequestPartitionId, org.hl7.fhir.instance.model.api.IIdType theId) getPidOrThrowException
(org.hl7.fhir.instance.model.api.IAnyResource theResource) getPidsOrThrowException
(RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds) boolean
idRequiresForcedId
(String theId) Returns true if the given resource ID should be stored in a forced ID.newPidFromStringIdAndResourceName
(String thePid, String theResourceType) resolveResourceIdentity
(RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) Given a forced ID, convert it to it's Long value.resolveResourceIdentity
(RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId, boolean theExcludeDeleted) Given a forced ID, convert it to it's Long value.resolveResourcePersistentIds
(RequestPartitionId theRequestPartitionId, String theResourceType, String theId) Given a resource type and ID, determines the internal persistent ID for the resource.resolveResourcePersistentIds
(RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted) Given a resource type and ID, determines the internal persistent ID for a resource.resolveResourcePersistentIds
(RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds) Returns a mapping of Id -> IResourcePersistentId.resolveResourcePersistentIds
(RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds, boolean theExcludeDeleted) Returns a mapping of Id -> IResourcePersistentId.resolveResourcePersistentIdsWithCache
(RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds) Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs.resolveResourcePersistentIdsWithCache
(RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds, boolean theOnlyForcedIds) Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs.org.hl7.fhir.instance.model.api.IIdType
resourceIdFromPidOrThrowException
(T thePid, String theResourceType) org.hl7.fhir.instance.model.api.IIdType
translatePidIdToForcedId
(ca.uhn.fhir.context.FhirContext theCtx, String theResourceType, T theId) Given a persistent ID, returns the associated resource IDtranslatePidIdToForcedIdWithCache
(T theResourcePersistentId) translatePidsToFhirResourceIds
(Set<T> thePids) Given a set of PIDs, return a set of public FHIR Resource IDs.translatePidsToForcedIds
(Set<T> theResourceIds)
-
Method Details
-
resolveResourcePersistentIdsWithCache
@Nonnull List<T> resolveResourcePersistentIdsWithCache(@Nonnull RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds, boolean theOnlyForcedIds) Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs.This implementation will always try to use a cache for performance, meaning that it can resolve resources that are deleted (but note that forced IDs can't change, so the cache can't return incorrect results)
- Parameters:
theOnlyForcedIds
- Iftrue
, resources which are not existing forced IDs will not be resolved
-
resolveResourcePersistentIds
@Nonnull T resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId) Given a resource type and ID, determines the internal persistent ID for the resource.- Throws:
ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException
- If the ID can not be found
-
resolveResourcePersistentIds
@Nonnull T resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted) Given a resource type and ID, determines the internal persistent ID for a resource. Optionally filters out deleted resources.- Throws:
ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException
- If the ID can not be found
-
resolveResourcePersistentIds
@Nonnull Map<String,T> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds) Returns a mapping of Id -> IResourcePersistentId. If any resource is not found, it will throw ResourceNotFound exception (and no map will be returned) -
resolveResourcePersistentIds
@Nonnull Map<String,T> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds, boolean theExcludeDeleted) Returns a mapping of Id -> IResourcePersistentId. If any resource is not found, it will throw ResourceNotFound exception (and no map will be returned) Optionally filters out deleted resources. -
translatePidIdToForcedId
@Nonnull org.hl7.fhir.instance.model.api.IIdType translatePidIdToForcedId(ca.uhn.fhir.context.FhirContext theCtx, String theResourceType, T theId) Given a persistent ID, returns the associated resource ID -
resolveResourceIdentity
@Nonnull IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) throws ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException Given a forced ID, convert it to it's Long value. Since you are allowed to use string IDs for resources, we need to convert those to the underlying Long values that are stored, for lookup and comparison purposes.- Throws:
ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException
- If the ID can not be found
-
resolveResourceIdentity
@Nonnull IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId, boolean theExcludeDeleted) throws ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException Given a forced ID, convert it to it's Long value. Since you are allowed to use string IDs for resources, we need to convert those to the underlying Long values that are stored, for lookup and comparison purposes. Optionally filters out deleted resources.- Throws:
ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException
- If the ID can not be found
-
idRequiresForcedId
Returns true if the given resource ID should be stored in a forced ID. Under default config (meaning client ID strategy isJpaStorageSettings.ClientIdStrategyEnum.ALPHANUMERIC
) this will return true if the ID has any non-digit characters.In
JpaStorageSettings.ClientIdStrategyEnum.ANY
mode it will always return true. -
resolveResourcePersistentIdsWithCache
@Nonnull List<T> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds) Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs.This implementation will always try to use a cache for performance, meaning that it can resolve resources that are deleted (but note that forced IDs can't change, so the cache can't return incorrect results)
-
translatePidIdToForcedIdWithCache
-
translatePidsToForcedIds
-
addResolvedPidToForcedId
void addResolvedPidToForcedId(T theResourcePersistentId, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt) Pre-cache a PID-to-Resource-ID mapping for later retrieval bytranslatePidsToForcedIds(Set)
and related methods -
getPidsOrThrowException
@Nonnull List<T> getPidsOrThrowException(RequestPartitionId theRequestPartitionId, List<org.hl7.fhir.instance.model.api.IIdType> theIds) -
getPidOrNull
@Nullable T getPidOrNull(RequestPartitionId theRequestPartitionId, org.hl7.fhir.instance.model.api.IBaseResource theResource) -
getPidOrThrowException
@Nonnull T getPidOrThrowException(RequestPartitionId theRequestPartitionId, org.hl7.fhir.instance.model.api.IIdType theId) -
getPidOrThrowException
@Nonnull T getPidOrThrowException(@Nonnull org.hl7.fhir.instance.model.api.IAnyResource theResource) -
resourceIdFromPidOrThrowException
org.hl7.fhir.instance.model.api.IIdType resourceIdFromPidOrThrowException(T thePid, String theResourceType) -
translatePidsToFhirResourceIds
Given a set of PIDs, return a set of public FHIR Resource IDs. This function will resolve a forced ID if it resolves, and if it fails to resolve to a forced it, will just return the pid Example: Let's say we have Patient/1(pid == 1), Patient/pat1 (pid == 2), Patient/3 (pid == 3), their pids would resolve as follows:[1,2,3] -> ["1","pat1","3"]
- Parameters:
thePids
- The Set of pids you would like to resolve to external FHIR Resource IDs.- Returns:
- A Set of strings representing the FHIR IDs of the pids.
-
newPid
-
newPidFromStringIdAndResourceName
-