Skip to content

Commit

Permalink
Move patient count to admin admin module since it is a function used …
Browse files Browse the repository at this point in the history
…exclusively by the admin panel.
  • Loading branch information
Robert Clark committed Aug 27, 2014
1 parent 10a8d1b commit f085854
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
9 changes: 9 additions & 0 deletions app/controllers/api/admin/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class PatientsController < ApplicationController
before_filter :validate_authorization!
skip_before_action :verify_authenticity_token

api :GET, "/patients/count", "Get count of patients in the database"
formats ['json']
example '{"patient_count":56}'
def count
json = {}
json['patient_count'] = Record.count
render :json => json
end

api :POST, "/admin/patients", "Upload a zip file of patients."
param :file, nil, :desc => 'The zip file of patients to upload.', :required => true
def create
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/api/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ def index
respond_with paginate(api_patients_url,records)
end

api :GET, "/patients/count", "Get count of patients in the database"
formats ['json']
example '{"patient_count":56}'
def count
json = {}
json['patient_count'] = Record.count
render :json => json
end

api :GET, "/patients/:id[?include_results=:include_results]", "Retrieve an individual patient"
formats ['json']
param :id, String, :desc => "Patient ID", :required => true
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/patients.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
});
(function poll(){
setTimeout(function(){
$.getJSON( "<%= count_api_patients_path %>", function(data){
$.getJSON( "<%= count_api_admin_patients_path %>", function(data){
$('#patient_count').html(data.patient_count);
//Setup the next poll recursively
poll();
Expand Down
9 changes: 5 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
get :count
end
end
resource :patients
resource :patients do
collection do
get :count
end
end
resource :providers do
collection do
get :count
Expand All @@ -73,9 +77,6 @@
end
end
resources :patients do
collection do
get :count
end
member do
get :results
end
Expand Down

0 comments on commit f085854

Please sign in to comment.