Skip to content

Commit

Permalink
Fixes #40. Fixes #41. Fixes #42. Fixes #43. Fixes #46.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahc-is committed Jan 26, 2018
1 parent e906b5c commit f9c6565
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 26 deletions.
3 changes: 0 additions & 3 deletions app/controllers/admin/conditions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ def recent_as

@start_date = (params[:start_date].nil?) ? (DateTime.now - 30.days).strftime('%m/%d/%Y') : params[:start_date]
@end_date = (params[:end_date].nil?) ? DateTime.now.strftime('%m/%d/%Y') : params[:end_date]

#d = params.has_key?('days') ? params[:days].to_i : 30
#@conditions = StudyFinder::Condition.recent_as(d.days).paginate(page: params[:page])
@conditions = StudyFinder::Condition.find_range(@start_date, @end_date)

add_breadcrumb 'Reports'
Expand Down
28 changes: 19 additions & 9 deletions app/controllers/admin/trials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ class Admin::TrialsController < ApplicationController
require 'parsers/oncore'

def new
# trial = Parsers::Ctgov.new('NCT01794143')
# trial.load
# trial.process

# raise Parsers::Oncore.new('2003NT036').process.to_yaml

@trial = StudyFinder::Trial.new
@systems = ['Ctgov', 'Oncore']

Expand Down Expand Up @@ -60,10 +54,22 @@ def review
end

def recent_as
d = params.has_key?('days') ? params[:days].to_i : 30
@trials = StudyFinder::Trial.recent_as(d.days).paginate(page: params[:page])
@start_date = (params[:start_date].nil?) ? (DateTime.now - 30.days).strftime('%m/%d/%Y') : params[:start_date]
@end_date = (params[:end_date].nil?) ? DateTime.now.strftime('%m/%d/%Y') : params[:end_date]
@trials = StudyFinder::Trial.includes(:disease_sites).find_range(@start_date, @end_date)

add_breadcrumb 'Trials Administration'
add_breadcrumb 'Recently Added'

respond_to do |format|
format.html

format.xls do
response.headers['Content-Type'] = 'application/vnd.ms-excel'
response.headers['Content-Disposition'] = "attachment; filename=\"study_finder_trials_#{DateTime.now}.xls\""
render "recent_as.xls.erb"
end
end
end

def index
Expand Down Expand Up @@ -110,7 +116,11 @@ def update

private
def trial_params
params.require(:study_finder_trial).permit(:simple_description, :visible, :featured, :recruiting, :contact_override, :contact_override_first_name, :contact_override_last_name, :recruitment_url, :reviewed, :irb_number, site_ids: [], disease_site_ids: [])
params.require(:study_finder_trial).permit(
:simple_description, :visible,
:featured, :recruiting, :contact_override, :cancer_yn,
:contact_override_first_name, :contact_override_last_name, :pi_name, :pi_id, :recruitment_url,
:reviewed, :irb_number, site_ids: [], disease_site_ids: [])
end

end
15 changes: 13 additions & 2 deletions app/models/study_finder/trial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def self.import_from_file(file)
end
end

def self.find_range(start_date, end_date)
where('updated_at between ? and ?', start_date, end_date ).order('updated_at DESC')
end

def display_title
display = brief_title
unless acronym.nil?
Expand Down Expand Up @@ -136,13 +140,17 @@ def mesh_terms
indexes :max_age, type: 'float'
indexes :gender
indexes :phase, type: 'string'
indexes :cancer_yn, type: 'string'
indexes :visible, type: 'boolean'
indexes :healthy_volunteers

indexes :contact_override
indexes :contact_override_first_name
indexes :contact_override_last_name

indexes :pi_name, type: 'string', analyzer: 'en'
indexes :pi_id

indexes :category_ids
indexes :keyword_suggest, type: 'completion', analyzer: 'typeahead', search_analyzer: 'typeahead', payloads: false

