caruby-tissue 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/History.txt +4 -0
  2. data/LICENSE +1 -1
  3. data/README.md +79 -30
  4. data/bin/crtmigrate +2 -2
  5. data/{examples/galena/bin → bin}/migrate.rb +0 -0
  6. data/bin/seed +26 -0
  7. data/bin/seed.rb +43 -0
  8. data/conf/extract/simple_fields.yaml +4 -0
  9. data/conf/migration/filter_fields.yaml +7 -0
  10. data/{examples/galena/conf → conf}/migration/filter_migration.yaml +0 -0
  11. data/conf/migration/frozen_fields.yaml +11 -0
  12. data/{examples/galena/conf → conf}/migration/frozen_migration.yaml +0 -0
  13. data/conf/migration/general_fields.yaml +44 -0
  14. data/{examples/galena/conf → conf}/migration/general_migration.yaml +0 -0
  15. data/conf/migration/simple_fields.yaml +30 -0
  16. data/{examples/galena/conf → conf}/migration/simple_migration.yaml +0 -0
  17. data/{examples/galena/conf → conf}/migration/small_fields.yaml +0 -0
  18. data/{examples/galena/conf → conf}/migration/small_migration.yaml +0 -0
  19. data/examples/galena/README.md +46 -6
  20. data/examples/galena/bin/seed +26 -0
  21. data/examples/galena/conf/migration/frozen_fields.yaml +1 -0
  22. data/examples/galena/conf/migration/general_fields.yaml +2 -0
  23. data/examples/galena/data/filter.csv +1 -1
  24. data/examples/galena/data/frozen.csv +1 -1
  25. data/examples/galena/data/general.csv +1 -1
  26. data/examples/galena/doc/CaTissue.html +2 -2
  27. data/examples/galena/doc/CaTissue/Participant.html +1 -1
  28. data/examples/galena/doc/CaTissue/SpecimenCollectionGroup.html +1 -1
  29. data/examples/galena/doc/CaTissue/StorageContainer.html +6 -6
  30. data/examples/galena/doc/CaTissue/TissueSpecimen.html +1 -1
  31. data/examples/galena/doc/Galena.html +4 -122
  32. data/examples/galena/doc/Galena/Seed.html +1 -1
  33. data/examples/galena/doc/Galena/Seed/Defaults.html +28 -24
  34. data/examples/galena/doc/_index.html +1 -8
  35. data/examples/galena/doc/class_list.html +1 -1
  36. data/examples/galena/doc/file.README.html +52 -7
  37. data/examples/galena/doc/index.html +52 -7
  38. data/examples/galena/doc/method_list.html +9 -25
  39. data/examples/galena/doc/top-level-namespace.html +1 -1
  40. data/examples/galena/lib/galena/migration/frozen_shims.rb +4 -15
  41. data/examples/galena/lib/galena/seed/defaults.rb +16 -4
  42. data/{examples/galena/lib → lib}/README.html +0 -0
  43. data/lib/catissue/cli/command.rb +6 -9
  44. data/lib/catissue/cli/migrate.rb +11 -10
  45. data/lib/catissue/cli/smoke.rb +5 -5
  46. data/lib/catissue/database.rb +31 -8
  47. data/lib/catissue/domain/abstract_specimen.rb +1 -1
  48. data/lib/catissue/domain/collection_protocol.rb +29 -13
  49. data/lib/catissue/domain/participant_medical_identifier.rb +1 -1
  50. data/lib/catissue/domain/site.rb +3 -0
  51. data/lib/catissue/domain/specimen.rb +17 -14
  52. data/lib/catissue/domain/specimen_collection_group.rb +2 -5
  53. data/lib/catissue/extract/delta.rb +2 -6
  54. data/lib/catissue/migration/migrator.rb +6 -0
  55. data/lib/catissue/resource.rb +5 -2
  56. data/lib/catissue/util/log.rb +3 -3
  57. data/lib/catissue/version.rb +1 -1
  58. data/{examples/galena/lib → lib}/galena.rb +0 -0
  59. data/{examples/galena/bin → lib/galena/cli}/seed.rb +1 -1
  60. data/lib/galena/migration/filter_shims.rb +43 -0
  61. data/lib/galena/migration/frozen_shims.rb +53 -0
  62. data/lib/galena/seed/defaults.rb +109 -0
  63. metadata +27 -17
  64. data/examples/galena/doc/CaTissue/CollectionProtocolRegistration.html +0 -181
