caruby-tissue 1.4.2 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/History.md +53 -0
  2. data/bin/crtdump +1 -6
  3. data/bin/crtexample +1 -6
  4. data/bin/crtmigrate +1 -6
  5. data/bin/crtsmoke +1 -6
  6. data/conf/migration/filter_fields.yaml +1 -1
  7. data/conf/migration/general_fields.yaml +1 -1
  8. data/conf/migration/simple_fields.yaml +1 -1
  9. data/conf/migration/small_fields.yaml +1 -1
  10. data/examples/galena/README.md +34 -25
  11. data/examples/galena/bin/seed +2 -7
  12. data/examples/galena/conf/migration/annotation_fields.yaml +1 -1
  13. data/examples/galena/conf/migration/filter_fields.yaml +1 -1
  14. data/examples/galena/conf/migration/frozen_fields.yaml +2 -2
  15. data/examples/galena/conf/migration/general_fields.yaml +1 -1
  16. data/examples/galena/conf/migration/registration_fields.yaml +1 -0
  17. data/examples/galena/conf/migration/simple_fields.yaml +1 -1
  18. data/examples/galena/data/frozen.csv +1 -1
  19. data/examples/galena/data/general.csv +1 -1
  20. data/examples/galena/data/registration.csv +1 -1
  21. data/examples/galena/lib/galena/tissue/migration/frozen_shims.rb +8 -4
  22. data/examples/galena/lib/galena/tissue/seed/defaults.rb +16 -9
  23. data/examples/pcbin/README.md +8 -8
  24. data/examples/pcbin/conf/biopsy_fields.yaml +1 -1
  25. data/examples/pcbin/conf/patient_fields.yaml +1 -1
  26. data/examples/pcbin/conf/surgery_fields.yaml +1 -1
  27. data/examples/pcbin/conf/t_stage_fields.yaml +1 -1
  28. data/examples/pcbin/conf/therapy_fields.yaml +1 -1
  29. data/lib/catissue.rb +1 -1
  30. data/lib/catissue/annotation/annotatable.rb +12 -22
  31. data/lib/catissue/annotation/annotatable_class.rb +87 -114
  32. data/lib/catissue/annotation/annotation.rb +9 -44
  33. data/lib/catissue/annotation/annotation_class.rb +238 -145
  34. data/lib/catissue/annotation/annotation_module.rb +47 -59
  35. data/lib/catissue/annotation/de_integration.rb +12 -2
  36. data/lib/catissue/annotation/proxy.rb +11 -17
  37. data/lib/catissue/annotation/proxy_1_1.rb +47 -0
  38. data/lib/catissue/annotation/proxy_class.rb +55 -37
  39. data/lib/catissue/annotation/record_entry_proxy.rb +20 -0
  40. data/lib/catissue/database.rb +164 -112
  41. data/lib/catissue/database/annotation/annotation_service.rb +5 -5
  42. data/lib/catissue/database/annotation/annotator.rb +2 -2
  43. data/lib/catissue/database/annotation/entity_facade.rb +24 -21
  44. data/lib/catissue/database/annotation/id_generator.rb +26 -26
  45. data/lib/catissue/database/annotation/integration_service.rb +8 -8
  46. data/lib/catissue/database/annotation/record_entry_integrator.rb +24 -6
  47. data/lib/catissue/database/annotation/reference_writer.rb +33 -6
  48. data/lib/catissue/domain.rb +26 -0
  49. data/lib/catissue/domain/abstract_position.rb +1 -1
  50. data/lib/catissue/domain/abstract_specimen.rb +16 -16
  51. data/lib/catissue/domain/check_in_check_out_event_parameter.rb +1 -1
  52. data/lib/catissue/domain/collection_event_parameters.rb +1 -1
  53. data/lib/catissue/domain/collection_protocol.rb +9 -13
  54. data/lib/catissue/domain/collection_protocol_event.rb +4 -4
  55. data/lib/catissue/domain/collection_protocol_registration.rb +4 -4
  56. data/lib/catissue/domain/container.rb +12 -21
  57. data/lib/catissue/domain/container_type.rb +65 -64
  58. data/lib/catissue/domain/disposal_event_parameters.rb +1 -1
  59. data/lib/catissue/domain/hash_code.rb +3 -6
  60. data/lib/catissue/domain/new_specimen_array_order_item.rb +4 -4
  61. data/lib/catissue/domain/order_details.rb +3 -3
  62. data/lib/catissue/domain/participant.rb +28 -20
  63. data/lib/catissue/domain/participant/clinical/chemotherapy.rb +21 -0
  64. data/lib/catissue/domain/participant/clinical/duration.rb +11 -0
  65. data/lib/catissue/domain/participant/clinical/radiation_therapy.rb +21 -0
  66. data/lib/catissue/domain/participant_medical_identifier.rb +2 -2
  67. data/lib/catissue/domain/site.rb +6 -6
  68. data/lib/catissue/domain/specimen.rb +41 -34
  69. data/lib/catissue/domain/specimen/pathology/prostate_specimen_gleason_score.rb +18 -0
  70. data/lib/catissue/domain/specimen/pathology/prostate_specimen_pathology_annotation.rb +13 -8
  71. data/lib/catissue/domain/specimen/pathology/specimen_additional_finding.rb +21 -0
  72. data/lib/catissue/domain/specimen/pathology/specimen_base_solid_tissue_pathology_annotation.rb +30 -7
  73. data/lib/catissue/domain/specimen/pathology/specimen_details.rb +18 -0
  74. data/lib/catissue/domain/specimen/pathology/specimen_histologic_grade.rb +18 -0
  75. data/lib/catissue/domain/specimen/pathology/specimen_histologic_type.rb +22 -6
  76. data/lib/catissue/domain/specimen/pathology/specimen_histologic_variant_type.rb +18 -0
  77. data/lib/catissue/domain/specimen/pathology/specimen_invasion.rb +18 -0
  78. data/lib/catissue/domain/specimen_array.rb +8 -8
  79. data/lib/catissue/domain/specimen_array_content.rb +4 -4
  80. data/lib/catissue/domain/specimen_collection_group.rb +43 -41
  81. data/lib/catissue/domain/specimen_collection_group/pathology/base_pathology_annotation.rb +16 -0
  82. data/lib/catissue/domain/specimen_collection_group/pathology/base_solid_tissue_pathology_annotation.rb +16 -0
  83. data/lib/catissue/domain/specimen_position.rb +3 -3
  84. data/lib/catissue/domain/specimen_protocol.rb +7 -7
  85. data/lib/catissue/domain/specimen_requirement.rb +9 -9
  86. data/lib/catissue/domain/storage_container.rb +13 -13
  87. data/lib/catissue/domain/storage_type.rb +12 -7
  88. data/lib/catissue/domain/transfer_event_parameters.rb +2 -2
  89. data/lib/catissue/domain/user.rb +15 -15
  90. data/lib/catissue/extract/extractor.rb +1 -1
  91. data/lib/catissue/resource.rb +8 -36
  92. data/lib/catissue/util/location.rb +0 -13
  93. data/lib/catissue/util/person.rb +2 -1
  94. data/lib/catissue/util/position.rb +1 -11
  95. data/lib/catissue/util/uniquify.rb +1 -1
  96. data/lib/catissue/version.rb +1 -1
  97. data/lib/catissue/wustl/logger.rb +17 -16
  98. data/test/fixtures/lib/catissue/defaults_test_fixture.rb +6 -4
  99. data/test/lib/catissue/domain/collection_protocol_test.rb +0 -1
  100. data/test/lib/catissue/domain/participant_test.rb +74 -19
  101. data/test/lib/catissue/domain/specimen_collection_group_test.rb +14 -10
  102. data/test/lib/catissue/domain/specimen_test.rb +36 -60
  103. data/test/lib/catissue/domain/storage_type_test.rb +5 -5
  104. data/test/lib/catissue/domain/transfer_event_parameters_test.rb +14 -12
  105. data/test/lib/catissue/migration/test_case.rb +0 -1
  106. data/test/lib/catissue/test_case.rb +12 -12
  107. data/test/lib/examples/galena/tissue/domain/examples_test.rb +1 -1
  108. data/test/lib/examples/galena/tissue/migration/annotation_test.rb +9 -7
  109. data/test/lib/examples/galena/tissue/migration/frozen_test.rb +1 -1
  110. data/test/lib/examples/galena/tissue/migration/general_test.rb +1 -1
  111. data/test/lib/examples/galena/tissue/migration/registration_test.rb +3 -9
  112. data/test/lib/examples/galena/tissue/migration/seedify.rb +3 -3
  113. data/test/lib/examples/pcbin/migration_test.rb +37 -16
  114. metadata +24 -10
  115. data/History.txt +0 -50
