Class: CaTissue::SpecimenCollectionGroup

Inherits:
Object
  • Object
show all
Includes:
Collectible, Jinx::Unique
Defined in:
lib/catissue/domain/specimen_collection_group.rb,
lib/catissue/migration/shims.rb,
lib/catissue/migration/unique.rb,
lib/catissue/migration/migratable.rb,
lib/catissue/domain/specimen_collection_group/pathology/base_pathology_annotation.rb,
lib/catissue/domain/specimen_collection_group/pathology/base_solid_tissue_pathology_annotation.rb

Overview

The SpecimenCollectionGroup domain class.

Note: the SpecimenCollectionGroup name attribute is auto-generated on create in caTissue 1.1 API and should not be set by API clients when creating a new SpecimenCollectionGroup in the database.

Defined Under Namespace

Modules: Pathology

Constant Summary collapse

[:consent_tier_statuses]
@@diagnosis_cv_finder =
nil

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Collectible

#collect, #collected?, #collectible_event_parameters, #collection_event_parameters, #collection_timestamp, #collector, #received?, #received_event_parameters, #receiver

Constructor Details

#initializeSpecimenCollectionGroup

Returns a new instance of SpecimenCollectionGroup.



104
105
106
107
108
# File 'lib/catissue/domain/specimen_collection_group.rb', line 104

def initialize
  super
  # work around caTissue Bug #64
  self.consent_tier_statuses ||= Java::JavaUtil::LinkedHashSet.new
end

Class Method Details

.diagnosis_cv_finder=(finder) ⇒ Object

Sets this SpecimenCollectionGroup diagnosis ControlledValueFinder.



11
12
13
# File 'lib/catissue/migration/shims.rb', line 11

def self.diagnosis_cv_finder=(finder)
  @@diagnosis_cv_finder = finder
end

.enable_cv_finderObject

Enables diagnosis controlled value lookup.



28
29
30
# File 'lib/catissue/migration/migratable.rb', line 28

def self.enable_cv_finder
  @diagnosis_cv_finder ||= ControlledValueFinder.new(:clinical_diagnosis)
end

Instance Method Details

#autogenerated?(operation) ⇒ Boolean

Relaxes the CaRuby::Persistable.saved_attributes_to_fetch condition for a SCG as follows:

  • If the SCG status was updated from Pending to Collected, then fetch the saved SCG event parameters.

Returns:

  • (Boolean)


206
207
208
# File 'lib/catissue/domain/specimen_collection_group.rb', line 206

def autogenerated?(operation)
  operation == :update && status_changed_to_complete? ? EVENT_PARAM_ATTRS : super
end

#collection_protocolCollectionProtocol

Returns the SCG CPE CP.

Returns:



111
112
113
# File 'lib/catissue/domain/specimen_collection_group.rb', line 111

def collection_protocol
  collection_protocol_event.collection_protocol if collection_protocol_event
end

#collection_status=(value) ⇒ Object

Sets the collection status for this SCG. If the SCG status is set to Complete, then the status of each of the SCG Specimens with status Pending is reset to Collected.

Parameters:

  • value (String)

    a permissible SCG status



27
28
29
30
31
32
# File 'lib/catissue/domain/specimen_collection_group.rb', line 27

def collection_status=(value)
  if value == 'Complete' then
    specimens.each { |spc| spc.collection_status = 'Collected' if spc.pending? }
  end
  setCollectionStatus(value)
end

Returns the statuses.

Returns:

  • (Java::JavaUtil::Set)

    the statuses



17
18
19
20
# File 'lib/catissue/domain/specimen_collection_group.rb', line 17

def consent_tier_statuses
  ctss = getConsentTierStatusCollection
  ctss ||= self.consent_tier_statuses = Java::JavaUtil::LinkedHashSet.new
end

#deleteObject

Removes associations to this registration.



136
137
138
# File 'lib/catissue/domain/specimen_collection_group.rb', line 136

def delete
  registration.specimen_collection_groups.delete(self) if registration
end

#direct_dependents(attribute) ⇒ Object

Overrides Jinx::Resource.direct_dependents in the case of the specimens attribute to select only top-level Specimens not derived from another Specimen.



173
174
175
176
177
178
179
# File 'lib/catissue/domain/specimen_collection_group.rb', line 173

