caruby-tissue 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/README.md +6 -0
- data/lib/catissue/annotation/annotation_class.rb +1 -1
- data/lib/catissue/cli/migrate.rb +1 -0
- data/lib/catissue/domain/container.rb +13 -8
- data/lib/catissue/domain/specimen.rb +9 -3
- data/lib/catissue/domain/specimen_event_parameters.rb +1 -8
- data/lib/catissue/domain/specimen_requirement.rb +1 -1
- data/lib/catissue/domain/storage_container.rb +4 -3
- data/lib/catissue/domain/uniquify.rb +82 -0
- data/lib/catissue/migration/migrator.rb +15 -7
- data/lib/catissue/migration/uniquify.rb +2 -111
- data/lib/catissue/util/position.rb +14 -2
- data/lib/catissue/version.rb +1 -1
- data/test/fixtures/catissue/domain/conf/catissue_override.yaml +9 -0
- data/test/fixtures/catissue/extract/conf/scg_extract.yaml +3 -0
- data/test/fixtures/catissue/extract/conf/scg_fields.yaml +3 -0
- data/test/fixtures/catissue/extract/conf/spc_extract.yaml +3 -0
- data/test/fixtures/catissue/extract/conf/spc_fields.yaml +4 -0
- data/test/fixtures/lib/catissue/defaults_test_fixture.rb +202 -0
- data/test/lib/catissue/database/controlled_values_test.rb +47 -0
- data/test/lib/catissue/database/database_test.rb +28 -0
- data/test/lib/catissue/domain/address_test.rb +53 -0
- data/test/lib/catissue/domain/base_haemotology_pathology_test.rb +25 -0
- data/test/lib/catissue/domain/ca_tissue_test_defaults_test.rb +27 -0
- data/test/lib/catissue/domain/capacity_test.rb +12 -0
- data/test/lib/catissue/domain/collection_event_parameters_test.rb +24 -0
- data/test/lib/catissue/domain/collection_protocol_event_test.rb +25 -0
- data/test/lib/catissue/domain/collection_protocol_registration_test.rb +71 -0
- data/test/lib/catissue/domain/collection_protocol_test.rb +69 -0
- data/test/lib/catissue/domain/container_position_test.rb +29 -0
- data/test/lib/catissue/domain/department_test.rb +21 -0
- data/test/lib/catissue/domain/disposal_event_parameters_test.rb +16 -0
- data/test/lib/catissue/domain/location_test.rb +38 -0
- data/test/lib/catissue/domain/metadata_test.rb +62 -0
- data/test/lib/catissue/domain/participant_medical_identifier_test.rb +26 -0
- data/test/lib/catissue/domain/participant_test.rb +96 -0
- data/test/lib/catissue/domain/site_test.rb +30 -0
- data/test/lib/catissue/domain/specimen_array_test.rb +38 -0
- data/test/lib/catissue/domain/specimen_array_type_test.rb +27 -0
- data/test/lib/catissue/domain/specimen_characteristics_test.rb +15 -0
- data/test/lib/catissue/domain/specimen_collection_group_test.rb +216 -0
- data/test/lib/catissue/domain/specimen_event_parameters_test.rb +61 -0
- data/test/lib/catissue/domain/specimen_position_test.rb +62 -0
- data/test/lib/catissue/domain/specimen_requirement_test.rb +61 -0
- data/test/lib/catissue/domain/specimen_test.rb +272 -0
- data/test/lib/catissue/domain/storage_container_test.rb +150 -0
- data/test/lib/catissue/domain/storage_type_test.rb +70 -0
- data/test/lib/catissue/domain/transfer_event_parameters_test.rb +38 -0
- data/test/lib/catissue/domain/user_test.rb +50 -0
- data/test/lib/catissue/extract/delta_test.rb +25 -0
- data/test/lib/catissue/extract/extractor_test.rb +43 -0
- data/test/lib/catissue/import/importable_module_test.rb +14 -0
- data/test/lib/catissue/migration/test_case.rb +103 -0
- data/test/lib/catissue/test_case.rb +225 -0
- data/test/lib/examples/galena/domain/examples_test.rb +70 -0
- data/test/lib/examples/galena/migration/catissue.log +0 -0
- data/test/lib/examples/galena/migration/filter_test.rb +26 -0
- data/test/lib/examples/galena/migration/frozen_test.rb +28 -0
- data/test/lib/examples/galena/migration/general_test.rb +44 -0
- data/test/lib/examples/galena/migration/simple_test.rb +29 -0
- data/test/lib/examples/galena/migration/test_case.rb +52 -0
- data/test/lib/examples/galena/migration/uniquify.rb +93 -0
- metadata +223 -184
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'test/fixtures/lib/catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class CollectionProtocolEventTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@evt = defaults.specimen_collection_group.collection_event
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_defaults
|
13
|
+
@evt.protocol.identifier = 1
|
14
|
+
verify_defaults(@evt)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_protocol_membership
|
18
|
+
assert(@evt.protocol.collection_protocol_events.include?(@evt), "Event not a member of its protcol events collection")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Tests creating a protocol event.
|
22
|
+
def test_save
|
23
|
+
verify_save(@evt)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'test/fixtures/lib/catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class CollectionProtocolRegistrationTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@reg = defaults.registration
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_defaults
|
13
|
+
verify_defaults(@reg)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_missing_ppi_defaults
|
17
|
+
@reg.protocol_participant_identifier = nil
|
18
|
+
verify_defaults(@reg)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_inverse_protocol
|
22
|
+
assert(@reg.protocol.registrations.include?(@reg), "Registration not included in protocol registrations")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Tests whether the registration date can be set to either a Ruby or a Java Date and always return a Ruby Date.
|
26
|
+
def test_registration_date
|
27
|
+
value = DateTime.now
|
28
|
+
@reg.registration_date = value
|
29
|
+
assert_equal(value.to_s, @reg.registration_date.to_s, "Registration date incorrect")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_numeric_identifier
|
33
|
+
@reg.protocol_participant_identifier = 1
|
34
|
+
assert_equal("1", @reg.protocol_participant_identifier)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_disable
|
38
|
+
# add a derived specimen
|
39
|
+
specimen = @reg.specimens.first
|
40
|
+
child = specimen.derive(:specimen_class => :molecular, :specimen_requirement => defaults.specimen_requirement)
|
41
|
+
attributes = [:specimen_collection_groups, :specimens, :child_specimens]
|
42
|
+
@reg.visit_path(attributes) { |obj| obj.activity_status = 'Disabled' }
|
43
|
+
assert_equal('Disabled', @reg.activity_status, "Registration not disabled")
|
44
|
+
@reg.specimen_collection_groups.each { |scg| assert_equal('Disabled', scg.activity_status, "SCG #{scg} not disabled") }
|
45
|
+
@reg.specimens.each { |spc| assert_equal('Disabled', spc.activity_status, "Specimen #{spc} not disabled") }
|
46
|
+
assert_equal('Disabled', child.activity_status, "Child Specimen #{child} not disabled")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Tests creating and fetching a registration.
|
50
|
+
def test_save
|
51
|
+
# store the registration without an SCG
|
52
|
+
@reg.specimen_collection_groups.clear
|
53
|
+
verify_save(@reg)
|
54
|
+
|
55
|
+
# an SCG should be auto-generated
|
56
|
+
scg = @reg.specimen_collection_groups.first
|
57
|
+
assert_not_nil(scg, "Missing auto-generated SCG")
|
58
|
+
# the SCG status is pending
|
59
|
+
assert_equal('Pending', scg.collection_status, "Auto-generated SCG collection status incorrect")
|
60
|
+
|
61
|
+
# modify the consent status and update
|
62
|
+
rsps = @reg.consent_tier_responses
|
63
|
+
assert_equal(1, rsps.size, "Consent tier responses size incorrect")
|
64
|
+
rsp = rsps.first
|
65
|
+
rsp.response = 'No'
|
66
|
+
# clear the CPR SCGs since CPR response change propagates to SCG consent status on create,
|
67
|
+
# which results in a test validation mismatch
|
68
|
+
@reg.specimen_collection_groups.clear
|
69
|
+
verify_save(@reg)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'test/fixtures/lib/catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class CollectionProtocolTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@pcl = defaults.protocol
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_defaults
|
13
|
+
verify_defaults(@pcl)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Tests the hash override.
|
17
|
+
def test_hash
|
18
|
+
hash = @pcl.hash
|
19
|
+
map = {@pcl => true}
|
20
|
+
@pcl.identifier = 1
|
21
|
+
assert_equal(hash, @pcl.hash, "Protocol identifier assignment changed hash")
|
22
|
+
assert(map[@pcl], "Protocol hash key inoperative")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_alias
|
26
|
+
assert(CaTissue::CollectionProtocol.method_defined?(:events), "Study alias not recogized: events")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Tests the work-around for caTissue bug - CollectionProtocol and CollectionProtocolEvent are equal in caTissue 1.1.
|
30
|
+
def test_equals
|
31
|
+
assert_not_equal(@pcl, CaTissue::CollectionProtocolEvent.new, "Protocol incorrectly equals a CollectionProtocolEvent")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Tests whether the child_collection_protocols domain type is inferred from the Java parameterized generic type property.
|
35
|
+
def test_assigned_protocol_users_type
|
36
|
+
assert_equal(CaTissue::User, @pcl.class.domain_type(:assigned_protocol_users), "assigned_protocol_users domain type incorrect")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_add_specimens
|
40
|
+
spc1 = CaTissue::TissueSpecimen.new
|
41
|
+
spc2 = CaTissue::TissueSpecimen.new
|
42
|
+
pnt = CaTissue::Participant.new(:name => 'Test Participant')
|
43
|
+
rcvr = CaTissue::User.new(:login_name => 'test_coordinator@example.edu')
|
44
|
+
site = CaTissue::Site.new(:name => 'Test Site')
|
45
|
+
scg = @pcl.add_specimens(spc1, spc2, :participant => pnt, :receiver => rcvr, :collection_site => site)
|
46
|
+
assert_equal(2, scg.size, "Specimen group size incorrect")
|
47
|
+
assert_equal(2, scg.specimen_event_parameters.size, "Specimen event parameters size incorrect")
|
48
|
+
assert_not_nil(scg.registration, "Specimen not registered")
|
49
|
+
assert_equal(2, @pcl.specimens(pnt).size, "Protocol specimens size incorrect")
|
50
|
+
assert(@pcl.specimens(pnt).include?(spc1), 'Specimen not found')
|
51
|
+
assert(@pcl.specimens(pnt).include?(spc2), 'Specimen not found')
|
52
|
+
end
|
53
|
+
|
54
|
+
# Verify the events.
|
55
|
+
def test_events
|
56
|
+
event = @pcl.events.first
|
57
|
+
assert_not_nil(event, "Protocol test default has no events")
|
58
|
+
event_cnt = @pcl.events.size
|
59
|
+
@pcl.events << event
|
60
|
+
assert_equal(event_cnt, @pcl.events.size, "Protocol events has duplicate event")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_save
|
64
|
+
# ignore registrations
|
65
|
+
@pcl.collection_protocol_registrations.clear
|
66
|
+
# create the protocol
|
67
|
+
verify_save(@pcl)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'test/fixtures/lib/catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class SpecimenPositionTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
site = defaults.tissue_bank
|
10
|
+
frz_type = CaTissue::StorageType.new(:name => 'Freezer'.uniquify, :columns => 2, :rows => 1)
|
11
|
+
rack_type = CaTissue::StorageType.new(:name => 'Rack'.uniquify, :columns => 1, :rows => 2)
|
12
|
+
frz_type << rack_type
|
13
|
+
freezer = CaTissue::StorageContainer.new(:site => site, :container_type => frz_type)
|
14
|
+
rack = CaTissue::StorageContainer.new(:site => site, :container_type => rack_type)
|
15
|
+
@pos = CaTissue::ContainerPosition.new(:holder => freezer, :occupant => rack, :column => 0, :row => 0)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_defaults
|
19
|
+
verify_defaults(@pos)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_inverse_setter
|
23
|
+
assert_same(@pos, @pos.occupant.position, "Container position not set")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_save
|
27
|
+
verify_save(@pos)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'caruby/util/uniquifier'
|
3
|
+
|
4
|
+
class CaTissueDepartmentTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
attr_reader :department
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
@department = CaTissue::Department.new(:name => 'Test Department'.uniquify)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_defaults
|
15
|
+
verify_defaults(department)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_save
|
19
|
+
verify_save(department)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class DisposalEventParametersTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
specimen = defaults.specimen
|
10
|
+
@dsp = CaTissue::DisposalEventParameters.new(:specimen => specimen, :user => specimen.specimen_collection_group.receiver, :reason => 'Test')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_save
|
14
|
+
verify_save(@dsp)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'test/fixtures/lib/catissue/defaults_test_fixture'
|
3
|
+
|
4
|
+
class LocationTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
ctr = defaults.box
|
10
|
+
ctr.capacity.columns = 1
|
11
|
+
ctr.capacity.rows = 2
|
12
|
+
@loc = CaTissue::Location.new(:in => ctr, :at => [0, 0])
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_equals
|
16
|
+
other = CaTissue::Location.new(:in => @loc.container, :at => [@loc.column, @loc.row])
|
17
|
+
assert_equal(@loc, other, "Location with equal content not equal")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_successor
|
21
|
+
successor = @loc.succ
|
22
|
+
assert_not_nil(successor, "Successor location not created")
|
23
|
+
assert_not_same(@loc, successor, "Location same as successor")
|
24
|
+
assert_same(@loc.container, successor.container, "Location container differs from successor container")
|
25
|
+
assert_not_nil(successor.row, "Successor row not set")
|
26
|
+
assert_not_nil(successor.column, "Successor column not set")
|
27
|
+
assert_equal(0, successor.row, "Successor row incorrect")
|
28
|
+
assert_equal(1, successor.column, "Successor column incorrect")
|
29
|
+
assert_nil(successor.succ, "Location out of bounds")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_successor_bang
|
33
|
+
assert_same(@loc, @loc.succ!, "Location differs from successor bang")
|
34
|
+
assert_equal(0, @loc.column, "Successor row incorrect")
|
35
|
+
assert_equal(1, @loc.row, "Successor column incorrect")
|
36
|
+
assert_raises(IndexError, "Location out of bounds") { @loc.succ! }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'caruby/util/uniquifier'
|
3
|
+
|
4
|
+
class MetadataTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
OVERRIDE_CONFIG_FILE = 'test/fixtures/catissue/domain/conf/catissue_override.yaml'
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
@metadata = CaTissue::CollectionProtocol.metadata
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_domain_attribute
|
15
|
+
assert(!@metadata.domain_attribute?(:title), 'String attribute considered domain attribute')
|
16
|
+
assert(@metadata.domain_attribute?(:collection_protocol_events), 'Domain collection attribute not recognized')
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_collection_attribute
|
20
|
+
assert(!@metadata.collection_attribute?(:principal_investigator), 'Atomic attribute considered a collection')
|
21
|
+
assert(@metadata.collection_attribute?(:collection_protocol_events), 'Domain collection attribute not recognized as collection')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_invalid_attribute
|
25
|
+
assert(!@metadata.attributes.include?(:parent_collection_protocol), 'Attribute marked as invalid recognized')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_secondary_key
|
29
|
+
assert(!@metadata.secondary_key_attributes.empty?, 'Secondary key not set')
|
30
|
+
assert_equal([:short_title], @metadata.secondary_key_attributes.to_a, 'Secondary key incorrect')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_mandatory_attributes
|
34
|
+
assert(@metadata.mandatory_attributes.include?(:short_title), 'Secondary key not in required key')
|
35
|
+
assert(@metadata.mandatory_attributes.include?(:start_date), 'Required attribute not found')
|
36
|
+
end
|
37
|
+
|
38
|
+
# TODO - enable config override and retest.
|
39
|
+
|
40
|
+
def test_secondary_key_override
|
41
|
+
# save the standard properties
|
42
|
+
properties = CaTissue.access_properties.copy_recursive
|
43
|
+
# load the override properties
|
44
|
+
CaTissue.load_access_properties(OVERRIDE_CONFIG_FILE)
|
45
|
+
@metadata = CaRuby::Metadata.new(CaTissue::CollectionProtocol)
|
46
|
+
assert_equal([:title], @metadata.secondary_key_attributes, 'Secondary key not overridden')
|
47
|
+
# restore the standard properties
|
48
|
+
CaTissue.access_properties.keys.each { |key| CaTissue.access_properties[key] = properties[key] }
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_mandatory_attributes_override
|
52
|
+
# save the standard properties
|
53
|
+
properties = CaTissue.access_properties.copy_recursive
|
54
|
+
# load the override properties
|
55
|
+
CaTissue.load_access_properties(OVERRIDE_CONFIG_FILE)
|
56
|
+
@metadata = CaRuby::Metadata.new(CaTissue::CollectionProtocol)
|
57
|
+
assert(@metadata.mandatory_attributes.include?(:sequence_number), 'Required attribute override not added')
|
58
|
+
assert(!@metadata.mandatory_attributes.include?(:start_date), 'Required attribute retained after override')
|
59
|
+
# restore the standard properties
|
60
|
+
CaTissue.access_properties.keys.each { |key| CaTissue.access_properties[key] = properties[key] }
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
|
3
|
+
class ParticipantMedicalIdentifierTest < Test::Unit::TestCase
|
4
|
+
include CaTissue::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@pmi = CaTissue::ParticipantMedicalIdentifier.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_i_to_s_conversion
|
12
|
+
@pmi.medical_record_number = 2
|
13
|
+
assert_equal('2', @pmi.medical_record_number, "MRN numeric argument not converted to string")
|
14
|
+
end
|
15
|
+
|
16
|
+
# Tests creating and fetching a participant.
|
17
|
+
def test_save
|
18
|
+
@pmi.medical_record_number = Uniquifier.qualifier
|
19
|
+
@pmi.site = defaults.tissue_bank
|
20
|
+
@pmi.participant = CaTissue::Participant.new(:name => 'Test Participant'.uniquify)
|
21
|
+
verify_save(@pmi)
|
22
|
+
# update the PMI
|
23
|
+
@pmi.medical_record_number = Uniquifier.qualifier
|
24
|
+
verify_save(@pmi)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_case')
|
2
|
+
require 'caruby/util/uniquifier'
|
3
|
+
|
4
|
+
class ParticipantTest < Test::Unit::TestCase
|
5
|
+
include CaTissue::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@pnt = CaTissue::Participant.new(:name => 'Test Participant'.uniquify)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_defaults
|
13
|
+
verify_defaults(@pnt)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Tests parsing the patient name.
|
17
|
+
def test_name
|
18
|
+
@pnt.name = 'John Q. Doe'
|
19
|
+
assert_equal('John', @pnt.first_name, 'Person first name incorrect')
|
20
|
+
assert_equal('Q.', @pnt.middle_name, 'Person middle name incorrect')
|
21
|
+
assert_equal('Doe', @pnt.last_name, 'Person last name incorrect')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Tests the participant SSN secondary key and MRN alternate key.
|
25
|
+
def test_key
|
26
|
+
mrn = '5555'
|
27
|
+
pmi = @pnt.add_mrn(defaults.tissue_bank, '5555')
|
28
|
+
assert_equal(pmi, @pnt.key, 'Person key is not the MRN')
|
29
|
+
# add the preferred SSN key
|
30
|
+
expected = @pnt.social_security_number = '555-55-5555'
|
31
|
+
assert_equal(expected, @pnt.key, 'Person key is not the SSN')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Tests making a participant lab annotation.
|
35
|
+
def test_clinical_annotation
|
36
|
+
labs = @pnt.lab_annotations
|
37
|
+
assert(labs.empty?, "Labs not empty at start")
|
38
|
+
lab = CaTissue::Participant::Clinical::LabAnnotation.new.merge_attributes(:lab_test_name => 'Test Lab', :participant => @pnt)
|
39
|
+
labs = @pnt.lab_annotations
|
40
|
+
assert_not_nil(labs.first, "Lab not added to participant labs")
|
41
|
+
assert_same(lab, labs.first, "Lab incorrect")
|
42
|
+
assert_same(@pnt, lab.owner, "Lab proxy hook not set")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Tests creating and fetching a participant.
|
46
|
+
def test_save
|
47
|
+
verify_save(@pnt)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_save_alcohol_annotation
|
51
|
+
alc = CaTissue::Participant::Clinical::AlcoholHealthAnnotation.new.merge_attributes(:drinks_per_week => 4, :years_agent_free => 2, :participant => @pnt)
|
52
|
+
verify_save(alc)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Tests saving a participant lab annotation.
|
56
|
+
def test_save_lab_annotation
|
57
|
+
date = DateTime.new(2010, 10, 10)
|
58
|
+
lab = CaTissue::Participant::Clinical::LabAnnotation.new.merge_attributes(:other_lab_test_name => 'Test Lab', :test_date => date, :participant => @pnt)
|
59
|
+
verify_save(lab)
|
60
|
+
assert_not_nil(lab.identifier, "Lab not saved")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_save_diagnosis_annotation
|
64
|
+
date = DateTime.new(2010, 10, 10)
|
65
|
+
dgn = CaTissue::Participant::Clinical::NewDiagnosisHealthAnnotation.new.merge_attributes(
|
66
|
+
:name_of_procedure => 'Biopsy of prostate', :date_of_examination => date, :participant => @pnt)
|
67
|
+
verify_save(dgn)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_save_treatment_annotation
|
71
|
+
date = DateTime.new(2010, 10, 10)
|
72
|
+
trt = CaTissue::Participant::Clinical::TreatmentAnnotation.new.merge_attributes(:other_agent => 'Radical Prostatectomy', :participant => @pnt)
|
73
|
+
dtn = CaTissue::Participant::Clinical::Duration.new.merge_attributes(:start_date => date, :end_date => date, :duration_in_days => 1, :treatment_annotation => trt)
|
74
|
+
verify_save(trt)
|
75
|
+
end
|
76
|
+
|
77
|
+
# caTissue alert - The RadiationTherapy DE class is not supported, since it is not a primary entity. RadRXAnnotation is used instead.
|
78
|
+
# Purpose of the caTissue RadiationTherapy class is unknown, since it adds nothing to RadRXAnnotation. The same consideration applies
|
79
|
+
# to Chemotherapy. TODO - check with caTissue support and either request deprecation or add caRuby support.
|
80
|
+
def test_save_radiation_annotation
|
81
|
+
rdx = CaTissue::Participant::Clinical::RadRXAnnotation.new.merge_attributes(:other_agent => 'Adjuvant Radiation Therapy', :participant => @pnt)
|
82
|
+
verify_save(rdx)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_save_exam_annotation
|
86
|
+
exam = CaTissue::Participant::Clinical::HealthExaminationAnnotation.new.merge_attributes(
|
87
|
+
:name_of_procedure => 'Prostatectomy', :participant => @pnt)
|
88
|
+
verify_save(exam)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_save_recurrence_exam_annotation
|
92
|
+
exam = CaTissue::Participant::Clinical::LocalRecurrenceHealthExaminationAnnotation.new.merge_attributes(
|
93
|
+
:name_of_procedure => 'Prostatectomy', :clinical_diagnosis => 'Malignant melanoma - NOS', :participant => @pnt)
|
94
|
+
verify_save(exam)
|
95
|
+
end
|
96
|
+
end
|