Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop client history #466

Merged
merged 1 commit into from Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions app/controllers/patients_controller.rb
Expand Up @@ -10,7 +10,7 @@ def show
end

def new
@patient = Patient.new(address: Address.new, clinic_history: ClinicHistory.new)
@patient = Patient.new(address: Address.new)
end

def edit
Expand Down Expand Up @@ -66,13 +66,6 @@ def patient_params
address_attributes: [
:id, :street, :number, :colony, :postal_code, :municipality,
:state, :country, :_destroy
],
clinic_history_attributes: [
:id, :description_diabetes, :description_hypertension,
:description_allergic, :description_traumatic,
:description_transfusion, :description_surgical,
:description_drug_addiction, :description_cancer,
:description_other, :patien_id, :_destroy
]
)
end
Expand Down
3 changes: 0 additions & 3 deletions app/models/clinic_history.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/models/patient.rb
@@ -1,5 +1,4 @@
class Patient < User
has_one :clinic_history, dependent: :destroy
has_one :address, as: :addressable, dependent: :destroy
has_and_belongs_to_many :doctors, join_table: "doctors_patients"
has_many :appoinments, -> { order(created_at: :desc) }, dependent: :destroy
Expand All @@ -8,7 +7,6 @@ class Patient < User

has_one_attached :avatar

accepts_nested_attributes_for :clinic_history, allow_destroy: true
accepts_nested_attributes_for :address, allow_destroy: true

validates :email, uniqueness: true, allow_nil: true
Expand Down
22 changes: 0 additions & 22 deletions app/views/clinic_histories/_clinic_history_fields.html.haml

This file was deleted.

19 changes: 19 additions & 0 deletions db/migrate/20240228054356_drop_clinic_histories.rb
@@ -0,0 +1,19 @@
class DropClinicHistories < ActiveRecord::Migration[7.1]
def change
drop_table :clinic_histories do |t|
t.text :description_diabetes
t.text :description_hypertension
t.text :description_allergic
t.text :description_traumatic
t.text :description_transfusion
t.text :description_surgical
t.text :description_drug_addiction
t.text :description_hereditary
t.text :description_cancer
t.text :description_other
t.references :patient, foreign_key: {to_table: :users}

t.timestamps
end
end
end
20 changes: 1 addition & 19 deletions db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2022_11_20_194132) do
ActiveRecord::Schema[7.1].define(version: 2024_02_28_054356) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "unaccent"
Expand Down Expand Up @@ -91,23 +91,6 @@
t.index ["patient_id"], name: "index_bentos_on_patient_id"
end

create_table "clinic_histories", force: :cascade do |t|
t.text "description_diabetes"
t.text "description_hypertension"
t.text "description_allergic"
t.text "description_traumatic"
t.text "description_transfusion"
t.text "description_surgical"
t.text "description_drug_addiction"
t.text "description_hereditary"
t.text "description_cancer"
t.text "description_other"
t.bigint "patient_id"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.index ["patient_id"], name: "index_clinic_histories_on_patient_id"
end

create_table "doctors_patients", id: false, force: :cascade do |t|
t.bigint "doctor_id", null: false
t.bigint "patient_id", null: false
Expand Down Expand Up @@ -264,7 +247,6 @@
add_foreign_key "appoinments", "users", column: "doctor_id"
add_foreign_key "appoinments", "users", column: "patient_id"
add_foreign_key "bentos", "users", column: "patient_id"
add_foreign_key "clinic_histories", "users", column: "patient_id"
add_foreign_key "hospitalizations", "referred_doctors"
add_foreign_key "hospitalizations", "users", column: "doctor_id"
add_foreign_key "hospitalizations", "users", column: "patient_id"
Expand Down
15 changes: 0 additions & 15 deletions spec/factories/clinic_histories.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/factories/patients.rb
Expand Up @@ -22,7 +22,6 @@
if patient.doctors.nil?
patient.doctors = build_list :doctor, 1
end
patient.clinic_history = build :clinic_history
patient.address = build :address
end

Expand Down
5 changes: 0 additions & 5 deletions spec/models/clinic_history_spec.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/models/patient_spec.rb
@@ -1,14 +1,12 @@
require "rails_helper"

RSpec.describe Patient do
it { should have_one(:clinic_history).dependent(:destroy) }
it { should have_one(:address).dependent(:destroy) }
it { should have_and_belong_to_many :doctors }
it { should have_many(:appoinments).dependent(:destroy) }
it { should have_many(:hospitalizations).dependent(:destroy) }
it { should have_many(:bentos).dependent(:destroy) }

it { should accept_nested_attributes_for(:clinic_history).allow_destroy(true) }
it { should accept_nested_attributes_for(:address).allow_destroy(true) }

it { should validate_presence_of :name }
Expand Down