
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).
This works better with IdStrategyEnum.UUID and CrossPartitionReferenceMode.ALLOWED_UNQUALIFIED.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPatientIdPartitionInterceptor(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 RequestPartitionIdprovideCompartmentMemberInstanceResponse(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Generate the partition for a given patient resource ID.protected RequestPartitionIdprovideNonCompartmentMemberTypeResponse(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 RequestPartitionIdReturn a partition or throw an error for FHIR operations that can not be used with this interceptorprotected intprovidePartitionIdForPatientId(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart) Translates an ID (e.g.protected RequestPartitionIdthrowNonCompartmentMemberInstanceFailureResponse(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.voidtransaction(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseBundle theBundle) If we're about to process a FHIR transaction, we want to note the mappings between placeholder IDs and their resources and stuff them into a userdata map where we can access them later.
-
Field Details
-
PLACEHOLDER_TO_REFERENCE_KEY
-
-
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) -
transaction
public void transaction(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IBaseBundle theBundle) If we're about to process a FHIR transaction, we want to note the mappings between placeholder IDs and their resources and stuff them into a userdata map where we can access them later. We do this so that when we see a resource in the patient compartment (e.g. an Encounter) and it has a subject reference that's just a placeholder ID, we can look up the target of that and figure out which compartment that Encounter actually belongs to. -
provideNonPatientSpecificQueryResponse
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.
-
throwNonCompartmentMemberInstanceFailureResponse
@Nonnull protected RequestPartitionId throwNonCompartmentMemberInstanceFailureResponse(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=foosince 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).
-