Sha256: c6464faa2352d574f28eac7056aa7e88167cf56fce3e9951c804fbc8f8005840

Contents?: true

Size: 876 Bytes

Versions: 11

Compression:

Stored size: 876 Bytes

Contents

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(id: row["id"])
        practice.code = row["code"]
        practice.name = row["name"]
        unless practice.address.present?
          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

11 entries across 11 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc3 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.rc1 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta12 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta11 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta10 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta9 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta8 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta7 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta6 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta5 db/seeds/default/practices/practices.rb
renalware-core-2.0.0.pre.beta4 db/seeds/default/practices/practices.rb