Class: CaTissue::SpecimenCollectionGroup
- Inherits:
-
Object
- Object
- CaTissue::SpecimenCollectionGroup
- 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_STATUS_ATTRS =
[:consent_tier_statuses]
- @@diagnosis_cv_finder =
nil
Class Method Summary collapse
-
.diagnosis_cv_finder=(finder) ⇒ Object
Sets this SpecimenCollectionGroup diagnosis ControlledValueFinder.
-
.enable_cv_finder ⇒ Object
Enables diagnosis controlled value lookup.
Instance Method Summary collapse
-
#autogenerated?(operation) ⇒ Boolean
Relaxes the
CaRuby::Persistable.saved_attributes_to_fetch
condition for a SCG as follows: * If the SCG status was updated fromPending
toCollected
, then fetch the saved SCG event parameters. -
#collection_protocol ⇒ CollectionProtocol
The SCG CPE CP.
-
#collection_status=(value) ⇒ Object
Sets the collection status for this SCG.
-
#consent_tier_statuses ⇒ Java::JavaUtil::Set
The statuses.
-
#delete ⇒ Object
Removes associations to this registration.
-
#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. -
#event_point ⇒ Double?
The SCG CPE event point.
-
#initialize ⇒ SpecimenCollectionGroup
constructor
A new instance of SpecimenCollectionGroup.
- #mandatory_attributes ⇒ Object
-
#merge_attributes(other, attributes = nil, matches = nil, &filter) ⇒ Object
Merges the other object into this SpecimenCollectionGroup.
-
#migrate_clinical_diagnosis(value, row) ⇒ String
The diagnosis controlled value.
-
#minimal_match?(other) ⇒ Boolean
Returns whether this SCG is the same as the other SCG in the scope of an existing parent CPR.
-
#pending? ⇒ Boolean
Whether this SCG collection status is one of the
Pending
statuses. - #protocol ⇒ Object
-
#requirements ⇒ <SpecimenRequirement>
The SCG CPE requirements.
-
#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 fromPending
toCollected
, then fetch the saved SCG event parameters. -
#size ⇒ Object
Returns the number of specimens in this SpecimenCollectionGroup.
Methods included from Collectible
#collect, #collected?, #collectible_event_parameters, #collection_event_parameters, #collection_timestamp, #collector, #received?, #received_event_parameters, #receiver
Constructor Details
#initialize ⇒ SpecimenCollectionGroup
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. ||= 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_finder ⇒ Object
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
toCollected
, then fetch the saved SCG event parameters.
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_protocol ⇒ CollectionProtocol
Returns the SCG CPE CP.
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
.
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 |
#consent_tier_statuses ⇒ Java::JavaUtil::Set
Returns the statuses.
17 18 19 20 |
# File 'lib/catissue/domain/specimen_collection_group.rb', line 17 def ctss = getConsentTierStatusCollection ctss ||= self. = Java::JavaUtil::LinkedHashSet.new end |
#delete ⇒ Object
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_point ⇒ Double?
Returns 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_attributes ⇒ Object
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..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.
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.
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.
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.
126 127 128 |
# File 'lib/catissue/domain/specimen_collection_group.rb', line 126 def pending? collection_status =~ /^Pending/ end |
#protocol ⇒ Object
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.
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
toCollected
, 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 |
#size ⇒ Object
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 |