1 | require 'test/unit'
|
---|
2 | require 'set'
|
---|
3 |
|
---|
4 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
5 | def setup
|
---|
6 | assert_nothing_raised(Exception){party_proxy = PartyProxy.new}
|
---|
7 | object_id = ObjectId.new('0.0.4')
|
---|
8 | party_ref = PartyRef.new('unknown', 'ORGANISATION', object_id)
|
---|
9 | assert_nothing_raised(Exception){
|
---|
10 | @party_proxy = PartyProxy.new(:external_ref => party_ref)}
|
---|
11 | assert_nothing_raised(Exception){party_self = PartySelf.new}
|
---|
12 | assert_nothing_raised(Exception){
|
---|
13 | @party_self = PartySelf.new(:external_ref => party_ref)}
|
---|
14 | assert_raise(ArgumentError){
|
---|
15 | party_identified = PartyIdentified.new}
|
---|
16 |
|
---|
17 | identifiers = []
|
---|
18 | identifiers << DvIdentifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
|
---|
19 | identifiers << DvIdentifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
|
---|
20 | identifiers << DvIdentifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
|
---|
21 | assert_nothing_raised(Exception){
|
---|
22 | @party_identified = PartyIdentified.new(:name => 'NERV',
|
---|
23 | :external_ref => party_ref,
|
---|
24 | :identifier => identifiers)}
|
---|
25 |
|
---|
26 | terminology_id = TerminologyId.new('test(0.04)')
|
---|
27 | code_phrase = CodePhrase.new('self', terminology_id)
|
---|
28 | dv_coded_text = DvCodedText.new('Seele',code_phrase)
|
---|
29 | assert_nothing_raised(Exception){
|
---|
30 | @party_related = PartyRelated.new(:name => 'GEHIRN',
|
---|
31 | :relationship => dv_coded_text)}
|
---|
32 | dv_text = DvText.new('commiter')
|
---|
33 | dv_coded_text = DvCodedText.new('present',terminology_id)
|
---|
34 | dv_date_time1 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-04T16:30:00')
|
---|
35 | dv_date_time2 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-14T00:00:00')
|
---|
36 | dv_interval = OpenEhr::RM::DataTypes::Quantity::DvInterval.new(dv_date_time1, dv_date_time2)
|
---|
37 | assert_nothing_raised(Exception){
|
---|
38 | @participation = Participation.new(:performer => @party_proxy,
|
---|
39 | :function => dv_text,
|
---|
40 | :mode => dv_coded_text,
|
---|
41 | :time => dv_interval)}
|
---|
42 | dv_date_time = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-04T18:56:00')
|
---|
43 | terminology_id = TerminologyId.new('openehr(1.0.2)')
|
---|
44 | code_phrase = CodePhrase.new('249', terminology_id)
|
---|
45 | dv_coded_text = DvCodedText.new('creation', code_phrase)
|
---|
46 | dv_text = DvText.new('test environment')
|
---|
47 | assert_nothing_raised(Exception){
|
---|
48 | @audit_details = AuditDetails.new(:system_id => 'MAGI',
|
---|
49 | :committer => @party_proxy,
|
---|
50 | :time_committed => dv_date_time,
|
---|
51 | :change_type => dv_coded_text,
|
---|
52 | :description => dv_text)}
|
---|
53 | dv_text = DvText.new('authorisation')
|
---|
54 | dv_ehr_uri = OpenEhr::RM::DataTypes::Uri::DvEhrUri.new('ehr://test/')
|
---|
55 | assert_nothing_raised(Exception){
|
---|
56 | @attestation = Attestation.new(:system_id => 'NERV',
|
---|
57 | :committer => @party_proxy,
|
---|
58 | :time_committed => dv_date_time,
|
---|
59 | :change_type => dv_coded_text,
|
---|
60 | :reason => dv_text,
|
---|
61 | :description => dv_text,
|
---|
62 | :proof => 'hashedstring',
|
---|
63 | :items => Set[dv_ehr_uri])}
|
---|
64 | object_version_id = ObjectVersionId.new('SHOGOUKI::NERV::1.1.1')
|
---|
65 | audit_details2 = AuditDetails.new(:system_id => 'MAGI',
|
---|
66 | :committer => @party_proxy,
|
---|
67 | :time_committed => dv_date_time2,
|
---|
68 | :change_type => dv_coded_text)
|
---|
69 | assert_nothing_raised(Exception){
|
---|
70 | @revision_history_item = RevisionHistoryItem.new(:audits => [@audit_details, audit_details2],
|
---|
71 | :version_id => object_version_id)}
|
---|
72 | dv_date_time3 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-14T12:00:00')
|
---|
73 | dv_date_time4 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-15T00:00:00')
|
---|
74 | audit_details3 = AuditDetails.new(:system_id => 'MAGI',
|
---|
75 | :committer => @party_proxy,
|
---|
76 | :time_committed => dv_date_time3,
|
---|
77 | :change_type => dv_coded_text)
|
---|
78 | audit_details4 = AuditDetails.new(:system_id => 'MAGI',
|
---|
79 | :committer => @party_proxy,
|
---|
80 | :time_committed => dv_date_time4,
|
---|
81 | :change_type => dv_coded_text)
|
---|
82 | object_version_id = ObjectVersionId.new('NIGOUKI::NERV::2.2.2')
|
---|
83 | revision_history_item2 = RevisionHistoryItem.new(:audits => [audit_details3, audit_details4],
|
---|
84 | :version_id => object_version_id)
|
---|
85 | assert_nothing_raised(Exception){
|
---|
86 | @revision_history = RevisionHistory.new([@revision_history_item, revision_history_item2])}
|
---|
87 | end
|
---|
88 |
|
---|
89 | def test_init
|
---|
90 | assert_instance_of PartyProxy, @party_proxy
|
---|
91 | assert_instance_of PartySelf, @party_self
|
---|
92 | assert_instance_of PartyIdentified, @party_identified
|
---|
93 | assert_instance_of Participation, @participation
|
---|
94 | assert_instance_of AuditDetails, @audit_details
|
---|
95 | assert_instance_of Attestation, @attestation
|
---|
96 | assert_instance_of RevisionHistoryItem, @revision_history_item
|
---|
97 | assert_instance_of RevisionHistory, @revision_history
|
---|
98 | end
|
---|
99 |
|
---|
100 | def test_party_proxy
|
---|
101 | assert_equal 'unknown', @party_proxy.external_ref.namespace
|
---|
102 | end
|
---|
103 |
|
---|
104 | def test_party_self
|
---|
105 | assert_equal 'ORGANISATION', @party_self.external_ref.type
|
---|
106 | end
|
---|
107 |
|
---|
108 | def test_party_identified
|
---|
109 | assert_equal 'NERV', @party_identified.name
|
---|
110 | assert_equal '0.0.4', @party_identified.external_ref.id.value
|
---|
111 | identifiers = @party_identified.identifier
|
---|
112 | ids = [ ]
|
---|
113 | identifiers.each do |id|
|
---|
114 | ids << id.id
|
---|
115 | end
|
---|
116 | assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
|
---|
117 | end
|
---|
118 |
|
---|
119 | def test_party_related
|
---|
120 | assert_equal 'GEHIRN', @party_related.name
|
---|
121 | end
|
---|
122 |
|
---|
123 | def test_participation
|
---|
124 | assert_equal 'unknown', @participation.performer.external_ref.namespace
|
---|
125 | assert_equal 'commiter', @participation.function.value
|
---|
126 | assert_equal 'present', @participation.mode.value
|
---|
127 | assert_equal 2009, @participation.time.lower.year
|
---|
128 | end
|
---|
129 |
|
---|
130 | def test_audit_details
|
---|
131 | assert_equal 'MAGI', @audit_details.system_id
|
---|
132 | assert_equal 'unknown', @audit_details.committer.external_ref.namespace
|
---|
133 | assert_equal '2009-07-04T18:56:00', @audit_details.time_committed.as_string
|
---|
134 | assert_equal 'creation', @audit_details.change_type.value
|
---|
135 | assert_equal 'test environment', @audit_details.description.value
|
---|
136 | end
|
---|
137 |
|
---|
138 | def test_attestation
|
---|
139 | assert_equal 'NERV', @attestation.system_id
|
---|
140 | assert_equal 'unknown', @attestation.committer.external_ref.namespace
|
---|
141 | assert_equal '249', @attestation.change_type.defining_code.code_string
|
---|
142 | assert_equal 7, @attestation.time_committed.month
|
---|
143 | assert_equal 'authorisation', @attestation.reason.value
|
---|
144 | assert_equal 'authorisation', @attestation.description.value
|
---|
145 | assert_equal 'hashedstring', @attestation.proof
|
---|
146 | assert_equal 'ehr://test/', @attestation.items.to_a[0].value
|
---|
147 | end
|
---|
148 |
|
---|
149 | def test_revision_history_item
|
---|
150 | assert_equal 'SHOGOUKI::NERV::1.1.1', @revision_history_item.version_id.value
|
---|
151 | assert_equal 'MAGI', @revision_history_item.audits[0].system_id
|
---|
152 | end
|
---|
153 |
|
---|
154 | def test_revision_history
|
---|
155 | assert_equal 'NIGOUKI::NERV::2.2.2', @revision_history.most_recent_version
|
---|
156 | assert_equal '2009-07-14T12:00:00', @revision_history.most_recent_version_time_committed
|
---|
157 | end
|
---|
158 | end
|
---|
159 |
|
---|
160 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
161 | def setup
|
---|
162 | archetype_node_id = 'at0001'
|
---|
163 | name = DvText.new('folder_test')
|
---|
164 | object_id = ObjectId.new('1.1.1')
|
---|
165 | object_ref = ObjectRef.new('local', 'PARTY', object_id)
|
---|
166 | assert_nothing_raised(Exception){
|
---|
167 | @folder = Folder.new(:archetype_node_id => archetype_node_id,
|
---|
168 | :name => name,
|
---|
169 | :items => [object_ref])}
|
---|
170 |
|
---|
171 |
|
---|
172 | end
|
---|
173 |
|
---|
174 | def test_init
|
---|
175 | assert_instance_of OpenEhr::RM::Common::Directory::Folder, @folder
|
---|
176 | end
|
---|
177 |
|
---|
178 | def test_folder
|
---|
179 | assert_equal 'at0001', @folder.archetype_node_id
|
---|
180 | assert_equal 'local', @folder.items[0].namespace
|
---|
181 | end
|
---|
182 | end
|
---|