caruby-tissue 1.5.6 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +17 -0
- data/History.md +5 -1
- data/README.md +2 -2
- data/bin/crtdump +2 -8
- data/bin/crtexample +2 -5
- data/bin/crtmigrate +3 -6
- data/bin/crtsmoke +3 -8
- data/conf/wustl/{log4j.properties → linux/log4j.properties} +3 -3
- data/conf/wustl/windows/log4j.properties +40 -0
- data/examples/galena/Gemfile +16 -0
- data/examples/galena/Gemfile.lock +88 -0
- data/examples/galena/README.md +16 -16
- data/examples/galena/Rakefile +30 -0
- data/examples/galena/bin/seed +5 -11
- data/examples/galena/conf/annotation/defaults.yaml +2 -0
- data/examples/galena/conf/{migration/annotation_fields.yaml → annotation/fields.yaml} +2 -4
- data/examples/galena/conf/defaults.yaml +9 -0
- data/examples/galena/conf/{migration/filter_fields.yaml → filter/fields.yaml} +0 -1
- data/examples/galena/conf/filter/values.yaml +8 -0
- data/examples/galena/conf/{migration/frozen_defaults.yaml → frozen/defaults.yaml} +0 -0
- data/examples/galena/conf/{migration/frozen_fields.yaml → frozen/fields.yaml} +0 -2
- data/examples/galena/conf/{migration/general_fields.yaml → general/fields.yaml} +0 -24
- data/examples/galena/conf/registration/fields.yaml +6 -0
- data/examples/galena/conf/{migration/simple_fields.yaml → simple/fields.yaml} +1 -6
- data/examples/galena/data/annotation.csv +1 -1
- data/examples/galena/data/filter.csv +1 -1
- data/examples/galena/data/frozen.csv +1 -1
- data/examples/galena/data/general.csv +1 -1
- data/examples/galena/data/registration.csv +1 -1
- data/examples/galena/data/simple.csv +1 -1
- data/examples/galena/galena.gemspec +24 -0
- data/examples/galena/lib/galena/filter.rb +25 -0
- data/examples/galena/lib/galena/{tissue/migration/frozen_shims.rb → frozen.rb} +6 -10
- data/examples/galena/lib/galena/seed.rb +126 -0
- data/examples/galena/lib/galena/version.rb +3 -0
- data/examples/galena/lib/galena.rb +18 -7
- data/examples/galena/log/galena.log +37351 -0
- data/examples/galena/log/galena.log.0 +147830 -0
- data/examples/galena/spec/annotation_spec.rb +46 -0
- data/examples/galena/spec/filter_spec.rb +94 -0
- data/examples/galena/spec/frozen_spec.rb +39 -0
- data/examples/galena/spec/general_spec.rb +62 -0
- data/examples/galena/spec/registration_spec.rb +37 -0
- data/examples/galena/spec/seed.rb +107 -0
- data/examples/galena/spec/simple_spec.rb +58 -0
- data/examples/galena/spec/spec_helper.rb +11 -0
- data/examples/galena/spec/support/migration.rb +70 -0
- data/lib/catissue/annotation/annotatable.rb +10 -8
- data/lib/catissue/annotation/annotation.rb +7 -7
- data/lib/catissue/annotation/de_integration.rb +9 -20
- data/lib/catissue/annotation/importer.rb +148 -0
- data/lib/catissue/annotation/introspector.rb +32 -0
- data/lib/catissue/annotation/metadata.rb +422 -0
- data/lib/catissue/annotation/proxy.rb +2 -2
- data/lib/catissue/annotation/proxy_class.rb +45 -30
- data/lib/catissue/annotation/record_entry_proxy.rb +2 -2
- data/lib/catissue/cli/command.rb +14 -24
- data/lib/catissue/cli/example.rb +5 -3
- data/lib/catissue/cli/migrate.rb +45 -37
- data/lib/catissue/cli/smoke.rb +2 -3
- data/lib/catissue/database/annotation/annotation_service.rb +8 -17
- data/lib/catissue/database/annotation/entity_facade.rb +33 -30
- data/lib/catissue/database/annotation/id_generator.rb +1 -1
- data/lib/catissue/database/annotation/integration_service.rb +11 -4
- data/lib/catissue/database/annotation/reference_writer.rb +38 -38
- data/lib/catissue/database/controlled_value_finder.rb +13 -28
- data/lib/catissue/database/controlled_values.rb +73 -45
- data/lib/catissue/database.rb +637 -277
- data/lib/catissue/domain/abstract_domain_object.rb +5 -0
- data/lib/catissue/domain/abstract_position.rb +3 -5
- data/lib/catissue/domain/abstract_specimen.rb +79 -65
- data/lib/catissue/domain/abstract_specimen_collection_group.rb +3 -6
- data/lib/catissue/domain/address.rb +0 -2
- data/lib/catissue/domain/cancer_research_group.rb +0 -3
- data/lib/catissue/domain/capacity.rb +2 -4
- data/lib/catissue/domain/check_in_check_out_event_parameter.rb +0 -3
- data/lib/catissue/domain/collection_event_parameters.rb +2 -7
- data/lib/catissue/domain/collection_protocol.rb +11 -16
- data/lib/catissue/domain/collection_protocol_event.rb +19 -12
- data/lib/catissue/domain/collection_protocol_registration.rb +8 -12
- data/lib/catissue/domain/consent_tier_response.rb +0 -4
- data/lib/catissue/domain/consent_tier_status.rb +1 -4
- data/lib/catissue/domain/container.rb +10 -10
- data/lib/catissue/domain/container_position.rb +4 -7
- data/lib/catissue/domain/container_type.rb +4 -7
- data/lib/catissue/domain/department.rb +0 -3
- data/lib/catissue/domain/disposal_event_parameters.rb +5 -5
- data/lib/catissue/domain/embedded_event_parameters.rb +1 -4
- data/lib/catissue/domain/external_identifier.rb +0 -12
- data/lib/catissue/domain/frozen_event_parameters.rb +1 -4
- data/lib/catissue/domain/institution.rb +0 -3
- data/lib/catissue/domain/new_specimen_array_order_item.rb +0 -5
- data/lib/catissue/domain/order_details.rb +0 -2
- data/lib/catissue/domain/participant/clinical/chemotherapy.rb +1 -3
- data/lib/catissue/domain/participant/clinical/duration.rb +2 -4
- data/lib/catissue/domain/participant/clinical/radiation_therapy.rb +2 -4
- data/lib/catissue/domain/participant.rb +22 -24
- data/lib/catissue/domain/participant_medical_identifier.rb +0 -4
- data/lib/catissue/domain/password.rb +0 -4
- data/lib/catissue/domain/race.rb +0 -3
- data/lib/catissue/domain/received_event_parameters.rb +3 -6
- data/lib/catissue/domain/site.rb +1 -4
- data/lib/catissue/domain/specimen/pathology/additional_finding.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/details.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/gleason_score.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/histologic_grade.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/histologic_type.rb +19 -0
- data/lib/catissue/domain/specimen/pathology/histologic_variant_type.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/invasion.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/prostate_specimen_gleason_score.rb +5 -11
- data/lib/catissue/domain/specimen/pathology/prostate_specimen_pathology_annotation.rb +12 -12
- data/lib/catissue/domain/specimen/pathology/specimen_additional_finding.rb +5 -14
- data/lib/catissue/domain/specimen/pathology/specimen_base_solid_tissue_pathology_annotation.rb +6 -21
- data/lib/catissue/domain/specimen/pathology/specimen_details.rb +4 -10
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_grade.rb +4 -10
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_type.rb +6 -14
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_variant_type.rb +5 -11
- data/lib/catissue/domain/specimen/pathology/specimen_invasion.rb +5 -11
- data/lib/catissue/domain/specimen.rb +113 -76
- data/lib/catissue/domain/specimen_array.rb +0 -3
- data/lib/catissue/domain/specimen_array_content.rb +1 -4
- data/lib/catissue/domain/specimen_array_type.rb +1 -4
- data/lib/catissue/domain/specimen_characteristics.rb +0 -3
- data/lib/catissue/domain/specimen_collection_group/pathology/base_pathology_annotation.rb +2 -4
- data/lib/catissue/domain/specimen_collection_group/pathology/base_solid_tissue_pathology_annotation.rb +2 -4
- data/lib/catissue/domain/specimen_collection_group.rb +43 -53
- data/lib/catissue/domain/specimen_event_parameters.rb +24 -32
- data/lib/catissue/domain/specimen_position.rb +8 -5
- data/lib/catissue/domain/specimen_protocol.rb +3 -6
- data/lib/catissue/domain/specimen_requirement.rb +22 -20
- data/lib/catissue/domain/storage_container.rb +9 -12
- data/lib/catissue/domain/storage_type.rb +6 -10
- data/lib/catissue/domain/transfer_event_parameters.rb +3 -6
- data/lib/catissue/domain/user.rb +22 -29
- data/lib/catissue/{util → helpers}/collectible.rb +23 -18
- data/lib/catissue/helpers/collectible_event_parameters.rb +68 -0
- data/lib/catissue/helpers/controlled_value.rb +35 -0
- data/lib/catissue/{domain → helpers}/hash_code.rb +0 -0
- data/lib/catissue/{util → helpers}/location.rb +6 -5
- data/lib/catissue/helpers/log.rb +4 -0
- data/lib/catissue/{util → helpers}/person.rb +1 -1
- data/lib/catissue/{util → helpers}/position.rb +10 -8
- data/lib/catissue/helpers/properties_loader.rb +143 -0
- data/lib/catissue/{util → helpers}/storable.rb +2 -1
- data/lib/catissue/{util → helpers}/storage_type_holder.rb +9 -3
- data/lib/catissue/{annotation/annotatable_class.rb → metadata.rb} +73 -95
- data/lib/catissue/migration/migratable.rb +93 -44
- data/lib/catissue/migration/migrator.rb +26 -42
- data/lib/catissue/migration/shims.rb +1 -1
- data/lib/catissue/migration/unique.rb +76 -0
- data/lib/catissue/resource.rb +16 -20
- data/lib/catissue/version.rb +1 -1
- data/lib/catissue/wustl/logger.rb +52 -32
- data/lib/catissue.rb +38 -20
- data/test/lib/catissue/database/controlled_values_test.rb +22 -27
- data/test/lib/catissue/database/database_test.rb +18 -0
- data/test/lib/catissue/domain/address_test.rb +9 -11
- data/test/lib/catissue/domain/ca_tissue_test_defaults_test.rb +5 -16
- data/test/lib/catissue/domain/capacity_test.rb +2 -2
- data/test/lib/catissue/domain/collection_event_parameters_test.rb +16 -8
- data/test/lib/catissue/domain/collection_protocol_event_test.rb +1 -1
- data/test/lib/catissue/domain/collection_protocol_registration_test.rb +26 -16
- data/test/lib/catissue/domain/collection_protocol_test.rb +2 -2
- data/test/lib/catissue/domain/container_position_test.rb +7 -4
- data/test/lib/catissue/domain/department_test.rb +3 -3
- data/test/lib/catissue/domain/disposal_event_parameters_test.rb +1 -1
- data/test/lib/catissue/domain/external_identifier_test.rb +5 -1
- data/test/lib/catissue/domain/location_test.rb +4 -4
- data/test/lib/catissue/domain/participant_medical_identifier_test.rb +3 -3
- data/test/lib/catissue/domain/participant_test.rb +33 -20
- data/test/lib/catissue/domain/received_event_parameters_test.rb +19 -0
- data/test/lib/catissue/domain/site_test.rb +2 -2
- data/test/lib/catissue/domain/specimen_array_test.rb +3 -3
- data/test/lib/catissue/domain/specimen_array_type_test.rb +6 -6
- data/test/lib/catissue/domain/specimen_characteristics_test.rb +1 -1
- data/test/lib/catissue/domain/specimen_collection_group_test.rb +49 -13
- data/test/lib/catissue/domain/specimen_event_parameters_test.rb +4 -4
- data/test/lib/catissue/domain/specimen_position_test.rb +1 -1
- data/test/lib/catissue/domain/specimen_requirement_test.rb +2 -2
- data/test/lib/catissue/domain/specimen_test.rb +58 -24
- data/test/lib/catissue/domain/storage_container_test.rb +3 -16
- data/test/lib/catissue/domain/storage_type_test.rb +3 -3
- data/test/lib/catissue/domain/transfer_event_parameters_test.rb +17 -17
- data/test/lib/catissue/domain/user_test.rb +32 -34
- data/test/lib/catissue/helpers/properties_loader_test.rb +19 -0
- data/test/lib/catissue/migration/{test_case.rb → helpers/test_case.rb} +30 -20
- data/test/lib/examples/galena/tissue/domain/examples_test.rb +28 -38
- data/test/lib/examples/galena/tissue/helpers/test_case.rb +24 -0
- metadata +175 -99
- data/bin/crtextract +0 -47
- data/examples/galena/conf/extract/simple_fields.yaml +0 -4
- data/examples/galena/conf/migration/annotation_defaults.yaml +0 -2
- data/examples/galena/conf/migration/filter_defaults.yaml +0 -1
- data/examples/galena/conf/migration/filter_values.yaml +0 -13
- data/examples/galena/conf/migration/participant_fields.yaml +0 -4
- data/examples/galena/conf/migration/registration_fields.yaml +0 -5
- data/examples/galena/data/participant.csv +0 -1
- data/examples/galena/lib/galena/tissue/migration/filter_shims.rb +0 -41
- data/examples/galena/lib/galena/tissue/seed/defaults.rb +0 -127
- data/examples/psbin/README.md +0 -45
- data/examples/psbin/conf/adjuvant_hormone_defaults.yaml +0 -2
- data/examples/psbin/conf/adjuvant_radiation_defaults.yaml +0 -3
- data/examples/psbin/conf/biopsy_defaults.yaml +0 -3
- data/examples/psbin/conf/biopsy_fields.yaml +0 -9
- data/examples/psbin/conf/neoadjuvant_hormone_defaults.yaml +0 -2
- data/examples/psbin/conf/neoadjuvant_radiation_defaults.yaml +0 -3
- data/examples/psbin/conf/patient_defaults.yaml +0 -3
- data/examples/psbin/conf/patient_fields.yaml +0 -5
- data/examples/psbin/conf/surgery_defaults.yaml +0 -4
- data/examples/psbin/conf/surgery_fields.yaml +0 -15
- data/examples/psbin/conf/t_stage_defaults.yaml +0 -1
- data/examples/psbin/conf/t_stage_fields.yaml +0 -4
- data/examples/psbin/conf/therapy_fields.yaml +0 -5
- data/examples/psbin/data/adjuvant_hormone.csv +0 -1
- data/examples/psbin/data/adjuvant_radiation.csv +0 -1
- data/examples/psbin/data/biopsy.csv +0 -1
- data/examples/psbin/data/neoadjuvant_hormone.csv +0 -1
- data/examples/psbin/data/neoadjuvant_radiation.csv +0 -1
- data/examples/psbin/data/patient.csv +0 -1
- data/examples/psbin/data/surgery.csv +0 -1
- data/examples/psbin/data/t_stage.csv +0 -1
- data/examples/psbin/lib/psbin/biopsy_shims.rb +0 -15
- data/examples/psbin/lib/psbin/surgery_shims.rb +0 -15
- data/lib/catissue/annotation/annotation_class.rb +0 -406
- data/lib/catissue/annotation/annotation_module.rb +0 -106
- data/lib/catissue/domain.rb +0 -26
- data/lib/catissue/extract/command.rb +0 -31
- data/lib/catissue/extract/delta.rb +0 -58
- data/lib/catissue/extract/extractor.rb +0 -99
- data/lib/catissue/migration/uniquify.rb +0 -2
- data/lib/catissue/util/collectible_event_parameters.rb +0 -71
- data/lib/catissue/util/controlled_value.rb +0 -29
- data/lib/catissue/util/uniquify.rb +0 -86
- data/test/fixtures/catissue/domain/conf/catissue_override.yaml +0 -9
- data/test/fixtures/catissue/extract/conf/scg_extract.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/scg_fields.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/spc_extract.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/spc_fields.yaml +0 -4
- data/test/fixtures/lib/catissue/defaults_test_fixture.rb +0 -206
- data/test/fixtures/lib/examples/galena/migration/alt_key_shims.rb +0 -7
- data/test/lib/catissue/domain/base_haemotology_pathology_test.rb +0 -24
- data/test/lib/catissue/extract/delta_test.rb +0 -25
- data/test/lib/catissue/extract/extractor_test.rb +0 -43
- data/test/lib/catissue/import/importable_module_test.rb +0 -14
- data/test/lib/catissue/test_case.rb +0 -247
- data/test/lib/examples/galena/tissue/migration/annotation_test.rb +0 -29
- data/test/lib/examples/galena/tissue/migration/filter_test.rb +0 -29
- data/test/lib/examples/galena/tissue/migration/frozen_test.rb +0 -36
- data/test/lib/examples/galena/tissue/migration/general_test.rb +0 -56
- data/test/lib/examples/galena/tissue/migration/participant_test.rb +0 -61
- data/test/lib/examples/galena/tissue/migration/registration_test.rb +0 -17
- data/test/lib/examples/galena/tissue/migration/seedify.rb +0 -119
- data/test/lib/examples/galena/tissue/migration/simple_test.rb +0 -30
- data/test/lib/examples/galena/tissue/migration/test_case.rb +0 -72
- data/test/lib/examples/psbin/migration_test.rb +0 -153
@@ -1,206 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'caruby/util/validation'
|
3
|
-
require 'caruby/util/uniquifier'
|
4
|
-
require 'catissue'
|
5
|
-
|
6
|
-
module CaTissueTest
|
7
|
-
# Error setting up the test fixture.
|
8
|
-
class TestError < RuntimeError; end
|
9
|
-
|
10
|
-
def self.defaults
|
11
|
-
Defaults.instance
|
12
|
-
end
|
13
|
-
|
14
|
-
# caTissue test default admin fixture.
|
15
|
-
class Defaults
|
16
|
-
include Singleton, Enumerable
|
17
|
-
|
18
|
-
attr_reader :tissue_bank, :protocol, :registration, :specimen,
|
19
|
-
:specimen_requirement, :specimen_collection_group, :box
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
super
|
23
|
-
populate
|
24
|
-
end
|
25
|
-
|
26
|
-
# Retusns this fixture's domain objects.
|
27
|
-
def domain_objects
|
28
|
-
instance_variables.map { |iv| instance_eval iv }.select { |value| CaRuby::Resource === value }
|
29
|
-
end
|
30
|
-
|
31
|
-
# Adds default values to this fixture's domain objects.
|
32
|
-
def add_defaults
|
33
|
-
domain_objects.each { |obj| obj.add_defaults unless obj.equal?(specimen) }
|
34
|
-
# Add specimen default values last, since SCG add_specimens propagates the collection event
|
35
|
-
# necessary to set the default specimen label.
|
36
|
-
specimen.add_defaults
|
37
|
-
self
|
38
|
-
end
|
39
|
-
|
40
|
-
# Fetches the default instances from the database. Creates new objects if necesssary.
|
41
|
-
#
|
42
|
-
# @raise [ValidationError] if a domain object fails validation
|
43
|
-
def validate
|
44
|
-
# identifiers are required for validation; these are removed following validation
|
45
|
-
objs_without_ids = domain_objects.select { |obj| obj.identifier.nil? }
|
46
|
-
objs_without_ids.each_with_index { |obj, index| obj.identifier = index + 1 }
|
47
|
-
domain_objects.each { |obj| obj.validate }
|
48
|
-
# restore null identifiers
|
49
|
-
objs_without_ids.each { |obj| obj.identifier = nil }
|
50
|
-
self
|
51
|
-
end
|
52
|
-
|
53
|
-
# Creates this fixture's {#domain_objects} in the database, if necessary.
|
54
|
-
def ensure_exists
|
55
|
-
domain_objects.each { |obj| obj.find(:create) unless obj.identifier or obj.class.dependent? }
|
56
|
-
end
|
57
|
-
|
58
|
-
# Repopulates the defaults and makes the following attributes unique:
|
59
|
-
# * collection_protocol short title
|
60
|
-
# * participant MRN
|
61
|
-
# * specimen label
|
62
|
-
#
|
63
|
-
# @return this fixture
|
64
|
-
def uniquify
|
65
|
-
populate
|
66
|
-
# make the CP and MRN unique; these values will ripple through the SCG, CPR, et al.
|
67
|
-
# to make them unique as well
|
68
|
-
@protocol.title = @protocol.title.uniquify
|
69
|
-
@registration.participant.medical_identifiers.each { |mid| mid.medical_record_number = Uniquifier.qualifier }
|
70
|
-
# unset the SCG name and specimen label so the default is set to a new unique value
|
71
|
-
@specimen_collection_group.name = @specimen.label = nil
|
72
|
-
self
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
# Adds data to this fixture.
|
78
|
-
#
|
79
|
-
# @return this fixture
|
80
|
-
def populate
|
81
|
-
logger.debug { "Populating the test fixture..." }
|
82
|
-
|
83
|
-
# the test institution
|
84
|
-
inst = CaTissue::Institution.new(:name => 'Test Institution')
|
85
|
-
|
86
|
-
# the standard test address
|
87
|
-
addr = CaTissue::Address.new
|
88
|
-
addr.city = 'Test City'
|
89
|
-
addr.state = 'Other'
|
90
|
-
addr.country = 'Niue'
|
91
|
-
addr.zipCode = '55555'
|
92
|
-
addr.street = '555 Test St'
|
93
|
-
addr.phoneNumber = '555-555-5555'
|
94
|
-
|
95
|
-
# the test department
|
96
|
-
dept = CaTissue::Department.new(:name => 'Test Department')
|
97
|
-
|
98
|
-
# the test cancer center
|
99
|
-
cc = CaTissue::CancerResearchGroup.new(:name => 'Test Cancer Center')
|
100
|
-
|
101
|
-
# the test tissue bank coordinator
|
102
|
-
coord = CaTissue::User.new
|
103
|
-
coord.loginName = coord.emailAddress = 'test_coordinator@example.edu'
|
104
|
-
coord.lastName = 'Coordinator'
|
105
|
-
coord.firstName = 'Test'
|
106
|
-
coord.address = addr.copy
|
107
|
-
coord.institution = inst
|
108
|
-
coord.department = dept
|
109
|
-
coord.cancer_research_group = cc
|
110
|
-
coord.add_defaults
|
111
|
-
|
112
|
-
# the test surgeon
|
113
|
-
surgeon = CaTissue::User.new
|
114
|
-
surgeon.loginName = surgeon.emailAddress = 'test_surgeon@example.edu'
|
115
|
-
surgeon.lastName = 'Scientist'
|
116
|
-
surgeon.firstName = 'Test'
|
117
|
-
surgeon.address = addr.copy
|
118
|
-
surgeon.institution = inst
|
119
|
-
surgeon.department = dept
|
120
|
-
surgeon.cancer_research_group = cc
|
121
|
-
|
122
|
-
# the test PI
|
123
|
-
pi = CaTissue::User.new
|
124
|
-
pi.loginName = pi.emailAddress = 'test_scientist@example.edu'
|
125
|
-
pi.lastName = 'Scientist'
|
126
|
-
pi.firstName = 'Test'
|
127
|
-
pi.address = addr.copy
|
128
|
-
pi.institution = inst
|
129
|
-
pi.department = dept
|
130
|
-
pi.cancer_research_group = cc
|
131
|
-
|
132
|
-
# the test hospital
|
133
|
-
hospital = CaTissue::Site.new(
|
134
|
-
:site_type => CaTissue::Site::SiteType::COLLECTION,
|
135
|
-
:name => 'Test Collection Site',
|
136
|
-
:address => addr.copy,
|
137
|
-
:coordinator => coord
|
138
|
-
)
|
139
|
-
|
140
|
-
# the test tissue bank
|
141
|
-
@tissue_bank = CaTissue::Site.new(
|
142
|
-
:site_type => CaTissue::Site::SiteType::REPOSITORY,
|
143
|
-
:name => 'Test Tissue Bank',
|
144
|
-
:address => addr.copy,
|
145
|
-
:coordinator => coord
|
146
|
-
)
|
147
|
-
|
148
|
-
# the test participant
|
149
|
-
pnt = CaTissue::Participant.new(:name => 'Test Participant')
|
150
|
-
|
151
|
-
# add the participant mrn
|
152
|
-
mrn = 555555
|
153
|
-
pnt.add_mrn(hospital, mrn)
|
154
|
-
|
155
|
-
# the test collection protocol
|
156
|
-
@protocol = CaTissue::CollectionProtocol.new(
|
157
|
-
:title => 'Test CP',
|
158
|
-
:principal_investigator => pi
|
159
|
-
)
|
160
|
-
|
161
|
-
# the test consent tier
|
162
|
-
ctier = CaTissue::ConsentTier.new(:statement => 'Test Consent Statement')
|
163
|
-
@protocol.consent_tiers << ctier
|
164
|
-
|
165
|
-
# the collection event template
|
166
|
-
cpe = CaTissue::CollectionProtocolEvent.new(:protocol => @protocol)
|
167
|
-
|
168
|
-
# the participant collection registration
|
169
|
-
@registration = @protocol.register(pnt)
|
170
|
-
# add a consent tier response
|
171
|
-
rsp = CaTissue::ConsentTierResponse.new(:consent_tier => ctier)
|
172
|
-
@registration.consent_tier_responses << rsp
|
173
|
-
|
174
|
-
# the specimen requirement template
|
175
|
-
@specimen_requirement = CaTissue::TissueSpecimenRequirement.new(
|
176
|
-
:collection_event => cpe,
|
177
|
-
:specimen_type => 'Frozen Tissue',
|
178
|
-
:specimen_characteristics => CaTissue::SpecimenCharacteristics.new,
|
179
|
-
:pathological_status => 'Malignant')
|
180
|
-
|
181
|
-
# the sole tissue specimen
|
182
|
-
@specimen = CaTissue::Specimen.create_specimen(:requirement => @specimen_requirement, :initial_quantity => 4.0)
|
183
|
-
|
184
|
-
# the SCG
|
185
|
-
@specimen_collection_group = @protocol.add_specimens(
|
186
|
-
@specimen,
|
187
|
-
:participant => pnt,
|
188
|
-
:collection_event => cpe,
|
189
|
-
:collection_site => hospital,
|
190
|
-
:receiver => coord)
|
191
|
-
|
192
|
-
# a storage container
|
193
|
-
frz_type = CaTissue::StorageType.new(:name => 'Test Freezer', :columns => 10, :rows => 1, :row_label => 'Rack')
|
194
|
-
rack_type = CaTissue::StorageType.new(:name => 'Test Rack', :columns => 10, :rows => 10)
|
195
|
-
box_type = CaTissue::StorageType.new(:name => 'Test Box', :columns => 10, :rows => 10)
|
196
|
-
frz_type << rack_type
|
197
|
-
rack_type << box_type
|
198
|
-
box_type << 'Tissue'
|
199
|
-
# a sample freezer box
|
200
|
-
@box = CaTissue::StorageContainer.new(:storage_type => box_type, :site => @tissue_bank)
|
201
|
-
|
202
|
-
logger.debug { "Test fixture populated." }
|
203
|
-
self
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
-
|
3
|
-
class BaseHaematologyPathologyTest < Test::Unit::TestCase
|
4
|
-
include CaTissue::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
@scg = defaults.specimen_collection_group
|
9
|
-
@ann = CaTissue::SpecimenCollectionGroup::Pathology::BaseHaematologyPathologyAnnotation.new(:specimen_collection_group => @scg)
|
10
|
-
@hist = CaTissue::SpecimenCollectionGroup::Pathology::HistologicType.new(:base_pathology_annotation => @ann, :histologic_type => 'Adenocarcinoma - NOS')
|
11
|
-
@fnd = CaTissue::SpecimenCollectionGroup::Pathology::AdditionalFinding.new(:base_pathology_annotation => @ann, :pathologic_finding => 'Test finding')
|
12
|
-
@dtl = CaTissue::SpecimenCollectionGroup::Pathology::Details.new(:additional_finding => @fnd, :detail => 'Test detail')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_dependents
|
16
|
-
assert_equal([@hist], @ann.histologic_types.to_a, "Annotation histologic types incorrect")
|
17
|
-
assert_equal([@fnd], @ann.additional_findings.to_a, "Annotation additional findings incorrect")
|
18
|
-
assert_equal([@dtl], @fnd.details.to_a, "Finding details incorrect")
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_save
|
22
|
-
verify_save(@ann)
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
3
|
-
require 'catissue/extract/delta'
|
4
|
-
|
5
|
-
class DeltaTest < Test::Unit::TestCase
|
6
|
-
include CaTissue::TestCase
|
7
|
-
|
8
|
-
def test_specimen
|
9
|
-
since = DateTime.now
|
10
|
-
spc = defaults.specimen.create
|
11
|
-
ids = CaTissue::Delta.new(spc.class, since).to_a
|
12
|
-
assert(!ids.empty?, "Delta is empty")
|
13
|
-
assert_equal(1, ids.size, "Delta count incorrect")
|
14
|
-
assert_equal(spc.identifier, ids.first, "Delta value incorrect")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_scg
|
18
|
-
since = DateTime.now
|
19
|
-
scg = defaults.specimen_collection_group.create
|
20
|
-
ids = CaTissue::Delta.new(scg.class, since).to_a
|
21
|
-
assert(!ids.empty?, "Delta is empty")
|
22
|
-
assert_equal(1, ids.size, "Delta count incorrect")
|
23
|
-
assert_equal(scg.identifier, ids.first, "Delta value incorrect")
|
24
|
-
end
|
25
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
-
require 'catissue/extract/extractor'
|
3
|
-
|
4
|
-
class ExtractorTest < Test::Unit::TestCase
|
5
|
-
include CaTissue::TestCase
|
6
|
-
|
7
|
-
CONFIG_DIR = File.join('test', 'fixtures', 'catissue', 'extract', 'conf')
|
8
|
-
|
9
|
-
def test_specimen_write
|
10
|
-
config = File.join(CONFIG_DIR, 'spc_extract.yaml')
|
11
|
-
spc = defaults.specimen.create
|
12
|
-
extractor = CaTissue::Extractor.new(:file => config, :ids => [spc.identifier])
|
13
|
-
extractor.run
|
14
|
-
mapping = File.join(CONFIG_DIR, 'spc_fields.yaml')
|
15
|
-
mapper = CaRuby::CsvMapper.new(mapping, spc.class, extractor.output)
|
16
|
-
rec = mapper.csvio.to_a.first
|
17
|
-
assert_not_nil(rec, "Specimen record not written")
|
18
|
-
mrn = spc.path_value("specimen_collection_group.registration.participant_identifier")
|
19
|
-
assert_equal(mrn.to_s, rec[:mrn].to_s, "Specimen MRN incorrect")
|
20
|
-
spn = spc.path_value("specimen_collection_group.surgical_pathology_number")
|
21
|
-
assert_equal(spn.to_s, rec[:spn].to_s, "Specimen SPN incorrect")
|
22
|
-
date = spc.path_value("specimen_collection_group.collection_event_parameters.timestamp")
|
23
|
-
assert_equal(date.to_s, rec[:collection_date].to_s, "Specimen collection date incorrect")
|
24
|
-
assert_equal(spc.initial_quantity.to_s, rec[:quantity].to_s, "Quantity incorrect")
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_scg_write
|
28
|
-
config = File.join(CONFIG_DIR, 'scg_extract.yaml')
|
29
|
-
scg = defaults.specimen_collection_group.create
|
30
|
-
extractor = CaTissue::Extractor.new(:file => config, :ids => [scg.identifier])
|
31
|
-
extractor.run
|
32
|
-
mapping = File.join(CONFIG_DIR, 'scg_fields.yaml')
|
33
|
-
mapper = CaRuby::CsvMapper.new(mapping, scg.class, extractor.output)
|
34
|
-
rec = mapper.csvio.to_a.first
|
35
|
-
assert_not_nil(rec, "SCG record not written")
|
36
|
-
mrn = scg.path_value("registration.participant_identifier")
|
37
|
-
assert_equal(mrn.to_s, rec[:mrn].to_s, "SCG MRN incorrect")
|
38
|
-
spn = scg.path_value("surgical_pathology_number")
|
39
|
-
assert_equal(spn.to_s, rec[:spn].to_s, "SCG SPN incorrect")
|
40
|
-
date = scg.path_value("collection_event_parameters.timestamp")
|
41
|
-
assert_equal(date.to_s, rec[:collection_date].to_s, "SCG collection date incorrect")
|
42
|
-
end
|
43
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
$:.unshift 'lib'
|
2
|
-
$:.unshift '../caruby/lib'
|
3
|
-
|
4
|
-
require "test/unit"
|
5
|
-
|
6
|
-
require 'catissue'
|
7
|
-
|
8
|
-
class ImportableTest < Test::Unit::TestCase
|
9
|
-
LOG_FILE = 'test/results/catissue/import/log/catissue.log'
|
10
|
-
|
11
|
-
def test_import
|
12
|
-
assert_nothing_raised(Exception, 'Java class not imported') { CaTissue::CollectionProtocol }
|
13
|
-
end
|
14
|
-
end
|
@@ -1,247 +0,0 @@
|
|
1
|
-
# load the core gem
|
2
|
-
require 'rubygems'
|
3
|
-
begin
|
4
|
-
gem 'caruby-core'
|
5
|
-
rescue LoadError
|
6
|
-
# if the gem is not available, then try a local development source
|
7
|
-
$:.unshift '../caruby/lib'
|
8
|
-
end
|
9
|
-
|
10
|
-
# open the logger
|
11
|
-
LOG_FILE = 'test/results/log/catissue.log' unless defined?(LOG_FILE)
|
12
|
-
require 'caruby/util/log' and
|
13
|
-
CaRuby::Log.instance.open(LOG_FILE, :shift_age => 10, :shift_size => 1048576, :debug => true)
|
14
|
-
|
15
|
-
# Add the caruby-tissue source
|
16
|
-
$:.unshift '../catissue/lib'
|
17
|
-
|
18
|
-
require 'catissue'
|
19
|
-
require '../catissue/test/fixtures/lib/catissue/defaults_test_fixture'
|
20
|
-
|
21
|
-
module CaTissue
|
22
|
-
module TestCase
|
23
|
-
attr_reader :database
|
24
|
-
|
25
|
-
def setup
|
26
|
-
super()
|
27
|
-
logger.info("Testing #{name}...")
|
28
|
-
@database = CaTissue::Database.instance
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
super
|
33
|
-
@database.close if @database
|
34
|
-
logger.info("Test #{name} completed.")
|
35
|
-
end
|
36
|
-
|
37
|
-
def defaults
|
38
|
-
@defaults ||= CaTissueTest.defaults.uniquify
|
39
|
-
end
|
40
|
-
|
41
|
-
# Tests the domain object +add_defaults_local+ method.
|
42
|
-
# Subclasses are responsible for setting every attribute that is a pre-condition for default value initialization.
|
43
|
-
def verify_defaults(subject)
|
44
|
-
subject.add_defaults
|
45
|
-
msg = "#{subject.qp} with default attributes fails validation"
|
46
|
-
assert_nothing_raised(ValidationError, msg) { subject.validate }
|
47
|
-
end
|
48
|
-
|
49
|
-
# Tests saving the subject. Calls {Database#save} on the subject and verifies that subject and its
|
50
|
-
# references were persisted.
|
51
|
-
#
|
52
|
-
# @param [Resource] subject the object to save
|
53
|
-
def verify_save(subject)
|
54
|
-
logger.debug{ "Verifying #{subject.qp} save with content:\n#{dump(subject)}" }
|
55
|
-
# capture the save operation time
|
56
|
-
@database.clear
|
57
|
-
st = Stopwatch.measure { @database.open { |db| db.save(subject) } }.elapsed
|
58
|
-
# the database execution time
|
59
|
-
dt = @database.execution_time
|
60
|
-
logger.debug { "#{subject.qp} save took #{'%.2f' % st} seconds, of which #{'%.2f' % dt} were database operations." }
|
61
|
-
verify_saved(subject)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Verifies that the given subject and its references were persisted.
|
65
|
-
#
|
66
|
-
# @param [Resource] subject the saved object to verify
|
67
|
-
def verify_saved(subject)
|
68
|
-
logger.debug { "Verifying saved content of #{subject}..." }
|
69
|
-
subject.dependent? ? verify_saved_dependent(subject) : verify_saved_independent(subject)
|
70
|
-
logger.debug { "Verified saved content of #{subject}." }
|
71
|
-
end
|
72
|
-
|
73
|
-
# Tests a query on the given template.
|
74
|
-
# The block given to this method is called on the query result.
|
75
|
-
def verify_query(template, *path) # :yields: result
|
76
|
-
yield database.query(template, *path)
|
77
|
-
end
|
78
|
-
|
79
|
-
# Returns the Ruby date as determined by setting a Java Date property.
|
80
|
-
def date(year, month, day)
|
81
|
-
jdate = java.util.Calendar.instance
|
82
|
-
jdate.clear
|
83
|
-
jdate.set(year, month - 1, day)
|
84
|
-
jdate.time.to_ruby_date
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def dump(obj)
|
90
|
-
@database.lazy_loader.suspend { obj.dump }
|
91
|
-
end
|
92
|
-
|
93
|
-
# @param (see #mock_storable_template)
|
94
|
-
# @return (see #mock_storable_template)
|
95
|
-
def mock_create_template(obj)
|
96
|
-
mock_storable_template(obj) { |ref| ref.class.creatable_domain_attributes }
|
97
|
-
end
|
98
|
-
|
99
|
-
# @param (see #mock_storable_template)
|
100
|
-
# @return (see #mock_storable_template)
|
101
|
-
def mock_update_template(obj)
|
102
|
-
mock_storable_template(obj) { |ref| ref.class.updatable_domain_attributes }
|
103
|
-
end
|
104
|
-
|
105
|
-
# @param [Resource] obj the domain object to "save"
|
106
|
-
# @return [Resource] the template to use in the save operation
|
107
|
-
# @yield [ref] the storable attributes
|
108
|
-
# @yieldparam [Resource] ref the domain object to "save"
|
109
|
-
def mock_storable_template(obj, &selector)
|
110
|
-
# add fake identifiers to prerequisite references
|
111
|
-
obj.class.storable_prerequisite_attributes.each do |attr|
|
112
|
-
obj.send(attr).enumerate { |ref| ref.identifier = 1 }
|
113
|
-
end
|
114
|
-
# the template builder
|
115
|
-
bldr = CaRuby::StoreTemplateBuilder.new(@database, &selector)
|
116
|
-
# the save template
|
117
|
-
bldr.build_template(obj)
|
118
|
-
end
|
119
|
-
|
120
|
-
def verify_saved_dependent(dependent)
|
121
|
-
verify_dependency(dependent)
|
122
|
-
verify_saved_content(dependent)
|
123
|
-
end
|
124
|
-
|
125
|
-
def verify_dependency(dependent)
|
126
|
-
return if dependent.class.owner_attribute.nil?
|
127
|
-
# kludge for annotation proxy nonsense (cf. Annotation#owner)
|
128
|
-
ownr = Annotation === dependent ? (dependent.proxy or dependent.owner) : dependent.owner
|
129
|
-
assert_not_nil(ownr, "Owner missing for dependent: #{dependent}")
|
130
|
-
attribute = ownr.class.dependent_attribute(dependent.class)
|
131
|
-
assert_not_nil(attribute, "#{ownr.class.qp} => #{dependent.class.qp} reference attribute not found")
|
132
|
-
# a dependent collection reference must be refetched
|
133
|
-
if ownr.class.collection_attribute?(attribute) then
|
134
|
-
verify_saved_dependent_collection_member(dependent, ownr, attribute)
|
135
|
-
else
|
136
|
-
assert_not_nil(dependent.identifier, "Stored dependent #{dependent} identifier is not set")
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# Verifies that the given dependent has an identifier and that the given owner dependent attribute value
|
141
|
-
# contains the dependent.
|
142
|
-
#
|
143
|
-
# @quirk JRuby Set include? incorrectly returns false in the OHSU PSR samples_test test_save_grade
|
144
|
-
# call to this method. Work around by using Set detect rather than include?.
|
145
|
-
def verify_saved_dependent_collection_member(dependent, owner, attribute)
|
146
|
-
deps = owner.send(attribute)
|
147
|
-
assert(deps.detect { |dep| dep == dependent }, "Owner #{owner.qp} #{attribute} value #{deps.pp_s} does not contain #{dependent}")
|
148
|
-
assert_not_nil(dependent.identifier, "Identifier not set for stored owner #{owner.qp} #{attribute} dependent collection member #{dependent}")
|
149
|
-
end
|
150
|
-
|
151
|
-
# Verifies the subject stored content.
|
152
|
-
def verify_saved_independent(subject)
|
153
|
-
subject_id = subject.identifier
|
154
|
-
assert_not_nil(subject_id, "#{subject.class.qp} identifier not set")
|
155
|
-
verify_saved_content(subject)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Verifies that the given subject matches the database content. Does not verify subject unless it has
|
159
|
-
# a secondary key.
|
160
|
-
def verify_saved_content(subject)
|
161
|
-
attrs = subject.class.secondary_key_attributes
|
162
|
-
return if attrs.empty?
|
163
|
-
rqd = attrs & subject.class.mandatory_attributes
|
164
|
-
missing = rqd.reject { |attr| subject.send(attr) }
|
165
|
-
assert(missing.empty?, "#{subject} is missing values for required secondary key attributes #{missing.to_series}")
|
166
|
-
# make a secondary key search template
|
167
|
-
vh = attrs.to_compact_hash do |attr|
|
168
|
-
v = subject.send(attr)
|
169
|
-
Resource === v ? v.copy : v
|
170
|
-
end
|
171
|
-
# return if there is a missing optional secondary key attribute
|
172
|
-
return unless vh.size == attrs.size
|
173
|
-
tmpl = subject.class.new(vh)
|
174
|
-
# find the template in the database
|
175
|
-
logger.debug { "Verifying #{subject.qp} by finding and comparing template #{tmpl.pp_s}..." }
|
176
|
-
assert_not_nil(tmpl.find, "#{subject} not found in database")
|
177
|
-
# compare the subject to the fetched template
|
178
|
-
verify_that_saved_matches_fetched(subject, tmpl)
|
179
|
-
end
|
180
|
-
|
181
|
-
# Verifies that the given expected domain object has the same content as actual,
|
182
|
-
# and that the dependents match.
|
183
|
-
#
|
184
|
-
# @quirk caTissue caTissue mutilates an unspecified specimen type available quantity, e.g.
|
185
|
-
# changing a Specimen with specimen type 'Not Specified' from available quantity 1, initial
|
186
|
-
# quantity 1 to available quantity 0, initial quantity 3 results in available quantity 2
|
187
|
-
# in database. The update is necessary when creating the Specimen with available quantity 0,
|
188
|
-
# initial quantity 3 to work around a different caTissue bug. Thus, the bug work-around
|
189
|
-
# is broken by a different caTissue bug.
|
190
|
-
#
|
191
|
-
# @param [Resource] expected the saved value
|
192
|
-
# @param [Resource] actual the fetched value
|
193
|
-
def verify_that_saved_matches_fetched(expected, actual)
|
194
|
-
expected.class.saved_nondomain_attributes.each do |attr|
|
195
|
-
# available_quantity broken for spc type Not Specified; see quirk above.
|
196
|
-
# TODO - Compare attributes that are fetched and set on create.
|
197
|
-
attr_md = expected.class.attribute_metadata(attr)
|
198
|
-
if verify_saved_attribute?(attr_md) then
|
199
|
-
eval = expected.database.lazy_loader.suspend { expected.send(attr) }
|
200
|
-
next if eval.nil_or_empty?
|
201
|
-
aval = actual.send(attr)
|
202
|
-
if eval.nil? then
|
203
|
-
assert_nil(aval, "#{expected.qp} was saved without a #{attr} value, but was stored in the database with value #{actual.qp}")
|
204
|
-
else
|
205
|
-
assert_not_nil(aval, "#{expected.qp} was saved with #{attr} value #{eval.qp}, but this value was not found in the database.")
|
206
|
-
if attr == :available_quantity and expected.specimen_type == 'Not Specified' and eval != aval then
|
207
|
-
logger.warn("Skipped broken caTissue unspecified specimen type available comparison.")
|
208
|
-
else
|
209
|
-
assert(CaRuby::Resource.value_equal?(eval, aval), "#{expected.qp} was saved with #{attr} value #{eval.qp} that does not match the database value #{aval.qp}")
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
verify_dependents_match(expected, actual)
|
215
|
-
end
|
216
|
-
|
217
|
-
# @param [Attribute] attr_md the saved attribute to check
|
218
|
-
# @return whether the attribute is fetched, creatable and not volatile
|
219
|
-
def verify_saved_attribute?(attr_md)
|
220
|
-
attr_md.fetched? and attr_md.creatable? and not attr_md.volatile?
|
221
|
-
end
|
222
|
-
|
223
|
-
# Verifies that each expected dependent matches an actual dependent and has the same content.
|
224
|
-
def verify_dependents_match(expected, actual)
|
225
|
-
expected.class.dependent_attributes.each_pair do |attr, attr_md|
|
226
|
-
# annotation query not supported
|
227
|
-
# TODO - enable when supported
|
228
|
-
next if attr_md.type < Annotation
|
229
|
-
edeps = expected.database.lazy_loader.suspend { expected.send(attr) }
|
230
|
-
next if edeps.nil_or_empty?
|
231
|
-
adeps = actual.send(attr)
|
232
|
-
logger.debug { "Verifying #{expected.qp} dependent #{attr} #{edeps.qp} against #{actual.qp} #{adeps.qp}..." } unless edeps.nil_or_empty?
|
233
|
-
if attr_md.collection? then
|
234
|
-
edeps.each do |edep|
|
235
|
-
adep = edep.match_in_owner_scope(adeps)
|
236
|
-
assert_not_nil(adep, "#{expected} #{attr} dependent #{edep} not found in fetched #{adeps.pp_s}")
|
237
|
-
verify_that_saved_matches_fetched(edep, adep)
|
238
|
-
end
|
239
|
-
else
|
240
|
-
edep = edeps; adep = adeps;
|
241
|
-
assert_not_nil(adep, "#{expected} #{attr} dependent #{edep} not found in database")
|
242
|
-
verify_that_saved_matches_fetched(edep, adep)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|