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

Develop #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 76 additions & 3 deletions app/controllers/ref_consult_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,34 @@ class RefConsultRequestsController < ApplicationController
# GET /ref_consult_requests
# GET /ref_consult_requests.json
def index
@ref_consult_requests = RefConsultRequest.all

if params[:record_id].nil?
## list all patients
@ref_consult_requests = RefConsultRequest.all
@patient_names = Hash.new
@ref_consult_requests.each do |ref_consult_request|
if ref_consult_request.patientRecordId
record = Record.find( ref_consult_request.patientRecordId )
next if record.nil?
@patient_names["#{ref_consult_request.patientRecordId}"] = record.last.upcase + ', ' + record.first
end
end

else
## list refs for this patient only
@patient_names = Hash.new
@ref_consult_requests = []
ref_consults = RefConsultRequest.all().to_a
ref_consults.each do |ref_consult|
record = Record.find( ref_consult.patientRecordId )
next if record.nil?
if record.medical_record_number == params[:record_id]
@ref_consult_requests << ref_consult
@patient_names["#{ref_consult.patientRecordId}"] = record.last.upcase + ', ' + record.first
end
end

end

respond_to do |format|
format.html # index.html.erb
Expand All @@ -12,6 +39,32 @@ def index
end
end

# GET /ref_consult_requests/1
# GET /ref_consult_requests/1.json
def email
@ref_consult_request = RefConsultRequest.find( params[:id] )

end


# GET /ref_consult_requests/email/1
def email
@ref_consult_request = RefConsultRequest.find( params[:id] )

end

# GET /ref_consult_requests/sendemail/1
def send_email
@ref_consult_request = RefConsultRequest.find( params[:id] )
@record = Record.find( @ref_consult_request.patientRecordId ) if !@ref_consult_request.patientRecordId.nil?

PdsMail.consult(@ref_consult_request, @record).deliver ##
respond_to do |format|
format.html { redirect_to ref_consult_requests_url, notice: 'PDS Direct Email sent!' }
end
end


# GET /ref_consult_requests/1
# GET /ref_consult_requests/1.json
def show
Expand All @@ -22,10 +75,22 @@ def show
return
end
@record = Record.find( @ref_consult_request.patientRecordId ) if !@ref_consult_request.patientRecordId.nil?
@medications = @record.medications.map {|x| "http://direct.rhex.us:3000/records/#{@record.medical_record_number}/medications/#{x._id}" }
@conditions = @record.conditions.map {|x| "http://direct.rhex.us:3000/records/#{@record.medical_record_number}/conditions/#{x._id}" }
@vital_signs = @record.vital_signs.map {|x| "http://direct.rhex.us:3000/records/#{@record.medical_record_number}/vital_signs/#{x._id}" }
# @conditions = @record.conditions.map {|x| x.description }
# @medications = @record.medications.map {|x| x.description }
@vitals = @record.vital_signs.sort { |a,b| b.time <=> a.time }
@vitals.map! {|y| [ Time.at(y.time).strftime("%Y-%m-%d"), y.description.split(" ")[0], y.value['scalar']] }


respond_to do |format|
format.html # show.html.erb
format.json { render json: @ref_consult_request }
format.json { render json: { :ref_consult_requests => @ref_consult_request,
:conditions => @conditions,
:medications => @medications,
:vital_signs => @vital_signs }
}
format.xml { render xml: @ref_consult_request.to_xml }
end
end
Expand All @@ -41,18 +106,26 @@ def new
if params[:id]
@ref_consult_request.patientRecordId = params[:id]
@record = Record.find( @ref_consult_request.patientRecordId )
@conditions = @record.conditions.map {|x| x.description }
@medications = @record.medications.map {|x| x.description }
@vitals = @record.vital_signs.sort { |a,b| b.time <=> a.time }
@vitals.map! {|y| [ Time.at(y.time).strftime("%Y-%m-%d"), y.description.split(" ")[0], y.value['scalar']] }
end

respond_to do |format|
format.html # new.html.erb
format.json { render json: @ref_consult_request }
format.json { render json: { :ref_consult_requests => @ref_consult_request } }
end
end

# GET /ref_consult_requests/1/edit
def edit
@ref_consult_request = RefConsultRequest.find(params[:id])
@record = Record.find( @ref_consult_request.patientRecordId ) if @ref_consult_request.patientRecordId
@conditions = @record.conditions.map {|x| x.description }
@medications = @record.medications.map {|x| x.description }
@vitals = @record.vital_signs.sort { |a,b| b.time <=> a.time }
@vitals.map! {|y| [ Time.at(y.time).strftime("%Y-%m-%d"), y.description.split(" ")[0], y.value['scalar']] }
end