@@ -31,7 +31,7 @@ module CaTissue
31
31
  location
32
32
  end
33
33
 
34
- add_attribute(:from)
34
+ add_attribute(:from, Location)
35
35
 
36
36
  # Returns the to Location.
37
37
  def to
@@ -46,6 +46,6 @@ module CaTissue
46
46
  self.to_column = location.column
47
47
  end
48
48
 
49
- add_attribute(:to)
49
+ add_attribute(:to, Location)
50
50
  end
51
51
  end
@@ -10,9 +10,9 @@ module CaTissue
10
10
  class User
11
11
  include Person
12
12
 
13
- # caTissue alert - work-around for caTissue Bug #66 - Client missing CSException class et al.
14
- # caTissue User class initializes roleId to "", which triggers a client exception on subsequent
15
- # getRoleId call. Use a private variable instead and bypass getRoleId.
13
+ # @quirk caTissue work-around for caTissue Bug #66 - Client missing CSException class et al.
14
+ # caTissue User class initializes roleId to "", which triggers a client exception on subsequent
15
+ # getRoleId call. Use a private variable instead and bypass getRoleId.
16
16
  def role_id
17
17
  # TODO - uncomment following and get rid of @role_id i.v. when bug is fixed.
18
18
  #value = send(old_method)
@@ -24,8 +24,8 @@ module CaTissue
24
24
  # Sets the role id to the given value, which can be either a String or an Integer.
