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,87 +1,136 @@
|
|
1
|
-
require '
|
1
|
+
require 'uom'
|
2
|
+
require 'jinx/migration/migrator'
|
3
|
+
require 'catissue/database/controlled_values'
|
4
|
+
require 'catissue/database/controlled_value_finder'
|
2
5
|
require 'catissue/annotation/proxy'
|
3
6
|
|
4
7
|
module CaTissue
|
5
|
-
shims SpecimenCollectionGroup,
|
6
|
-
SpecimenEventParameters,
|
8
|
+
shims SpecimenCollectionGroup, TissueSpecimen, SpecimenCharacteristics,
|
9
|
+
SpecimenEventParameters, CollectibleEventParameters
|
7
10
|
|
8
11
|
class SpecimenCollectionGroup
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
# @return [String] the diagnosis controlled value
|
13
|
+
# @raise [Jinx::MigrationError] if the value is not supported
|
14
|
+
def migrate_clinical_diagnosis(value, row)
|
15
|
+
cv = standard_cv_diagnosis(value)
|
16
|
+
if cv.nil? then
|
17
|
+
cv = variant_cv_diagnosis(value)
|
18
|
+
if cv then
|
19
|
+
logger.warn("Migrator substituted diagnosis #{cv} for #{value}.")
|
20
|
+
else
|
21
|
+
raise Jinx::MigrationError.new("#{cv} is not a recognized controlled value.")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
cv
|
25
|
+
end
|
26
|
+
|
27
|
+
# Enables diagnosis controlled value lookup.
|
28
|
+
def self.enable_cv_finder
|
29
|
+
@diagnosis_cv_finder ||= ControlledValueFinder.new(:clinical_diagnosis)
|
14
30
|
end
|
31
|
+
|
32
|
+
private
|
15
33
|
|
16
34
|
# Returns the diagnosis controlled value as follows:
|
17
35
|
# * If CV lookup is disabled, then this method returns value.
|
18
|
-
# * Otherwise,
|
19
|
-
# then this method returns the remapped CV.
|
20
|
-
# * Otherwise, if the value is a valid CV, then this method returns value.
|
21
|
-
# * Otherwise, this method returns nil.
|
36
|
+
# * Otherwise, delegate to the CV finder.
|
22
37
|
#
|
23
38
|
# @param [String] value the input diagnosis
|
24
39
|
# @return [String] the mapped CV
|
25
40
|
def self.diagnosis_controlled_value(value)
|
26
|
-
|
41
|
+
@diagnosis_cv_finder.nil? ? value : @diagnosis_cv_finder.controlled_value(value)
|
27
42
|
end
|
28
43
|
|
29
|
-
# @return [String] the
|
30
|
-
def
|
31
|
-
SpecimenCollectionGroup.diagnosis_controlled_value(value)
|
44
|
+
# @return [String, nil] the caTissue diagnosis permissible value, or nil if not found
|
45
|
+
def standard_cv_diagnosis(value)
|
46
|
+
SpecimenCollectionGroup.diagnosis_controlled_value(value) rescue nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the tissue site which adds the 'NOS' suffix to a value without one or removes
|
50
|
+
# 'NOS' from a value with the suffix.
|
51
|
+
#
|
52
|
+
# @return [String, nil] a supported variant of the input value, or nil if none
|
53
|
+
# @raise (see ControlledValueFinder#controlled_value)
|
54
|
+
def variant_cv_diagnosise(value)
|
55
|
+
# try an NOS suffix variation
|
56
|
+
variation = value =~ /, NOS$/ ? value[0...-', NOS'.length] : value + ', NOS'
|
57
|
+
SpecimenCollectionGroup.diagnosis_controlled_value(variation) rescue nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Specimen
|
62
|
+
# Parses the source field as a UOM::Measurement if it is a string.
|
63
|
+
# Otherwises, returns the source value.
|
64
|
+
def migrate_initial_quantity(value, row)
|
65
|
+
standardize_quantity(value)
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
# Parses the source field as a UOM::Measurement if it is a string.
|
71
|
+
# Otherwises, returns the source value.
|
72
|
+
def standardize_quantity(value)
|
73
|
+
# if value is not a string, then use it as is
|
74
|
+
return value unless value.is_a?(String)
|
75
|
+
# the value has a unit qualifier; parse the measurement.
|
76
|
+
# the unit is normalized to the Specimen standard unit.
|
77
|
+
value.to_measurement_quantity(standard_unit)
|
32
78
|
end
|
33
79
|
end
|
34
80
|
|
35
81
|
class SpecimenCharacteristics
|
36
|
-
|
82
|
+
# Enables tissue site controlled value lookup.
|
83
|
+
def self.enable_cv_finder
|
84
|
+
@site_finder ||= ControlledValueFinder.new(:tissue_site)
|
85
|
+
end
|
37
86
|
|
38
|
-
#
|
39
|
-
|
40
|
-
|
87
|
+
# @return [String] the tissue site controlled value
|
88
|
+
# @raise [Jinx::MigrationError] if the value is not supported
|
89
|
+
def migrate_tissue_site(value, row)
|
90
|
+
cv = standard_cv_tissue_site(value)
|
91
|
+
if cv.nil? then
|
92
|
+
cv = variant_cv_tissue_site(value)
|
93
|
+
if cv then
|
94
|
+
logger.warn("Migrator substituted tissue site #{cv} for #{value}.")
|
95
|
+
else
|
96
|
+
raise Jinx::MigrationError.new("#{cv} is not a recognized controlled value.")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
cv
|
41
100
|
end
|
42
101
|
|
102
|
+
private
|
103
|
+
|
43
104
|
# Returns the tissue site controlled value as follows:
|
44
105
|
# * If CV lookup is disabled, then this method returns value.
|
45
|
-
# * Otherwise,
|
46
|
-
# then this method returns the remapped CV.
|
47
|
-
# * Otherwise, if the value is a valid CV, then this method returns value.
|
48
|
-
# * Otherwise, this method returns nil.
|
106
|
+
# * Otherwise, delegate to the CV finder.
|
49
107
|
#
|
50
108
|
# @return [String] the caTissue tissue site permissible value
|
51
109
|
def self.tissue_site_controlled_value(value)
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [String] the {tissue_site_controlled_value}
|
56
|
-
def migrate_tissue_site(value, row)
|
57
|
-
standard_cv_tissue_site(value) or variant_cv_tissue_site(value)
|
110
|
+
@site_finder.nil? ? value : @site_finder.controlled_value(value)
|
58
111
|
end
|
59
112
|
|
60
|
-
|
61
|
-
|
62
|
-
# Returns the {tissue_site_controlled_value}.
|
63
|
-
#
|
64
|
-
# @return the caTissue tissue site permissible value
|
113
|
+
# @return [String, nil] the caTissue tissue site permissible value,
|
114
|
+
# or nil if not found
|
65
115
|
def standard_cv_tissue_site(value)
|
66
|
-
SpecimenCharacteristics.tissue_site_controlled_value(value)
|
116
|
+
SpecimenCharacteristics.tissue_site_controlled_value(value) rescue nil
|
67
117
|
end
|
68
118
|
|
69
|
-
# Returns the
|
70
|
-
#
|
119
|
+
# Returns the tissue site which adds the 'NOS' suffix to a value without one
|
120
|
+
# or removes 'NOS' from a value with the suffix.
|
71
121
|
#
|
72
|
-
# @return the
|
122
|
+
# @return [String, nil] a supported variant of the input value, or nil if none
|
73
123
|
def variant_cv_tissue_site(value)
|
74
124
|
# try an NOS suffix variation
|
75
125
|
variation = value =~ /, NOS$/ ? value[0...-', NOS'.length] : value + ', NOS'
|
76
|
-
|
77
|
-
logger.warn("Migrator substituted tissue site #{cv} for #{value}.") if cv
|
78
|
-
cv
|
126
|
+
SpecimenCharacteristics.tissue_site_controlled_value(variation) rescue nil
|
79
127
|
end
|
80
128
|
end
|
81
129
|
|
82
130
|
class SpecimenEventParameters
|
83
131
|
# Returns nil by default, since only CollectibleEventParameters have a SCG owner.
|
84
|
-
# {CollectibleEventParameters#migrate_specimen_collection_group} overrides this
|
132
|
+
# {CollectibleEventParameters#migrate_specimen_collection_group} overrides this
|
133
|
+
# method.
|
85
134
|
#
|
86
135
|
# @return nil
|
87
136
|
def migrate_specimen_collection_group(scg, row)
|
@@ -103,7 +152,7 @@ module CaTissue
|
|
103
152
|
# A CollectibleEventParameters is preferentially set to a migrated SCG rather than a migrated
|
104
153
|
# Specimen.
|
105
154
|
#
|
106
|
-
# Overrides
|
155
|
+
# Overrides +Jinx::Migratable.migratable__target_value+ to confer precedence to
|
107
156
|
# a SCG over a Specimen when setting this event parameters' owner. If the migrated
|
108
157
|
# collection includes both a Specimen and a SCG, then this event parameters
|
109
158
|
# +specimen+ reference is ambiguous, but the +specimen_collection_group+ reference
|
@@ -1,15 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'catissue/resource'
|
4
|
-
require 'catissue/database/controlled_values'
|
5
|
-
require 'catissue/database/controlled_value_finder'
|
1
|
+
require 'jinx/helpers/log'
|
2
|
+
require 'jinx/migration/migrator'
|
6
3
|
|
7
4
|
module CaTissue
|
8
5
|
# Migrates a CSV extract to caTissue. See the {#initialize} documentation for usage options.
|
9
6
|
#
|
10
|
-
# See the Galena
|
11
|
-
#
|
12
|
-
class Migrator <
|
7
|
+
# See the Galena migration example for further information about to tailor the migration,
|
8
|
+
# esp. the use of the field mappings and shims.
|
9
|
+
class Migrator < Jinx::Migrator
|
13
10
|
# Creates a new Migrator with the given options.
|
14
11
|
#
|
15
12
|
# This migrator must include sufficient information to build a well-formed migration target object.
|
@@ -17,10 +14,9 @@ module CaTissue
|
|
17
14
|
# able to build that SCG's CollectionProtocolRegistration. The CPR in turn must either exist in the
|
18
15
|
# database or the migration must build a Participant and a CollectionProtocol.
|
19
16
|
#
|
20
|
-
# @option (see
|
21
|
-
# @option opts [String] :
|
22
|
-
# @option opts [String] :
|
23
|
-
# @option opts [String] :database target application {CaRuby::Database}
|
17
|
+
# @option (see Jinx::Migrator#initialize)
|
18
|
+
# @option opts [String] :controlled_values enable controlled value lookup
|
19
|
+
# @option opts [String] :database target application +CaRuby::Database+
|
24
20
|
# @option opts [String] :target required target domain class
|
25
21
|
# @option opts [String] :input required source file to migrate
|
26
22
|
# @option opts [String] :shims optional array of shim files to load
|
@@ -36,14 +32,9 @@ module CaTissue
|
|
36
32
|
# add config options but don't override the parameter options
|
37
33
|
opts.merge!(conf, :deep) { |key, oldval, newval| oldval }
|
38
34
|
end
|
39
|
-
# open the log file before building structure
|
40
|
-
log_file = opts[:log]
|
41
|
-
CaRuby::Log.instance.open(log_file, :debug => opts[:debug]) if log_file
|
42
|
-
|
43
35
|
# tailor the options
|
44
36
|
opts[:name] ||= NAME
|
45
37
|
opts[:database] ||= CaTissue::Database.instance
|
46
|
-
|
47
38
|
# the shims file(s)
|
48
39
|
opts[:shims] ||= []
|
49
40
|
shims = opts[:shims] ||= []
|
@@ -51,52 +42,45 @@ module CaTissue
|
|
51
42
|
shims = opts[:shims] = [shims] unless shims.collection?
|
52
43
|
# prepend this migrator's shims
|
53
44
|
shims.unshift(MIGRATABLE_SHIM)
|
54
|
-
|
55
|
-
# If the unique option is set, then append the CaTissue-specific uniquifier shim.
|
45
|
+
# If the unique option is set, then prepend the CaTissue-specific uniquifier shim.
|
56
46
|
if opts[:unique] then
|
57
|
-
|
58
|
-
shims << UNIQUIFY_SHIM
|
47
|
+
shims.unshift(UNIQUIFY_SHIM)
|
59
48
|
logger.debug { "Migrator added uniquification shim #{UNIQUIFY_SHIM}." }
|
60
49
|
end
|
61
50
|
|
62
|
-
# call the
|
51
|
+
# call the Jinx::Migrator initializer with the augmented options
|
63
52
|
super
|
64
53
|
|
65
54
|
# The remaining options are handled by this CaTissue::Migrator subclass.
|
66
55
|
|
67
|
-
# The
|
68
|
-
|
69
|
-
|
70
|
-
CaTissue::
|
71
|
-
logger.info("Migrator enabled tissue site controlled value lookup.")
|
72
|
-
end
|
73
|
-
|
74
|
-
# The clinical diagnosis CV look-up option.
|
75
|
-
diagnoses = opts[:diagnoses]
|
76
|
-
if diagnoses then
|
77
|
-
CaTissue::SpecimenCollectionGroup.diagnosis_cv_finder = ControlledValueFinder.new(:clinical_diagnosis, diagnoses)
|
78
|
-
logger.info("Migrator enabled clinical diagnosis controlled value lookup.")
|
56
|
+
# The CV look-up option.
|
57
|
+
if opts[:controlled_values] then
|
58
|
+
CaTissue::SpecimenCharacteristics.enable_cv_finder
|
59
|
+
CaTissue::SpecimenCollectionGroup.enable_cv_finder
|
60
|
+
logger.info("Migrator enabled tissue site and clinical diagnosis controlled value lookup.")
|
79
61
|
end
|
80
62
|
end
|
81
63
|
|
82
64
|
private
|
65
|
+
|
83
66
|
# The default name of this migrator.
|
84
67
|
NAME = 'caTissue Migrator'
|
85
68
|
|
86
69
|
# The built-in caTissue migration shims.
|
87
|
-
MIGRATABLE_SHIM = File.
|
70
|
+
MIGRATABLE_SHIM = File.expand_path('migratable.rb', File.dirname(__FILE__))
|
88
71
|
|
89
|
-
UNIQUIFY_SHIM = File.
|
72
|
+
UNIQUIFY_SHIM = File.expand_path('unique.rb', File.dirname(__FILE__))
|
90
73
|
|
91
74
|
# The context module is determined as follows:
|
92
|
-
# * For an {Annotation} target class, the context module is the
|
93
|
-
# * Otherwise, delegate to +
|
94
|
-
# * For an {Annotation} target class, the context module is the annotated class's
|
95
|
-
#
|
75
|
+
# * For an {Annotation} target class, the context module is the {Annotation::Metadata#annotation_module}.
|
76
|
+
# * Otherwise, delegate to +Jinx::Migrator+.
|
77
|
+
# * For an {Annotation} target class, the context module is the annotated class's
|
78
|
+
# +CaRuby::Metadata.annotation_module+.
|
79
|
+
# * Otherwise, delegate to +Jinx::Migrator+.
|
96
80
|
#
|
97
|
-
# @return (see
|
81
|
+
# @return (see Jinx::Migrator#context_module)
|
98
82
|
def context_module
|
99
|
-
@target_class < Annotation ? @target_class.
|
83
|
+
@target_class < Annotation ? @target_class.annotation_module : super
|
100
84
|
end
|
101
85
|
|
102
86
|
# Clears the migration protocol CPR and SCG references.
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'jinx/resource/unique'
|
2
|
+
|
3
|
+
module CaTissue
|
4
|
+
shims CollectionProtocol, CollectionProtocolEvent, Container, ContainerType, StorageType,
|
5
|
+
ParticipantMedicalIdentifier, CollectionProtocolRegistration, SpecimenCollectionGroup,
|
6
|
+
ExternalIdentifier, User
|
7
|
+
|
8
|
+
class CollectionProtocol
|
9
|
+
include Jinx::Unique
|
10
|
+
|
11
|
+
# Makes this CP's short and long title unique.
|
12
|
+
def uniquify
|
13
|
+
super
|
14
|
+
self.short_title = title
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class CollectionProtocolEvent
|
19
|
+
include Jinx::Unique
|
20
|
+
end
|
21
|
+
|
22
|
+
class Container
|
23
|
+
include Jinx::Unique
|
24
|
+
|
25
|
+
# Makes this Container and all of its subcontainers unique.
|
26
|
+
def uniquify
|
27
|
+
super
|
28
|
+
subcontainers.each { |ctr| ctr.uniquify }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ContainerType
|
33
|
+
include Jinx::Unique
|
34
|
+
end
|
35
|
+
|
36
|
+
class StorageType
|
37
|
+
def uniquify
|
38
|
+
super
|
39
|
+
child_container_types.each { |type| type.uniquify }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class ParticipantMedicalIdentifier
|
44
|
+
include Jinx::Unique
|
45
|
+
end
|
46
|
+
|
47
|
+
class CollectionProtocolRegistration
|
48
|
+
include Jinx::Unique
|
49
|
+
end
|
50
|
+
|
51
|
+
class SpecimenCollectionGroup
|
52
|
+
include Jinx::Unique
|
53
|
+
end
|
54
|
+
|
55
|
+
class Specimen
|
56
|
+
include Jinx::Unique
|
57
|
+
end
|
58
|
+
|
59
|
+
class ExternalIdentifier
|
60
|
+
include Jinx::Unique
|
61
|
+
end
|
62
|
+
|
63
|
+
class User
|
64
|
+
include Jinx::Unique
|
65
|
+
|
66
|
+
# Makes this User's login id and email address unique.
|
67
|
+
# The result is in the form _name___suffix_+@test.com+
|
68
|
+
# where:
|
69
|
+
# * _name_ is the name prefix portion of the original email address
|
70
|
+
# * _suffix_ is a unique number
|
71
|
+
def uniquify
|
72
|
+
email = email_address ||= self.login_name || return
|
73
|
+
self.login_name = self.email_address = uniquify_value(email[/[^@]+/]) + '@test.com'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/catissue/resource.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
+
require 'jinx/metadata/id_alias'
|
1
2
|
require 'caruby/resource'
|
2
|
-
require 'catissue/
|
3
|
+
require 'catissue/database'
|
3
4
|
|
5
|
+
# The caTissue-specific Resource mix-in.
|
4
6
|
module CaTissue
|
5
|
-
# The module included by all CaTissue domain classes.
|
6
|
-
#
|
7
|
-
# A Resource class is extended to support an attribute -> value hash argument
|
8
|
-
# to the initialize method. Subclasses which override the initialize method
|
9
|
-
# should not include the hash argument, since it is defined by a class
|
10
|
-
# instance new method override rather than initialize to work around a JRuby
|
11
|
-
# bug.
|
12
7
|
module Resource
|
13
|
-
include
|
14
|
-
|
8
|
+
include Jinx::IdAlias, CaRuby::Resource
|
9
|
+
|
15
10
|
# Returns whether each of the given attribute values either equals the
|
16
11
|
# respective other attribute value or one of the values is nil or 'Not Specified'.
|
17
12
|
#
|
@@ -20,18 +15,18 @@ module CaTissue
|
|
20
15
|
# @return [Boolean} whether this domain object is a tolerant match with the other
|
21
16
|
# domain object on the given attributes
|
22
17
|
def tolerant_match?(other, attributes)
|
23
|
-
attributes.all? { |
|
18
|
+
attributes.all? { |pa| Resource.tolerant_value_match?(send(pa), other.send(pa)) }
|
24
19
|
end
|
25
20
|
|
26
|
-
#
|
21
|
+
# @return [Database] the database which stores this object
|
27
22
|
def database
|
28
|
-
|
23
|
+
Database.instance
|
29
24
|
end
|
30
25
|
|
31
26
|
protected
|
32
27
|
|
33
28
|
# Returns the required attributes which are nil for this domain object.
|
34
|
-
# Overrides the
|
29
|
+
# Overrides the Jinx::Resource method to handle the following bug:
|
35
30
|
#
|
36
31
|
# @quirk caTissue Bug #67: AbstractSpecimen.setActivityStatus
|
37
32
|
# is a no-op. The Specimen activityStatus property is incorrectly pulled
|
@@ -51,16 +46,17 @@ module CaTissue
|
|
51
46
|
end
|
52
47
|
|
53
48
|
private
|
54
|
-
|
55
|
-
# The unspecified value.
|
49
|
+
|
50
|
+
# The unspecified default value.
|
51
|
+
# @private
|
56
52
|
UNSPECIFIED = 'Not Specified'
|
57
|
-
|
58
|
-
# @return whether the given value equals the other value or one of the values is nil or 'Not Specified'
|
53
|
+
|
54
|
+
# @return [Boolean] whether the given value equals the other value or one of the values is nil or 'Not Specified'
|
59
55
|
def self.tolerant_value_match?(value, other)
|
60
56
|
value == other or unpsecified_value?(value) or unpsecified_value?(other)
|
61
57
|
end
|
62
|
-
|
63
|
-
# @return whether the given value equals nil or {Resource.UNSPECIFIED}
|
58
|
+
|
59
|
+
# @return [Boolean] whether the given value equals nil or {Resource.UNSPECIFIED}
|
64
60
|
def self.unpsecified_value?(value)
|
65
61
|
value.nil? or value == UNSPECIFIED
|
66
62
|
end
|