Class: CaTissue::CollectionProtocolRegistration

Inherits:
Object
  • Object
show all
Includes:
CaRuby::Resource::Unique, Resource
Defined in:
lib/catissue/domain/collection_protocol_registration.rb,
lib/catissue/domain/uniquify.rb

Overview

The CollectionProtocolRegistration domain class.

Instance Method Summary collapse

Methods included from Resource

#database, included, #tolerant_match?

Methods included from Annotatable

#annotation_proxy, #create_proxy, #method_missing

Constructor Details

#initialize(params = nil) ⇒ CollectionProtocolRegistration

Returns a new instance of CollectionProtocolRegistration.



77
78
79
80
81
82
83
84
# File 'lib/catissue/domain/collection_protocol_registration.rb', line 77

def initialize(params=nil)
  super
  # following line works around an obscure problem whereby CPR init could not call consent_tier_responses below;
  # TODO - verify that it is still necessary
  respond_to?(:consent_tier_responses)
  # work around caTissue Bug #64
  self.consent_tier_responses ||= Java::JavaUtil::LinkedHashSet.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CaTissue::Annotatable

Instance Method Details

Returns whether the consent available flag is equal to the String ‘true’. This method converts the caTissue String to a Boolean.



21
22
23
# File 'lib/catissue/domain/collection_protocol_registration.rb', line 21

def consent_available
  getIsConsentAvailable == 'true'
end

Sets the consent available flag to the specified value. A Boolean value is converted to a String.



26
27
28
29
# File 'lib/catissue/domain/collection_protocol_registration.rb', line 26

def consent_available=(value)
  value = value.to_s if value
  setIsConsentAvailable(value)
end

caTissue alert - Bug #64: Some domain collection properties not initialized. Initialize consent_tier_responses if necessary.

Returns:

  • (Java::JavaUtil::Set)

    the responses



15
16
17
# File 'lib/catissue/domain/collection_protocol_registration.rb', line 15

def consent_tier_responses
  getConsentTierResponseCollection or (self.consent_tier_responses = Java::JavaUtil::LinkedHashSet.new)
end

#deleteObject

Removes associations to this registration



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

def delete
  participant.collection_registrations.delete(self) if participant
  protocol.registrations.delete(self) if protocol
end

#protocol_participant_identifier=(value) ⇒ Object

Sets the consent available flag to the specified value. An Integer value is converted to a String.



32
33
34
35
# File 'lib/catissue/domain/collection_protocol_registration.rb', line 32

def protocol_participant_identifier=(value)
  value = value.to_s if value
  setProtocolParticipantIdentifier(value)
end

#specimensObject

Returns all specimens collected for this CollectionProtocolRegistration.

Returns:

  • all specimens collected for this CollectionProtocolRegistration



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

def specimens
  Flattener.new(specimen_collection_groups.map { |group| group.specimens })
end

#uniquifyObject

Makes this CPR’s PPI unique.



32
33
34
35
36
37
# File 'lib/catissue/domain/uniquify.rb', line 32

def uniquify
  oldval = protocol_participant_identifier || return
  newval = uniquify_value(oldval)
  self.protocol_participant_identifier = newval
  logger.debug { "Reset #{qp} PPI from #{oldval} to unique value #{newval}." }
end