25
25
  # An empty or zero value is converted to nil.
26
26
  #
27
- # caTissue alert - caTissue API roleId is a String although the intended value domain is the
28
- # integer csm_role.identifier.
27
+ # @quirk caTissue caTissue API roleId is a String although the intended value domain is the
28
+ # integer csm_role.identifier.
29
29
  def role_id=(value)
30
30
  # value as an integer (nil is zero)
31
31
  value_i = value.to_i
@@ -37,14 +37,14 @@ module CaTissue
37
37
  setRoleId(value_s)
38
38
  end
39
39
 
40
- # caTissue alert - caTissue 1.2 User has an adminuser Java property, but caTissue throws an
41
- # UnsupportedOperationException if they are called.
40
+ # @quirk caTissue caTissue 1.2 User has an adminuser Java property, but caTissue throws an
41
+ # UnsupportedOperationException if they are called.
42
42
  if attribute_defined?(:adminuser) then remove_attribute(:adminuser) end
43
43
 
44
- # make the convenience Person name a first-class attribute
45
- add_attribute(:name)
44
+ # make the convenience {, CaRuby::Person::Name} name a first-class attribute
45
+ add_attribute(:name, CaRuby::Person::Name)
46
46
 
47
- # caTissue alert - clinical study is unsupported by 1.1.x caTissue, removed in 1.2.
47
+ # @quirk caTissue clinical study is unsupported by 1.1.x caTissue, removed in 1.2.
48
48
  if attribute_defined?(:clinical_studies) then remove_attribute(:clinical_studies) end
49
49
 
50
50
  # clarify that collection_protocols is a coordinator -> protocol association.
@@ -63,16 +63,16 @@ module CaTissue
63
63
  # * initial password is 'changeMe1'
64
64
  add_attribute_defaults(:activity_status => 'Active', :page_of => 'pageOfUserAdmin', :role_id => 7, :new_password => 'changeMe1')
65
65
 
66
- # caTissue alert - obscure GUI artifact User page_of attribute pollutes the data layer as a
67
- # required attribute. Work-around is to simulate the GUI with a default value.
66
+ # @quirk caTissue obscure GUI artifact User page_of attribute pollutes the data layer as a
67
+ # required attribute. Work-around is to simulate the GUI with a default value.
68
68
  add_mandatory_attributes(:activity_status, :address, :cancer_research_group, :department,
69
69
  :email_address, :first_name, :institution, :last_name, :page_of, :role_id)
