Class: CaTissue::Participant

Inherits:
Object
  • Object
show all
Includes:
Person
Defined in:
lib/catissue/domain/participant.rb,
lib/catissue/domain/participant/clinical/duration.rb,
lib/catissue/domain/participant/clinical/chemotherapy.rb,
lib/catissue/domain/participant/clinical/radiation_therapy.rb,
lib/catissue/domain/participant/clinical/treatment_regimen.rb

Overview

The Participant domain class.

Defined Under Namespace

Modules: Clinical

Instance Method Summary collapse

Methods included from Person

#name, #name=

Instance Method Details

#add_mrn(site, mrn) ⇒ CaTissue::ParticipantMedicalIdentifier

Returns a new PMI which adds this Participant to the site with the MRN.

Parameters:

  • the (CaTissue::Site)

    registration site

  • mrn (String)

    the registration MRN

Returns:



77
78
79
# File 'lib/catissue/domain/participant.rb', line 77

def add_mrn(site, mrn)
  CaTissue::ParticipantMedicalIdentifier.new(:participant => self, :site => site, :medical_record_number => mrn)
end

#collection_protocolsObject

Returns this Participant’s CollectionProtocolRegistration protocols.



93
94
95
# File 'lib/catissue/domain/participant.rb', line 93

def collection_protocols
  collection_registrations.map { |reg| reg.protocol }.uniq
end

#collection_siteCaTissue::Site

Returns the collection site for which this participant has a MRN. If there is not exactly one such site, then this method returns nil. This method is a convenience for the common situation where a participant is enrolled at one site.

Returns:



110
111
112
113
114
115
# File 'lib/catissue/domain/participant.rb', line 110

def collection_site
  return unless medical_identifiers.size == 1
  site = medical_identifiers.first.site
  return if site.nil?
  site.site_type == Site::SiteType::COLLECTION ? site : nil
end

#keyObject

Returns the SSN if it exists, otherwise the first ParticipantMedicalIdentifier, if any, otherwise nil.

Returns:

  • the SSN if it exists, otherwise the first ParticipantMedicalIdentifier, if any, otherwise nil



69
70
71
# File 'lib/catissue/domain/participant.rb', line 69

def key
  super or medical_identifiers.first
end

#medical_record_numberString

Returns the MRN for this participant. If this Participant does not have exactly one MRN, then this method returns nil. This method is a convenience for the common situation where a participant is enrolled at one site.

Returns:

  • (String)

    the MRN



101
102
103
# File 'lib/catissue/domain/participant.rb', line 101

def medical_record_number
  return medical_identifiers.first.medical_record_number if medical_identifiers.size == 1
end

#medical_record_numbers<String>

Returns this Participant’s medical record numbers. Each medical record number is site-specific.

Returns:

  • (<String>)

    this Participant’s medical record numbers. Each medical record number is site-specific.

See Also:

  • medical_identifiers attribute for MRN-site associations


83
84
85
# File 'lib/catissue/domain/participant.rb', line 83

def medical_record_numbers
  medical_identifiers.map { |pmi| pmi.medicalRecordNumber }
end

#merge_attribute(attribute, newval, matches = nil) ⇒ Object

Overrides CaRuby::Mergable.merge_attribute to work around the caTissue

bugs described in {CaTissue::Participant.remove_phantom_medical_identifier}.


61
62
63
64
65
66
# File 'lib/catissue/domain/participant.rb', line 61

def merge_attribute(attribute, newval, matches=nil)
  if attribute == :participant_medical_identifiers and newval then
    CaTissue::Participant.remove_phantom_medical_identifier(newval)
  end
  super
end

#specimens<CTissue::Specimen>

Returns all specimens collected from this participant.

Returns:

  • (<CTissue::Specimen>)

    all specimens collected from this participant



88
89
90
# File 'lib/catissue/domain/participant.rb', line 88

def specimens
  Jinx::Flattener.new(registrations.map { |cpr| cpr.specimens })
end