@@ -39,7 +39,7 @@ module CaTissue
39
39
  add_dependent_attribute(:specimen_characteristics, :autogenerated, :no_cascade_update_to_create)
40
40
 
41
41
  add_dependent_attribute(:specimen_events, :create_only, :disjoint, :no_cascade_update_to_create)
42
-
42
+
43
43
  set_attribute_inverse(:parent_specimen, :child_specimens)
44
44
 
45
45
  # caTissue alert - SCG specimens query result does not set the Specimen children and parent, even though they are
@@ -93,25 +93,27 @@ module CaTissue
93
93
  reg.nil? ? Array::EMPTY_ARRAY : reg.specimens
94
94
  end
95
95
 
96
- # Adds specimens to this protocol. Arguments:
97
- # * participant - the Participant from whom the specimen is collected
98
- # * biospecimens - the collected top-level underived specimens
99
- # * params - additional SCG parameters as described in {SpecimenCollectionGroup#merge} method
100
- # If params does not include a :collectionProtocolEvent parameter, then the SCG is assigned
96
+ # Adds specimens to this protocol. The following parameter options are supported:
97
+ # * :participant - the Participant from whom the specimen is collected
98
+ # * :biospecimens - the collected top-level underived specimens
99
+ # * additional SCG parameters as described in {SpecimenCollectionGroup#merge}.
100
+ #
101
+ # If the options does not include a :collection_protocol_event, then the SCG is assigned
101
102
  # to the first collection event in this protocol.
102
- # If params does not include a :specimen_collection_site parameter, then the SCG is assigned
103
- # to the participant's collection site as determined by {Participant#collection_site}, if that
104
- # can be uniquely determined.
103
+ # If the options does not include a :specimen_collection_site, then the SCG is assigned
104
+ # to the participant's collection site as determined by {Participant#collection_site},
105
+ # if that can be uniquely determined.
105
106
  #
106
- # This add_specimens method adds the following association to params before calling the
107
- # SpecimenCollectionGroup constructor:
107
+ # This add_specimens method adds the following parameter options before calling the
108
+ # {SpecimenCollectionGroup} constructor:
108
109
  # * :registration => a new CollectionProtocolRegistration for this protocol and the specified participant
109
110
  # If there is no :name parameter, then this method builds a new unique SCG name as this
110
111
  # CollectionProtocol's name followed by a unique suffix.
111
112
  #
112
- # Returns a new SpecimenCollectionGroup for the given participant containing the specimens.
113
- #
114
- # Raises ArgumentError if the SpecimenCollectionGroup does not include all required attributes.
113
+ # @param [(<Specimen>, {Symbol => Object})] specimens_and_params the specimens to add followed
114
+ # by the required parameter hash
115
+ # @return [SpecimenCollectionGroup] a new SCG for the given participant containing the specimens
116
+ # @raise [ArgumentError] if the {SpecimenCollectionGroup} does not include all required attributes
115
117
  def add_specimens(*specimens_and_params)
116
118
  params = specimens_and_params.pop
117
119
  spcs = specimens_and_params
@@ -136,6 +138,20 @@ module CaTissue
136
138
  spcs.each { |spc| spc.specimen_collection_group = scg }
137
139
  scg
138
140
  end
141
+
142
+ # Returns the default protocol site, determined as follows:
143
+ # * If there is exactly one authorized site for this protocol, then that is the default site.
144
+ # * If there is exactly two authorized sites for this protocol, then the site other than the
145
+ # {CaTissue::Site::DEF_SITE_NAME} is returned.
146
+ # * Otherwise, this method returns nil.
147
+ #
148
+ # @return [CaTissue::Site, nil] the default site
149
+ def default_site
150
+ case sites.size
151
+ when 1 then sites.first
152
+ when 2 then sites.select { |site| site.name != CaTissue::Site::DEF_SITE_NAME }
153
+ end
154
+ end
139
155
 
140
156
  private
141
157
 
@@ -32,7 +32,7 @@ module CaTissue
32
32
  def default_site
33
33
  cprs = participant.registrations if participant
34
34
  cp = cprs.first.protocol if cprs and cprs.size == 1
35
- cp.sites.first if cp and cp.sites.size == 1
35
+ cp.default_site if cp
36
36
  end
37
37
  end
38
38
  end
@@ -5,6 +5,9 @@ module CaTissue
5
5
  # The Site domain class.
6
6
  class Site
7
7
  include Resource
8
+
9
+ # The default pre-defined caTissue site name.
10
+ DEF_SITE_NAME = 'In Transit'
8
11
 
9
12
  # caTissue alert - the Site SCG collection is ignored, since it is not fetched with the Site,
10
13
  # the caCORE query builder doesn't support abstract types, and even if it worked it would
@@ -91,10 +91,6 @@ module CaTissue
91
91
  # argument.
92
92
  qualify_attribute(:available_quantity, :autogenerated)
93
93
 
94
- MERGEABLE_RQMT_ATTRS = nondomain_java_attributes - primary_key_attributes
95
-
96
- MERGEABLE_SPC_CHR_ATTRS = SpecimenCharacteristics.nondomain_java_attributes - SpecimenCharacteristics.primary_key_attributes
97
-
98
94
  # Specimen storage is constrained on the basis of the +specimen_class+.
99
95
  alias :storable_type :specimen_class
100
96
 
@@ -181,20 +177,21 @@ module CaTissue
181
177
  raise ValidationError.new("#{self} available quantity #{available_quantity} cannot exceed initial quantity #{initial_quantity}")
182
178
  end
183
179
  if available? and available_quantity.zero? then
184
- raise ValidationError.new("#{self} availablility flag cannot be set when the avaialble quantity is zero.")
180
+ raise ValidationError.new("#{self} availablility flag cannot be set when the avaialble quantity is zero")
185
181
  end
186
182
  if collected? then
187
183
  unless event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep } then
188
- raise ValidationError.new("#{self} is missing CollectionEventParameters.")
184
+ raise ValidationError.new("#{self} is missing CollectionEventParameters")
189
185
  end
190
186
  unless event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep } then
191
- raise ValidationError.new("#{self} is missing ReceivedEventParameters.")
187
+ raise ValidationError.new("#{self} is missing ReceivedEventParameters")
192
188
  end
193
189
  end
194
190
  end
195
191
 
196
192
  # Returns the Specimen in others which matches this Specimen in the scope of an owner SCG.
197
- # This method relaxes {CaRuby::Resource#match_in_owner_scope} to include a match on at least one external identifier.
193
+ # This method relaxes {CaRuby::Resource#match_in_owner_scope} to include a match on at least
194
+ # one external identifier.
198
195
  def match_in_owner_scope(others)
199
196
  super or others.detect do |other|
200
197
  external_identifiers.any? do |eid|
@@ -302,9 +299,9 @@ module CaTissue
302
299
  elsif specimen_collection_group.consent_tier_statuses.size == 1 then
303
300
  statuses.first
304
301
  elsif specimen_collection_group.consent_tier_statuses.size == 0 then
305
- raise ValidationError.new("Specimen #{self} SCG does not have a consent tier status.")
302
+ raise ValidationError.new("Specimen #{self} SCG does not have a consent tier status")
306
303
  else