70
70
 
71
- # caTissue alert - User address can be created but not updated in 1.2.
71
+ # @quirk caTissue User address can be created but not updated in 1.2.
72
72
  #
73
- # caTissue alert - User address is not fetched on create in 1.2.
73
+ # @quirk caTissue User address is not fetched on create in 1.2.
74
74
  #
75
- # caRuby alert - adding the :saved_fetch qualifier results in JRuby load_error. TODO - fix this.
75
+ # @quirk caRuby adding the :saved_fetch qualifier results in JRuby load_error. TODO - fix this.
76
76
  add_dependent_attribute(:address)
77
77
 
78
78
  # Password cannot be saved in 1.2.
@@ -46,7 +46,7 @@ module CaTissue
46
46
  fld = mapper.header(path)
47
47
  # the path node is either an attribute symbol or attribute metadata;
48
48
  # if metadata, then use the reader method.
49
- @fld_path_hash[fld] = path.map { |attr_or_md| CaRuby::AttributeMetadata === attr_or_md ? attr_or_md.reader : attr_or_md }
49
+ @fld_path_hash[fld] = path.map { |attr_or_md| CaRuby::Domain::Attribute === attr_or_md ? attr_or_md.reader : attr_or_md }
50
50
  end
51
51
  logger.debug { "Extract field => path map: #{@fld_path_hash.transform { |path| path.join('.') }.pp_s}" }
52
52
  end
@@ -1,14 +1,7 @@
1
1
  require 'caruby/resource'
2
- require 'caruby/domain/resource_module'
3
2
  require 'catissue/annotation/annotatable'
4
- require 'catissue/wustl/logger'
5
3
 
6
4
  module CaTissue
7
- extend CaRuby::ResourceModule
8
-
9
- # Set up the caTissue client logger.
10
- Wustl::Logger.configure
11
-
12
5
  # The module included by all CaTissue domain classes.
13
6
  #
14
7
  # A Resource class is extended to support an attribute -> value hash argument
@@ -40,14 +33,14 @@ module CaTissue
40
33
  # Returns the required attributes which are nil for this domain object.
41
34
  # Overrides the CaRuby::Resource method to handle the following bug:
42
35
  #
43
- # caTissue alert - Bug #67: AbstractSpecimen.setActivityStatus
44
- # is a no-op. The Specimen activityStatus property is incorrectly pulled
45
- # up to AbstractSpecimen. AbstractSpecimen.activityStatus is marked as
46
- # mandatory, since it is required for Specimen. However, it is not
47
- # mandatory, and in fact can't be set, for SpecimenRequirement.
48
- # Work-around is to add special code to exclude activityStatus from
49
- # the caRuby SpecimenRequirement missing mandatory attributes validation
50
- # check.
36
+ # @quirk caTissue Bug #67: AbstractSpecimen.setActivityStatus
37
+ # is a no-op. The Specimen activityStatus property is incorrectly pulled
38
+ # up to AbstractSpecimen. AbstractSpecimen.activityStatus is marked as
39
+ # mandatory, since it is required for Specimen. However, it is not
40
+ # mandatory, and in fact can't be set, for SpecimenRequirement.
41
+ # Work-around is to add special code to exclude activityStatus from
42
+ # the caRuby SpecimenRequirement missing mandatory attributes validation
43
+ # check.
51
44
  def missing_mandatory_attributes
52
45
  invalid = super
53
46
  # Special case: AbstractSpecimen.setActivityStatus is a no-op.
@@ -72,26 +65,5 @@ module CaTissue
72
65
  value.nil? or value == UNSPECIFIED
73
66
  end
74
67
  end
75
-
76
- # The include mix-in module.
77
- @mixin = Resource
78
-
79
- # The required Java package name.
80
- @java_package = 'edu.wustl.catissuecore.domain'
81
-
82
- # Extends the given domain class as an #{AnnotatableClass}.
83
- #
84
- # @param [Class] klass the class that was added to this domain module
85
- def self.class_added(klass)
86
- # Defer loading AnnotatableClass to avoid pulling in Database, which in turn
87
- # attempts to import java classes before the path is established. Obscure
88
- # detail, but don't know how to avoid it.
89
- require 'catissue/annotation/annotatable_class'
90
- klass.extend(AnnotatableClass)
91
- end
92
-
93
- # Load the domain class definitions.
94
- dir = File.join(File.dirname(__FILE__), 'domain')
95
- load_dir(dir)
96
68
  end
