Class DataAccess


  • public class DataAccess
    extends Object
    The data access layer encapsulating interactions with the FHIR bucket schema
    • Method Detail

      • init

        public void init()
        Initialize the object
      • registerBucketItem

        public void registerBucketItem​(CosItem item)
        Create a record in the database to track this item if it doesn't currently exist
        Parameters:
        item -
      • allocateJobs

        public void allocateJobs​(List<BucketLoaderJob> jobList,
                                 FileType fileType,
                                 int free,
                                 int recycleSeconds,
                                 Collection<BucketPath> bucketPaths)
        Allocate up to free jobs to this loader instance
        Parameters:
        jobList -
        free -
      • recordLogicalId

        public void recordLogicalId​(String resourceType,
                                    String logicalId,
                                    long resourceBundleLoadId,
                                    int lineNumber,
                                    Integer responseTimeMs)
        Save the logical id
        Parameters:
        simpleName -
        logicalId -
      • heartbeat

        public void heartbeat()
        Update the heartbeat tstamp of the record representing this loader instance to tell everyone that we're still alive.
      • markJobDone

        public void markJobDone​(BucketLoaderJob job)
        Parameters:
        job -
      • recordLogicalIds

        public void recordLogicalIds​(long resourceBundleLoadId,
                                     int lineNumber,
                                     List<ResourceIdValue> idValues,
                                     int batchSize)
        Load the list of resourceType/logicalId DTO objects as a batch in one transaction
        Parameters:
        resourceBundleId -
        lineNumber -
        idValues -
      • recordErrors

        public void recordErrors​(long resourceBundleLoadId,
                                 int lineNumber,
                                 List<ResourceBundleError> errors)
        Save the errors generated when loading the given resource bundle. Because a given bundle may be loaded multiple times with different outcomes, the error records are each associated with the current loaderInstanceId. This can occur when a loader dies before the bundle completes.
        Parameters:
        resourceBundleId -
        lineNumber -
        errors -
        batchSize -
      • getLastProcessedLineNumber

        public Integer getLastProcessedLineNumber​(long resourceBundleId,
                                                  int version)
        Get the last processed line number for the given resource bundle identified by its id. This is calculated by looking for the max line_number value recorded for the bundle in the logical_resources table.
        Parameters:
        resourceBundleId -
        version -
      • getResourceRefsForLine

        public List<ResourceRef> getResourceRefsForLine​(long resourceBundleId,
                                                        int version,
                                                        int lineNumber)
        Get the list of resourceType/logicalId resource references generated when processing the given lineNumber of the identified resource bundle and its version
        Parameters:
        resourceBundleId -
        version -
        lineNumber -
        Returns:
      • selectRandomPatientIds

        public void selectRandomPatientIds​(List<String> patientIds,
                                           int maxPatients)
        Parameters:
        patientIds -
        patientsPerBatch -