<commit_before>ruby:
  view = options.current_view
  attribute_names = options.patients.first.class.columns.map(&:name) - %w(id secure_id document)
  attribute_names = (view.columns.map(&:code) + attribute_names).uniq
  columns = attribute_names.map do |attr|
    view.columns.detect{ |col| col.code == attr } || Renalware::System::ColumnDefinition.new(code: attr, hidden: false)
  end
  # TODO move to a helper or view object
  # Sort column headers and remove hidden ones.
  # attrs = options.patients.first.class.columns.map(&:name) - %w(id secure_id document)
  # use the older of cols in view.columns to sort attrs - works even if only a few cols are in view.columns
  #if options.current_view.columns.present?
  #  attrs = options.current_view.columns & attrs
  #end

table
  thead
    tr
      th.col-width-tiny
      - columns.each do |col|
        - code = col.code
        - klasses = []
        - klasses << "col-width-date" if code.end_with?("_date") || code.end_with?("_on")
        - klasses << "col-width-date-time" if code.end_with?("_at")
        - klasses << "col-width-nhs-no" if code == "nhs_number"
        - klasses << "col-width-tiny" if code == "sex"
        - klasses << "col-width-tiny" if code == "age"
        - klasses << "col-width-large" if code == "patient_name"
        - if klasses.empty? && col.width.present?
          - klasses << "col-width-#{col.width}"

        - next if col.hidden
        th(class=klasses.join(" "))
          = sort_link(options.search, col.code, col.title)
      th
        / empty to allow tabl;e to expand to the right
  tbody
    - options.patients.each do |patient|
      tr
        td.actions
          = link_to options.view_proc.call(patient), target: "_blank" do
            i.fa.fa-external-link-square-alt
            | &nbsp;&nbsp;
            | MDM
        - columns.each do |col|
          - next if col.hidden
          - klass = "col-width-#{col.width}-with-ellipsis" if col.truncate
          - code = col.code
          - value = patient.attributes[code]
          - if code == "patient_name"
            td= default_patient_link(patient)
          - else
            - if value.respond_to?(:strftime)
              - value = l(value)

            / Add title attribute if the cell content is truncated, so its possible to see the
            / entire content if you hover
            - title = value if col.truncate

            / Boolean values we will show as a tick icon
            td(class=klass title=title)
              - if value == true || value == "Y"
                i.far.fa-check-circle.text-green-700
              - elsif value == false || value == "N"
                i.far.fa-circle.text-gray-400
              - else
                = value
        td
          / empty to allow table to expand to the right

/= paginate options.patients
== pagy_foundation_nav options.pagination<commit_msg>Fix truncation of column values on patient MDM list<commit_after>ruby:
  view = options.current_view
  attribute_names = options.patients.first.class.columns.map(&:name) - %w(id secure_id document)
  attribute_names = (view.columns.map(&:code) + attribute_names).uniq
  columns = attribute_names.map do |attr|
    view.columns.detect{ |col| col.code == attr } || Renalware::System::ColumnDefinition.new(code: attr, hidden: false)
  end
  # TODO move to a helper or view object
  # Sort column headers and remove hidden ones.
  # attrs = options.patients.first.class.columns.map(&:name) - %w(id secure_id document)
  # use the older of cols in view.columns to sort attrs - works even if only a few cols are in view.columns
  #if options.current_view.columns.present?
  #  attrs = options.current_view.columns & attrs
  #end

table
  thead
    tr
      th.col-width-tiny
      - columns.each do |col|
        - code = col.code
        - klasses = []
        - klasses << "col-width-date" if code.end_with?("_date") || code.end_with?("_on")
        - klasses << "col-width-date-time" if code.end_with?("_at")
        - klasses << "col-width-nhs-no" if code == "nhs_number"
        - klasses << "col-width-tiny" if code == "sex"
        - klasses << "col-width-tiny" if code == "age"
        - klasses << "col-width-large" if code == "patient_name"
        - if klasses.empty? && col.width.present?
          - klasses << "col-width-#{col.width}"

        - next if col.hidden
        th(class=klasses.join(" "))
          = sort_link(options.search, col.code, col.title)
      th
        / empty to allow tabl;e to expand to the right
  tbody
    - options.patients.each do |patient|
      tr
        td.actions
          = link_to options.view_proc.call(patient), target: "_blank" do
            i.fa.fa-external-link-square-alt
            | &nbsp;&nbsp;
            | MDM
        - columns.each do |col|
          - next if col.hidden
          - klass = "col-width-#{col.width} with-ellipsis" if col.truncate
          - code = col.code
          - value = patient.attributes[code]
          - if code == "patient_name"
            td= default_patient_link(patient)
          - else
            - if value.respond_to?(:strftime)
              - value = l(value)

            / Add title attribute if the cell content is truncated, so its possible to see the
            / entire content if you hover
            - title = value if col.truncate

            / Boolean values we will show as a tick icon
            td(class=klass title=title)
              - if value == true || value == "Y"
                i.far.fa-check-circle.text-green-700
              - elsif value == false || value == "N"
                i.far.fa-circle.text-gray-400
              - else
                = value
        td
          / empty to allow table to expand to the right

== pagy_foundation_nav options.pagination
{'fraction_non_alphanumeric': 0.11888716087782962, 'fraction_numerical': 0.002073613271124935, 'mean_word_length': 1.9958592132505175, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '365687', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1757, 'n_words': 470}