97
69
 
@@ -7,8 +7,6 @@ module CaTissue
7
7
  # Location does not capture the occupant; therefore, changing a location coordinate value alone does not
8
8
  # change the storage assignment of an occupant.
9
9
  class Location
10
- include Comparable
11
-
12
10
  attr_accessor :container, :coordinate
13
11
 
14
12
  alias_attribute(:holder, :container)
@@ -55,17 +53,6 @@ module CaTissue
55
53
  super rescue false
56
54
  end
57
55
 
58
- # @param [Location] other the position to compare
59
- # @return (see Coordinate#<=>)
60
- # @raise [ArgumentError] if other is not an Location
61
- def <=>(other)
62
- raise ArgumentError.new("Can't compare #{qp} to #{other.qp}") unless @container and Location === other
63
- unless container == other.container then
64
- raise ArgumentError.new("Can't compare #{qp} in container #{container} to #{other.qp} in container #{other.container}")
65
- end
66
- @coordinate <=> other.coordinate
67
- end
68
-
69
56
  # @return [Location, nil] a new Location at the next slot in this Location's {#container},
70
57
  # or nil if there are no more locations
71
58
  def succ
@@ -15,6 +15,8 @@ module CaTissue
15
15
 
16
16
  # Sets this Person's name to the name string or Name object.
17
17
  # A string name argument is parsed using Name.parse.
18
+ #
19
+ # @quirk caTissue CaTissue person names are inconsistent: Participant has a middle name, User doesn't.
18
20
  def name=(value)
19
21
  value = Name.parse(value) if String === value
20
22
  # a missing name is equivalent to an empty name for our purposes here
@@ -24,7 +26,6 @@ module CaTissue
24
26
  end
25
27
  self.first_name = value.first
26
28
  self.last_name = value.last
27
- # caTissue alert - CaTissue person names are inconsistent: Participant has a middle name, User doesn't.
28
29
  self.middle_name = value.middle if respond_to?(:middle_name)
29
30
  end
30
31
  end
@@ -7,16 +7,6 @@ module CaTissue
7
7
  # and holder methods. The occupant must be a {Storable}. The holder must be
8
8
  # a {Container}.
9
9
  module Position
10
- include Comparable
11
-
12
- # @param [Position] other the position to compare
13
- # @return (see Location#<=>)
14
- # @raise [ArgumentError] if other is not an instance of this Position's concrete class
15
- def <=>(other)
16
- raise ArgumentError.new("Can't compare #{qp} to #{other.qp}") unless self.class === other
17
- equal?(other) ? 0 : location <=> other.location
18
- end
19
-
20
10
  # @return [Boolean] whether other is an instance of this position's class with the same
21
11
  # occupant and equal location
22
12
  #
@@ -30,7 +20,7 @@ module CaTissue
30
20
  location.coordinate
31
21
  end
32
22
 
33
- # @return [Location] the location of this Position.
23
+ # @return [Location] the location of this Position
34
24
  def location
35
25
  @location ||= Location.new
36
26
  # always ensure that the location is consistent with the Java state
@@ -7,7 +7,7 @@ module CaTissue
7
7
  # Makes this CP's short and long title unique.
8
8
  def uniquify
9
9
  super
10
- self.title = short_title
10
+ self.short_title = title
11
11
  end
12
12
  end
13
13
 
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # The version of this caRuby Tissue release.
3
- VERSION = "1.4.2"
3
+ VERSION = "1.5.1"
4
4
 
5
5
  # The supported caTissue release versions.
6
6
  CATISSUE_VERSIONS = "1.1.2-1.2"
@@ -2,23 +2,23 @@
2
2
  module Wustl
3
3
  # Logger configures the +edu.wustl+ logger.
4
4
  module Logger
