JuanVqz/doctors

View on GitHub
app/views/appointments/show.html.haml

Summary

Maintainability
Test Coverage
= render 'shared/section' do
  .flex.flex-col.md:flex-row.space-y-2.md:space-y-0.md:space-x-2
    = link_to :back, class: secondary_button do
      %span.fa.fa-arrow-left
      %span= t('.back')
    = link_to edit_appointment_path(@appointment), data: { tooltip: t('tooltips.defaults.edit') }, class: "#{secondary_button} tooltip tooltip-top" do
      %span.fa.fa-edit.text-yellow-600
      %span= t('tooltips.defaults.edit')
    = link_to appointment_path(@appointment, format: :pdf), data: { tooltip: t('tooltips.defaults.print') }, class: "#{secondary_button} tooltip tooltip-top", target: :_blank do
      %span.fa.fa-print.text-red-600
      %span= t('tooltips.defaults.print')
    = link_to new_appointment_path(patient_id: @appointment.patient_id), data: { tooltip: t('tooltips.appointments.new') }, class: "#{secondary_button} tooltip tooltip-top" do
      %span.fa.fa-book
      %span= t('tooltips.appointments.new')
    = link_to new_hospitalization_path(patient_id: @appointment.patient_id), data: { tooltip: t('tooltips.hospitalizations.new') }, class: "#{secondary_button} tooltip tooltip-top" do
      %span.fa.fa-ambulance
      %span= t('tooltips.hospitalizations.new')


= render 'shared/section' do
  = render 'shared/title', title: t('.identifier', model: t('shared.actions.appointment.one', count: 1), id: @appointment.id)
  .grid.gap-2.grid-rows-1.grid-flow-row
    - @appointment.attributes.slice('patient_id', 'reason', 'note', 'prescription', 'recommendations', 'cabinet_results', 'histopathology', 'created_at').map do |key, value|
      - if value.present?
        %dl
          %dt.text-sm.text-gray-400.my-2= t("activerecord.attributes.appointment.#{key}")
          - if key.eql?('patient_id')
            %dd= @appointment.patient
          - elsif key.eql?('created_at')
            %dd= value.to_date
          - else
            %dd= raw value

  .grid.gap-2.grid-rows-1.grid-flow-row.md:grid-flow-col
    - @appointment.attributes.slice('height', 'weight', 'imc', 'blood_pressure', 'glycaemia', 'sat_02', 'heart_rate', 'breathing_rate', 'temperature', 'cost').map do |key, value|
      - if value.present?
        %dl
          %dt.text-sm.text-gray-400.my-2= t("activerecord.attributes.appointment.#{key}")
          - if key.eql?('height')
            %dd= height_for_human @appointment
          - elsif key.eql?('weight')
            %dd= weight_for_human @appointment
          - elsif key.eql?('imc')
            %dd= imc_for_human @appointment
          - elsif key.eql?('temperature')
            %dd= temperature @appointment
          - else
            %dd= raw value

= render 'shared/section' do
  = render 'patients/general', patient: @appointment.patient

= render 'shared/section' do
  = render 'patients/clinic_history', patient: @appointment.patient

- if @appointment.files.attached?
  = render 'shared/section' do
    = render 'shared/title', title: t('.files')
    .grid.gap-2.grid-rows-1.grid-flow-row.md:grid-flow-cols-2
      - @appointment.files.each do |file|
        %dl
          %dt.text-sm.my-2
            = link_to rails_blob_path(file, disposition: :attachment) do
              = image_tag rails_storage_proxy_path(file), class: 'object-scale-down'