<commit_before>#	==	requires
#	*	subject_type_id
#	*	race_id
class Subject < Shared

#	belongs_to :hispanicity
	belongs_to :race
	belongs_to :subject_type
	belongs_to :vital_status

	with_options :foreign_key => 'study_subject_id' do |f|
		f.has_and_belongs_to_many :analyses
		f.has_many :addressings
		f.has_many :enrollments
		f.has_many :gift_cards
		f.has_many :phone_numbers
		f.has_many :samples
		f.has_one :identifier
		f.has_one :home_exposure_response
		f.has_one :homex_outcome
		f.has_one :patient
		f.has_one :pii
		f.with_options :conditions => ["projects.code = 'HomeExposures'"], :include => :project do |p|
			p.has_one :hx_enrollment, :class_name => "Enrollment"
			p.has_one :hx_gift_card,  :class_name => "GiftCard"
		end
	end

	has_many :addresses, :through => :addressings
	accepts_nested_attributes_for :gift_cards

	validates_presence_of :subject_type
	validates_presence_of :race
	validates_presence_of :subject_type_id
	validates_presence_of :race_id

	validates_inclusion_of :do_not_contact, :in => [ true, false ]

	with_options :allow_nil => true do |n|
		n.validates_complete_date_for :reference_date
		n.with_options :to => :pii do |o|
			o.delegate :full_name
			o.delegate :email
			o.delegate :last_name
			o.delegate :first_name
			o.delegate :dob
			o.delegate :fathers_name
			o.delegate :mothers_name
			o.delegate :state_id_no
		end<commit_msg>Added delegation of mother_maiden_name from subject to pii.[homex#333]<commit_after>#	==	requires
#	*	subject_type_id
#	*	race_id
class Subject < Shared

#	belongs_to :hispanicity
	belongs_to :race
	belongs_to :subject_type
	belongs_to :vital_status

	with_options :foreign_key => 'study_subject_id' do |f|
		f.has_and_belongs_to_many :analyses
		f.has_many :addressings
		f.has_many :enrollments
		f.has_many :gift_cards
		f.has_many :phone_numbers
		f.has_many :samples
		f.has_one :identifier
		f.has_one :home_exposure_response
		f.has_one :homex_outcome
		f.has_one :patient
		f.has_one :pii
		f.with_options :conditions => ["projects.code = 'HomeExposures'"], :include => :project do |p|
			p.has_one :hx_enrollment, :class_name => "Enrollment"
			p.has_one :hx_gift_card,  :class_name => "GiftCard"
		end
	end

	has_many :addresses, :through => :addressings
	accepts_nested_attributes_for :gift_cards

	validates_presence_of :subject_type
	validates_presence_of :race
	validates_presence_of :subject_type_id
	validates_presence_of :race_id

	validates_inclusion_of :do_not_contact, :in => [ true, false ]

	with_options :allow_nil => true do |n|
		n.validates_complete_date_for :reference_date
		n.with_options :to => :pii do |o|
			o.delegate :full_name
			o.delegate :email
			o.delegate :last_name
			o.delegate :first_name
			o.delegate :dob
			o.delegate :fathers_name
			o.delegate :mothers_name
			o.delegate :mother_maiden_name
			o.delegate :state_id_no
		end
{'fraction_non_alphanumeric': 0.09233997901364113, 'fraction_numerical': 0.001049317943336831, 'mean_word_length': 4.945945945945946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3059713', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1110, 'n_words': 224}