5
- # caTissue alert - the caTissue logger must be initialized before caTissue objects are created.
6
- # The logger at issue is the caTissue client logger, not the caTissue server logger nor
7
- # the caRuby logger. The caTissue logger facade class is edu.wustl.common.util.logger.Logger.
8
- # In caTissue 1.1.x, initialization is done with +configure+, in 1.2 with
9
- # +LoggerConfig.configureLogger+.
5
+ # @quirk caTissue the caTissue logger must be initialized before caTissue objects are created.
6
+ # The logger at issue is the caTissue client logger, not the caTissue server logger nor
7
+ # the caRuby logger. The caTissue logger facade class is edu.wustl.common.util.logger.Logger.
8
+ # In caTissue 1.1.x, initialization is done with +configure+, in 1.2 with
9
+ # +LoggerConfig.configureLogger+.
10
10
  #
11
- # catTissue alert - +LoggerConfig.configureLogger+ expects file +log4j.properties+ in the class
12
- # path. However, in 1.2 the client property file is +client_log4j.properties+. Work-around is
13
- # as follows:
14
- # * copy this file into the caRuby Tissue distribution as +conf/wustl/log4.properties+
15
- # * add +conf/wustl+ to the classpath.
16
- # * call +LoggerConfig.configureLogger+ with the config directory as an argument
11
+ # @quirk catTissue +LoggerConfig.configureLogger+ expects file +log4j.properties+ in the class
12
+ # path. However, in 1.2 the client property file is +client_log4j.properties+. Work-around is
13
+ # as follows:
14
+ # * copy this file into the caRuby Tissue distribution as +conf/wustl/log4.properties+
15
+ # * add +conf/wustl+ to the classpath.
16
+ # * call +LoggerConfig.configureLogger+ with the config directory as an argument
17
17
  #
18
- # caTissue alert - The caTissue client log location is unfortunately hard-coded in a caTissue client
19
- # configuration file, does not create the parent directory on demand, and issues an obscure error
20
- # message if the directory does not exist in release 1.1.x. The work-around is to ensure that the
21
- # working directory contains a log subdirectory.
18
+ # @quirk caTissue The caTissue client log location is unfortunately hard-coded in a caTissue client
19
+ # configuration file, does not create the parent directory on demand, and issues an obscure error
20
+ # message if the directory does not exist in release 1.1.x. The work-around is to ensure that the
21
+ # working directory contains a log subdirectory.
22
22
  def self.configure
23
23
  # Set the configured flag. Configure only once.
24
24
  if @configured then return else @configured = true end
@@ -40,8 +40,9 @@ module Wustl
40
40
 
41
41
  # Makes a +./log+ subdirectory to avoid a caTissue log initializer error. This method should be called
42
42
  # before configuring the logger.
43
+ #
44
+ # @quirk caTissue avoid caTissue error by creating log subdirectory.
43
45
  def self.ensure_log_directory_exists
44
- # caTissue alert - avoid caTissue error by creating log subdirectory
45
46
  if File.directory?('log') then
46
47
  unless File.writable?('log') then
47
48
  raise StandardError.new("caTissue log subdirectory #{File.expand_path('log')} is not writable")
@@ -55,15 +55,17 @@ module CaTissueTest
55
55
  domain_objects.each { |obj| obj.find(:create) unless obj.identifier or obj.class.dependent? }
56
56
  end
57
57
 
58
- # Repopulates the defaults and makes a unique collection_protocol short_title, participant MRN and
59
- # specimen label.
58
+ # Repopulates the defaults and makes the following attributes unique:
59
+ # * collection_protocol short title
60
+ # * participant MRN
61
+ # * specimen label
60
62
  #
61
63
  # @return this fixture
62
64
  def uniquify
63
65
  populate
64
66
  # make the CP and MRN unique; these values will ripple through the SCG, CPR, et al.
65
67
  # to make them unique as well
66
- @protocol.short_title = @protocol.short_title.uniquify
68
+ @protocol.title = @protocol.title.uniquify
67
69
  @registration.participant.medical_identifiers.each { |mid| mid.medical_record_number = Uniquifier.qualifier }
68
70
  # unset the SCG name and specimen label so the default is set to a new unique value
69
71
  @specimen_collection_group.name = @specimen.label = nil
@@ -152,7 +154,7 @@ module CaTissueTest
152
154
 