def direct_dependents(attribute)
  if attribute == :specimens then
    super.reject { |spc| spc.parent }
  else
    super
  end
end

#event_pointDouble?

Returns the SCG CPE event point.

Returns:

  • (Double, nil)

    the SCG CPE event point



116
117
118
# File 'lib/catissue/domain/specimen_collection_group.rb', line 116

def event_point
  collection_protocol_event and collection_protocol_event.study_calendar_event_point
end

#mandatory_attributesObject



183
184
185
186
187
188
189
190
# File 'lib/catissue/domain/specimen_collection_group.rb', line 183

def mandatory_attributes
  pas = super
  if registration and not registration.consent_tier_responses.empty? then
    pas + CONSENT_TIER_STATUS_ATTRS
  else
    pas
  end
end

#merge_attributes(other, attributes = nil, matches = nil, &filter) ⇒ Object

Merges the other object into this SpecimenCollectionGroup. This method augments Collectible#merge_attributes as follows:

  • Adds the transitive closure of each non-derived Specimen in the source.

Parameters:

  • other (Collectible, {Symbol => Object})

    other the source object or Hash

  • opts (Hash)

    a customizable set of options

Options Hash (other):

  • :specimen_event_parameters (Enumerable)

    the optional SEP merge collection to augment

  • :receiver (CaTissue::User)

    the tissue bank user who received the tissue

  • :received_date (Date)

    the received date (defaults to now)

  • :collector (CaTissue::User)

    the user who acquired the tissue (defaults to the receiver)



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/catissue/domain/specimen_collection_group.rb', line 146

def merge_attributes(other, attributes=nil, matches=nil, &filter)
  if Hash === other then
    # take the transitive closure of the specimens
    spcs = other.delete(:specimens)
    if spcs then
      spcs = [spcs] if CaTissue::Specimen === spcs
      # take the transitive closure of the root specimens in the hierarchy
      other[:specimens] = spcs.select { |spc| spc.parent.nil? }.transitive_closure(:children)
    end
  end
  # delegate to Collectible
  super
end

#migrate_clinical_diagnosis(value, row) ⇒ String

Returns the diagnosis controlled value.

Returns:

  • (String)

    the diagnosis controlled value

Raises:

  • (Jinx::MigrationError)

    if the value is not supported



29
30
31
# File 'lib/catissue/migration/shims.rb', line 29

def migrate_clinical_diagnosis(value, row)
  SpecimenCollectionGroup.diagnosis_controlled_value(value)
end

#minimal_match?(other) ⇒ Boolean

Returns whether this SCG is the same as the other SCG in the scope of an existing parent CPR. This method returns whether the other SCG status is Pending and the event point is the same as the other event point.

Returns:

  • (Boolean)


167
168
169
# File 'lib/catissue/domain/specimen_collection_group.rb', line 167

def minimal_match?(other)
  super and event_point == other.event_point
end

#pending?Boolean

Returns whether this SCG collection status is one of the Pending statuses.

Returns:

  • (Boolean)

    whether this SCG collection status is one of the Pending statuses.



126
127
128
# File 'lib/catissue/domain/specimen_collection_group.rb', line 126

def pending?
  collection_status =~ /^Pending/
end

#protocolObject



160
161
162
# File 'lib/catissue/domain/specimen_collection_group.rb', line 160

def protocol
  collection_event.protocol if collection_event
end

#requirements<SpecimenRequirement>

Returns the SCG CPE requirements.

Returns:



121
122
123
# File 'lib/catissue/domain/specimen_collection_group.rb', line 121

def requirements
  collection_protocol_event.nil? ? Array::EMPTY_ARRAY : collection_protocol_event.requirements
end

#saved_attributes_to_fetch(operation) ⇒ Object

Relaxes the CaRuby::Persistable.saved_attributes_to_fetch condition for a SCG as follows:

  • If the SCG status was updated from Pending to Collected, then fetch the saved SCG event parameters.



197
198
199
# File 'lib/catissue/domain/specimen_collection_group.rb', line 197

def saved_attributes_to_fetch(operation)
  operation == :update && status_changed_to_complete? ? EVENT_PARAM_ATTRS : super
end

#sizeObject

Returns the number of specimens in this SpecimenCollectionGroup.



131
132
133
# File 'lib/catissue/domain/specimen_collection_group.rb', line 131

def size
  specimens.size
end