forked from project-rhex/patient-data-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
451 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ db/*.sqlite3 | |
log/*.log | ||
tmp/ | ||
.sass-cache/ | ||
.idea | ||
.rvmrc* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
before_filter :authenticate_user! | ||
|
||
|
||
#before_filter :audit_log, :find_record | ||
before_filter :find_record | ||
|
||
private | ||
|
||
def find_record | ||
record_id = params[:record_id] || params[:id] | ||
@record = Record.first(conditions: {medical_record_number: record_id}) | ||
render file: "public/404.html", :status => :not_found unless @record | ||
##render file: "public/404.html", :status => :not_found unless @record | ||
end | ||
end | ||
|
||
def audit_log | ||
AuditLog.create(:username => "gganley", :event => "doc read", :description => "this is a desc"); | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class AuditLogsController < ApplicationController | ||
|
||
#before_filter :authenticate_user! | ||
#before_filter :validate_authorization! | ||
##add_breadcrumb 'access logs', '/logs' | ||
|
||
# All attributes of the AuditLog class are valid to sort on except ones that start with an underscore. | ||
VALID_SORTABLE_COLUMNS = AuditLog.fields.keys.reject {|k| k[0] == '_'} | ||
VALID_SORT_ORDERS = ['desc', 'asc'] | ||
|
||
def index | ||
order = [] | ||
if VALID_SORTABLE_COLUMNS.include?(params[:sort]) && VALID_SORT_ORDERS.include?(params[:order]) | ||
order << [params[:sort].to_sym, params[:order].to_sym] | ||
end | ||
|
||
# If no valid order is specified, order by date | ||
# If anything else is provided as a sort order, make date a secondary order | ||
if order.empty? || order[0][0] != :created_at | ||
order << [:created_at, :desc] | ||
end | ||
|
||
where = {} | ||
##where[:username] = current_user.username unless current_user.admin? | ||
|
||
start_date = date_param_to_date(params[:log_start_date]) | ||
if start_date | ||
where[:created_at] = {'$gte' => start_date} | ||
end | ||
|
||
end_date = date_param_to_date(params[:log_end_date]) | ||
if end_date | ||
# will create an empty hash if created_at is nil or leave start_date alone if it is there | ||
where[:created_at] ||= {} | ||
where[:created_at].merge!('$lt' => end_date.next_day) # becomes less than midnight the next day | ||
end | ||
|
||
@audit_logs = AuditLog.where(where).order_by(order) ##.paginate(:page => params[:page], :per_page => 20) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @audit_logs } | ||
end | ||
|
||
end | ||
|
||
private | ||
|
||
def date_param_to_date(date_string) | ||
if date_string && date_string.split('/').length == 3 | ||
split_date = date_string.split('/').map(&:to_i) | ||
Date.new(split_date[2], split_date[0], split_date[1]) | ||
else | ||
nil | ||
end | ||
end | ||
|
||
#def validate_authorization! | ||
# authorize! :read, Log | ||
#end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class AuthenticationsController < | ||
def index | ||
@authentications = current_user.authentications if current_user | ||
end | ||
|
||
def create | ||
auth = request.env["omni.auth"] | ||
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid']) | ||
flash[:notice] = "Authentication successful." | ||
redirect_to authentications_url | ||
end | ||
|
||
def destroy | ||
@authentication = current_user.authentications.find(params[:id]) | ||
@authentication.destroy | ||
flash[:notice] = "Successfully destroyed authentication." | ||
redirect_to authentications_url | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
class C32Controller < ApplicationController | ||
|
||
respond_to :xml, :json, :atom | ||
|
||
def index | ||
|
||
respond_to do |wants| | ||
wants.atom {} | ||
end | ||
end | ||
|
||
def show | ||
respond_to do |wants| | ||
wants.xml { render xml: HealthDataStandards::Export::C32.export(@record) } | ||
end | ||
respond_with(@record) | ||
end | ||
|
||
end |
Oops, something went wrong.