Skip to content

Instantly share code, notes, and snippets.

@codejoy
Created November 5, 2015 21:23
Show Gist options
  • Save codejoy/e2b54cf1762e144e88cf to your computer and use it in GitHub Desktop.
Save codejoy/e2b54cf1762e144e88cf to your computer and use it in GitHub Desktop.
# Running:
E
Finished in 0.108843s, 9.1875 runs/s, 0.0000 assertions/s.
1) Error:
ProviderTermTest#test_terming_a_provider:
ActiveRecord::UnknownAttributeError: unknown attribute: provider
test/models/provider_term_test.rb:17:in `block in <class:ProviderTermTest>'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
class Group < ActiveRecord::Base
#I have to figure out how providers will be held in this app if its going to be an intermediary table or what. Does deleting a provider from a group remove them
#from the db all together or just that group?
#validations
validates :group_name, presence: true
#associations
has_many :provider_terms
#i think my issue is here, I have a lot of providers through provider_locations but there is no way to tell a group that provider_locations and group_locations are linked.
has_many :group_locations
has_many :providers, through: :provider_locations
has_many :provider_locations, through: :group_locations
has_many :invoices
has_and_belongs_to_many :billings
has_many :addresses, through: :group_locations
belongs_to :group_terms
belongs_to :billing_address, class_name: 'Address', foreign_key: 'billing_address_id'
belongs_to :mailing_address, class_name: 'Address', foreign_key: 'mailing_address_id'
has_and_belongs_to_many :insurances
#has_many :provider_locations, through: :group_locations
accepts_nested_attributes_for :billing_address
accepts_nested_attributes_for :mailing_address
end
class Provider < ActiveRecord::Base
has_many :provider_locations
has_many :group_locations, through: :provider_locations
has_many :groups, through: :group_locations
belongs_to :designation
belongs_to :specialty
#has_many :provider_locations
has_many :invoices
has_many :provider_terms
end
class ProviderTerm < ActiveRecord::Base
belongs_to :groups
belongs_to :providers
end
require 'test_helper'
class ProviderTermTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
group = Group.create(group_name: 'My Awesome')
adr = Address.create(city: 'Las Cruces', state: 'New Mexico', zip: '88012', address_line_one: '382 Dark Side of the Moon', address_line_two: '')
@provider = Provider.create(first_name: 'Shane', last_name: 'Thomas')
end
test 'terming a provider' do
#just trying to get something to work.
@pt = ProviderTerm.create(provider: @provider, termdate: DateTime.now.to_date)
#again just testing...
puts @pt
end
end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151105205127) do
create_table "addresses", force: true do |t|
t.text "city"
t.text "state"
t.text "zip"
t.text "address_line_one"
t.text "address_line_two"
t.datetime "created_at"
t.datetime "updated_at"
t.string "contact"
t.string "phone"
t.string "fax"
end
create_table "billings", force: true do |t|
t.text "name"
t.text "contact"
t.integer "address_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "group_id"
end
add_index "billings", ["address_id"], name: "index_billings_on_address_id"
add_index "billings", ["group_id"], name: "index_billings_on_group_id"
create_table "billings_groups", id: false, force: true do |t|
t.integer "group_id", null: false
t.integer "billing_id", null: false
end
create_table "designations", force: true do |t|
t.text "designation"
t.text "dues"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "theDate"
t.string "status"
end
create_table "group_locations", force: true do |t|
t.integer "address_id"
t.integer "group_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "dba"
end
add_index "group_locations", ["address_id"], name: "index_group_locations_on_address_id"
add_index "group_locations", ["group_id"], name: "index_group_locations_on_group_id"
create_table "group_terms", force: true do |t|
t.datetime "termdate"
t.integer "group_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "group_terms", ["group_id"], name: "index_group_terms_on_group_id"
create_table "groups", force: true do |t|
t.text "group_name"
t.text "group_contact"
t.text "tin"
t.text "npi"
t.text "notes"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "billing_address_id"
t.integer "mailing_address_id"
t.datetime "startdate"
t.datetime "enddate"
t.datetime "changedate"
t.text "changetext"
t.boolean "istermed"
t.text "termcomment"
t.string "groupphone"
t.string "groupfax"
end
add_index "groups", ["billing_address_id"], name: "index_groups_on_billing_address_id"
add_index "groups", ["mailing_address_id"], name: "index_groups_on_mailing_address_id"
create_table "groups_insurances", id: false, force: true do |t|
t.integer "group_id", null: false
t.integer "insurance_id", null: false
end
create_table "insurances", force: true do |t|
t.text "name"
t.text "provider_relations_rep"
t.text "provider_relations_phone"
t.text "provider_relations_ext"
t.text "provider_relations_fax"
t.text "provider_relations_email"
t.text "network_contract_rep"
t.text "network_contract_phone"
t.text "network_contract_ext"
t.text "network_contract_fax"
t.text "network_conract_email"
t.text "credentialing_rep"
t.text "credentialing_phone"
t.text "credentialing_ext"
t.text "credentialing_fax"
t.text "credentialing_email"
t.text "notes"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "invoices", force: true do |t|
t.decimal "dues"
t.decimal "adjustments"
t.text "description"
t.datetime "date_of_invoice"
t.text "invoice_num"
t.decimal "total"
t.integer "group_id"
t.integer "providers_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "invoices", ["group_id"], name: "index_invoices_on_group_id"
add_index "invoices", ["providers_id"], name: "index_invoices_on_providers_id"
create_table "provider_locations", force: true do |t|
t.integer "provider_id"
t.integer "group_location_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "provider_locations", ["group_location_id"], name: "index_provider_locations_on_group_location_id"
add_index "provider_locations", ["provider_id"], name: "index_provider_locations_on_provider_id"
create_table "provider_terms", force: true do |t|
t.datetime "termdate"
t.integer "provider_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "group_id"
end
add_index "provider_terms", ["group_id"], name: "index_provider_terms_on_group_id"
add_index "provider_terms", ["provider_id"], name: "index_provider_terms_on_provider_id"
create_table "providers", force: true do |t|
t.text "first_name"
t.text "last_name"
t.integer "designation_id"
t.integer "specialty_id"
t.datetime "dob"
t.text "license_num"
t.datetime "license_exp"
t.text "dea_num"
t.datetime "dea_exp"
t.text "phone"
t.text "fax"
t.text "ptan"
t.text "caqh_num"
t.datetime "effective_date"
t.text "provider_npi"
t.datetime "provisional_effective_date"
t.datetime "date_joined"
t.text "provider_contact"
t.text "credentialing_contact"
t.text "notes"
t.datetime "created_at"
t.datetime "updated_at"
t.string "hospitalaffiliation"
end
add_index "providers", ["designation_id"], name: "index_providers_on_designation_id"
add_index "providers", ["specialty_id"], name: "index_providers_on_specialty_id"
create_table "specialties", force: true do |t|
t.text "name"
t.text "notes"
t.datetime "created_at"
t.datetime "updated_at"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment