
Package ca.uhn.fhir.jpa.cache
Class ResourceIdentifierCacheSvcImpl
java.lang.Object
ca.uhn.fhir.jpa.cache.ResourceIdentifierCacheSvcImpl
- All Implemented Interfaces:
IResourceIdentifierCacheSvc
-
Constructor Summary
ConstructorsConstructorDescriptionResourceIdentifierCacheSvcImpl
(IHapiTransactionService theTransactionService, MemoryCacheService theMemoryCache, IResourceIdentifierSystemEntityDao theResourceIdentifierSystemEntityDao, IResourceIdentifierPatientUniqueEntityDao theResourceIdentifierPatientUniqueEntityDao, jakarta.persistence.EntityManager theEntityManager) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetFhirIdAssociatedWithUniquePatientIdentifier
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, RequestPartitionId theRequestPartitionId, String theSystem, String theValue, Supplier<String> theNewIdSupplier) Retrieves the FHIR ID associated with the given Patient identifier, creating a new record using the given Supplier if no existing record is found.long
getOrCreateResourceIdentifierSystem
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, RequestPartitionId theRequestPartitionId, String theSystem) Retrieves (and creates if necessary) the PID associated with the given identifier system URL.
-
Constructor Details
-
ResourceIdentifierCacheSvcImpl
public ResourceIdentifierCacheSvcImpl(IHapiTransactionService theTransactionService, MemoryCacheService theMemoryCache, IResourceIdentifierSystemEntityDao theResourceIdentifierSystemEntityDao, IResourceIdentifierPatientUniqueEntityDao theResourceIdentifierPatientUniqueEntityDao, jakarta.persistence.EntityManager theEntityManager) Constructor
-
-
Method Details
-
getOrCreateResourceIdentifierSystem
public long getOrCreateResourceIdentifierSystem(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, RequestPartitionId theRequestPartitionId, String theSystem) Description copied from interface:IResourceIdentifierCacheSvc
Retrieves (and creates if necessary) the PID associated with the given identifier system URL.Thread-safety: This method is designed to be thread-safe, including in cases where multiple threads are attempting to create a new FHIR ID for the same identifier system. It will internally retry automatically if multiple threads attempt to create a new identifier system and will not fail in this case.
Transactionality: This method will open a new transaction if one is not already open.
- Specified by:
getOrCreateResourceIdentifierSystem
in interfaceIResourceIdentifierCacheSvc
- Parameters:
theRequestDetails
- The request details associated with the current requesttheRequestPartitionId
- The partition ID associated with the current requesttheSystem
- TheIdentifier.system
value- Returns:
- Returns a PID associated with the given identifier system URL.
-
getFhirIdAssociatedWithUniquePatientIdentifier
@Nonnull public String getFhirIdAssociatedWithUniquePatientIdentifier(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, RequestPartitionId theRequestPartitionId, String theSystem, String theValue, Supplier<String> theNewIdSupplier) Description copied from interface:IResourceIdentifierCacheSvc
Retrieves the FHIR ID associated with the given Patient identifier, creating a new record using the given Supplier if no existing record is found. This method enforces uniqueness on the identifier using a database constraint and will therefore only allow one FHIR ID to be associated with one Identifier. No uniqueness is enforced on the FHIR ID.Thread safety: This method will fail with a constraint error if multiple threads attempt to assign a FHIR ID for the same system+value combination concurrently.
Transactionality: This method will open a new transaction if one is not already open.
- Specified by:
getFhirIdAssociatedWithUniquePatientIdentifier
in interfaceIResourceIdentifierCacheSvc
- Parameters:
theSystem
- TheIdentifier.system
valuetheValue
- TheIdentifier.value
valuetheNewIdSupplier
- If no existing FHIR ID is found, a new entry will be created using this ID supplier- Returns:
- The FHIR ID associated with this identifier
-