<commit_before>-# Copyright (C) 2007, 2008, 2009 The Collaborative Software Foundation
-#
-# This file is part of TriSano.
-#
-# TriSano is free software: you can redistribute it and/or modify it under the terms of the
-# GNU Affero General Public License as published by the Free Software Foundation, either 
-# version 3 of the License, or (at your option) any later version.
-#
-# TriSano is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-# See the GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License along with TriSano. 
-# If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

-# Display the search results of a contact live search
%br
- if defined? @events
  -if @events.empty?
    %b No results
  -else
    %table.list
      %tr
        %th Name
        %th Birth Date
        %th Gender
        %th Event Type
        %th Jurisdiction
        %th Created Date
        %th Disease
        %th Actions
      - previous_entity_id = nil
      - for event in @events do
        - current_entity_id = event.interested_party.person_entity.id
        - if previous_entity_id != current_entity_id
          - output_name = true
          - previous_entity_id = current_entity_id
        - else
          - output_name = false

        - jurisdictions = event.all_jurisdictions.collect { | participation | participation.secondary_entity_id }
        - can_update = User.current_user.is_entitled_to_in?(:update_event, jurisdictions)
        - can_view   = User.current_user.is_entitled_to_in?(:view_event,   jurisdictions)
        %tr
          %td 
            = event.party.last_comma_first if output_name
          %td
            = event.party.birth_date if output_name
          %td
            = l event.party.birth_gender if output_name
          %td= event['type'].underscore.humanize 
          %td= event.primary_jurisdiction.short_name
          %td= event.event_onset_date
          - if can_update || can_view
            %td= event.safe_call_chain(:disease_event, :disease, :disease_name)
          - else
            %td Private
          %td
            - fields_for(:morbidity_event, MorbidityEvent.new, :builder => ExtendedFormBuilder) do |f|
              - contact_event = ContactEvent.new
              - contact_event.build_interested_party(:primary_entity_id => event.interested_party.primary_entity_id)
              - contact_event.build_participations_contact
              - contact_event.interested_party.person_entity.telephones.build if contact_event.interested_party.person_entity.telephones.empty?
              = add_record_link f, :contact_child_events, "Add contact", :object => contact_event, :partial => "events/contact_from_search"
%hr
<commit_msg>Fixes bug where searching for contacts in a CMR blowed up<commit_after>-# Copyright (C) 2007, 2008, 2009 The Collaborative Software Foundation
-#
-# This file is part of TriSano.
-#
-# TriSano is free software: you can redistribute it and/or modify it under the terms of the
-# GNU Affero General Public License as published by the Free Software Foundation, either 
-# version 3 of the License, or (at your option) any later version.
-#
-# TriSano is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-# See the GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License along with TriSano. 
-# If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

-# Display the search results of a contact live search

%br
- if defined? @events
  -if @events.empty?
    %b No results
  -else
    %table.list
      %tr
        %th Name
        %th Birth Date
        %th Gender
        %th Event Type
        %th Jurisdiction
        %th Created Date
        %th Disease
        %th Actions
      - previous_entity_id = nil
      - for event in @events do
        - if (event['deleted_at'].nil?)
          - result_class = 'search-active tabular'
        - else
          - result_class = 'search-inactive tabular'
        - current_entity_id = event['entity_id']
        - if previous_entity_id != current_entity_id
          - output_name = true
          - previous_entity_id = current_entity_id
        - else
          - output_name = false

        - jurisdictions = pg_array(event['secondary_jurisdictions']) << event['jurisdiction_entity_id']
        - can_update = User.current_user.is_entitled_to_in?(:update_event, jurisdictions)
        - can_view   = User.current_user.is_entitled_to_in?(:view_event,   jurisdictions)
        %tr{:class => result_class, :id => "event_#{event['id']}"}
          %td 
            = "#{event['last_name']}, #{event['first_name']}" if output_name
          %td
            = event['birth_date'] if output_name
          %td
            = event['birth_gender'] if output_name
          %td= event['event_type'].underscore.humanize 
          %td= event['jurisdiction_short_name']
          %td= event['event_onset_date']
          - if can_update || can_view
            %td= event['disease_name']
          - else
            %td Private
          %td
            - fields_for(:morbidity_event, MorbidityEvent.new, :builder => ExtendedFormBuilder) do |f|
              - contact_event = ContactEvent.new
              - contact_event.build_interested_party(:primary_entity_id => event.interested_party.primary_entity_id)
              - contact_event.build_participations_contact
              - contact_event.interested_party.person_entity.telephones.build if contact_event.interested_party.person_entity.telephones.empty?
              = add_record_link f, :contact_child_events, "Add contact", :object => contact_event, :partial => "events/contact_from_search"
%hr

{'fraction_non_alphanumeric': 0.08665105386416862, 'fraction_numerical': 0.005018400802944129, 'mean_word_length': 2.565295169946333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5557612', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1685, 'n_words': 497}