# POST /ref_consult_requests
Expand Down
22 changes: 22 additions & 0 deletions app/mailers/pds_mail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class PdsMail < ActionMailer::Base
#default from: "[email protected]"
add_template_helper(ApplicationHelper)

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.rhex_mail.consult.subject
#
def consult(ref_consult_request, record)
@ref_consult_request = ref_consult_request
@record = record
@greeting = "Hi"

begin
mail from: "[email protected]", to: "[email protected]", subject: "RHEx email from PDS - Consult REF##{@ref_consult_request.refNumber}"
rescue Exception=>e
puts e.inspect
end

end
end
3 changes: 2 additions & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<a href="/settings">Settings</a>
<a href="/audit_logs">Audit Log</a>
<a href="/notifications">Alerts</a>
<% end %>
<a href="/ref_consult_requests">Consult Requests</a>
<% end %>
<span id="logo">Patient Data Server</span>
<% unless current_user.nil? || current_user.username.nil? %>
<span id="user">Welcome, <%= current_user.username %></span>
Expand Down
29 changes: 29 additions & 0 deletions app/views/pds_mail/consult.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Dear <%= @ref_consult_request.requestedConsultingProviderId %>

The following email is a request for consultation regarding the patient below.
Please click on this link for more details:

<a href=http://localhost:3000/ref_consult_requests/<%= @ref_consult_request.id %>>Consult REF#<%= @ref_consult_request.refNumber %> </a>

Please checkout the following consult:


Date: <%= @ref_consult_request.refDate %>

Priority: <%= @ref_consult_request.priority %>

Reason: <%= @ref_consult_request.reasonText %>

Patient Name: <%= (@record.last.upcase + ',&nbsp;' + @record.first).html_safe if @record %>
Gender: <%= (@record.gender).html_safe if @record %>
Age: <%= getAgeText(@record.birthdate).html_safe if @record %>

Conditions: <%= @ref_consult_request.reasonConditionId %>

Specialty: <%= @ref_consult_request.requestedSpecialty %>

Specialist: <%= @ref_consult_request.requestedConsultingProviderId %>

Description: <%= @ref_consult_request.reasonDescription %>


25 changes: 19 additions & 6 deletions app/views/ref_consult_requests/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,32 @@

<tr><div class="field">
<td><%= f.label "Conditions:" %> </td>
<td><%= f.select :reasonConditionId, [ "DJD/Osteoarthritis, spine", "Diabetes Mellitus, Non-Insulin Dependent"], :prompt => 'Select...' %> </td>
<td><%= f.select :reasonConditionId, @conditions, :prompt => 'Select...' %> </td>
</div>
</tr>

<tr><div class="field">
<td><%= f.label "Specialty:" %> </td>
<td><%= f.select :requestedSpecialty, RefConsultRequest.get_requestedSpecialty_values, :prompt => 'Select Specialty...' %> </td>
<td><%= f.label "Medications:" %> </td>
<td><%= @medications.inspect %> </td>
</div>
</tr>

<tr><div class="field">
<td><%= f.label "Specialist:" %> </td>
<td><%= f.select :requestedConsultingProviderId, [ "Dr. Bill Schwartz", "Dr. Tom Jones"], :prompt => 'Select...' %> </td>
<tr><div class="field">
<td><%= f.label "Recent Vitals:" %> </td>
</tr>

<% cnt = 0
@vitals.each do |x| %>
<tr><td></td><td> <%= x.inspect %> </td>
<% break if cnt > 4
cnt += 1
end %>
</tr>
</div>
<p>
<tr><div class="field">
<td><%= f.label "Specialty:" %> </td>
<td><%= f.select :requestedSpecialty, RefConsultRequest.get_requestedSpecialty_values, :prompt => 'Select Specialty...' %> </td>
</div>
</tr>

Expand Down
100 changes: 100 additions & 0 deletions app/views/ref_consult_requests/email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<%= stylesheet_link_tag :common %>
<p id="notice"><%= notice %></p>


<table>
<tr>
<h2> <td><%= @ref_consult_request.reasonConditionId %> </td>
<td><%= @ref_consult_request.refNumber %> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </td>
<td>Status:</td>
<td> <%= @ref_consult_request.status %> </td> </h2>
</table>
<p>
Email this consult ?
<p>