153
155
  # the test collection protocol
154
156
  @protocol = CaTissue::CollectionProtocol.new(
155
- :short_title => 'Test CP',
157
+ :title => 'Test CP',
156
158
  :principal_investigator => pi
157
159
  )
158
160
 
@@ -50,7 +50,6 @@ class CollectionProtocolTest < Test::Unit::TestCase
50
50
  assert(@pcl.specimens(pnt).include?(spc2), 'Specimen not found')
51
51
  end
52
52
 
53
- # Verify the events.
54
53
  def test_events
55
54
  event = @pcl.events.first
56
55
  assert_not_nil(event, "Protocol test default has no events")
@@ -30,19 +30,70 @@ class ParticipantTest < Test::Unit::TestCase
30
30
  expected = @pnt.social_security_number = '555-55-5555'
31
31
  assert_equal(expected, @pnt.key, 'Person key is not the SSN')
32
32
  end
33
+
34
+ def test_treatment_annotation
35
+ trt = CaTissue::Participant::Clinical::TreatmentAnnotation.new
36
+ trt.merge_attributes(:agent => 'ACACIA', :participant => @pnt)
37
+ dur = CaTissue::Participant::Clinical::Duration.new
38
+ dur.merge_attributes(:start_date => DateTime.new(2010, 10, 10), :end_date => DateTime.new(2010, 12, 10), :treatment => trt)
39
+ cln = @pnt.clinical.first
40
+ assert_not_nil(cln, "Clinical annotation not added to participant")
41
+ trts = cln.treatment_annotations
42
+ assert_not_nil(trts.first, "Treatment not added to participant annotations")
43
+ assert_same(trt, trts.first, "Treatment incorrect")
44
+ assert_same(@pnt, trt.hook, "Treatment proxy hook not set")
45
+ assert_not_nil(trt.durations.first, "Duration not added to treatment annotation")
46
+ assert_same(dur, trt.durations.first, "Treatment duration incorrect")
47
+ end
48
+
49
+ def test_exposure_annotation
50
+ exp = CaTissue::Participant::Clinical::EnvironmentalExposuresHealthAnnotation.new
51
+ exp.merge_attributes(:years_agent_free => 2, :participant => @pnt)
52
+ cln = @pnt.clinical.first
53
+ assert_not_nil(cln, "Clinical annotation not added to participant")
54
+ exps = cln.environmental_exposures_health_annotations
55
+ assert_not_nil(exps.first, "Exposures not added to participant annotations")
56
+ assert_same(exp, exps.first, "Exposures incorrect")
57
+ assert_same(@pnt, exp.hook, "Exposure proxy hook not set")
58
+ end
59
+
60
+ def test_alcohol_annotation
61
+ alc = CaTissue::Participant::Clinical::AlcoholHealthAnnotation.new
62
+ alc.merge_attributes(:drinks_per_week => 4, :years_agent_free => 2, :participant => @pnt)
63
+ cln = @pnt.clinical.first
64
+ assert_not_nil(cln, "Clinical annotation not added to participant")
65
+ alcs = cln.alcohol_health_annotations
66
+ assert_not_nil(alcs.first, "Alcohol health not added to participant annotations")
67
+ assert_same(alc, alcs.first, "Alcohol health incorrect")
68
+ assert_same(@pnt, alc.hook, "Alcohol health proxy hook not set")
69
+ end
33
70
 
34
71
  # Tests making a participant lab annotation.
35
72
  def test_lab_annotation
36
- labs = @pnt.lab_annotations
37
- assert(labs.empty?, "Labs not empty at start")
38
73
  lab = CaTissue::Participant::Clinical::LabAnnotation.new
39
74
  lab.merge_attributes(:lab_test_name => 'Test Lab', :participant => @pnt)
40
- labs = @pnt.lab_annotations
75
+ cln = @pnt.clinical.first
76
+ assert_not_nil(cln, "Clinical annotation not added to participant")
77
+ labs = cln.lab_annotations
41
78
  assert_not_nil(labs.first, "Lab not added to participant labs")
42
79
  assert_same(lab, labs.first, "Lab incorrect")