Expand Down Expand Up @@ -198,9 +206,12 @@ def as_indexed_json(options={})
:contact_email,
:contact_backup_last_name,
:contact_backup_email,
:pi_name,
:pi_id,
:recruitment_url,
:irb_number,
:phase,
:cancer_yn,
:min_age_unit,
:max_age_unit,
:featured
Expand Down Expand Up @@ -273,7 +284,7 @@ def self.match_all_search(search)
query_string: {
query: search[:q],
default_operator: "AND",
fields: ["display_title", "interventions", "conditions_map", "simple_description", "eligibility_criteria", "system_id", "keywords"]
fields: ["display_title", "interventions", "conditions_map", "simple_description", "eligibility_criteria", "system_id", "keywords", "pi_name"]
}
},
filter: create_filters(search)
Expand Down Expand Up @@ -301,7 +312,7 @@ def self.match_all_admin(search)
multi_match: {
query: search[:q],
operator: "and",
fields: ["display_title", "interventions", "conditions_map", "simple_description", "eligibility_criteria", "system_id", "keywords"]
fields: ["display_title", "interventions", "conditions_map", "simple_description", "eligibility_criteria", "system_id", "keywords", "pi_name"]
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/views/admin/trials/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
= f.input :irb_number, label: 'IRB Number'
= f.input :visible, as: :select
= f.input :featured, as: :select, collection: [['No', 0],['Yes', 1]], include_blank: false
= f.input :cancer_yn, as: :select, collection: [['Yes', 'Y'],['No', 'N']], include_blank: true, label: 'Cancer Y/N'

= f.input :pi_name, label: 'PI Name'
= f.input :pi_id, label: 'PI ID'

= f.association :sites, label_method: :site_name, value_method: :id, input_html: { class: 'select2' }
= f.association :disease_sites, label_method: :disease_site_label, value_method: :id, input_html: { class: 'select2' }
Expand Down
24 changes: 17 additions & 7 deletions app/views/admin/trials/recent_as.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
.admin
.clearfix
.pull-left
%h3 Recent Trials
.pull-right
= will_paginate @collection, renderer: BootstrapPagination::Rails
%h3 Recent Trials (#{@trials.size})
%p.description
This section is where the administrator can review recently imported trials within StudyFinder.
%hr
.clearfix
.pull-right
= link_to 'Back to Admin', admin_trials_path, class: 'btn btn-default'
= form_tag admin_trial_recent_as_path, method: :get do |f|
.pull-left.row
.col-md-4
%label Start Date
%input#start_date.form-control.datepicker{ name: 'start_date', type: 'text', value: @start_date }
.col-md-4
%label End Date
%input#end_date.form-control.datepicker{ name: 'end_date', type: 'text', value: @end_date }
.col-md-4
%button.btn.btn-primary{ style: 'margin-top: 25px;'} Filter Trials
.pull-right
= link_to 'Back to Reports', admin_reports_path, class: 'btn btn-default'
%table.table.table-bordered.table-trials
%thead
%tr
%th System Id
%th Brief Title
%th Disease Sites
%th{nowrap: true} Last Updated
%tbody
- if @trials.empty?
Expand All @@ -26,6 +35,7 @@
%tr
%td= t.system_id
%td= t.display_title
%td= t.disease_sites.map { |d| "#{d.disease_site_name}" }.join('; ')
%td= t.updated_at.localtime.strftime('%m/%d/%Y')
= will_paginate @collection, renderer: BootstrapPagination::Rails

= link_to "Export to Excel", admin_trial_recent_as_path(format: :xls, start_date: params[:start_date], end_date: params[:end_date]), class: 'btn btn-success'
25 changes: 25 additions & 0 deletions app/views/admin/trials/recent_as.xls.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="conditions">
<Table>
<Row>
<Cell><Data ss:Type="String">System ID</Data></Cell>
<Cell><Data ss:Type="String">Brief Title</Data></Cell>
<Cell><Data ss:Type="String">Disease Sites</Data></Cell>
<Cell><Data ss:Type="String">Last Updated</Data></Cell>
</Row>
<% @trials.each do |t| %>
<Row>
<Cell><Data ss:Type="String"><%= t.system_id %></Data></Cell>
<Cell><Data ss:Type="String"><%= t.display_title %></Data></Cell>
<Cell><Data ss:Type="String"><%= t.disease_sites.map { |d| "#{d.disease_site_name}" }.join('; ') %></Data></Cell>
<Cell><Data ss:Type="String"><%= t.try(:updated_at).strftime('%m/%d/%Y') %></Data></Cell>
</Row>
<% end %>
</Table>
</Worksheet>
</Workbook>
10 changes: 10 additions & 0 deletions app/views/studies/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- c = determine_contacts(t)
= contacts_display(c)

- if t.respond_to?(:pi_name)
.field.important.nomargin
%label.single Principal Investigator:
%strong #{t.pi_name}

- if t.respond_to?(:pi_id)
.field.important.nomargin
%label.single Principal Investigator ID:
%strong #{t.pi_id}

.field.important.nomargin
%label.single Gender:
%strong
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCancerYnToStudyFinderTrials < ActiveRecord::Migration
def change
add_column :study_finder_trials, :cancer_yn, :string
end
end
6 changes: 6 additions & 0 deletions db/migrate/20180126133905_add_pi_to_study_finder_trials.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddPiToStudyFinderTrials < ActiveRecord::Migration
def change
add_column :study_finder_trials, :pi_name, :string
add_column :study_finder_trials, :pi_id, :string
end
end
18 changes: 13 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170220010712) do
ActiveRecord::Schema.define(version: 20180126133905) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -29,11 +29,16 @@
t.datetime "updated_at"
end

create_table "study_finder_disease_categories", force: :cascade do |t|
t.string "disease_category_name"
create_table "study_finder_disease_sites", force: :cascade do |t|
t.string "disease_site_name"
t.integer "group_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "study_finder_ds_trials", force: :cascade do |t|
t.integer "disease_site_id"
t.integer "trial_id"
end

create_table "study_finder_groups", force: :cascade do |t|
Expand Down Expand Up @@ -198,6 +203,9 @@
t.boolean "reviewed", default: false
t.integer "featured", default: 0
t.string "irb_number"
t.string "cancer_yn"
t.string "pi_name"
t.string "pi_id"
end

create_table "study_finder_updaters", force: :cascade do |t|
Expand Down

0 comments on commit f9c6565

Please sign in to comment.