Skip to content

Instantly share code, notes, and snippets.

@Haguilar91
Created December 11, 2019 19:11
Show Gist options
  • Save Haguilar91/3cbd9811663f029a0ef55dd47cc6fd4e to your computer and use it in GitHub Desktop.
Save Haguilar91/3cbd9811663f029a0ef55dd47cc6fd4e to your computer and use it in GitHub Desktop.
<% if current_doctor %>
<!--Ficha va aqui-->
<%conversation = current_member.mailbox.conversations.find(params[:id])%>
<div class="jumbotron">
<h1>Informacion de Paciente</h1>
<p>Edad: <%=@user.age%></p>
<p>Resumen del paciente: </p>
<p><%=@user.username%></p>
<p> Ingresar notas: </p>
<%=conversation.id%>
</div>
<div class="container">
<%= form_with model: @note, url: notes_path,:method => :POST, local: true do |f| %>
<%= f.hidden_field(:doctor_id, :value => current_doctor.id)%>
<%= f.hidden_field(:user_id, :value => @user.id)%>
<%= f.rich_text_area :body %>
<%= f.submit%>
<% end %>
</div>
<!--Ficha termina aqui-->
<%end%>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-10">
<div class="jumbotron">
<h1 class="display-4">Consulta en linea</h1>
<% recipient = @conversation.participants.find { |p| p != current_member } %>
<p class="lead"><span class="text-dark"><%=recipient.name%></span> y <span class="text-primary"><%=current_member.name%> (yo)</span></p>
<hr class="my-4">
<p><%=@conversation.subject %></p>
</div>
</div>
<div class="col-md-1">
</div>
</div>
<div class="row">
<div class="col-md-1" style="background-color:blue;">
</div>
<div class="col-md-5" style="background-color:red;">
<!--Chat va aqui-->
<div class="form-group">
<div class="scrolleame bg-light">
<section>
<% @conversation.receipts_for(current_member).each do |receipt|%>
<p><%= receipt.message.sender.name%> dijo: &nbsp; <%= receipt.message.body%></p>
<%end%>
<div id="msg">
</div>
</section>
</div>
<hr>
<%= form_tag conversation_messages_path(@conversation), method: :post do%>
<div class="container-fluid ">
<%= text_area_tag :body,nil, class: "form-control-lg", id:"sample5", placeholder: "Introduce un mensaje...", :rows => 10, style: 'width:100%;' %>
</div >
<button class="btn btn-outline-success bg-dark" id="tte">
<i class="fa fa-paper-plane" aria-hidden="true"></i>
&nbsp; Enviar
</button>
<%end%>
<!--Chat termina aqui-->
</div>
</div>
<div class="col col-md-4" style="background-color:blueviolet;">
<%= render "walls/notes.html.erb"%>
</div>
<div class="col col-md-1" style="background-color:yellow;">
</div>
</div>
</div>
</div>
</div>
class ConversationsController < ApplicationController
before_action :authenticate_member!
def index
@conversations = current_member.mailbox.conversations
end
def show
@conversation = current_member.mailbox.conversations.find(params[:id])
@user = User.find_by_id(@conversation.participants.find { |p| p != current_doctor })
if(Note.find_by user_id: @user.id)
@note=Note.find_by user_id: @user.id
else
@note=Note.new
end
end
def new
@recipients = Doctor.find_by_id(params[:doctor_id])
recipient = Doctor.find(params[:doctor_id])
end
def create
recipient = Doctor.find(params[:user_id])
receipt = current_member.send_message(recipient, params[:body],params[:subject])
redirect_to conversation_path(receipt.conversation)
end
end
class NotesController < ApplicationController
before_action :set_note, only: [:show, :edit, :update, :destroy]
# GET /notes
# GET /notes.json
def index
@notes = Note.all
end
# GET /notes/1
# GET /notes/1.json
def show
end
# GET /notes/new
def new
@note = Note.new
end
# GET /notes/1/edit
def edit
end
# POST /notes
# POST /notes.json
def create
@note = Note.new(note_params)
respond_to do |format|
if @note.save
format.html { redirect_to @note, notice: 'Note was successfully created.' }
format.json { render :show, status: :created, location: @note }
else
format.html { render :new }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /notes/1
# PATCH/PUT /notes/1.json
def update
respond_to do |format|
if @note.update(note_params)
format.html { redirect_to @note, notice: 'Note was successfully updated.' }
format.json { render :show, status: :ok, location: @note }
else
format.html { render :edit }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
end
# DELETE /notes/1
# DELETE /notes/1.json
def destroy
@note.destroy
respond_to do |format|
format.html { redirect_to notes_url, notice: 'Note was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_note
@note = Note.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def note_params
params.require(:note).permit(:title, :user_id, :doctor_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment