MakersNetwork/agenda-saude

View on GitHub
app/views/admin/patients/show.html.erb

Summary

Maintainability
Test Coverage
<div class="row">
  <div class="col-10">
    <h1 class="h4">
      Paciente: <%= @patient.name %>
    </h1>
  </div>

  <div class="col-2">
    <%= link_to "Editar", edit_admin_patient_path(@patient), class: 'btn btn-primary btn-block' %>
  </div>
</div>

<p>
  <% if @patient.locked? -%>
    Paciente bloqueado.
    <%= link_to "Desbloquear", unblock_admin_patient_path(id: @patient.id), method: :patch,
                class: "btn btn-secondary " %>
  <% end -%>
</p>

<div class='row'>
  <div class='col'>
    <strong>Nome completo:</strong> <%= @patient.name %>
  </div>

  <div class='col'>
    <strong>CPF:</strong> <%= ApplicationHelper.humanize_cpf(@patient.cpf) %>
  </div>

  <div class='col'>
    <strong>Data de Nascimento:</strong> <%= l(@patient.birthday) %>
  </div>
</div>

<div class='row'>
  <div class='col'>
    <strong>Nome da mãe:</strong> <%= @patient.mother_name %>
  </div>

  <div class='col'>
    <strong>Bairro:</strong> <%= @patient.neighborhood.name %>
  </div>

  <div class='col'>
    <strong>Telefones:</strong> <%= @patient.phones %>
  </div>
</div>

<div class="card mt-4 mb-4">
  <div class="card-header">
    <h4>Grupos que pertence</h4>
  </div>
  <div class="card-body">
    <% if @patient.groups.any? -%>
      <table class="table">
        <thead>
        <tr>
          <th scope="col" width="1%">#</th>
          <th scope="col">Grupo</th>
        </tr>
        </thead>
        <tbody>
        <% @patient.groups.admin_order.each do |group| -%>
          <tr>
            <td>
              <%= group.id %>
            </td>
            <td>
              <%= group.name_with_parent %>
            </td>
          </tr>
        <% end -%>
        </tbody>
      </table>
    <% else -%>
      <p>Não preencheu nenhum grupo.</p>
    <% end -%>
  </div>
</div>

<div class="card mt-4 mb-4">
  <div class="card-header">
    <h4>Agendamentos</h4>
  </div>
  <div class="card-body">
    <% if @patient.appointments.any? -%>
      <p>Clique no # do agendamento para realizar procedimentos no mesmo.</p>
      <table class="table">
        <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">Data agendada</th>
          <th scope="col">Unidade</th>
          <th scope="col">Check-in</th>
          <th scope="col">Check-out</th>
          <th scope="col">Dose</th>
          <th scope="col">Vacina</th>
          <th scope="col">Suspenso?</th>
          <th scope="col">Criou dose #</th>
        </tr>
        </thead>
        <tbody>

        <% @patient.appointments.order(:start).each do |appointment| -%>
          <tr>
            <td>
              <%= link_to appointment.id, admin_appointment_path(appointment) %>
            </td>
            <th scope="row">
              <strong><%= l(appointment.start, format: :human) %></strong>
            </th>
            <td>
              <%= appointment.ubs.name %>
            </td>
            <td>
              <% if appointment.checked_in? -%>
                <%= l(appointment.check_in, format: :human) %>
              <% end -%>
            </td>
            <td>
              <% if appointment.checked_out? -%>
                <%= l(appointment.check_out, format: :human) %>
              <% end -%>
            </td>
            <td>
              <%= appointment.dose_sequence_number %>
            </td>
            <td>
              <%= appointment.dose_vaccine&.name %>
            </td>
            <td>
              <%= appointment.active ? "Não" : "Sim" %>
            </td>
            <td>
              <% if appointment.dose -%>
                <%= appointment.dose.id %>
              <% end -%>
            </td>
          </tr>
        <% end -%>
        </tbody>
      </table>
    <% else -%>
      <p>Paciente sem nenhum agendamento.</p>
    <% end -%>
  </div>
</div>

<div class="card mt-4 mb-4">
  <div class="card-header">
    <div class="row">
      <div class="col-10">
        <h1 class="h4">
          Doses de vacinas
        </h1>
      </div>
      <div class="col-2">
        <%= link_to "Registrar dose", new_admin_appointment_path(patient_id: @patient.id), class: 'btn btn-success' %>
      </div>
    </div>
  </div>

  <div class="card-body mb-5">
    <% if @patient.doses.any? -%>
      <p>
        Caso deseje remover uma dose registrada incorretamente, vá no agendamento onde ocorreu a vacinação e clique para desfazer o check-out do mesmo.
      </p>

      <table class="table">
        <thead>
        <tr>
          <th scope="col" width="1%">#</th>
          <th scope="col">Data da aplicação</th>
          <th scope="col">Unidade</th>
          <th scope="col">Vacina</th>
          <th scope="col">Dose</th>
          <th scope="col">Agendamento #</th>
          <th scope="col">Reforço #</th>
        </tr>
        </thead>
        <tbody>

        <% @patient.doses.order(:created_at).each do |dose| -%>
          <tr>
            <td>
              <%= dose.id %>
            </td>
            <th scope="row">
              <strong><%= l(dose.created_at, format: :human) %></strong>
            </th>
            <td>
              <%= dose.appointment.ubs.name %>
            </td>
            <td>
              <%= dose.vaccine.name %>
            </td>
            <td>
              <%= dose.sequence_number %><sup>a</sup>
            </td>
            <td>
              <%= link_to dose.appointment.id, admin_appointment_path(dose.appointment) %>
            </td>
            <td>
              <% if dose.follow_up_appointment -%>
                <%= link_to dose.follow_up_appointment.id, admin_appointment_path(dose.follow_up_appointment) %>
              <% end -%>
            </td>
          </tr>
        <% end -%>
        </tbody>
      </table>
    <% else -%>
      <p>Paciente sem nenhuma vacina.</p>
    <% end -%>
  </div>
</div>

<p>
  <%= link_to "Voltar", admin_patients_path %>
</p>