<commit_before>require 'uom'

module CaTissue
  # Declares the classes modified for migration.
  shims Participant, TissueSpecimen, SpecimenCollectionGroup

  class Participant
    # Extracts the Participant first name from the +Initials+ input field.
    def migrate_first_name(value, row)
      value[0, 1]
    end

    # Extracts the Participant last name from the +Initials+ input field.
    def migrate_last_name(value, row)
      value[-1, 1]
    end
  end

  class TissueSpecimen
    # Transforms the +Frozen?+ flag input field to the caTissue specimen type +Frozen Tissue+ value.
    def migrate_specimen_type(value, row)
      'Frozen Tissue' if value =~ /TRUE/i
    end

    # Parses the source field as a UOM::Measurement if it is a string.
    # Otherwises, returns the source value.
    def migrate_initial_quantity(value, row)
      # if value is not a string, then use it as is
      return value unless value.is_a?(String)
      # the value has a unit qualifier; parse the measurement.
      # the unit is normalized to the Specimen standard unit.
      value.to_measurement_quantity(standard_unit)
    end
  end

  class SpecimenCollectionGroup
    # Returns whether this SCG has a SPN.
    def migration_valid?
      surgical_pathology_number
    end
  end
end<commit_msg>Default specimen type is Fixed.<commit_after>require 'uom'

module CaTissue
  # Declares the classes modified for migration.
  shims Participant, TissueSpecimen, SpecimenCollectionGroup

  class Participant
    # Extracts the Participant first name from the +Initials+ input field.
    def migrate_first_name(value, row)
      value[0, 1]
    end

    # Extracts the Participant last name from the +Initials+ input field.
    def migrate_last_name(value, row)
      value[-1, 1]
    end
  end

  class TissueSpecimen
    # Transforms the +Frozen?+ flag input field to the caTissue specimen type +Frozen Tissue+ value.
    def migrate_specimen_type(value, row)
      value =~ /TRUE/i ? 'Frozen Tissue' : 'Fixed Tissue'
    end

    # Parses the source field as a UOM::Measurement if it is a string.
    # Otherwises, returns the source value.
    def migrate_initial_quantity(value, row)
      # if value is not a string, then use it as is
      return value unless value.is_a?(String)
      # the value has a unit qualifier; parse the measurement.
      # the unit is normalized to the Specimen standard unit.
      value.to_measurement_quantity(standard_unit)
    end
  end

  class SpecimenCollectionGroup
    # Returns whether this SCG has a SPN.
    def migration_valid?
      surgical_pathology_number
    end
  end
end
{'fraction_non_alphanumeric': 0.05776587605202754, 'fraction_numerical': 0.00306044376434583, 'mean_word_length': 3.1706539074960127, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3433497', 'n_tokens_mistral': 805, 'n_tokens_neox': 761, 'n_words': 294}