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

    Constructors
    Constructor
    Description
    Constructor
    PatientIdPartitionInterceptor​(ca.uhn.fhir.context.FhirContext theFhirContext, ISearchParamExtractor theSearchParamExtractor)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    ca.uhn.fhir.interceptor.model.RequestPartitionId
    identifyForCreate​(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails)
     
    ca.uhn.fhir.interceptor.model.RequestPartitionId
    identifyForRead​(ca.uhn.fhir.interceptor.model.ReadPartitionIdRequestDetails theReadDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails)
     
    protected ca.uhn.fhir.interceptor.model.RequestPartitionId
    provideCompartmentMemberInstanceResponse​(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart)
    Generate the partition for a given patient resource ID.
    protected ca.uhn.fhir.interceptor.model.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 ca.uhn.fhir.interceptor.model.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 ca.uhn.fhir.interceptor.model.RequestPartitionId
    provideNonPatientSpecificQueryResponse​(ca.uhn.fhir.interceptor.model.ReadPartitionIdRequestDetails theRequestDetails)
    Return a partition or throw an error for FHIR operations that can not be used with this interceptor
    protected int
    providePartitionIdForPatientId​(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theResourceIdPart)
    Translates an ID (e.g.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • identifyForCreate

      public ca.uhn.fhir.interceptor.model.RequestPartitionId identifyForCreate(org.hl7.fhir.instance.model.api.IBaseResource theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails)
    • identifyForRead

      public ca.uhn.fhir.interceptor.model.RequestPartitionId identifyForRead(ca.uhn.fhir.interceptor.model.ReadPartitionIdRequestDetails theReadDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails)
    • provideNonPatientSpecificQueryResponse

      protected ca.uhn.fhir.interceptor.model.RequestPartitionId provideNonPatientSpecificQueryResponse(ca.uhn.fhir.interceptor.model.ReadPartitionIdRequestDetails theRequestDetails)
      Return a partition or throw an error for FHIR operations that can not be used with this interceptor
    • provideCompartmentMemberInstanceResponse

      @Nonnull protected ca.uhn.fhir.interceptor.model.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 override providePartitionIdForPatientId(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 ca.uhn.fhir.interceptor.model.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 ca.uhn.fhir.interceptor.model.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).