Package ca.uhn.fhir.jpa.interceptor
Class PatientIdPartitionInterceptor
java.lang.Object
ca.uhn.fhir.jpa.interceptor.PatientIdPartitionInterceptor
This interceptor allows JPA servers to be partitioned by Patient ID. It selects the compartment for read/create operations
based on the patient ID associated with the resource (and uses a default partition ID for any resources
not in the patient compartment).
-
Constructor Summary
ConstructorDescriptionPatientIdPartitionInterceptor
(ca.uhn.fhir.context.FhirContext theFhirContext, ISearchParamExtractor theSearchParamExtractor, PartitionSettings thePartitionSettings) Constructor -
Method Summary
Modifier and TypeMethodDescriptionidentifyForCreate
(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) identifyForRead
(ReadPartitionIdRequestDetails theReadDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) protected RequestPartitionId
provideCompartmentMemberInstanceResponse
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Generate the partition for a given patient resource ID.protected RequestPartitionId
provideNonCompartmentMemberInstanceResponse
(org.hl7.fhir.instance.model.api.IBaseResource theResource) Return a compartment ID (or throw an exception) when an attempt is made to search for a resource that is in the patient compartment, but without any search parameter identifying which compartment to search.protected RequestPartitionId
provideNonCompartmentMemberTypeResponse
(org.hl7.fhir.instance.model.api.IBaseResource theResource) Return a compartment ID (or throw an exception) when storing/reading resource types that are not in the patient compartment (e.g.protected RequestPartitionId
provideNonPatientSpecificQueryResponse
(ReadPartitionIdRequestDetails theRequestDetails) Return a partition or throw an error for FHIR operations that can not be used with this interceptorprotected int
providePartitionIdForPatientId
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Translates an ID (e.g.
-
Constructor Details
-
PatientIdPartitionInterceptor
public PatientIdPartitionInterceptor(ca.uhn.fhir.context.FhirContext theFhirContext, ISearchParamExtractor theSearchParamExtractor, PartitionSettings thePartitionSettings) Constructor
-
-
Method Details
-
identifyForCreate
public RequestPartitionId identifyForCreate(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) -
identifyForRead
public RequestPartitionId identifyForRead(@Nonnull ReadPartitionIdRequestDetails theReadDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) -
provideNonPatientSpecificQueryResponse
protected RequestPartitionId provideNonPatientSpecificQueryResponse(ReadPartitionIdRequestDetails theRequestDetails) Return a partition or throw an error for FHIR operations that can not be used with this interceptor -
provideCompartmentMemberInstanceResponse
@Nonnull protected RequestPartitionId provideCompartmentMemberInstanceResponse(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Generate the partition for a given patient resource ID. This method may be overridden in subclasses, but it may be easier to overrideprovidePartitionIdForPatientId(RequestDetails, String)
instead. -
providePartitionIdForPatientId
protected int providePartitionIdForPatientId(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Translates an ID (e.g. "ABC") into a compartment ID number.The default implementation of this method returns:
Math.abs(theResourceIdPart.hashCode()) % 15000
.This logic can be replaced with other logic of your choosing.
-
provideNonCompartmentMemberInstanceResponse
@Nonnull protected RequestPartitionId provideNonCompartmentMemberInstanceResponse(org.hl7.fhir.instance.model.api.IBaseResource theResource) Return a compartment ID (or throw an exception) when an attempt is made to search for a resource that is in the patient compartment, but without any search parameter identifying which compartment to search.E.g. this method will be called for the search
Observation?code=foo
since the patient is not identified in the URL. -
provideNonCompartmentMemberTypeResponse
@Nonnull protected RequestPartitionId provideNonCompartmentMemberTypeResponse(org.hl7.fhir.instance.model.api.IBaseResource theResource) Return a compartment ID (or throw an exception) when storing/reading resource types that are not in the patient compartment (e.g. ValueSet).
-