Sha256: 92f56bccd0dd6300fc59bea86d92e14f90d53971d2917edc1636f34a15d89fc2
Contents?: true
Size: 1.81 KB
Versions: 76
Compression:
Stored size: 1.81 KB
Contents
# frozen_string_literal: true require_dependency "renalware/patients" require "nhs_api_client" module Renalware module Patients # # A background job to fetch practice and GP updates from the NHS Organisation Data Service (ODS) # The order in which we fetch data is neccessarily strict in order to build the relationships: # 1. Practices # 2. GPS # 3. Practice memberships # class SyncODSJob < ApplicationJob # Do not retry this job as we do not want to keep hitting the ODS API. # If it fails this job will be removed form the queue, but make sure we report the error. discard_on(StandardError) do |_job, exception| Renalware::Engine.exception_notifier.notify(exception) Rails.logger.error exception end # If dry_run: true when we should not save any changes. def perform(dry_run: false) sync_practices(dry_run) sync_gps_and_memberships(dry_run) end private # For practices, call the NHS Organisation Data Service (ODS) API to get any recent # changes/additions. The first time this runs it will take a while because it will fetch all # practices. On successive runs it will just find changes since the last run. def sync_practices(dry_run) Renalware::System::APILog.with_log("nhs_data_api", dry_run: dry_run) do |api_log| Renalware::Patients::SyncPracticesViaApi.call( dry_run: dry_run, api_log: api_log ) end end # Kick off another job to download GP and practice membership zip files and import # any changes, additions etc. # Note at some point ODS might publish this as an API. def sync_gps_and_memberships(dry_run) return if dry_run SyncGpsViaFileDownloadJob.perform_later end end end end
Version data entries
76 entries across 76 versions & 1 rubygems