Skip to content

Commit

Permalink
Added culture type
Browse files Browse the repository at this point in the history
  • Loading branch information
hdf1996 committed Jul 5, 2019
1 parent 2ca5113 commit 5fc568a
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/controllers/api/v1/culture_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Api
module V1
class CultureTypesController < ApiController
def index
render_paginated CultureType.all
end
end
end
end
3 changes: 3 additions & 0 deletions app/models/culture_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class CultureType < ApplicationRecord
validates :name, presence: true
end
3 changes: 3 additions & 0 deletions app/serializers/culture_type_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class CultureTypeSerializer < ActiveModel::Serializer
attributes :id, :name, :created_at, :updated_at
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
end
resources :labs, only: [:index, :create]
resources :specimen_sources, only: [:index]
resources :culture_types, only: [:index]
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20190705163829_create_culture_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateCultureTypes < ActiveRecord::Migration[5.1]
def change
create_table :culture_types do |t|
t.string :name

t.timestamps
end
end
end
8 changes: 7 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20190702135353) do
ActiveRecord::Schema.define(version: 20190705163829) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -41,6 +41,12 @@
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end

create_table "culture_types", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "labs", force: :cascade do |t|
t.string "name"
t.string "address"
Expand Down
9 changes: 9 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@
SpecimenSource.find_or_create_by(
name: row['name']
)
end

CSV.foreach(
Rails.root.join('db', 'seeds', "culture_type.csv"),
headers: true
) do |row|
CultureType.find_or_create_by(
name: row['name']
)
end
68 changes: 68 additions & 0 deletions db/seeds/culture_type.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name
Culture Type Original
AEROBIC
Aerobic culture
Anaerobic culture
Bacterial Aerobic
Bacterial Culture
Bacterial Culture, Blood
Bacterial Culture/Smear (Aerobic)
Bacterial Culture/Smear (Aerobic/Anaerobic)
Bacterial Stool Culture/NAT
Bacterial Stool Nucleic Acid Test
Bacterial/Yeast Culture, Blood
Blood - Culture & Sensitivity
Blood anaerobic
Blood culture
BLOOD CULTURE & SUSCEPTIBILITY (BACTEC)
Body Fluid - Culture & Sensitivity
Body fluid culture
Catheter Tip Culture & Sensitivity
Central Line Tip for Culture & Sensitivity
CSF Culture & Sensitivity
CSF Culture and gram stain
Culture & Sensitivity
CULTURE AEROBIC
CULTURE AEROBIC & SUSCEPTIBILITY
CULTURE ANAEROBIC
Culture and gram stain
Culture and Sensitivity
CULTURE STOOL
CULTURE SURVEILLANCE, MRSA
Culture Urine
CULTURE URINE WITH SUSCEPTIBILITY
Cystic Fibrosis Respiratory Culture
Fungal Culture
Gonococcus Culture
Group B Streptococcus Susceptibility
High Vaginal Swab Culture and Sensitivity
HVS Culture for Group B streptococcus
MRSA Surveillance Culture
Organism Identification and Susceptibility
Other (specify in additional information)
Paired Blood Culture & Sensitivity
Peritoneal Fluid Culture & Sensitivity
Pleural Fluid Culture & Sensitivity
Pus Culture & Sensitivity
Quantitative Culture Tissue
Respiratory Culture and Smear
Respiratory Surveillance Culture
Skin Culture & Sensitivity
Specimen source not given
Sputum culture
Sputum Culture & Sensitivity
Stool Culture
Stool Culture & Sensitivity
Stool ID AND SENSITIVITY
Surveillance Culture
Susceptibility
Throat culture
Throat Swab Culture & Sensitivity
Tip Culture & Sensitivity
Tissue Culture & Sensitivity
Tracheal Secretions Culture & Sensitivity
Urine culture
Urine Culture & Sensitivity
Wound ID AND SENSITIVITY
Wound Swab Culture & Sensitivity
Yeast Identification
28 changes: 28 additions & 0 deletions spec/controllers/api/v1/culture_types_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'rails_helper'

RSpec.describe Api::V1::CultureTypesController, type: :controller do
describe 'GET /culture_types' do
context 'with an unauthenticated user' do
before { get :index }

it 'should respond unauthorized' do
expect(response).to have_http_status(:unauthorized)
end
end

context 'with an authenticated user' do
let(:user) { create :user }
let!(:culture_types) { create_list :culture_type, 10 }
before do
authenticate(user)
get :index
end

it 'responds ok' do
expect(response).to have_http_status(:ok)
end

it_behaves_like 'a paginated request', CultureType.all
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

context 'with an authenticated user' do
let(:user) { create :user }
let!(:labs) { create_list :specimen_source, 10 }
let!(:specimen_sources) { create_list :specimen_source, 10 }
before do
authenticate(user)
get :index
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/culture_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :culture_type do
name { FFaker::HealthcareIpsum.word }
end
end
9 changes: 9 additions & 0 deletions spec/models/culture_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rails_helper'

RSpec.describe CultureType, type: :model do
subject { build :culture_type }

it { is_expected.to validate_presence_of(:name) }

it { is_expected.to be_valid }
end

0 comments on commit 5fc568a

Please sign in to comment.