Sha256: fedb5fe37fb8983f3062ebe12cf832ff8cb020c952d76feca01c620486865ffd

Contents?: true

Size: 870 Bytes

Versions: 30

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

module Renalware
  log "Adding NHS Practices\n" do
    sample_status = "SAMPLE ONLY"
    Patients::Practice.transaction do
      # NOTE: use '_sample' file for demo/devel
      CSV.foreach(File.join(File.dirname(__FILE__), "nhs_practices_sample.csv"), headers: true) do |row|
        practice = Patients::Practice.find_or_initialize_by(code: row["code"])
        practice.name = row["name"]
        if practice.address.blank?
          practice.build_address(
            organisation_name: row["name"],
            postcode: row["postcode"],
            street_1: row["street_1"],
            street_2: row["street_2"],
            town: row["town"]
          )
        end
        practice.save!
      end
    end

    log_count = Patients::Practice.count
    log "#{log_count} practices imported #{sample_status}", type: :sub
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
renalware-core-2.1.1 db/seeds/default/practices/practices.rb
renalware-core-2.1.0 db/seeds/default/practices/practices.rb
renalware-core-2.0.167 db/seeds/default/practices/practices.rb
renalware-core-2.0.166 db/seeds/default/practices/practices.rb
renalware-core-2.0.165 db/seeds/default/practices/practices.rb
renalware-core-2.0.164 db/seeds/default/practices/practices.rb
renalware-core-2.0.163 db/seeds/default/practices/practices.rb
renalware-core-2.0.162 db/seeds/default/practices/practices.rb
renalware-core-2.0.161 db/seeds/default/practices/practices.rb
renalware-core-2.0.160 db/seeds/default/practices/practices.rb
renalware-core-2.0.159 db/seeds/default/practices/practices.rb
renalware-core-2.0.158 db/seeds/default/practices/practices.rb
renalware-core-2.0.157 db/seeds/default/practices/practices.rb
renalware-core-2.0.156 db/seeds/default/practices/practices.rb
renalware-core-2.0.155 db/seeds/default/practices/practices.rb
renalware-core-2.0.153 db/seeds/default/practices/practices.rb
renalware-core-2.0.152 db/seeds/default/practices/practices.rb
renalware-core-2.0.151 db/seeds/default/practices/practices.rb
renalware-core-2.0.149 db/seeds/default/practices/practices.rb
renalware-core-2.0.148 db/seeds/default/practices/practices.rb