<table>
<tr>
<div class="field">
<td>Date:</td>
<td><%= @ref_consult_request.refDate %> </td>
</div>
</tr>

<tr><div class="field">
<td>Priority: </td>
<td><%= @ref_consult_request.priority %> </td>
</div>
</tr>

<tr><div class="field">
<td>Reason:</td>
<td><%= @ref_consult_request.reasonText %> </td>
</div>
</tr>



<tr><div class="field">
<td>Patient Name: &nbsp;&nbsp;&nbsp; </td>
<td><%= (@record.last.upcase + ',&nbsp;' + @record.first).html_safe if @record %></td>
</div>
</tr>

<tr><div class="field">
<td>Insurance:</td>
<td></td>
</div>
</tr>

<tr><div class="field">
<td>Gender: </td>
<td><%= (@record.gender).html_safe if @record %></td>

</div>
</tr>

<tr><div class="field">
<td>Age:</td>
<td><%= getAgeText(@record.birthdate).html_safe if @record %></td>
</div>
</tr>


<tr><div class="field">
<td>Conditions: </td>
<td><%= @ref_consult_request.reasonConditionId %> </td>
</div>
</tr>

<tr><div class="field">
<td>Specialty: </td>
<td><%= @ref_consult_request.requestedSpecialty %> </td>
</div>
</tr>

<tr><div class="field">
<td>Specialist: </td>
<td><%= @ref_consult_request.requestedConsultingProviderId %> </td>
</div>
</tr>

<tr><div class="field">
<td>Description:</td>
<td><%= @ref_consult_request.reasonDescription %></td>
</div>
</tr>

<tr></tr>

<div class="actions">
<td></td>
<td><%= link_to 'Send Email', send_email_ref_consult_request_path(@ref_consult_request) %>
<%= link_to 'Back', ref_consult_requests_path %> </td>
</div>
</tr>

</table>


10 changes: 6 additions & 4 deletions app/views/ref_consult_requests/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<%= stylesheet_link_tag :common %>
<p id="notice"><%= notice %></p>

<h1>Consults You've Initiated</h1>

To initiate a consult, search for a patient and then press the
Expand All @@ -13,7 +16,6 @@ Or, you can click create consult request and then select the patient from the Pa
<th colspan="2">Reason</th>
<th>Patient</th>
<th>Status</th>
<th>Specialist</th>
</tr>

<% @ref_consult_requests.each do |ref_consult_request| %>
Expand All @@ -22,14 +24,14 @@ Or, you can click create consult request and then select the patient from the Pa
<td><%= ref_consult_request.refNumber %></td>
<td><%= ref_consult_request.priority %></td>
<td colspan="2"><%= ref_consult_request.reasonText %></td>
<td>Fred Smith</td>
<td><%= @patient_names[ref_consult_request.patientRecordId] if ref_consult_request.patientRecordId %></td>
<td><%= ref_consult_request.status %></td>
<td><%= ref_consult_request.requestedConsultingProviderId %></td>

<td><%= link_to 'Show', ref_consult_request %></td>
<td><%= link_to 'Edit', edit_ref_consult_request_path(ref_consult_request) %></td>
<td><%= link_to 'Destroy', ref_consult_request, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<td><%= link_to 'Email Request w/Direct', email_ref_consult_request_path(ref_consult_request) %></td>
</tr>
<% end %>
</table>

Expand Down
26 changes: 20 additions & 6 deletions app/views/ref_consult_requests/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ Your consult request has been submitted for authorization by the insurance provi
</div>
</tr>

<tr><div class="field">
<td>Medications:</td>
<td><%= @medications.inspect %> </td>
</div>
</tr>

<tr><div class="field">
<td>Recent Vitals:</td>
</tr>

<% cnt = 0
@vitals.each do |x| %>
<tr><td></td><td> <%= x.inspect %> </td>
<% break if cnt > 4
cnt += 1
end %>
</tr>
</div>


<tr><div class="field">
<td>Gender: </td>
<td><%= (@record.gender).html_safe if @record %></td>
Expand All @@ -72,12 +92,6 @@ Your consult request has been submitted for authorization by the insurance provi
<td>Specialty: </td>
<td><%= @ref_consult_request.requestedSpecialty %> </td>
</div>
</tr>

<tr><div class="field">
<td>Specialist: </td>
<td><%= @ref_consult_request.requestedConsultingProviderId %> </td>
</div>
</tr>

<tr><div class="field">
Expand Down
Loading