MakersNetwork/agenda-saude

View on GitHub
app/views/operator/appointments/index.html.erb

Summary

Maintainability
Test Coverage
<%= render "operator/shared/ubs_nav" %>

<% if @appointments.any? %>
  <table class="table table-hover">
    <thead>
      <tr>
        <th scope="col">Horário</th>
        <th scope="col">Paciente</th>
        <th scope="col">Telefones</th>
        <th scope="col"></th>
      </tr>
    </thead>
    <tbody>
      <% @appointments.each do |appointment| -%>
        <tr data-cy="appointment">
          <th scope="row" class="align-middle">
            <%= l appointment.start, format: :short_hour %>
          </th>
          <td class="align-middle">
            <%= link_to appointment.patient.name, admin_appointment_path(appointment, return_to: request.url) %>
            <br>
            <small class="badge bg-light text-dark" data-cy="patientCpf"><%= ApplicationHelper.humanize_cpf appointment.patient.cpf %></small>
            <% if appointment.follow_up_for_dose -%>
              <small class="badge bg-success text-light">
                <%= appointment.follow_up_for_dose.next_sequence_number %><sup>a</sup> dose
                <%= appointment.follow_up_for_dose.vaccine.name %>
              </small>
            <% else -%>
              <small class="badge bg-info text-light">
                1<sup>a</sup> dose
              </small>
            <% end -%>
          </td>
          <td class="align-middle">
            <small class="text-muted">
              <%= appointment.patient.phones %>
            </small>
          </td>
          <td class="align-middle">
            <%
              case appointment.state
              when :suspended
            -%>
              <%= link_to "Reativar", admin_appointment_path(appointment, return_to: request.url), class: "btn btn-block btn-warning" %>
            <% when :checked_out -%>
              <%= link_to "Vacinado", admin_appointment_path(appointment, return_to: request.url), class: "btn btn-block btn-light" %>
            <% when :checked_in -%>
              <%= link_to "Check-out", admin_appointment_path(appointment, return_to: request.url), class: "btn btn-block btn-success" %>
            <% when :waiting -%>
              <%= link_to "Check-in", admin_appointment_path(appointment, return_to: request.url), class: "btn btn-block btn-primary" %>
            <% end -%>
          </td>
        </tr>
      <% end -%>
    </tbody>
  </table>

  <div>
    <%= paginate @appointments %>
  </div>

  <div class="container">
    <div class="row">
      <div class="col mt-5">
        <%= link_to 'Exportar agendamentos do dia',
                    operator_ubs_appointments_path(@ubs, filter: nil, search: nil, per_page: 10_000, format: :xlsx),
                    class: 'btn btn-block btn-outline-primary',
                    data: { confirm: "Tem certeza que deseja exportar agendamentos de hoje para planilha do Excel?" } %>
      </div>
    </div>
  </div>
<% else -%>
  <h3 data-cy="noAppointmentsText">Nenhum agendamento com os critérios selecionados para este dia.</h3>
<% end -%>