43
- assert_same(@pnt, lab.owner, "Lab proxy hook not set")
80
+ assert_same(@pnt, lab.hook, "Lab proxy hook not set")
81
+ end
82
+
83
+ def test_radiation_annotation
84
+ if CaTissue::Participant::Clinical::RadiationTherapy != CaTissue::Participant::Clinical::RadRXAnnotation then
85
+ assert_raises(CaTissue::AnnotationError, "RadiationTherapy is not deprecated.") { CaTissue::Participant::Clinical::RadiationTherapy.new}
86
+ end
87
+ end
88
+
89
+ def test_chemotherapy_annotation
90
+ if CaTissue::Participant::Clinical::Chemotherapy != CaTissue::Participant::Clinical::ChemoRXAnnotation then
91
+ assert_raises(CaTissue::AnnotationError, "Chemotherapy is not deprecated.") { CaTissue::Participant::Clinical::Chemotherapy.new}
92
+ end
44
93
  end
45
94
 
95
+ ## DATABASE TEST CASES
96
+
46
97
  # Tests creating a participant.
47
98
  def test_save
48
99
  verify_save(@pnt)
@@ -72,6 +123,17 @@ class ParticipantTest < Test::Unit::TestCase
72
123
  assert_not_nil(lab.identifier, "Lab not saved")
73
124
  end
74
125
 
126
+ # Tests saving a participant treatment annotation.
127
+ def test_save_treatment_annotation
128
+ trt = CaTissue::Participant::Clinical::TreatmentAnnotation.new
129
+ trt.merge_attributes(:agent => 'ACACIA', :participant => @pnt)
130
+ dur = CaTissue::Participant::Clinical::Duration.new
131
+ dur.merge_attributes(:start_date => DateTime.new(2010, 10, 10), :end_date => DateTime.new(2010, 12, 10), :treatment => trt)
132
+ verify_save(trt)
133
+ assert_not_nil(trt.identifier, "Treatment not saved")
134
+ assert_not_nil(dur.identifier, "Treatment duration not saved")
135
+ end
136
+
75
137
  # Exercises creation of both a HealthExaminationAnnotation and a NewDiagnosisHealthAnnotation.
76
138
  # These annotation classes are both primary and share a comman ancestor entity used
77
139
  # as the basis for generating database identifiers.
@@ -86,23 +148,16 @@ class ParticipantTest < Test::Unit::TestCase
86
148
  verify_save(hdgn)
87
149
  end
88
150
 
89
- def test_save_treatment_annotation
90
- date = DateTime.new(2010, 10, 10)
91
- trt = CaTissue::Participant::Clinical::TreatmentAnnotation.new
92
- trt.merge_attributes(:other_agent => 'Radical Prostatectomy', :participant => @pnt)
93
- dtn = CaTissue::Participant::Clinical::Duration.new
94
- dtn.merge_attributes(:start_date => date, :end_date => date, :duration_in_days => 1, :treatment_annotation => trt)
95
- verify_save(trt)
151
+ def test_save_radiation_annotation
152
+ rad = CaTissue::Participant::Clinical::RadRXAnnotation.new
153
+ rad.merge_attributes(:other_agent => 'Adjuvant Radiation Therapy', :participant => @pnt)
154
+ verify_save(rad)
96
155
  end
97
156
 
98
- # caTissue alert - The RadiationTherapy DE class is not supported, since it is not a primary entity.
99
- # RadRXAnnotation is used instead. The purpose of the caTissue RadiationTherapy class is unknown,
100
- # since it adds nothing to RadRXAnnotation. The same consideration applies to Chemotherapy.
101
- # TODO - check with caTissue support and either request deprecation or add caRuby support.
102
- def test_save_radiation_annotation
103
- rdx = CaTissue::Participant::Clinical::RadRXAnnotation.new
104
- rdx.merge_attributes(:other_agent => 'Adjuvant Radiation Therapy', :participant => @pnt)
105
- verify_save(rdx)
157
+ def test_save_chemo_annotation
158
+ chm = CaTissue::Participant::Clinical::ChemoRXAnnotation.new
159
+ chm.merge_attributes(:other_agent => 'Adjuvant Chemotherapy', :participant => @pnt)
160
+ verify_save(chm)
106
161
  end
107
162
 
108
163
  def test_save_exam_annotation