307
- raise ValidationError.new("Specimen #{self} SCG consent tier is ambiguous:#{consent_tier_statuses.select { |cts| "\n #{cts.statement}" }.to_series('or')}.")
304
+ raise ValidationError.new("Specimen #{self} SCG consent tier is ambiguous:#{consent_tier_statuses.select { |cts| "\n #{cts.statement}" }.to_series('or')}")
308
305
  end
309
306
  ct = status.consent_tier
310
307
  cts = consent_tier_statuses.detect { |item| item.consent_tier == ct }
@@ -334,6 +331,10 @@ module CaTissue
334
331
 
335
332
  private
336
333
 
334
+ MERGEABLE_RQMT_ATTRS = nondomain_java_attributes - primary_key_attributes
335
+
336
+ MERGEABLE_SPC_CHR_ATTRS = SpecimenCharacteristics.nondomain_java_attributes - SpecimenCharacteristics.primary_key_attributes
337
+
337
338
  # Adds this Specimen's defaults, as follows:
338
339
  # * The default specimen_collection_group is the parent specimen_collection_group.
339
340
  # * Add default collection and received event parameters if this Specimen is collected.
@@ -358,10 +359,12 @@ module CaTissue
358
359
  self.specimen_collection_group ||= parent.specimen_collection_group if parent
359
360
  add_default_event_parameters
360
361
 
361
- # The default available quantity is 0 if the is_available flag is false,
362
- # otherwise the initial quantity.
363
- self.available_quantity ||= is_available == false ? 0.0 : initial_quantity
364
-
362
+ # The default available quantity is the initial quantity.
363
+ aq = available_quantity
364
+ if aq.nil? or aq.zero? then
365
+ self.available_quantity = is_available == false ? 0.0 : initial_quantity
366
+ end
367
+
365
368
  # The specimen is available by default if there is a positive available quantity.
366
369
  # If is_available is set to false, then set it to nil to work around a caTissue bug.
367
370
  self.is_available ||= available_quantity.zero? ? nil : true
@@ -271,14 +271,11 @@ module CaTissue
271
271
  each_dependent { |dep| yield dep unless ReceivedEventParameters === dep }
272
272
  end
273
273
 
274
- # The default In Transit collection site.
275
- DEF_SITE = Site.new(:name => 'In Transit')
276
-
277
274
  # Adds defaults as follows:
278
275
  # * the default collection event is the first event in the protocol registered with this SCG.
279
276
  # * the default collection status is 'Complete' if there is a received event, 'Pending' otherwise.
280
277
  # * the default collection site is the CP site, if this SCG is {#received?} and there is only CP one,
281
- # otherwise the 'In Transit' site.
278
+ # otherwise the {CaTissue::Site::DEF_SITE_NAME} site.
282
279
  # * the default conset tier status is 'Complete' if there is a received event, 'Pending' otherwise.
283
280
  # * a default ReceivedEventParameters is added to this SCG if the collection status is
284
281
  # 'Complete' and there is no other ReceivedEventParameters. The receiver is an arbitrary
@@ -334,7 +331,7 @@ module CaTissue
334
331
 
335
332
  def default_site
336
333
  cp = collection_event.protocol if collection_event
337
- cp && cp.sites.size == 1 ? cp.sites.first : DEF_SITE
334
+ cp.default_site if cp
338
335
  end
339
336
 
340
337
  # Returns the first event in the protocol registered with this SCG.
@@ -10,12 +10,6 @@ module CaTissue
10
10
  class Delta
11
11
  include Enumerable
12
12
 
13
- private
14
-
15
- SQL_FILE = File.join(File.dirname(__FILE__), '..', '..', '..', 'sql', 'delta.sql')
16
-
17
- public
18
-
19
13
  # Creates a new Delta for objects of the given target type which changed
20
14
  # at or after the since Date and earlier but not at the before Date.
21
15
  # The default before Date is now.
@@ -36,6 +30,8 @@ module CaTissue
36
30
 
37
31
  private
38
32
 
33
+ SQL_FILE = File.join(File.dirname(__FILE__), '..', '..', '..', 'sql', 'delta.sql')
34
+
39
35
  # Returns the result of running the delta SQL on the target CaTissue domain class.
40
36
  def execute_query
41
37
  sql = File.open(SQL_FILE) { |file| file.read }
@@ -33,6 +33,12 @@ module CaTissue
33
33
  # database or the migration must build a Participant and a CollectionProtocol.
34
34
  #
35
35
  # @option (see CaRuby::Migrator#initialize)
36
+ # @option opts [String] :database target application {CaRuby::Database}
37
+ # @option opts [String] :target required target domain class
38
+ # @option opts [String] :input required source file to migrate
39
+ # @option opts [String] :shims optional array of shim files to load
40
+ # @option opts [String] :bad write each invalid record to the given file and continue migration
41
+ # @option opts [String] :offset zero-based starting source record number to process (default 0)
36
42
  def initialize(opts={})
37
43
  # if there is a configuration file, then add config options into the parameter options
38
44
  conf_file = opts.delete(:file)
@@ -8,10 +8,13 @@ module CaTissue
8
8
  module Resource
9
9
  include CaRuby::Resource
10
10
 
11
+ # Returns whether each of the given attribute values either equals the
12
+ # respective other attribute value or one of the values is nil or 'Not Specified'.
13
+ #
11
14
  # @param [Resource] other the domain object to compare
12
15
  # @param [<Symbol>] attributes the attributes to compare
13
- # @return [Boolean} whether each of the given attribute values either equals the
14
- # respective other attribute value or one of the values is nil or 'Not Specified'
16
+ # @return [Boolean} whether this domain object is a tolerant match with the other
17
+ # domain object on the given attributes
15
18
  def tolerant_match?(other, attributes)
16
19
  attributes.all? { |attr| Resource.tolerant_value_match?(send(attr), other.send(attr)) }
17
20
  end
@@ -12,15 +12,15 @@ module CaTissue
12
12
  # caTissue alert - avoid caTissue error by creating log subdirectory
13
13
  if File.directory?('log') then
14
14
  unless File.writable?('log') then
15
- raise StandardError.new("caTissue log subdirectory #{File.expand_path('log')} is not writable.")
15
+ raise StandardError.new("caTissue log subdirectory #{File.expand_path('log')} is not writable")
16
16
  end
17
17
  elsif File.exists?('log') then
18
- raise StandardError.new("Existing file #{File.expand_path('log')} prevents creation of the required caTissue log subdirectory.")
18
+ raise StandardError.new("Existing file #{File.expand_path('log')} prevents creation of the required caTissue log subdirectory")
19
19
  else
20
20
  begin
21
21
  Dir.mkdir('log')
22
22
  rescue Exception => e
23
- raise StandardError.new("Cannot create the log subdirectory required by the caTissue client: #{File.expand_path('log')}.")
23
+ raise StandardError.new("Cannot create the log subdirectory required by the caTissue client: #{File.expand_path('log')}")
24
24
  end
25
25
  end
26
26
  end
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # The version of this caRuby Tissue release.
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
 
5
5
  # The supported caTissue release versions.
6
6
  CATISSUE_VERSIONS = "1.1.2"
File without changes
@@ -40,4 +40,4 @@ require 'catissue/cli/command'
40
40
 
41
41
  require 'galena/seed/defaults'
42
42
 
43
- CaTissue::Command.new.start { Galena::Seed.defaults.ensure_exists }
43
+ CaTissue::Command.new.execute { Galena::Seed.defaults.ensure_exists }
@@ -0,0 +1,43 @@
1
+ require 'uom'
2
+
3
+ module CaTissue
4
+
5
+ # Declares the classes modified for migration.
6
+ shims Participant, TissueSpecimen, SpecimenCollectionGroup
7
+
8
+ class Participant
9
+ # Extracts the Participant first name from the +Initials+ input field.
10
+ def migrate_first_name(value, row)
11
+ self.first_name = value[0, 1]
12
+ end
13
+
14
+ # Extracts the Participant last name from the +Initials+ input field.
15
+ def migrate_last_name(value, row)
16
+ self.last_name = value[-1, 1]
17
+ end
18
+ end
19
+
20
+ class TissueSpecimen
21
+ # Transforms the +Frozen?+ flag input field to the caTissue specimen type +Frozen Tissue+ value.
22
+ def migrate_specimen_type(value, row)
23
+ 'Frozen Tissue' if value =~ /TRUE/i
24
+ end
25
+
26
+ # Parses the source field as a UOM::Measurement if it is a string.
27
+ # Otherwises, returns the source value.
28
+ def migrate_initial_quantity(value, row)
29
+ # if value is not a string, then use it as is
30
+ return value unless value.is_a?(String)
31
+ # the value has a unit qualifier; parse the measurement.
32
+ # the unit is normalized to the Specimen standard unit.
33
+ value.to_measurement_quantity(standard_unit)
34
+ end
35
+ end
36
+
37
+ class SpecimenCollectionGroup
38
+ # Returns whether this SCG has a SPN.
39
+ def migration_valid?
40
+ surgical_pathology_number
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,53 @@
1
+ # load the defaults file in the seed directory
2
+ require File.join(File.dirname(__FILE__), '..', 'seed', 'defaults')
3
+
4
+ module CaTissue
5
+ # Declares the classes modified for migration.
6
+ shims TissueSpecimen, CollectionProtocolRegistration, StorageContainer
7
+
8
+ class TissueSpecimen
9
+ # Sets the specimen type to +Frozen Tissue+.
10
+ #
11
+ # @param (see CaRuby::Migratable#migrate)
12
+ def migrate(row, migrated)
13
+ super
14
+ self.specimen_type = 'Frozen Tissue'
15
+ end
16
+ end
17
+
18
+ class CollectionProtocolRegistration
19
+ # Sets this CPR's protocol to the pre-defined {Galena::Migration::Defaults#protocol}.
20
+ #
21
+ # @param (see CaRuby::Migratable#migrate)
22
+ def migrate(row, migrated)
23
+ super
24
+ self.protocol = Galena::Seed.defaults.protocol
25
+ end
26
+ end
27
+
28
+ class StorageContainer
29
+ # Creates the migrated box in the database, if necessary.
30
+ #
31
+ # @param (see CaRuby::Migratable#migrate)
32
+ def migrate(row, migrated)
33
+ super
34
+ find or create_box
35
+ end
36
+
37
+ private
38
+
39
+ # Creates a new box of type {Galena::Seed::Defaults#box_type} in a freezer of type
40
+ # {Galena::Seed::Defaults#freezer_type}.
41
+ #
42
+ # @return [StorageContainer] the new box
43
+ def create_box
44
+ defs = Galena::Seed.defaults
45
+ self.storage_type = defs.box_type
46
+ # A freezer with a spot for the box
47
+ frz = defs.freezer_type.find_available(site, :create)
48
+ if frz.nil? then raise CaRuby::MigrationError.new("Freezer not available to place #{self}") end
49
+ # Add this box to the first open slot in the first unfilled rack in the freezer.
50
+ frz << self
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,109 @@
1
+ require 'singleton'
2
+ require 'catissue'
3
+
4
+ module Galena
5
+ # Creates the {Galena::Seed::Defaults} administrative objects as necessary.
6
+ def self.seed
7
+ Seed.defaults.ensure_exists
8
+ end
9
+
10
+ # Galena example utility module to populate the database with pre-defined administrative objects.
11
+ module Seed
12
+ # @return [Defaults] the defaults instance
13
+ def self.defaults
14
+ Defaults.instance
15
+ end
16
+
17
+ # Pre-defined Galena example administrative objects. If the Galena example is already set up
18
+ # in the caTissue database, then the default object secondary key attributes can be used as a
19
+ # {CaRuby::Persistable#find} template to retrieve the existing objects. Otherwise, the Defaults
20
+ # attributes can be created by calling {CaRuby::Persistable#create}.
21
+ #
22
+ # In a real-world use case, the administrative objects are typically built in the UI before-hand.
23
+ # In that case, it is only necessary to define the object secondary key rather than content, e.g.:
24
+ # pcl = CaTissue::CollectionProtocol.new(:short_title => 'Galena CP')
25
+ # The complete definitions are included in this method for convenience in order to seed the
26
+ # example in a test database. A real-world migration might find it useful to create a similar
27
+ # defaults file in order to rapidly seed an empty test or staging database.
28
+ class Defaults
29
+ include Singleton
30
+
31
+ attr_reader :protocol, :hospital, :tissue_bank, :freezer_type, :box_type
32
+
33
+ # Creates the Galena example Defaults singleton and populates the attributes.
34
+ def initialize
35
+ super
36
+ populate
37
+ end
38
+
39
+ # Creates the Galena example administrative objects as necessary.
40
+ def ensure_exists
41
+ @protocol.find(:create)
42
+ @hospital.find(:create)
43
+ @surgeon.find(:create)
44
+ @box.find(:create)
45
+ end
46
+
47
+ private
48
+
49
+ # Sets the Galena example Defaults attributes to new objects.
50
+ def populate
51
+ galena = CaTissue::Institution.new(:name => 'Galena University')
52
+
53
+ addr = CaTissue::Address.new(
54
+ :city => 'Galena', :state => 'Illinois', :country => 'United States', :zipCode => '37544',
55
+ :street => '411 Basin St', :phoneNumber => '311-555-5555')
56
+
57
+ dept = CaTissue::Department.new(:name => 'Pathology')
58
+
59
+ crg = CaTissue::CancerResearchGroup.new(:name => 'Don Thomas Cancer Center')
60
+
61
+ coord = CaTissue::User.new(
62
+ :email_address => 'corey.nator@galena.edu',
63
+ :last_name => 'Nator', :first_name => 'Corey', :address => addr.copy,
64
+ :institution => galena, :department => dept, :cancer_research_group => crg)
65
+
66
+ @hospital = CaTissue::Site.new(
67
+ :site_type => CaTissue::Site::SiteType::COLLECTION, :name => 'Galena Hospital',
68
+ :address => addr, :coordinator => coord)
69
+
70
+ @tissue_bank = CaTissue::Site.new(
71
+ :site_type => CaTissue::Site::SiteType::REPOSITORY, :name => 'Galena Tissue Bank',
72
+ :address => addr, :coordinator => coord)
73
+
74
+ pi = CaTissue::User.new(
75
+ :email_address => 'vesta.gator@galena.edu',
76
+ :last_name => 'Gator', :first_name => 'Vesta', :address => addr.copy,
77
+ :institution => galena, :department => dept, :cancer_research_group => crg)
78
+
79
+ @surgeon = CaTissue::User.new(
80
+ :email_address => 'serge.on@galena.edu',
81
+ :first_name => 'Serge', :last_name => 'On', :address => addr.copy,
82
+ :institution => galena, :department => dept, :cancer_research_group => crg)
83
+
84
+ @protocol = CaTissue::CollectionProtocol.new(:short_title => 'Galena Migration',
85
+ :principal_investigator => pi, :sites => [@tissue_bank])
86
+
87
+ # CPE has default 1.0 event point and label
88
+ cpe = CaTissue::CollectionProtocolEvent.new(:collection_protocol => @protocol)
89
+
90
+ # the sole specimen requirement. Setting the requirement collection_event attribute to a CPE automatically
91
+ # sets the CPE requirement inverse attribute in caRuby.
92
+ CaTissue::TissueSpecimenRequirement.new(:collection_event => cpe, :specimen_type => 'Fixed Tissue')
93
+
94
+ # the storage container type hierarchy
95
+ @freezer_type = CaTissue::StorageType.new(:name => 'GTB Freezer', :columns => 10, :rows => 1, :column_label => 'Rack')
96
+ rack_type = CaTissue::StorageType.new(:name => 'GTB Rack', :columns => 10, :rows => 10)
97
+ @box_type = CaTissue::StorageType.new(:name => 'GTB Box', :columns => 10, :rows => 10)
98
+ @freezer_type << rack_type
99
+ rack_type << box_type
100
+ @box_type << 'Tissue'
101
+
102
+ # a sample freezer and box
103
+ frz = CaTissue::StorageContainer.new(:name => 'GTB Freezer 1', :storage_type=>@freezer_type, :site=>@tissue_bank)
104
+ @box = CaTissue::StorageContainer.new(:name => 'GTB Box 1', :storage_type=>@box_type)
105
+ frz << @box
106
+ end
107
+ end
108
+ end
109
+ end