Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 280:5daa3896981c
testing storage commitment reports
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Mar 2020 20:54:57 +0100 |
parents | 31e1e49df380 |
children | 99acf0c17348 |
rev | line source |
---|---|
22 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 | |
3 | 5 # Orthanc - A Lightweight, RESTful DICOM Store |
73 | 6 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3 | 7 # Department, University Hospital of Liege, Belgium |
260
943166deebcb
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
8 # Copyright (C) 2017-2020 Osimis S.A., Belgium |
3 | 9 # |
10 # This program is free software: you can redistribute it and/or | |
11 # modify it under the terms of the GNU General Public License as | |
12 # published by the Free Software Foundation, either version 3 of the | |
13 # License, or (at your option) any later version. | |
14 # | |
15 # This program is distributed in the hope that it will be useful, but | |
16 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 # General Public License for more details. | |
19 # | |
20 # You should have received a copy of the GNU General Public License | |
21 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | |
23 | |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
24 import base64 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
25 import copy |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
26 import pprint |
14 | 27 import tempfile |
3 | 28 import unittest |
29 | |
11 | 30 from PIL import ImageChops |
3 | 31 from Toolbox import * |
13 | 32 from xml.dom import minidom |
3 | 33 |
34 _LOCAL = None | |
35 _REMOTE = None | |
36 | |
37 | |
38 def SetOrthancParameters(local, remote): | |
39 global _LOCAL, _REMOTE | |
40 _LOCAL = local | |
41 _REMOTE = remote | |
42 | |
43 | |
14 | 44 def ExtractDicomTags(rawDicom, tags): |
45 with tempfile.NamedTemporaryFile(delete = True) as f: | |
46 f.write(rawDicom) | |
47 f.flush() | |
45 | 48 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 49 |
50 result = [] | |
51 for tag in tags: | |
52 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
53 if match == None: | |
54 result.append('') | |
55 else: | |
56 result.append(match.group(1)) | |
57 | |
58 return result | |
59 | |
60 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
61 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
62 if len(a) != len(b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
63 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
64 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
65 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
66 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
67 if abs(d) >= 0.51: # Add some tolerance for rounding errors |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
68 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
69 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
70 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
73 def CompareTags(a, b, tagsToIgnore): |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
74 for i in tagsToIgnore: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
75 if i in a: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
76 del a[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
77 if i in b: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
78 del b[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
79 |
123 | 80 if a.keys() == b.keys(): |
81 return True | |
82 else: | |
83 print('Mismatch in tags: %s' % str(set(a.keys()) ^ set(b.keys()))) | |
84 return False | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
85 |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
86 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
87 def CallFindScu(args): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
88 p = subprocess.Popen([ FindExecutable('findscu'), |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
89 '-P', '-aec', _REMOTE['DicomAet'], '-aet', _LOCAL['DicomAet'], |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
90 _REMOTE['Server'], str(_REMOTE['DicomPort']) ] + args, |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
91 stderr=subprocess.PIPE) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
92 return p.communicate()[1] |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
93 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
94 |
142 | 95 def GetMoveScuCommand(): |
96 return [ | |
97 FindExecutable('movescu'), | |
98 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) | |
99 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) | |
100 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) | |
101 _REMOTE['Server'], | |
102 str(_REMOTE['DicomPort']) | |
103 ] | |
104 | |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
105 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
106 def CallMoveScu(args): |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
107 try: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
108 subprocess.check_call(GetMoveScuCommand() + args, |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
109 stderr=subprocess.PIPE) |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
110 except subprocess.CalledProcessError as e: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
111 # The error code "69" corresponds to "EXITCODE_CMOVE_ERROR", |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
112 # that has been introduced in DCMTK 3.6.2. This error code is |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
113 # expected by some tests that try and C-MOVE non-existing |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
114 # DICOM instances. |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
115 # https://groups.google.com/d/msg/orthanc-users/DCRc5NeSCbM/DG-pSWj-BwAJ |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
116 if e.returncode != 69: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
117 raise e |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
118 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
119 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
120 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
121 return [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
122 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
123 'StudyDescription': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
124 'ReferencedStudySequence' : [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
125 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
126 'StudyDescription': 'Toto', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
127 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
128 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
129 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
130 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
131 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
132 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
133 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
134 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
135 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
136 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
137 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
138 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
139 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
140 |
15 | 141 |
3 | 142 class Orthanc(unittest.TestCase): |
143 def setUp(self): | |
83 | 144 if (sys.version_info >= (3, 0)): |
145 # Remove annoying warnings about unclosed socket in Python 3 | |
146 import warnings | |
147 warnings.simplefilter("ignore", ResourceWarning) | |
148 | |
3 | 149 DropOrthanc(_LOCAL) |
150 DropOrthanc(_REMOTE) | |
174 | 151 UninstallLuaCallbacks(_REMOTE) |
45 | 152 #print "In test", self._testMethodName |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
153 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
154 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
155 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
156 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
157 |
3 | 158 |
159 def test_system(self): | |
177 | 160 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) |
161 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
162 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
163 | |
164 systemInfo = DoGet(_REMOTE, '/system') | |
165 if systemInfo["Version"] == "mainline": | |
166 print "Skipping version checks since you're currently in mainline" | |
167 return | |
168 | |
173 | 169 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 8, 6)) |
170 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 8, 7)) | |
171 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 7, 6)) | |
172 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 9, 6)) | |
173 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 1, 8, 6)) | |
3 | 174 |
175 def test_upload(self): | |
173 | 176 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
177 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
178 | |
179 sizeDummyCT = 2472 | |
180 sizeOverwrite = 2476 | |
181 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
182 | |
3 | 183 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
183 | 184 self.assertEqual(instance, u['ID']) |
3 | 185 self.assertEqual('Success', u['Status']) |
173 | 186 |
183 | 187 if True: |
188 # New test for Orthanc 1.4.3 | |
189 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', u['ParentSeries']) | |
190 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', u['ParentStudy']) | |
191 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', u['ParentPatient']) | |
192 | |
173 | 193 j = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) |
194 s = sizeDummyCT + j | |
195 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
196 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
197 | |
3 | 198 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
199 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
200 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
201 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
202 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
173 | 203 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
204 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
205 | |
206 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
3 | 207 self.assertEqual('20070101', i['StudyDate']) |
173 | 208 self.assertEqual('KNIX', i['PatientName']) |
209 | |
210 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
211 # Overwriting | |
212 self.assertEqual('Success', u['Status']) | |
213 else: | |
214 self.assertEqual('AlreadyStored', u['Status']) | |
215 | |
216 u = UploadInstance(_REMOTE, 'DummyCT-overwrite.dcm') | |
217 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
218 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
219 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
220 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
221 | |
222 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
223 # Overwriting | |
224 self.assertEqual('Success', u['Status']) | |
225 j2 = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) | |
226 s2 = sizeOverwrite + j2 | |
227 self.assertNotEqual(s, s2) | |
228 self.assertNotEqual(j, j2) | |
229 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
230 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
231 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
232 self.assertEqual('ANOTHER', i['PatientName']) | |
233 else: | |
234 self.assertEqual('AlreadyStored', u['Status']) | |
235 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
236 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
3 | 237 |
5 | 238 def test_upload_2(self): |
3 | 239 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
240 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
241 self.assertEqual(i, instance['ID']) | |
242 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
243 instance['MainDicomTags']['SOPInstanceUID']) | |
244 | |
245 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
246 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
247 series['MainDicomTags']['SeriesInstanceUID']) | |
248 | |
249 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
250 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
251 study['MainDicomTags']['StudyInstanceUID']) | |
252 | |
253 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
254 self.assertEqual('ozp00SjY2xG', | |
255 patient['MainDicomTags']['PatientID']) | |
256 | |
257 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
258 self.assertEqual(2472, len(dicom)) | |
259 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
260 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
261 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
262 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags' % i)['0008,1010']['Value']) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
263 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['StationName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
264 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?short' % i)['0008,1010']) |
3 | 265 |
266 | |
5 | 267 def test_images(self): |
268 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
269 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 270 |
5 | 271 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
272 self.assertEqual("L", im.mode) | |
273 self.assertEqual(512, im.size[0]) | |
274 self.assertEqual(358, im.size[1]) | |
275 | |
276 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
277 self.assertEqual("L", im.mode) | |
278 self.assertEqual(512, im.size[0]) | |
279 self.assertEqual(358, im.size[1]) | |
280 | |
281 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
282 self.assertEqual(512, im.size[0]) | |
283 self.assertEqual(358, im.size[1]) | |
284 | |
285 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
286 self.assertEqual("L", im.mode) | |
287 self.assertEqual(512, im.size[0]) | |
288 self.assertEqual(358, im.size[1]) | |
289 | |
290 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
291 self.assertEqual("L", im.mode) | |
292 self.assertEqual(512, im.size[0]) | |
293 self.assertEqual(358, im.size[1]) | |
294 | |
295 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
296 self.assertEqual(512, im.size[0]) | |
297 self.assertEqual(358, im.size[1]) | |
64 | 298 |
299 # This is Little Endian Explicit | |
300 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
301 | |
6 | 302 |
303 def test_hierarchy(self): | |
304 UploadFolder(_REMOTE, 'Brainix/Epi') | |
305 UploadFolder(_REMOTE, 'Brainix/Flair') | |
306 UploadFolder(_REMOTE, 'Knee/T1') | |
307 UploadFolder(_REMOTE, 'Knee/T2') | |
308 | |
309 p = DoGet(_REMOTE, '/patients') | |
310 s = DoGet(_REMOTE, '/studies') | |
311 t = DoGet(_REMOTE, '/series') | |
312 self.assertEqual(2, len(p)) | |
313 self.assertEqual(2, len(s)) | |
314 self.assertEqual(4, len(t)) | |
315 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
316 | |
317 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
318 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
319 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
320 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
321 | |
322 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
323 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
324 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
325 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
326 | |
327 self.assertTrue(brainixPatient in p) | |
328 self.assertTrue(kneePatient in p) | |
329 self.assertTrue(brainixStudy in s) | |
330 self.assertTrue(kneeStudy in s) | |
331 self.assertTrue(brainixEpi in t) | |
332 self.assertTrue(brainixFlair in t) | |
333 self.assertTrue(kneeT1 in t) | |
334 self.assertTrue(kneeT2 in t) | |
335 | |
336 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
337 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
338 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
339 | |
340 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
341 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
342 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
343 | |
344 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
345 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
346 | |
347 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
348 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
349 | |
350 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
351 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
352 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
353 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
354 | |
355 for patient in p: | |
356 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
357 self.assertEqual(patient, study['ParentPatient']) | |
358 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
359 self.assertEqual(study['ID'], series['ParentStudy']) | |
211 | 360 self.assertEqual('Unknown', series['Status']) |
6 | 361 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): |
362 self.assertEqual(series['ID'], instance['ParentSeries']) | |
363 | |
364 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), | |
365 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) | |
366 | |
367 | |
368 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
369 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
370 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
371 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
372 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
373 self.assertEqual(None, r) | |
374 | |
375 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
376 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
377 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
378 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
379 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
380 self.assertEqual('Study', r['Type']) | |
381 self.assertEqual(kneeStudy, r['ID']) | |
382 | |
383 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
384 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
385 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
386 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
387 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
388 self.assertEqual('Series', r['Type']) | |
389 self.assertEqual(kneeT1, r['ID']) | |
390 | |
391 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
392 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
393 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
394 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
395 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
396 self.assertEqual(None, r) | |
397 | |
398 DropOrthanc(_REMOTE) | |
399 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
400 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 401 |
213
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
402 def test_delete_cascade(self): |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
403 # make sure deleting the last instance of a study deletes the series, study and patient |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
404 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
405 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) # make sure orthanc is empty when starting the test |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
406 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
407 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
408 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
409 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
410 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
411 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
412 DoDelete(_REMOTE, '/instances/%s' % a) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
413 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
414 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
415 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
416 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
417 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
418 |
7 | 419 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
420 def test_multiframe(self): |
7 | 421 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
422 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
423 | |
424 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
425 self.assertEqual("L", im.mode) | |
426 self.assertEqual(512, im.size[0]) | |
427 self.assertEqual(512, im.size[1]) | |
428 | |
429 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
430 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
431 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
432 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
433 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
434 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
435 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
436 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
437 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
438 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
440 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
441 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
442 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
443 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
444 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
445 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
446 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
449 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
451 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
452 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 self.assertEqual(c['Changes'][-1]['Seq'], c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
454 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
455 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
456 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
457 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
459 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 1)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
460 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
461 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
462 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
463 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 2)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
464 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
465 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
466 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
467 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 3)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
468 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
469 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
470 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
471 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
472 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
473 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
474 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
475 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
476 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
477 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
478 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
479 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
480 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
481 c = DoGet(_REMOTE, '/changes', { 'since' : since, 'limit' : 3 }) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
482 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
483 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
484 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
485 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
486 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
487 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
488 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
489 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
490 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
491 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
492 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
493 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
494 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
495 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
496 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
497 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
498 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
499 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
500 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
501 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
502 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
503 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
504 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
505 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
506 break |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
507 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
508 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
509 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
510 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
511 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
512 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
513 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
514 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
515 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
516 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
517 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
192 | 518 knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' |
519 | |
520 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
521 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
522 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
523 z = GetArchive(_REMOTE, '/studies/%s/archive' % DoGet(_REMOTE, '/studies')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
524 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
525 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
526 z = GetArchive(_REMOTE, '/series/%s/archive' % DoGet(_REMOTE, '/series')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
527 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
528 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
529 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
192 | 530 brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' |
531 | |
532 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
533 self.assertEqual(2, len(z.namelist())) |
192 | 534 |
535 z = PostArchive(_REMOTE, '/tools/create-archive', { | |
536 'Resources' : [ brainix, knee ] | |
537 }) | |
538 self.assertEqual(3, len(z.namelist())) | |
539 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
540 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
541 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
542 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
543 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
544 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
545 z = GetArchive(_REMOTE, '/patients/%s/media' % DoGet(_REMOTE, '/patients')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
546 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
547 self.assertTrue('IMAGES/IM0' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
548 self.assertTrue('IMAGES/IM1' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
549 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
550 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
551 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
552 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
553 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
554 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
555 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
556 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
557 z.extract('DICOMDIR', '/tmp') |
45 | 558 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
559 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
560 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
561 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
562 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
563 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
564 |
45 | 565 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
566 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
567 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
568 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
569 |
45 | 570 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
571 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
572 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081909113806560', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
573 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
574 os.remove('/tmp/DICOMDIR') |
10 | 575 |
576 | |
577 def test_protection(self): | |
578 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
579 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
580 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
581 a = DoGet(_REMOTE, '/patients')[0] | |
582 b = DoGet(_REMOTE, '/patients')[1] | |
583 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
584 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
585 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
586 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
587 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
588 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
589 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
590 | |
591 | |
12 | 592 def test_raw_tags(self): |
10 | 593 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
594 | |
595 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
596 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
597 | |
598 s = '/instances/%s/content/' % i | |
599 | |
600 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
601 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
602 | |
603 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
604 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
605 | |
606 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
607 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
608 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
609 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
610 | |
611 for i in DoGet(_REMOTE, '/instances'): | |
612 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
613 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
614 | |
615 | |
616 def test_raw_tags_mdn(self): | |
617 # Bug reported by Cyril Paulus | |
618 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
619 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
620 | |
621 | |
622 def test_modify_instance(self): | |
623 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
624 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
625 json.dumps({ | |
626 "Replace" : { | |
627 "PatientName" : "hello", | |
628 #"PatientID" : "world" | |
629 }, | |
630 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
631 "RemovePrivateTags" : True |
10 | 632 }), |
633 'application/json') | |
634 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
635 | |
636 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
637 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 638 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 639 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
640 | |
641 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
642 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
643 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
644 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
645 | |
646 | |
647 def test_modify_series(self): | |
648 # Upload 4 images from the same series | |
649 for i in range(4): | |
650 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
651 | |
652 origSeries = DoGet(_REMOTE, '/series')[0] | |
653 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
654 '{"Replace":{"PatientName":"Jodogne"}}', | |
655 'application/json')['ID'] | |
656 | |
657 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
658 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
659 self.assertEqual(4, len(instances)) | |
660 for i in instances: | |
661 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
662 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
663 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
664 | |
665 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
666 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
667 | |
668 | |
669 def test_modify_study(self): | |
670 # Upload 4 images from the 2 series of the same study | |
671 for i in range(4): | |
672 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
673 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
674 | |
675 origStudy = DoGet(_REMOTE, '/studies')[0] | |
676 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
677 '{"Replace":{"PatientName":"Jodogne"}}', | |
678 'application/json')['ID'] | |
679 | |
680 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
681 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
682 self.assertEqual(2, len(series)) | |
683 for s in series: | |
684 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
685 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
686 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
687 | |
688 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
689 for i in instances: | |
690 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
691 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
692 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
693 | |
694 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
695 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
696 | |
697 | |
698 def test_anonymize_series(self): | |
699 # Upload 4 images from the same series | |
700 for i in range(4): | |
701 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
702 | |
703 origSeries = DoGet(_REMOTE, '/series')[0] | |
704 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
705 '{}', | |
706 'application/json')['ID'] | |
707 | |
708 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
709 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
710 self.assertEqual(4, len(instances)) | |
711 for i in instances: | |
712 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
713 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
714 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
715 | |
716 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
717 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
718 | |
719 | |
720 def test_anonymize_study(self): | |
721 # Upload 4 images from the 2 series of the same study | |
722 for i in range(4): | |
723 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
724 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
725 | |
726 origStudy = DoGet(_REMOTE, '/studies')[0] | |
727 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
728 '{"Replace":{"PatientName":"Jodogne"}}', | |
729 'application/json')['ID'] | |
730 | |
731 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
732 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
733 self.assertEqual(2, len(series)) | |
734 for s in series: | |
735 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
736 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
737 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
738 | |
739 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
740 for i in instances: | |
741 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
742 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
743 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
744 | |
745 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
746 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 747 |
748 | |
749 | |
750 def test_storescu(self): | |
751 # Check emptiness | |
752 e = DoGet(_REMOTE, '/exports') | |
753 self.assertEqual(0, len(e['Exports'])) | |
754 self.assertEqual(0, e['Last']) | |
755 self.assertTrue(e['Done']) | |
756 e = DoGet(_REMOTE, '/exports?last') | |
757 self.assertEqual(0, len(e['Exports'])) | |
758 self.assertEqual(0, e['Last']) | |
759 self.assertTrue(e['Done']) | |
760 | |
761 # Add 1 instance | |
762 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
763 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
764 | |
765 # Export the instance | |
766 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
767 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
768 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
769 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
770 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
771 | |
772 e = DoGet(_REMOTE, '/exports') | |
773 self.assertEqual(1, len(e['Exports'])) | |
774 self.assertTrue(e['Done']) | |
775 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
776 e = DoGet(_REMOTE, '/exports?limit=1') | |
777 self.assertEqual(1, len(e['Exports'])) | |
778 self.assertTrue(e['Done']) | |
779 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
780 e = DoGet(_REMOTE, '/exports?last') | |
781 self.assertEqual(1, len(e['Exports'])) | |
782 self.assertTrue(e['Done']) | |
783 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
784 seqInstance = e['Last'] | |
785 | |
786 # Export the series | |
787 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
788 | |
789 e = DoGet(_REMOTE, '/exports') | |
790 self.assertEqual(2, len(e['Exports'])) | |
791 self.assertTrue(e['Done']) | |
792 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
793 seqSeries = e['Last'] | |
794 self.assertNotEqual(seqInstance, seqSeries) | |
795 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
796 self.assertEqual(1, len(e['Exports'])) | |
797 self.assertFalse(e['Done']) | |
798 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
799 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
800 self.assertEqual(1, len(e['Exports'])) | |
801 self.assertTrue(e['Done']) | |
802 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
803 e = DoGet(_REMOTE, '/exports?last') | |
804 self.assertEqual(1, len(e['Exports'])) | |
805 self.assertTrue(e['Done']) | |
806 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
807 | |
808 # Export the study | |
809 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
810 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
811 | |
812 # Export the patient | |
813 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
814 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
815 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
816 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
817 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
818 | |
819 e = DoGet(_REMOTE, '/exports') | |
820 self.assertEqual(4, len(e['Exports'])) | |
821 self.assertTrue(e['Done']) | |
822 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
823 seqPatient = e['Last'] | |
824 self.assertNotEqual(seqInstance, seqSeries) | |
825 self.assertNotEqual(seqSeries, seqStudy) | |
826 self.assertNotEqual(seqStudy, seqPatient) | |
827 self.assertTrue(seqInstance < seqSeries) | |
828 self.assertTrue(seqSeries < seqStudy) | |
829 self.assertTrue(seqStudy < seqPatient) | |
830 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
831 self.assertEqual(1, len(e['Exports'])) | |
832 self.assertFalse(e['Done']) | |
833 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
834 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
835 self.assertEqual(1, len(e['Exports'])) | |
836 self.assertFalse(e['Done']) | |
837 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
838 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
839 self.assertEqual(1, len(e['Exports'])) | |
840 self.assertFalse(e['Done']) | |
841 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
842 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
843 self.assertEqual(1, len(e['Exports'])) | |
844 self.assertTrue(e['Done']) | |
845 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
846 e = DoGet(_REMOTE, '/exports?last') | |
847 self.assertEqual(1, len(e['Exports'])) | |
848 self.assertTrue(e['Done']) | |
849 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
850 | |
851 | |
852 # Check the content of the logged information | |
853 e = DoGet(_REMOTE, '/exports')['Exports'] | |
854 | |
855 if 'PatientID' in e[0]: | |
856 # Since Orthanc 0.8.6 | |
857 patient = 'PatientID' | |
858 study = 'StudyInstanceUID' | |
859 series = 'SeriesInstanceUID' | |
860 instance = 'SOPInstanceUID' | |
861 else: | |
862 # Up to Orthanc 0.8.5 | |
863 patient = 'PatientId' | |
864 study = 'StudyInstanceUid' | |
865 series = 'SeriesInstanceUid' | |
866 instance = 'SopInstanceUid' | |
867 | |
868 for k in range(4): | |
869 self.assertTrue('Date' in e[k]) | |
870 self.assertTrue('Seq' in e[k]) | |
871 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
872 | |
873 self.assertEqual(10, len(e[0])) | |
874 self.assertEqual('Instance', e[0]['ResourceType']) | |
875 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
876 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
877 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
878 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
879 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
880 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
881 | |
882 self.assertEqual(9, len(e[1])) | |
883 self.assertEqual('Series', e[1]['ResourceType']) | |
884 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
885 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
886 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
887 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
888 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
889 | |
890 self.assertEqual(8, len(e[2])) | |
891 self.assertEqual('Study', e[2]['ResourceType']) | |
892 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
893 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
894 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
895 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
896 | |
897 self.assertEqual(7, len(e[3])) | |
898 self.assertEqual('Patient', e[3]['ResourceType']) | |
899 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
900 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
901 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
902 | |
903 DropOrthanc(_REMOTE) | |
904 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
905 | |
906 | |
907 def test_store_peer(self): | |
908 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
909 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
910 | |
911 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
912 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
913 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
914 | |
915 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
916 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
917 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
918 | |
919 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
920 | |
921 DropOrthanc(_REMOTE) | |
922 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
923 | |
924 | |
925 def test_bulk_storescu(self): | |
926 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
927 | |
928 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
929 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
930 | |
931 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
932 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
933 | |
934 DropOrthanc(_LOCAL) | |
935 | |
936 # Send using patient's UUID | |
937 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
938 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
939 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
940 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
941 | |
942 | |
943 def test_color(self): | |
944 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
945 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
946 self.assertEqual("RGB", im.mode) | |
947 self.assertEqual(41, im.size[0]) | |
948 self.assertEqual(41, im.size[1]) | |
949 | |
950 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 951 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 952 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
953 | |
954 | |
12 | 955 def test_faking_ruby_put(self): |
956 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
957 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
958 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
959 a = DoGet(_REMOTE, '/patients')[0] | |
960 b = DoGet(_REMOTE, '/patients')[1] | |
961 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
962 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
963 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
964 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
965 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
966 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
967 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
968 | |
969 | |
970 def test_faking_ruby_delete(self): | |
971 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
972 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
973 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
974 a = DoGet(_REMOTE, '/patients')[0] | |
975 b = DoGet(_REMOTE, '/patients')[1] | |
976 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
977 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
978 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
979 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
980 | |
981 | |
982 def test_faking_google_put(self): | |
983 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
984 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
985 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
986 a = DoGet(_REMOTE, '/patients')[0] | |
987 b = DoGet(_REMOTE, '/patients')[1] | |
988 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
989 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
990 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
991 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
992 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
993 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
994 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
995 | |
996 | |
997 def test_faking_google_delete(self): | |
998 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
999 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1000 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1001 a = DoGet(_REMOTE, '/patients')[0] | |
1002 b = DoGet(_REMOTE, '/patients')[1] | |
1003 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1004 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1005 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1006 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1007 | |
1008 | |
1009 def test_lua(self): | |
1010 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
1011 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
1012 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
1013 | |
1014 | |
1015 def test_metadata(self): | |
1016 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1017 p = DoGet(_REMOTE, '/patients')[0] | |
1018 i = DoGet(_REMOTE, '/instances')[0] | |
1019 | |
1020 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1021 self.assertEqual(1, len(m)) | |
1022 self.assertEqual('LastUpdate', m[0]) | |
1023 | |
1024 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
145 | 1025 self.assertEqual(8, len(m)) |
12 | 1026 self.assertTrue('IndexInSeries' in m) |
1027 self.assertTrue('ReceptionDate' in m) | |
1028 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1029 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1030 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1031 self.assertTrue('SopClassUid' in m) |
145 | 1032 self.assertTrue('RemoteIP' in m) |
1033 self.assertTrue('HttpUsername' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1034 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1035 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i), 'RestApi') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1036 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i), '') # None, received by REST API |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1037 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i), '1.2.840.10008.1.2.4.91') # JPEG2k |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1038 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 1039 |
1040 # Play with custom metadata | |
1041 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
1042 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1043 self.assertEqual(2, len(m)) | |
1044 self.assertTrue('LastUpdate' in m) | |
1045 self.assertTrue('5555' in m) | |
1046 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1047 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
1048 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1049 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
1050 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1051 self.assertEqual(1, len(m)) | |
1052 self.assertTrue('LastUpdate' in m) | |
13 | 1053 |
1054 | |
1055 def test_statistics(self): | |
1056 # Upload 16 instances | |
1057 for i in range(4): | |
1058 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1059 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1060 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1061 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1062 | |
1063 s = DoGet(_REMOTE, '/statistics') | |
1064 self.assertEqual(16, s['CountInstances']) | |
1065 self.assertEqual(2, s['CountPatients']) | |
1066 self.assertEqual(2, s['CountStudies']) | |
1067 self.assertEqual(4, s['CountSeries']) | |
1068 d = int(s['TotalUncompressedSize']) | |
1069 | |
1070 e = 0 | |
1071 for patient in DoGet(_REMOTE, '/patients'): | |
1072 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
1073 self.assertEqual(8, s['CountInstances']) | |
1074 self.assertEqual(1, s['CountStudies']) | |
1075 self.assertEqual(2, s['CountSeries']) | |
1076 e += int(s['UncompressedSize']) | |
1077 | |
1078 for study in DoGet(_REMOTE, '/studies'): | |
1079 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
1080 self.assertEqual(8, s['CountInstances']) | |
1081 self.assertEqual(2, s['CountSeries']) | |
1082 e += int(s['UncompressedSize']) | |
1083 | |
1084 for series in DoGet(_REMOTE, '/series'): | |
1085 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
1086 self.assertEqual(4, s['CountInstances']) | |
1087 e += int(s['UncompressedSize']) | |
1088 | |
1089 self.assertEqual(3 * d, e) | |
1090 | |
1091 | |
1092 def test_custom_attachment(self): | |
1093 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1094 patient = DoGet(_REMOTE, '/patients')[0] | |
1095 instance = DoGet(_REMOTE, '/instances')[0] | |
1096 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1097 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1098 | |
1099 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1100 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
1101 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1102 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1103 | |
1104 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1105 hello = 'hellohellohellohellohellohellohellohellohello' | |
1106 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1107 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1108 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1109 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1110 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1111 | |
1112 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
1113 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1114 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1115 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1116 size + | |
1117 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1118 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1119 | |
1120 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1121 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1122 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1123 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1124 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1125 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1126 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1127 | |
1128 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1129 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1130 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1131 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1132 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1133 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1134 | |
1135 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1136 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1137 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1138 | |
1139 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1140 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1141 | |
1142 | |
1143 def test_incoming_storescu(self): | |
1144 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1145 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1146 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1147 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1148 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1149 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1150 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1151 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1152 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
145 | 1153 self.assertEqual(8, len(m)) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1154 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1155 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1156 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1157 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1158 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1159 self.assertTrue('SopClassUid' in m) |
145 | 1160 self.assertTrue('RemoteIP' in m) |
1161 self.assertTrue('CalledAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1162 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i[0]), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1163 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i[0]), 'DicomProtocol') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1164 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i[0]), 'STORESCU') |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1165 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i[0]), '1.2.840.10008.1.2.1') |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1166 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i[0]), '1.2.840.10008.5.1.4.1.1.7') |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1167 |
13 | 1168 |
1169 def test_incoming_findscu(self): | |
1170 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1171 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1172 | |
1173 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1174 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1175 self.assertEqual(2, len(patientNames)) | |
1176 self.assertTrue('Test Patient BG ' in patientNames) | |
1177 self.assertTrue('Anonymized' in patientNames) | |
1178 | |
1179 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1180 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1181 self.assertEqual(2, len(series)) | |
1182 self.assertTrue('20070208' in series) | |
1183 self.assertTrue('19980312' in series) | |
1184 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1185 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021', '-k', 'ModalitiesInStudy=MR\\XA' ]) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1186 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1187 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1188 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1189 |
13 | 1190 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1191 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1192 self.assertEqual(1, len(series)) | |
1193 | |
1194 # Test the "CaseSentitivePN" flag (false by default) | |
1195 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1196 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1197 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1198 |
70 | 1199 # Test range search (buggy if Orthanc <= 0.9.6) |
1200 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1201 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1202 self.assertEqual(2, len(studies)) | |
1203 self.assertTrue('20070208' in studies) | |
1204 self.assertTrue('19980312' in studies) | |
1205 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1206 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1207 self.assertEqual(1, len(studies)) | |
1208 self.assertTrue('19980312' in studies) | |
1209 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1210 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1211 self.assertEqual(1, len(studies)) | |
1212 self.assertTrue('19980312' in studies) | |
13 | 1213 |
1214 | |
191
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1215 def test_incoming_findscu_2(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1216 # This test fails if "LookupMode_DatabaseOnly" is used |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1217 # (sequences are not available in this mode, and only main |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1218 # DICOM tags are returned) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1219 UploadInstance(_REMOTE, 'Multiframe.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1220 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1221 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1222 # Test returning sequence values (only since Orthanc 0.9.5) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1223 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,2112' ]) # "ColorTestImageJ" has this sequence tag |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1224 sequences = re.findall('\(0008,2112\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1225 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1226 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1227 # Test returning a non-main DICOM tag, |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1228 # "SecondaryCaptureDeviceID" (0018,1010), whose value is |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1229 # "MEDPC" in "ColorTestImageJ.dcm" |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1230 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1231 tags = re.findall('\(0018,1010\).*MEDPC', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1232 self.assertEqual(1, len(tags)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1233 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1234 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1235 def test_incoming_findscu_3(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1236 # This test fails if "LookupMode_DatabaseOnly" or |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1237 # "LookupMode_DiskOnAnswer" is used, as |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1238 # "SecondaryCaptureDeviceID" (0018,1010) is not a main DICOM |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1239 # tag, as thus a constraint cannot be applied to it |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1240 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1241 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1242 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010=MEDPC' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1243 sequences = re.findall('\(0018,1010\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1244 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1245 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1246 |
13 | 1247 def test_incoming_movescu(self): |
1248 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1249 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1250 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1251 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1252 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1253 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1254 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1255 # 1 Matching patient, track the job |
138 | 1256 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1257 '--patient', | |
1258 '-k', '0008,0052=PATIENT', | |
1259 '-k', 'PatientID=12345678' | |
1260 ]))) | |
13 | 1261 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1262 | |
1263 | |
1264 def test_findscu(self): | |
1265 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1266 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1267 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1268 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1269 | |
1270 # Test the "find-patient" level | |
1271 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1272 self.assertEqual(1, len(p)) | |
1273 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1274 | |
1275 # Test wildcards constraints. The "LO" value representation | |
1276 # for PatientID is always case-sensitive, but the "PN" for | |
1277 # PatientName might depend on the implementation: | |
1278 # "GenerateConfigurationForTests.py" will force it to be case | |
1279 # insensitive (which was the default until Orthanc 0.8.6). | |
1280 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1281 self.assertEqual(1, len(p)) | |
1282 | |
1283 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1284 self.assertEqual(1, len(p)) | |
1285 | |
1286 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1287 self.assertEqual(1, len(p)) | |
1288 | |
1289 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1290 self.assertEqual(1, len(p)) | |
1291 | |
1292 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1293 self.assertEqual(0, len(p)) | |
1294 | |
1295 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1296 self.assertEqual(0, len(p)) | |
1297 | |
1298 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1299 self.assertEqual(0, len(p)) | |
1300 | |
1301 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1302 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1303 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1304 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1305 | |
1306 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1307 self.assertEqual(2, len(p)) | |
1308 | |
1309 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1310 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1311 self.assertEqual(1, len(s)) | |
1312 self.assertEqual('20070208', s[0]['StudyDate']) | |
1313 | |
1314 # Test range searches | |
1315 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1316 'StudyDate' : '-20070101' }) | |
1317 self.assertEqual(0, len(t)) | |
1318 | |
1319 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1320 'StudyDate' : '20090101-' }) | |
1321 self.assertEqual(0, len(t)) | |
1322 | |
1323 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1324 'StudyDate' : '20070101-' }) | |
1325 self.assertEqual(1, len(t)) | |
1326 | |
1327 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1328 'StudyDate' : '-20090101' }) | |
1329 self.assertEqual(1, len(t)) | |
1330 | |
1331 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1332 'StudyDate' : '20070207-20070207' }) | |
1333 self.assertEqual(0, len(t)) | |
1334 | |
1335 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1336 'StudyDate' : '20070208-20070208' }) | |
1337 self.assertEqual(1, len(t)) | |
1338 | |
1339 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1340 'StudyDate' : '20070209-20070209' }) | |
1341 self.assertEqual(0, len(t)) | |
1342 | |
1343 # Test the ModalitiesInStudy tag | |
1344 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1345 'PatientID' : 'B9uTHKOZ', | |
1346 'ModalitiesInStudy' : 'US' }) | |
1347 self.assertEqual(0, len(t)) | |
1348 | |
1349 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1350 'PatientID' : 'B9uTHKOZ', | |
1351 'ModalitiesInStudy' : 'CT' }) | |
1352 self.assertEqual(1, len(t)) | |
1353 | |
1354 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1355 'PatientID' : 'B9uTHKOZ', | |
1356 'ModalitiesInStudy' : 'US\\CT' }) | |
1357 self.assertEqual(1, len(t)) | |
1358 | |
1359 # Test the "find-series" level | |
1360 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1361 'PatientID' : 'B9uTHKOZ', | |
1362 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1363 self.assertEqual(1, len(t)) | |
1364 | |
1365 # Test "\" separator | |
1366 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1367 'PatientID' : 'B9uTHKOZ', | |
1368 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1369 'Modality' : 'MR\\CT\\US' }) | |
1370 self.assertEqual(1, len(t)) | |
1371 | |
1372 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1373 'PatientID' : 'B9uTHKOZ', | |
1374 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1375 'Modality' : 'MR\\US' }) | |
1376 self.assertEqual(0, len(t)) | |
1377 | |
1378 | |
1379 def test_update_modalities(self): | |
1380 try: | |
1381 DoDelete(_REMOTE, '/modalities/toto') | |
1382 except: | |
1383 pass | |
1384 try: | |
1385 DoDelete(_REMOTE, '/modalities/tata') | |
1386 except: | |
1387 pass | |
1388 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1389 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
116 | 1390 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1391 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1392 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1393 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1394 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1395 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
182
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1396 self.assertEqual('STORESCP', modalitiesReadback['tata']['AET']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1397 self.assertEqual('localhost', modalitiesReadback['tata']['Host']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1398 self.assertEqual(2000, modalitiesReadback['tata']['Port']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1399 self.assertEqual('GenericNoWildcardInDates', modalitiesReadback['tata']['Manufacturer']) |
116 | 1400 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1401 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1402 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1403 DoDelete(_REMOTE, '/modalities/toto') | |
1404 DoDelete(_REMOTE, '/modalities/tata') | |
1405 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1406 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1407 | |
1408 | |
1409 def test_update_peers(self): | |
1410 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1411 try: | |
1412 DoDelete(_REMOTE, '/peers/toto') | |
1413 except: | |
1414 pass | |
1415 try: | |
1416 DoDelete(_REMOTE, '/peers/tata') | |
1417 except: | |
1418 pass | |
1419 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1420 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
214 | 1421 DoPut(_REMOTE, '/peers/tata', { 'Url': 'http://localhost:8042/', |
1422 'Username': 'user', | |
1423 'Password' : 'pass', | |
1424 'RemoteSelf' : 'self' }) | |
128 | 1425 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1426 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1427 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1428 self.assertEqual('user', peersReadback['tata']['Username']) | |
214 | 1429 |
1430 if IsOrthancVersionAbove(_REMOTE, 1, 5, 4): | |
1431 self.assertEqual(None, peersReadback['tata']['Password']) # make sure no sensitive data is included | |
1432 self.assertFalse(peersReadback['tata']['Pkcs11']) # make sure no sensitive data is included | |
1433 self.assertEqual('self', peersReadback['tata']['RemoteSelf']) | |
1434 else: | |
1435 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1436 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
1437 self.assertFalse('RemoteSelf' in peersReadback['tata']) | |
1438 | |
128 | 1439 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included |
1440 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1441 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
214 | 1442 |
13 | 1443 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1444 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1445 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1446 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1447 DoDelete(_REMOTE, '/peers/toto') | |
1448 DoDelete(_REMOTE, '/peers/tata') | |
1449 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1450 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1451 | |
1452 | |
1453 def test_mesterhazy_modification(self): | |
1454 # When I modify a series ( eg. curl | |
1455 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1456 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1457 # series is added to a new Study, instead of the existing | |
1458 # Study. Fixed in Orthanc 0.7.5 | |
1459 | |
1460 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1461 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1462 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1463 | |
1464 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1465 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1466 | |
1467 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1468 | |
1469 | |
1470 def test_create(self): | |
1471 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1472 json.dumps({ | |
1473 'PatientName' : 'Jodogne', | |
1474 'Modality' : 'CT', | |
58 | 1475 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1476 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1477 })) | |
1478 | |
1479 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1480 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1481 | |
1482 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1483 self.assertEqual((5, 5), png.size) | |
1484 | |
38 | 1485 j = DoGet(_REMOTE, i['Path']) |
1486 self.assertEqual('Instance', j['Type']) | |
1487 self.assertEqual(j['ID'], i['ID']) | |
1488 | |
13 | 1489 |
1490 def test_pilates(self): | |
1491 # "SCU failed error when accessing orthanc with osirix" by | |
1492 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1493 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1494 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1495 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1496 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1497 | |
1498 | |
1499 def test_shared_tags(self): | |
1500 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1501 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1502 p = DoGet(_REMOTE, '/patients')[0] | |
1503 | |
1504 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1505 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1506 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1507 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1508 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags' % p)['0010,0010']['Value']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1509 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)['PatientName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1510 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)['0010,0010']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1511 |
13 | 1512 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1513 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1514 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1515 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1516 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1517 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1518 | |
1519 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1520 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1521 | |
1522 | |
1523 def test_modules(self): | |
1524 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1525 p = DoGet(_REMOTE, '/patients')[0] | |
1526 s = DoGet(_REMOTE, '/studies')[0] | |
1527 t = DoGet(_REMOTE, '/series')[0] | |
1528 | |
1529 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1530 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1531 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1532 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1533 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1534 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1535 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1536 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1537 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1538 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1539 | |
1540 | |
1541 def test_auto_directory(self): | |
1542 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1543 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1544 self.assertTrue('dicom-conformance' in DoGet(_REMOTE, '/tools')) | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
1545 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1546 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1547 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1548 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1549 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1550 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1551 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1552 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1553 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1554 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1555 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1556 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1557 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1558 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1559 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1560 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1561 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1562 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1563 |
1564 | |
1565 def test_echo(self): | |
1566 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1567 | |
1568 | |
1569 def test_xml(self): | |
1570 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1571 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1572 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1573 self.assertEqual(len(items), len(json)) | |
1574 | |
1575 self.assertTrue('dicom-conformance' in json) | |
1576 | |
1577 ok = False | |
1578 for i in items: | |
1579 if i.childNodes[0].data == 'dicom-conformance': | |
1580 ok = True | |
1581 self.assertTrue(ok) | |
1582 | |
1583 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1584 def test_googlecode_issue_16(self): |
13 | 1585 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1586 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1587 self.assertEqual('0018,1063', t) | |
1588 | |
1589 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1590 def test_googlecode_issue_22(self): |
13 | 1591 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1592 a = [ | |
1593 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1594 "c69eee9a51eea3e8611e82e578897254", | |
1595 "315666be83e2d0111c77bc0996d84901", | |
1596 "3e27aa959d911172c48a1436443c72b1", | |
1597 "958642c9e7e9d232d3869faff546058c", | |
1598 "5e7ea8e3e4230cae707d143481355c59", | |
1599 "eda37f83558d858a596175aed8b2ad47", | |
1600 "486713bd2895c4ecbe0e97715ac7f80a", | |
1601 "091ef729eb169e67da8a0faa9631f9a8", | |
1602 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1603 "e2f39e85896fe58876654b94cd0b5013", | |
1604 "6fd2129e4950abbe1be053bc814d5da8", | |
1605 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1606 "746f808582156734dd6b6fdfd3a0b72c", | |
1607 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1608 "806b8b3e300c615099c11a5ec23465aa", | |
1609 "7c836aa298ba6eef96434579af631a11", | |
1610 "a0357dc9f4f72d73a885c33d7c287446", | |
1611 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1612 "8b114c526b8cbed6cad8a3248b7b480c", | |
1613 "44e6670f127e612a2b4aa60a0d207698", | |
1614 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1615 "95c796c2fa8f59018b15cf2987b1f79b", | |
1616 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1617 ] | |
1618 | |
1619 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1620 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1621 | |
1622 for i in range(len(a)): | |
1623 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1624 | |
1625 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1626 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1627 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1628 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1629 | |
1630 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1631 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1632 |
1633 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1634 def test_googlecode_issue_37(self): |
13 | 1635 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1636 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1637 | |
1638 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1639 'CaseSensitive' : True, | |
1640 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1641 self.assertEqual(1, len(a)) | |
14 | 1642 |
1643 | |
1644 def test_rest_find(self): | |
1645 # Upload 8 instances | |
1646 for i in range(2): | |
1647 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1648 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1649 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1650 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1651 | |
1652 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1653 'CaseSensitive' : False, | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1654 'Query' : { 'PatientName' : 'BRAINIX' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1655 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1656 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1657 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1658 'CaseSensitive' : False, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1659 'Query' : { 'PatientName' : 'BRAINIX\\KNEE\\NOPE' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1660 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1661 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1662 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1663 'CaseSensitive' : False, |
14 | 1664 'Query' : { 'PatientName' : '*n*' }}) |
1665 self.assertEqual(2, len(a)) | |
1666 | |
1667 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1668 'CaseSensitive' : True, | |
1669 'Query' : { 'PatientName' : '*n*' }}) | |
1670 self.assertEqual(0, len(a)) | |
1671 | |
1672 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1673 'Level' : 'Patient', | |
1674 'CaseSensitive' : False, | |
1675 'Query' : { 'PatientName' : '*ne*' }}) | |
1676 self.assertEqual(1, len(a)) | |
1677 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1678 | |
1679 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1680 'CaseSensitive' : True, | |
1681 'Query' : { 'PatientName' : '*ne*' }}) | |
1682 self.assertEqual(0, len(a)) | |
1683 | |
1684 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1685 'CaseSensitive' : True, | |
1686 'Query' : { 'PatientName' : '*NE*' }}) | |
1687 self.assertEqual(1, len(a)) | |
1688 | |
1689 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1690 'CaseSensitive' : True, | |
1691 'Query' : { 'PatientName' : '*NE*' }}) | |
1692 self.assertEqual(2, len(a)) | |
1693 | |
1694 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1695 'CaseSensitive' : True, | |
1696 'Query' : { 'PatientName' : '*NE*' }}) | |
1697 self.assertEqual(4, len(a)) | |
1698 | |
1699 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1700 self.assertEqual(2, len(a)) | |
1701 | |
1702 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1703 self.assertEqual(2, len(a)) | |
1704 | |
1705 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1706 self.assertEqual(4, len(a)) | |
1707 | |
1708 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1709 self.assertEqual(8, len(a)) | |
1710 | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1711 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1712 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1713 'Query' : { 'StudyDate' : '20061201-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1714 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1715 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1716 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1717 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1718 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1719 'Query' : { 'StudyDate' : '20061201-20091201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1720 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1721 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1722 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1723 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1724 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1725 'Query' : { 'StudyDate' : '20061202-20061202' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1726 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1727 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1728 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1729 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1730 'Query' : { 'StudyDate' : '-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1731 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1732 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1733 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1734 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1735 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1736 'Query' : { 'StudyDate' : '-20051201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1737 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1738 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1739 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1740 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1741 'Query' : { 'StudyDate' : '20061201-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1742 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1743 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1744 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1745 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1746 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1747 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1748 'Query' : { 'StudyDate' : '20061202-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1749 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1750 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1751 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1752 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1753 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1754 'Query' : { 'StudyDate' : '20080819-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1755 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1756 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1757 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1758 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1759 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1760 'Query' : { 'StudyDate' : '20080820-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1761 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1762 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1763 |
14 | 1764 |
1765 def test_rest_query_retrieve(self): | |
1766 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1767 | |
1768 # Upload 8 instances | |
1769 for i in range(2): | |
1770 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1771 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1772 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1773 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1774 | |
1775 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1776 for p in DoGet(_REMOTE, '/patients'): | |
1777 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1778 DoDelete(_REMOTE, '/patients/%s' % p) | |
1779 | |
1780 for q in DoGet(_REMOTE, '/queries'): | |
1781 DoDelete(_REMOTE, '/queries/%s' % q) | |
1782 | |
1783 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1784 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1785 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1786 'Query' : { |
1787 'PatientName' : '*NE*', | |
1788 'StudyDate' : '*', | |
1789 }})['ID'] | |
14 | 1790 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1791 | |
1792 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1793 self.assertTrue('answers' in b) | |
1794 self.assertTrue('level' in b) | |
1795 self.assertTrue('modality' in b) | |
1796 self.assertTrue('query' in b) | |
1797 self.assertTrue('retrieve' in b) | |
1798 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1799 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1800 | |
1801 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1802 self.assertEqual(2, len(q)) |
14 | 1803 self.assertTrue('PatientName' in q) |
27 | 1804 self.assertTrue('StudyDate' in q) |
14 | 1805 self.assertEqual('*NE*', q['PatientName']) |
27 | 1806 self.assertEqual('*', q['StudyDate']) |
14 | 1807 |
1808 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1809 | |
1810 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1811 self.assertTrue('content' in s) | |
1812 self.assertTrue('retrieve' in s) | |
1813 | |
1814 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1815 self.assertEqual('887', s['PatientID']) | |
1816 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1817 | |
1818 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1819 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1820 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1821 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1822 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1823 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1824 | |
112 | 1825 DoPost(_REMOTE, '/queries/%s/answers/1/retrieve' % a, 'ORTHANC', 'application/json') # make sure the issue #36 is fixed (query/retrieve Rest API: /retrieve route shall accept application/json content type) |
14 | 1826 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1827 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1828 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1829 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1830 | |
186
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1831 # New in Orthanc 1.4.3 |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1832 s = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1833 self.assertEqual(2, len(s)) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1834 for i in range(2): |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1835 self.assertEqual('SERIES', s[i]['QueryRetrieveLevel']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1836 self.assertEqual('887', s[i]['PatientID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1837 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s[i]['StudyInstanceUID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1838 |
14 | 1839 DoDelete(_REMOTE, '/queries/%s' % a) |
1840 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1841 | |
1842 | |
1843 def test_parent(self): | |
1844 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1845 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1846 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1847 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1848 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1849 self.assertEqual(instance, u) |
14 | 1850 |
1851 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1852 self.assertEqual('Patient', a['Type']) | |
1853 self.assertEqual(patient, a['ID']) | |
1854 | |
1855 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1856 self.assertEqual('Patient', a['Type']) | |
1857 self.assertEqual(patient, a['ID']) | |
1858 | |
1859 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1860 self.assertEqual('Study', a['Type']) | |
1861 self.assertEqual(study, a['ID']) | |
1862 | |
1863 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1864 self.assertEqual('Patient', a['Type']) | |
1865 self.assertEqual(patient, a['ID']) | |
1866 | |
1867 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1868 self.assertEqual('Study', a['Type']) | |
1869 self.assertEqual(study, a['ID']) | |
1870 | |
1871 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1872 self.assertEqual('Series', a['Type']) | |
1873 self.assertEqual(series, a['ID']) | |
1874 | |
1875 | |
1876 def test_shanon(self): | |
1877 def Anonymize(instance, replacements = {}): | |
119 | 1878 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
1879 'Replace' : replacements, | |
1880 'Force' : True, | |
1881 }, 'application/json') | |
14 | 1882 |
1883 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1884 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1885 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1886 | |
1887 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1888 ids = [ 'ozp00SjY2xG', | |
1889 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1890 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1891 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1892 | |
1893 a = ExtractDicomTags(Anonymize(u), tags) | |
1894 for i in range(4): | |
1895 self.assertNotEqual(ids[i], a[i]) | |
1896 self.assertTrue(a[4].startswith('Orthanc')) | |
1897 | |
1898 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1899 for i in range(4): | |
1900 self.assertNotEqual(ids[i], a[i]) | |
1901 self.assertFalse(a[4].startswith('Orthanc')) | |
1902 | |
1903 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1904 self.assertEqual('instance', a[3]) | |
1905 self.assertFalse(a[4].startswith('Orthanc')) | |
1906 | |
1907 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1908 self.assertEqual('series', a[2]) | |
1909 self.assertFalse(a[4].startswith('Orthanc')) | |
1910 | |
1911 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1912 self.assertEqual('study', a[1]) | |
1913 self.assertFalse(a[4].startswith('Orthanc')) | |
1914 | |
1915 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1916 self.assertEqual('patient', a[0]) | |
1917 self.assertFalse(a[4].startswith('Orthanc')) | |
1918 | |
1919 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1920 'StudyInstanceUID' : 'study', | |
1921 'SeriesInstanceUID' : 'series', | |
1922 'SOPInstanceUID' : 'instance' }), tags) | |
1923 self.assertEqual('patient', a[0]) | |
1924 self.assertFalse(a[4].startswith('Orthanc')) | |
1925 | |
1926 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1927 | |
1928 | |
1929 def test_shanon_2(self): | |
1930 def Modify(instance, replacements = {}): | |
119 | 1931 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
1932 'Replace' : replacements, | |
1933 'Force': True, | |
1934 }, 'application/json') | |
14 | 1935 |
1936 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1937 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1938 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1939 | |
1940 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1941 ids = [ 'ozp00SjY2xG', | |
1942 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1943 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1944 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1945 | |
1946 a = ExtractDicomTags(Modify(u), tags) | |
1947 self.assertEqual(ids[0], a[0]) | |
1948 self.assertEqual(ids[1], a[1]) | |
1949 self.assertEqual(ids[2], a[2]) | |
1950 self.assertNotEqual(ids[3], a[3]) | |
1951 self.assertEqual(0, len(a[4])) | |
1952 | |
1953 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1954 self.assertEqual(ids[0], a[0]) | |
1955 self.assertEqual(ids[1], a[1]) | |
1956 self.assertEqual(ids[2], a[2]) | |
1957 self.assertEqual('instance', a[3]) | |
1958 | |
1959 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1960 self.assertEqual(ids[0], a[0]) | |
1961 self.assertEqual(ids[1], a[1]) | |
1962 self.assertEqual('series', a[2]) | |
1963 self.assertNotEqual(ids[3], a[3]) | |
1964 | |
1965 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1966 self.assertEqual(ids[0], a[0]) | |
1967 self.assertEqual('study', a[1]) | |
1968 self.assertNotEqual(ids[2], a[2]) | |
1969 self.assertNotEqual(ids[3], a[3]) | |
1970 | |
1971 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1972 self.assertEqual('patient', a[0]) | |
1973 self.assertNotEqual(ids[1], a[1]) | |
1974 self.assertNotEqual(ids[2], a[2]) | |
1975 self.assertNotEqual(ids[3], a[3]) | |
1976 | |
1977 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1978 'StudyInstanceUID' : 'study', | |
1979 'SeriesInstanceUID' : 'series', | |
1980 'SOPInstanceUID' : 'instance' }), tags) | |
1981 self.assertEqual('patient', a[0]) | |
1982 self.assertEqual('study', a[1]) | |
1983 self.assertEqual('series', a[2]) | |
1984 self.assertEqual('instance', a[3]) | |
1985 | |
1986 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1987 | |
1988 | |
1989 def test_instances_tags(self): | |
1990 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1991 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1992 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1993 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1994 | |
1995 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1996 self.assertEqual(2, len(i)) | |
1997 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1998 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1999 | |
2000 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
2001 self.assertEqual(2, len(i)) | |
2002 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2003 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
2004 | |
2005 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
2006 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
2007 self.assertEqual(1, len(i)) | |
2008 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2009 | |
2010 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
2011 self.assertEqual(1, len(i)) | |
2012 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2013 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2014 i = DoGet(_REMOTE, '/patients/%s/instances-tags?short' % DoGet(_REMOTE, '/series')[1]) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2015 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2016 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2017 |
14 | 2018 |
2019 def test_lookup(self): | |
2020 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2021 self.assertEqual(0, len(a)) | |
2022 | |
2023 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
2024 | |
2025 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2026 self.assertEqual(1, len(a)) | |
2027 self.assertEqual('Patient', a[0]['Type']) | |
2028 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
2029 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
2030 | |
2031 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
2032 self.assertEqual(1, len(a)) | |
2033 self.assertEqual('Study', a[0]['Type']) | |
2034 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
2035 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
2036 | |
2037 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
2038 self.assertEqual(1, len(a)) | |
2039 self.assertEqual('Series', a[0]['Type']) | |
2040 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
2041 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
2042 | |
2043 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
2044 self.assertEqual(1, len(a)) | |
2045 self.assertEqual('Instance', a[0]['Type']) | |
2046 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
2047 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
2048 | |
2049 DropOrthanc(_REMOTE) | |
2050 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
2051 self.assertEqual(0, len(a)) | |
2052 | |
15 | 2053 |
2054 def test_autorouting(self): | |
2055 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
2056 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
2057 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
2058 | |
2059 # Check that this version is >= 0.8.0 | |
2060 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
2061 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
2062 | |
2063 UploadInstance(_REMOTE, knee1) | |
2064 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2065 | |
2066 DropOrthanc(_REMOTE) | |
2067 DropOrthanc(_LOCAL) | |
174 | 2068 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
15 | 2069 UploadInstance(_REMOTE, knee1) |
2070 UploadInstance(_REMOTE, knee2) | |
2071 UploadInstance(_REMOTE, other) | |
2072 WaitEmpty(_REMOTE) | |
174 | 2073 UninstallLuaCallbacks(_REMOTE) |
15 | 2074 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
2075 | |
2076 DropOrthanc(_REMOTE) | |
2077 DropOrthanc(_LOCAL) | |
174 | 2078 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
15 | 2079 UploadInstance(_REMOTE, knee1) |
2080 UploadInstance(_REMOTE, knee2) | |
2081 UploadInstance(_REMOTE, other) | |
2082 WaitEmpty(_REMOTE) | |
174 | 2083 UninstallLuaCallbacks(_REMOTE) |
15 | 2084 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
2085 | |
2086 DropOrthanc(_REMOTE) | |
2087 DropOrthanc(_LOCAL) | |
174 | 2088 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
15 | 2089 UploadInstance(_REMOTE, knee1) |
2090 WaitEmpty(_REMOTE) | |
174 | 2091 UninstallLuaCallbacks(_REMOTE) |
15 | 2092 i = DoGet(_LOCAL, '/instances') |
2093 self.assertEqual(1, len(i)) | |
2094 | |
2095 with tempfile.NamedTemporaryFile(delete = True) as f: | |
2096 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
2097 f.flush() | |
45 | 2098 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 2099 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
2100 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
2101 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 2102 |
2103 | |
2104 def test_storescu_rf(self): | |
2105 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
2106 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2107 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
2108 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 2109 |
2110 | |
2111 def test_anonymize_instance(self): | |
2112 def AnonymizeAndUpload(instanceId, parameters): | |
2113 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
2114 'application/json'), 'application/dicom')['ID'] | |
2115 | |
2116 def ModifyAndUpload(instanceId, parameters): | |
2117 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
2118 'application/json'), 'application/dicom')['ID'] | |
2119 | |
2120 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
2121 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
2122 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
2123 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
2124 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
2125 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2126 | |
2127 b = AnonymizeAndUpload(a, '{}') | |
2128 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2129 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2130 | |
2131 # Keep private tag (only OK since Orthanc 0.8.0) | |
2132 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
2133 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2134 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2135 | |
2136 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
2137 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2138 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2139 | |
2140 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
2141 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2142 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
2143 | |
2144 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2145 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 2146 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2147 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2148 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2149 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2150 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2151 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2152 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2153 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2154 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2155 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 2156 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2157 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2158 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2159 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2160 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2161 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2162 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2163 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 2164 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2165 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2166 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
2167 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2168 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2169 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2170 | |
2171 | |
2172 # Test modify non-existing | |
2173 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2174 json.dumps({ | |
2175 'PatientName' : 'Jodogne', | |
2176 'Modality' : 'CT', | |
2177 }))['ID'] | |
2178 | |
2179 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
2180 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
2181 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
2182 | |
2183 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
2184 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
2185 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
2186 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
2187 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2188 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2189 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2190 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2191 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2192 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2193 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2194 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2195 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2196 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2197 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2198 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2199 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2200 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2201 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2202 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2203 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2204 self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False)) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2205 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2206 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2207 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
2208 DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')") |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2209 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2210 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2211 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2212 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2213 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2214 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2215 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2216 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2217 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2218 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2219 | |
2220 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2221 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2222 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2223 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2224 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2225 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2226 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2227 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2228 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2229 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2230 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2231 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2232 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2233 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2234 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2235 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2236 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2237 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2238 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2239 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2240 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2241 jpeg = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2242 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2243 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2244 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2245 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2246 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2247 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2248 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2249 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2250 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2251 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2252 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2253 self.assertEqual(0, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2254 self.assertEqual(jpegSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/1' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2255 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2256 self.assertEqual(phenixSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2257 self.assertEqual(colorSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2258 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2259 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2260 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2261 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2262 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2263 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm')['ID'], # JPEG-LS, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2264 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm')['ID'], # JPEG, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2265 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2266 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2267 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2268 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2269 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2270 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2271 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2272 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2273 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2274 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2275 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2276 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2277 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2278 truth2 = map(lambda x: x * 255.0 / maxValue, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2279 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2280 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2281 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2282 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2283 self.assertEqual(h, ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % i))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2284 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2285 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2286 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2287 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2288 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2289 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2290 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2291 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2292 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/%s' % (i, j))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2293 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2294 self.assertEqual('c14c687f7a1ea9fe022479fc87c67274', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2295 self.assertEqual('a87d122918a56f803bcfe9d2586b9125', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2296 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2297 self.assertEqual('30cc46bfa7aba77a40e4178f6184c25a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2298 self.assertEqual('ff195005cef06b59666fd220a9b4cd9a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2299 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2300 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2301 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2302 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2303 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2304 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2305 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2306 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2307 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2308 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2309 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2310 self.assertEqual('42254d70efd2f4a1b8f3455909689f0e', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % rf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2311 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2312 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2313 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2314 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2315 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2316 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2317 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2318 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2319 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2320 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2321 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2322 self.assertEqual('9812b99d93bbcd4e7684ded089b5dfb3', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % mf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2323 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2324 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/0/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2325 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2326 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2327 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2328 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/75/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2329 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2330 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2331 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2332 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2333 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2334 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2335 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2336 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2337 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2338 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2339 truth2 = map(lambda x: 0 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2340 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2341 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2342 truth3 = map(lambda x: 255 if x >= 256 else x, truth2) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2343 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2344 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2345 tmp = map(lambda x: x - 65536 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2346 tmp = map(lambda x: (255.0 * (x - minValue)) / (maxValue - minValue), tmp) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2347 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2348 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2349 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2350 |
2351 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2352 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2353 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2354 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2355 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2356 |
22 | 2357 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2358 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2359 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2360 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2361 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2362 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2363 # Replay the same test using Latin1 as default encoding: This must fail |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2364 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2365 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2366 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2367 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2368 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2369 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2370 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2371 |
22 | 2372 def test_encodings(self): |
23 | 2373 # Latin-1 (ISO_IR 100) |
22 | 2374 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2375 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2376 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2377 |
2378 # Latin-2 (ISO_IR 101) | |
2379 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2380 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2381 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2382 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2383 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2384 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2385 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2386 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2387 # This tests a feature introduced in Orthanc 0.9.1: "Custom |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2388 # setting of the local AET during C-Store SCU (both in Lua and |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2389 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2390 # https://groups.google.com/forum/#!msg/orthanc-users/o5qMULformU/wZjW2iSaMcAJ |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2391 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2392 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2393 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2394 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2395 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2396 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2397 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2398 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2399 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2400 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2401 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2402 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2403 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2404 self.assertEqual('YOP', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2405 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2406 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2407 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2408 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2409 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2410 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2411 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2412 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2413 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2414 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2415 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2416 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2417 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2418 |
174 | 2419 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2420 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2421 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2422 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2423 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2424 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2425 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2426 self.assertEqual('HELLO', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2427 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2428 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2429 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2430 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2431 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2432 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % b['ID'])) |
34
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2433 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2434 def test_resources_since_limit(self): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2435 # Upload 16 instances |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2436 for i in range(4): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2437 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2438 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2439 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2440 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2441 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2442 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2443 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2444 self.assertEqual(4, len(DoGet(_REMOTE, '/series'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2445 self.assertEqual(16, len(DoGet(_REMOTE, '/instances'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2446 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2447 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&since=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2448 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&limit=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2449 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2450 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=0&limit=0'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2451 self.assertEqual(2, len(DoGet(_REMOTE, '/patients?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2452 self.assertEqual(2, len(DoGet(_REMOTE, '/studies?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2453 self.assertEqual(4, len(DoGet(_REMOTE, '/series?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2454 self.assertEqual(16, len(DoGet(_REMOTE, '/instances?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2455 self.assertEqual(1, len(DoGet(_REMOTE, '/patients?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2456 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2457 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2458 self.assertEqual(1, len(DoGet(_REMOTE, '/studies?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2459 self.assertEqual(3, len(DoGet(_REMOTE, '/series?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2460 self.assertEqual(2, len(DoGet(_REMOTE, '/series?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2461 self.assertEqual(1, len(DoGet(_REMOTE, '/series?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2462 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=4&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2463 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=100&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2464 self.assertEqual(15, len(DoGet(_REMOTE, '/instances?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2465 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2466 for limit in [ 1, 2, 3, 7, 16, 17 ]: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2467 s = {} |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2468 since = 0 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2469 while True: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2470 t = DoGet(_REMOTE, '/instances?since=%d&limit=%d' % (since, limit)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2471 if len(t) == 0: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2472 break |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2473 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2474 since += len(t) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2475 for i in t: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2476 s[i] = None |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2477 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2478 self.assertEqual(16, len(s)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2479 for instance in DoGet(_REMOTE, '/instances'): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2480 self.assertTrue(instance in s) |
36 | 2481 |
2482 | |
2483 def test_create_pdf(self): | |
2484 # Upload 4 instances | |
2485 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2486 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2487 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2488 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2489 | |
2490 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2491 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2492 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2493 | |
2494 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2495 pdf = f.read() | |
2496 | |
2497 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2498 json.dumps({ | |
2499 'Tags' : { | |
2500 'PatientName' : 'Jodogne', | |
2501 'Modality' : 'CT', | |
2502 }, | |
2503 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2504 })) | |
2505 | |
2506 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2507 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2508 | |
2509 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2510 self.assertEqual(len(b), len(pdf) + 1) | |
2511 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2512 | |
2513 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2514 json.dumps({ | |
2515 'Parent' : brainixPatient, | |
2516 'Tags' : { | |
2517 'PatientName' : 'Jodogne', | |
2518 } | |
2519 }))) | |
2520 | |
2521 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2522 json.dumps({ | |
2523 'Parent' : brainixPatient, | |
2524 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2525 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2526 })) | |
2527 | |
2528 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2529 | |
2530 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2531 json.dumps({ | |
2532 'Parent' : brainixStudy, | |
2533 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2534 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2535 })) | |
2536 | |
2537 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2538 | |
2539 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2540 json.dumps({ | |
2541 'Parent' : brainixEpi, | |
37 | 2542 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2543 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2544 })) | |
2545 | |
2546 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2547 | |
2548 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2549 self.assertEqual(len(b), len(pdf)) | |
2550 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2551 | |
2552 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2553 |
2554 | |
2555 def test_create_series(self): | |
2556 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2557 json.dumps({ | |
2558 'Tags' : { | |
40 | 2559 'SpecificCharacterSet' : 'ISO_IR 100', |
2560 'PatientName' : 'Sébastien Jodogne', | |
38 | 2561 'Modality' : 'CT', |
2562 }, | |
2563 'Content' : [ | |
40 | 2564 { |
2565 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2566 'Tags' : { 'ImageComments' : 'Tutu' } | |
2567 }, | |
38 | 2568 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2569 ] | |
2570 })) | |
2571 | |
2572 s = DoGet(_REMOTE, i['Path']) | |
2573 self.assertEqual('Series', s['Type']) | |
2574 self.assertEqual(s['ID'], i['ID']) | |
2575 self.assertEqual(2, len(s['Instances'])) | |
39 | 2576 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2577 self.assertEqual('Complete', s['Status']) | |
40 | 2578 |
2579 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2580 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2581 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2582 if 'ImageComments' in a: | |
2583 self.assertEqual('Tutu', a['ImageComments']) | |
2584 else: | |
2585 self.assertEqual('Tutu', b['ImageComments']) | |
2586 | |
2587 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2588 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2589 'Sébastien Jodogne') | |
47 | 2590 |
2591 | |
2592 def test_create_binary(self): | |
2593 binary = ''.join(map(chr, range(256))) | |
2594 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2595 tags = { | |
2596 'PatientName' : 'Jodogne', | |
2597 '8899-8899' : encoded | |
2598 } | |
2599 | |
2600 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2601 json.dumps({ | |
266 | 2602 'Tags' : tags, |
2603 'PrivateCreator' : 'TestBinary', | |
47 | 2604 })) |
2605 | |
2606 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2607 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2608 | |
2609 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2610 json.dumps({ | |
2611 'InterpretBinaryTags' : False, | |
266 | 2612 'Tags' : tags, |
2613 'PrivateCreator' : 'TestBinary', | |
47 | 2614 })) |
2615 | |
2616 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2617 self.assertEqual(encoded, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID'])[0:-1]) | |
48
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2618 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2619 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2620 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2621 # Upload 3 instances from 3 different studies, but with the |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2622 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2623 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2624 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2625 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2626 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2627 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2628 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2629 self.assertEqual('COMMON', DoGet(_REMOTE, '/patients/%s' % a[0]) ['MainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2630 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2631 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2632 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2633 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2634 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2635 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2636 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2637 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2638 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2639 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2640 self.assertEqual('FOO^SERIES', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['MainDicomTags']['StudyDescription']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2641 self.assertEqual('FOO', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientName']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2642 self.assertEqual('COMMON', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2643 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2644 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2645 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2646 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2647 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['MainDicomTags']['StudyDescription'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2648 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2649 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2650 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2651 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2652 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['PatientMainDicomTags']['PatientID'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2653 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2654 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2655 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2656 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2657 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2658 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2659 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2660 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2661 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2662 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2663 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2664 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2665 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2666 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2667 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2668 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2669 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2670 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2671 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2672 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2673 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2674 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2675 i1 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[0])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2676 i2 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[1])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2677 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2678 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2679 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2680 j = DoPost(_REMOTE, '/modalities/orthanctest/store', i2[0:1] + i1 + i2[1:3]) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2681 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2682 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2683 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2684 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2685 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2686 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2687 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2688 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2689 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2690 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2691 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2692 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2693 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2694 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2695 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2696 self.assertEqual('Hello^', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2697 self.assertEqual('Toto', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2698 self.assertEqual('Tata', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/1/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2699 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2700 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2701 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2702 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2703 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2704 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2705 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % i)) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2706 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2707 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2708 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2709 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2710 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2711 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2712 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2713 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2714 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2715 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2716 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2717 |
52 | 2718 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2719 | |
2720 | |
2721 def test_compression(self): | |
2722 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2723 | |
2724 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2725 | |
2726 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2727 # uncompress the data before running the test | |
2728 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2729 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2730 | |
2731 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2732 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2733 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2734 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2735 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2736 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2737 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2738 | |
2739 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2740 self.assertTrue('compress' in ops) | |
2741 self.assertTrue('uncompress' in ops) | |
2742 self.assertTrue('is-compressed' in ops) | |
2743 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2744 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2745 | |
2746 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2747 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2748 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2749 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2750 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2751 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2752 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2753 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2754 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2755 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2756 | |
2757 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2758 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2759 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2760 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2761 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2762 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2763 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2764 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2765 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2766 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2767 |
2768 | |
2769 def test_ordered_slices(self): | |
2770 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2771 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2772 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2773 self.assertEqual('Sequence', o['Type']) | |
2774 self.assertEqual(1, len(o['Dicom'])) | |
2775 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2776 self.assertEqual(76, len(o['Slices'])) | |
2777 for j in range(76): | |
2778 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2779 | |
68 | 2780 self.assertEqual(1, len(o['SlicesShort'])) |
2781 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2782 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2783 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2784 | |
53 | 2785 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2786 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2787 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2788 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2789 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2790 | |
2791 self.assertEqual('Volume', o['Type']) | |
2792 self.assertEqual(3, len(o['Dicom'])) | |
2793 self.assertEqual(3, len(o['Slices'])) | |
2794 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2795 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2796 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2797 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2798 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2799 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2800 | |
68 | 2801 self.assertEqual(3, len(o['SlicesShort'])) |
2802 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2803 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2804 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2805 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2806 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2807 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2808 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2809 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2810 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2811 | |
53 | 2812 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2813 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2814 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2815 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2816 | |
2817 self.assertEqual('Sequence', o['Type']) | |
2818 self.assertEqual(2, len(o['Dicom'])) | |
2819 self.assertEqual(2, len(o['Slices'])) | |
2820 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2821 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2822 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2823 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2824 |
68 | 2825 self.assertEqual(2, len(o['SlicesShort'])) |
2826 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2827 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2828 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2829 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2830 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2831 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2832 | |
2833 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2834 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2835 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2836 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2837 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2838 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2839 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2840 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2841 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2842 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2843 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2844 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2845 # 1 Matching patient, track the job |
138 | 2846 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
2847 '--study', | |
2848 '-k', '0008,0052=STUDY', | |
2849 '-k', 'AccessionNumber=A10003245599' | |
2850 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2851 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2852 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2853 |
55 | 2854 |
2855 def test_dicom_to_json(self): | |
2856 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2857 j = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2858 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2859 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2860 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2861 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 2862 # Tags for compatibility with DCMTK 3.6.0 |
2863 'RETIRED_OtherPatientIDs', | |
2864 'OtherPatientIDs', | |
2865 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2866 ])) |
55 | 2867 |
2868 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2869 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f: | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2870 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2871 ])) |
55 | 2872 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2873 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2874 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2875 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2876 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2877 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2878 t = DoGet(_REMOTE, '/instances/%s/tags' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2879 with open(GetDatabasePath('PrivateTagsFull.json'), 'r') as f: |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2880 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2881 aa = json.dumps(a).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2882 tt = json.dumps(t).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2883 self.assertEqual(aa, tt) |
57 | 2884 |
2885 | |
2886 def test_batch_archive(self): | |
2887 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2888 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2889 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2890 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2891 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2892 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2893 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2894 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2895 | |
2896 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2897 z = zipfile.ZipFile(StringIO(s), "r") | |
2898 self.assertEqual(0, len(z.namelist())) | |
2899 | |
2900 # One patient | |
2901 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2902 z = zipfile.ZipFile(StringIO(s), "r") | |
2903 self.assertEqual(4, len(z.namelist())) | |
2904 | |
2905 # One patient + twice its study + one series from other patient | |
2906 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2907 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2908 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2909 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2910 ]) | |
2911 z = zipfile.ZipFile(StringIO(s), "r") | |
2912 self.assertEqual(6, len(z.namelist())) | |
2913 | |
2914 # One patient + one series + one instance | |
2915 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2916 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2917 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2918 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2919 ]) | |
2920 z = zipfile.ZipFile(StringIO(s), "r") | |
2921 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2922 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2923 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2924 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2925 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2926 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2927 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2928 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2929 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2930 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2931 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2932 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : '*/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2933 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2934 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2935 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2936 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2937 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2938 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/png' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2939 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2940 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2941 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2942 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2943 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2944 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2945 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2946 a = len(DoGet(_REMOTE, '/instances/%s/preview?quality=50' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2947 b = len(DoGet(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2948 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2949 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2950 j = GetImage(_REMOTE, '/instances/%s/image-uint8' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2951 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2952 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2953 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2954 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-uint16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2955 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-int16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2956 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2957 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2958 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'application/pdf' })) |
69
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2959 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2960 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2961 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2962 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2963 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2964 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2965 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2966 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2967 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2968 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2969 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2970 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2971 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2972 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2973 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2974 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2975 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2976 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2977 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2978 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2979 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2980 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2981 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2982 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2983 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2984 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2985 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2986 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2987 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2988 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2989 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2990 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2991 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2992 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2993 self.assertTrue(re.search('1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114333648576', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2994 self.assertTrue(re.search('1.2.826.0.1.3680043.2.1569.1.4.323026757.1700.1399452091.57', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2995 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2996 os.remove('/tmp/DICOMDIR') |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2997 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2998 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2999 def test_findscu_counters(self): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3000 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3001 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3002 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0002.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3003 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3004 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedStudies' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3005 s = re.findall('\(0020,1200\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3006 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3007 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3008 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3009 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3010 s = re.findall('\(0020,1202\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3011 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3012 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3013 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3014 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3015 s = re.findall('\(0020,1204\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3016 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3017 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3018 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3019 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3020 s = re.findall('\(0020,1206\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3021 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3022 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3023 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3024 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3025 s = re.findall('\(0020,1208\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3026 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3027 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3028 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3029 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'NumberOfSeriesRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3030 s = re.findall('\(0020,1209\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3031 self.assertEqual(2, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3032 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3033 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3034 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3035 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'ModalitiesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3036 s = re.findall('\(0008,0061\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3037 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3038 t = map(lambda x: x.strip(), s[0].split('\\')) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3039 self.assertTrue('PT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3040 self.assertTrue('CT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3041 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3042 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'SOPClassesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3043 s = re.findall('\(0008,0062\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3044 self.assertEqual(1, len(s)) |
176
48cc188ffb09
strip trailing 0 char that appears with some findscu versions
am@osimis.io
parents:
175
diff
changeset
|
3045 t = map(lambda x: x.strip('\x00'), s[0].split('\\')) |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3046 self.assertTrue('1.2.840.10008.5.1.4.1.1.2' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3047 self.assertTrue('1.2.840.10008.5.1.4.1.1.128' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3048 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3049 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3050 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3051 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3052 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3053 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3054 if t != '1.2.840.10008.1.2': # This file has no meta header |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3055 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3056 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3057 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3058 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3059 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3060 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3061 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3062 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3063 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3064 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3065 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3066 Check('1.2.840.10008.1.2.4.50', '496326046974eea718dbc16b997c646b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3067 Check('1.2.840.10008.1.2.4.51', 'ccbe75909fe5c9f7361b48416a53fc41') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3068 Check('1.2.840.10008.1.2.4.57', '7bbefe11d976b1be4e568915c6a82fc3') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3069 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3070 Check('1.2.840.10008.1.2.4.80', '6ff51ae525d362e0d04f550a64075a0e') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3071 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3072 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3073 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3074 Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3075 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |
79 | 3076 |
3077 | |
3078 def test_raw_frame(self): | |
3079 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
3080 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3081 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3082 self.assertEqual(512 * 512 * 2, len(a)) | |
3083 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
3084 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
3085 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
3086 | |
3087 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
3088 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3089 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
3090 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
3091 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
3092 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3093 self.assertEqual("L", im.mode) | |
3094 self.assertEqual(512, im.size[0]) | |
3095 self.assertEqual(512, im.size[1]) | |
3096 | |
3097 # Test an image with 2 JPEG frames spread over multiple fragments | |
3098 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
3099 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3100 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3101 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
3102 self.assertEqual(69214, len(a)) | |
3103 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
3104 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
3105 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3106 self.assertEqual("RGB", im.mode) | |
3107 self.assertEqual(512, im.size[0]) | |
3108 self.assertEqual(512, im.size[1]) | |
3109 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) | |
3110 self.assertEqual("RGB", im.mode) | |
3111 self.assertEqual(512, im.size[0]) | |
3112 self.assertEqual(512, im.size[1]) | |
81 | 3113 |
3114 | |
3115 | |
3116 def test_rest_movescu(self): | |
3117 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3118 | |
3119 # Upload 4 instances | |
3120 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3121 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3122 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3123 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3124 | |
3125 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3126 for p in DoGet(_REMOTE, '/patients'): | |
3127 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
3128 DoDelete(_REMOTE, '/patients/%s' % p) | |
3129 | |
3130 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3131 | |
3132 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
3133 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
3134 'Resources' : [ | |
3135 { | |
3136 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3137 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3138 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
3139 } | |
3140 ]}) | |
3141 | |
3142 # Upload series Brainix/Flair/* | |
3143 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3144 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3145 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3146 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
3147 | |
3148 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3149 'Resources' : [ | |
3150 { | |
3151 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3152 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3153 } | |
3154 ]}) | |
3155 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3156 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3157 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3158 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
3159 | |
3160 # Upload series Brainix/Epi/* | |
3161 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3162 'Resources' : [ | |
3163 { | |
3164 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3165 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
3166 } | |
3167 ]}) | |
3168 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3169 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3170 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
3171 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
3172 | |
3173 # Upload study Knee/* | |
3174 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3175 'Resources' : [ | |
3176 { | |
3177 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3178 } | |
3179 ]}) | |
3180 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3181 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3182 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3183 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3184 | |
3185 # Reset | |
3186 for p in DoGet(_REMOTE, '/patients'): | |
3187 DoDelete(_REMOTE, '/patients/%s' % p) | |
3188 | |
3189 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3190 | |
3191 | |
3192 # Upload all at once | |
3193 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3194 'Resources' : [ | |
3195 { | |
3196 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3197 }, | |
3198 { | |
3199 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3200 } | |
3201 ]}) | |
3202 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3203 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3204 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3205 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3206 | |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3207 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3208 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3209 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3210 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3211 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3212 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3213 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3214 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3215 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3216 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3217 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3218 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3219 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3220 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3221 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3222 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3223 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3224 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3225 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3226 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3227 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3228 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3229 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/dicom-as-json' % patient, 'hello')) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3230 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3231 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3232 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3233 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3234 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3235 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3236 third = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3237 self.assertEqual(str(first), str(second)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3238 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3239 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3240 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3241 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3242 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3243 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3244 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3245 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3246 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3247 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3248 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3249 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3250 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3251 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3252 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3253 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3254 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3255 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3256 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3257 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3258 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3259 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3260 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3261 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3262 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3263 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3264 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3265 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3266 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3267 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3268 self.assertEqual('1.2.840.113704.1.111.6320.1342451261.21', t['PET-CT Multi Modality Name']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3269 self.assertEqual('p37s0_na_ctac.img', t['Original Image Filename']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3270 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3271 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3272 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3273 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3274 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3275 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3276 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3277 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3278 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3279 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3280 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3281 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3282 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3283 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3284 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3285 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3286 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3287 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3288 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3289 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3290 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3291 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3292 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3293 ENCODINGS[name].append(name.lower()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3294 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3295 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3296 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3297 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3298 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3299 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3300 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3301 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3302 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3303 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3304 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3305 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3306 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3307 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3308 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3309 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3310 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3311 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3312 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3313 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3314 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3315 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3316 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3317 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3318 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3319 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3320 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3321 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3322 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3323 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3324 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3325 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3326 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3327 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3328 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3329 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3330 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3331 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3332 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3333 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3334 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3335 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3336 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3337 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3338 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3339 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3340 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3341 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3342 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3343 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3344 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3345 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3346 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3347 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3348 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3349 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3350 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3351 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3352 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3353 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3354 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3355 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3356 self.assertEqual(TEST.encode(tmp, 'ignore').decode(tmp), a[0]["PatientMainDicomTags"]["PatientName"]) |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3357 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3358 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3359 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3360 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3361 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3362 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3363 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3364 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3365 studies = DoGet(_REMOTE, '/studies/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3366 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3367 self.assertEqual(1, len(studies)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3368 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3369 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3370 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3371 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3372 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3373 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3374 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3375 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3376 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3377 }, |
119 | 3378 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3379 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3380 }) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3381 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3382 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3383 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3384 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3385 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3386 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3387 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3388 b = instances[0] if instances[1] == a else instances[1] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3389 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3390 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3391 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3392 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3393 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3394 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % a).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3395 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % b).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3396 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3397 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3398 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3399 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3400 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3401 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3402 |
104 | 3403 def test_httpClient_lua(self): |
3404 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3405 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3406 | |
3407 self.assertIn('OK', result) | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3408 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3409 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3410 def test_bitbucket_issue_44(self): |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3411 # https://bitbucket.org/sjodogne/orthanc/issues/44/bad-interpretation-of-photometric |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3412 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3413 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3414 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3415 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3416 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3417 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3418 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3419 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3420 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3421 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3422 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3423 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3424 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3425 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3426 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3427 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3428 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3429 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3430 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3431 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3432 # This is the chest image, with MONOCHROME1. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3433 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3434 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3435 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3436 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3437 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3438 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3439 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3440 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3441 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3442 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3443 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3444 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3445 # This is the key image, with MONOCHROME2. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3446 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3447 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3448 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3449 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3450 def test_bitbucket_issue_42(self): |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3451 # https://bitbucket.org/sjodogne/orthanc/issues/42/fails-to-modify-a-dicom-video-file |
123 | 3452 # This test fails on DCMTK 3.6.0, but succeeds in DCMTK 3.6.1 snapshots and DCMTK 3.6.2 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3453 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3454 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3455 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3456 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"},"Force":true}', |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3457 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3458 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3459 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3460 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3461 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3462 # Check the "Since" and "Limit" parameters in URI "/tools/find" |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3463 # Related to issue 53: https://bitbucket.org/sjodogne/orthanc/issues/53 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3464 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3465 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3466 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3467 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3468 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3469 brainix.append(UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3470 brainix.append(UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3471 knee.append(UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3472 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3473 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3474 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3475 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3476 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3477 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3478 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3479 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3480 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3481 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3482 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3483 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3484 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3485 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3486 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3487 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3488 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3489 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3490 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3491 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3492 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3493 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3494 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3495 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3496 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3497 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3498 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3499 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3500 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3501 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3502 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3503 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3504 # Check whether the two sets are equal through symmetric difference |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3505 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3506 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3507 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3508 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3509 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3510 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3511 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3512 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3513 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3514 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3515 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3516 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3517 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3518 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3519 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3520 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3521 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3522 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3523 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3524 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3525 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3526 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3527 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3528 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3529 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3530 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3531 # "PHI remaining after anonymization" |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3532 # https://bitbucket.org/sjodogne/orthanc/issues/46 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3533 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3534 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3535 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3536 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3537 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3538 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3539 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3540 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3541 instance = a[0]['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3542 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3543 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3544 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3545 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3546 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3547 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3548 # Add the 0032,1033 (Requesting Service) and the 0010,1060 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3549 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3550 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3551 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3552 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3553 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3554 # Use Table E.1-1 from PS 3.15-2008 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3555 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3556 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3557 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3558 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3559 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3560 # Use Table E.1-1 from PS 3.15-2011 (only if Orthanc >= 1.2.1) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3561 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3562 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3563 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3564 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3565 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3566 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3567 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3568 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3569 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3570 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3571 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3572 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3573 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3574 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3575 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3576 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3577 # Run "dciodvfy" on the anonymized file to be sure it is still valid |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3578 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3579 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3580 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3581 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3582 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3583 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3584 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3585 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3586 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3587 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3588 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3589 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3590 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3591 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3592 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3593 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3594 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3595 a = DoPost(_REMOTE, '/studies/%s/%s' % (study, operation), query)['Path'] |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3596 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3597 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3598 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3599 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3600 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3601 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3602 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3603 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3604 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3605 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3606 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3607 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3608 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3609 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3610 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3611 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3612 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3613 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3614 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3615 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3616 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3617 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3618 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3619 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3620 # is set to "false" (default value). |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3621 # https://bitbucket.org/sjodogne/orthanc/issues/56 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3622 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3623 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3624 a = CallFindScu([ '-k', '0008,0005=ISO_IR 192', # Use UTF-8 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3625 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3626 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3627 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3628 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3629 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3630 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3631 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3632 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3633 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3634 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3635 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3636 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3637 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3638 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3639 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3640 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3641 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3642 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3643 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3644 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3645 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3646 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3647 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3648 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3649 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3650 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3651 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3652 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3653 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3654 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3655 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3656 |
125 | 3657 |
3658 def test_gbk_alias(self): | |
3659 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3660 # This test fails on Orthanc <= 1.3.0 | |
3661 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3662 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3663 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3664 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3665 |
3666 | |
3667 def test_long_tag(self): | |
3668 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3669 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3670 | |
3671 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3672 self.assertTrue('0018,1020' in tags) | |
3673 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3674 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3675 self.assertEqual(None, tags['0018,1020']['Value']) | |
3676 | |
3677 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3678 self.assertTrue('0018,1020' in tags) | |
3679 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3680 self.assertEqual('String', tags['0018,1020']['Type']) | |
3681 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3682 | |
3683 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3684 self.assertTrue('SoftwareVersions' in tags) | |
3685 self.assertEqual(None, tags['SoftwareVersions']) | |
3686 self.assertTrue('HeartRate' in tags) | |
3687 self.assertEqual(474, int(tags['HeartRate'])) | |
3688 | |
3689 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3690 self.assertTrue('SoftwareVersions' in tags) | |
3691 self.assertEqual(None, tags['SoftwareVersions']) | |
3692 | |
3693 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3694 self.assertTrue('SoftwareVersions' in tags) | |
3695 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3696 | |
3697 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3698 self.assertTrue('SoftwareVersions' in tags) | |
3699 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3700 | |
3701 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3702 self.assertEqual(1, len(tags)) | |
3703 self.assertTrue(i in tags.keys()) | |
3704 self.assertTrue('0018,1020' in tags[i]) | |
3705 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3706 | |
3707 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3708 self.assertEqual(1, len(tags)) | |
3709 self.assertTrue(i in tags.keys()) | |
3710 self.assertTrue('0018,1020' in tags[i]) | |
3711 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3712 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3713 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3714 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3715 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3716 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3717 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3718 z = GetArchive(_REMOTE, '/patients/%s/media?extended' % DoGet(_REMOTE, '/patients')[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3719 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3720 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3721 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3722 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3723 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3724 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3725 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3726 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3727 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3728 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3729 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3730 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3731 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3732 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3733 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3734 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3735 self.assertTrue('not present in standard DICOM IOD' in a[2]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3736 self.assertTrue('not present in standard DICOM IOD' in a[3]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3737 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3738 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3739 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3740 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3741 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3742 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3743 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3744 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3745 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3746 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3747 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3748 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3749 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3750 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3751 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3752 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3753 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3754 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3755 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3756 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3757 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3758 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3759 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3760 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3761 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3762 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3763 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3764 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3765 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3766 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3767 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3768 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3769 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3770 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3771 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3772 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3773 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3774 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3775 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3776 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3777 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3778 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3779 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3780 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3781 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3782 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3783 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3784 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3785 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3786 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3787 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3788 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3789 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3790 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3791 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3792 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3793 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3794 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3795 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3796 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3797 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3798 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3799 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3800 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3801 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3802 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3803 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3804 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3805 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3806 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3807 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3808 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3809 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3810 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3811 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3812 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3813 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3814 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3815 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3816 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3817 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3818 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3819 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3820 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3821 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3822 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3823 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3824 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3825 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3826 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3827 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3828 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3829 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3830 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3831 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3832 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3833 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3834 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3835 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3836 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3837 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3838 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3839 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3840 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3841 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3842 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3843 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3844 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3845 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3846 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3847 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3848 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3849 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3850 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3851 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3852 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3853 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3854 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3855 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3856 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3857 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3858 if DoGet(_REMOTE, '/instances/%s/content/Modality' % a[0]['ID']) == 'SR': |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3859 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3860 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3861 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3862 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3863 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3864 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3865 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3866 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3867 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3868 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3869 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3870 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3871 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3872 mrSeries1 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3873 mrSeries2 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3874 mrStudy1 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3875 mrStudy2 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3876 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3877 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3878 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3879 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3880 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3881 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3882 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3883 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3884 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3885 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3886 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3887 self.assertEqual(mrSeries1, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3888 self.assertEqual(mrStudy1, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3889 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3890 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3891 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3892 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3893 self.assertEqual(DoGet(_REMOTE, PATH5 % sr1), DoGet(_REMOTE, PATH5 % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3894 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3895 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3896 self.assertEqual(mrSeries2, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3897 self.assertEqual(mrStudy2, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3898 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3899 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3900 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3901 self.assertEqual(str(content1), str(content2)) |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3902 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3903 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3904 def test_bitbucket_issue_94(self): |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3905 # "a simple instance modification should not modify FrameOfReferenceUID + ..." |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3906 # https://bitbucket.org/sjodogne/orthanc/issues/94 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3907 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3908 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3909 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3910 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3911 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3912 { "Replace" : {"PatientID" : "toto"}, "Force": True}) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3913 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3914 anonymized = DoPost(_REMOTE, '/instances/%s/anonymize' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3915 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3916 a = ExtractDicomTags(source, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3917 self.assertEqual(1, len(a)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3918 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3919 b = ExtractDicomTags(modified, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3920 self.assertEqual(1, len(b)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3921 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3922 c = ExtractDicomTags(anonymized, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3923 self.assertEqual(1, len(c)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3924 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3925 self.assertEqual(a, b) # Modified DICOM |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3926 self.assertNotEqual(a, c) # Anonymized DICOM |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3927 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3928 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3929 def test_metadata_origin(self): |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3930 # Upload using the REST API |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3931 i = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3932 self.assertEqual('RestApi', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3933 self.assertEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3934 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3935 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata/CalledAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3936 self.assertEqual('alice', DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3937 |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3938 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3939 self.assertEqual('RestApi', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3940 self.assertEqual('', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3941 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3942 self.assertFalse('CalledAET' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3943 self.assertEqual('alice', m['HttpUsername']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3944 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3945 self.assertEqual('1.2.840.10008.1.2.4.91', m['TransferSyntax']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3946 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', m['SopClassUid']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3947 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3948 self.assertTrue('ReceptionDate' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3949 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3950 DoDelete(_REMOTE, '/instances/%s' % i) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3951 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3952 # Upload using the DICOM protocol |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3953 subprocess.check_call([ FindExecutable('storescu'), |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3954 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3955 GetDatabasePath('Knee/T1/IM-0001-0001.dcm'), |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3956 '-xw' ]) # Propose JPEG2000 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3957 self.assertEqual('DicomProtocol', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3958 self.assertEqual('STORESCU', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3959 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3960 self.assertEqual('ANY-SCP', DoGet(_REMOTE, '/instances/%s/metadata/CalledAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3961 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3962 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3963 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3964 self.assertEqual('DicomProtocol', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3965 self.assertEqual('STORESCU', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3966 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3967 self.assertEqual('ANY-SCP', m['CalledAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3968 self.assertFalse('HttpUsername' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3969 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3970 self.assertEqual('1.2.840.10008.1.2.4.91', m['TransferSyntax']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3971 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', m['SopClassUid']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3972 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3973 self.assertTrue('ReceptionDate' in m) |
147 | 3974 |
3975 | |
3976 def test_lua_deadlock(self): | |
3977 # Rana Asim Wajid (2018-07-14): "It does seem that the issue | |
3978 # is with the lua script I'm using for conversion of images to | |
3979 # JPEG2000. When the script is used with 1.4.0 the first | |
3980 # instance appears to be stored and then everything just | |
3981 # halts, ie Orthanc wont respond to anything after that." | |
3982 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | |
174 | 3983 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
147 | 3984 |
3985 subprocess.check_call([ FindExecutable('storescu'), | |
3986 _REMOTE['Server'], str(_REMOTE['DicomPort']), | |
3987 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | |
3988 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | |
3989 ]) | |
3990 | |
3991 instances = DoGet(_REMOTE, '/instances') | |
3992 self.assertEqual(2, len(instances)) | |
3993 | |
3994 t1 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[0]) | |
3995 t2 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[1]) | |
175 | 3996 self.assertEqual('1.2.840.10008.1.2.4.90', t1) # this will fail if libgdcm-tools is not installed |
147 | 3997 self.assertEqual(t1, t2); |
154
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3998 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3999 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4000 def test_find_group_length(self): |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4001 # Orthanc <= 1.4.1 fails to answer C-FIND queries that contain |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4002 # one of the Generic Group Length tags (*, 0x0000) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4003 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4004 result = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0008,0000=80' ]) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4005 self.assertFalse('UnableToProcess' in result) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4006 self.assertFalse('E:' in result) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4007 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4008 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4009 def test_split(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4010 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4011 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4012 knee1Sop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4013 knee2Sop = '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4014 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4015 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4016 t2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4017 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4018 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4019 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4020 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4021 info = DoGet(_REMOTE, '/studies/%s' % study) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4022 self.assertTrue('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4023 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4024 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4025 (_REMOTE, '/studies/%s/split' % study, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4026 'Series' : [ t2 ], |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4027 'Replace' : { 'PatientName' : 'Hello' }, |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4028 'Remove' : [ 'ReferringPhysicianName' ], |
181 | 4029 'KeepSource' : False, |
4030 'Asynchronous' : True | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4031 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4032 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4033 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4034 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4035 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4036 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4037 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4038 series = set(DoGet(_REMOTE, '/series')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4039 self.assertEqual(2, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4040 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4041 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4042 study2 = DoGet(_REMOTE, '/jobs/%s' % job)['Content']['TargetStudy'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4043 self.assertTrue(study in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4044 self.assertTrue(study2 in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4045 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4046 info = DoGet(_REMOTE, '/studies/%s' % study2) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4047 self.assertTrue('Hello', info['PatientMainDicomTags']['PatientName']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4048 self.assertFalse('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4049 |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4050 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4051 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4052 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4053 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4054 self.assertTrue(knee1Sop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4055 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4056 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4057 self.assertFalse(knee2Sop in sopInstanceUids) # Because "KeepSource" is False |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4058 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4059 # One original instance is kept, another one is added because of the split |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4060 self.assertEqual(2, len(sopInstanceUids)) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4061 |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4062 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4063 def test_merge(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4064 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4065 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4066 kneeSop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4067 brainixSop = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4068 knee = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4069 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4070 brainix = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4071 flair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4072 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4073 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4074 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4075 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4076 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4077 (_REMOTE, '/studies/%s/merge' % knee, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4078 'Resources' : [ brainix ], |
181 | 4079 'KeepSource' : True, |
4080 'Synchronous' : False | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4081 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4082 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4083 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4084 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4085 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4086 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4087 self.assertTrue(knee in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4088 self.assertTrue(brainix in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4089 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4090 series = set(DoGet(_REMOTE, '/studies/%s' % knee)['Series']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4091 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4092 series.remove(t1) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4093 self.assertEqual(1, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4094 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4095 instances = DoGet(_REMOTE, '/series/%s' % list(series)[0])['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4096 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4097 merged = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4098 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4099 instances = DoGet(_REMOTE, '/series/%s' % t1)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4100 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4101 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4102 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4103 instances = DoGet(_REMOTE, '/series/%s' % flair)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4104 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4105 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4106 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4107 tags = DoGet(_REMOTE, '/studies/%s' % knee) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4108 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4109 for key in tags['PatientMainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4110 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4111 if (key in b and key != 'PatientSex'): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4112 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4113 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4114 for key in tags['MainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4115 # Not in the patient/study module |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4116 if (not key in [ 'InstitutionName', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4117 'RequestingPhysician', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4118 'RequestedProcedureDescription', ]): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4119 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4120 if (key in b): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4121 self.assertNotEqual(a[key], b[key]) |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4122 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4123 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4124 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4125 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4126 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4127 self.assertTrue(kneeSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4128 self.assertTrue(brainixSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4129 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4130 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4131 # The 2 original instances are kept, another one is added because of the merge |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4132 self.assertEqual(3, len(sopInstanceUids)) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4133 |
187 | 4134 |
4135 def test_async_archive(self): | |
4136 # Testing the asynchronous generation of archives/medias (new | |
4137 # in Orthanc 1.4.3) | |
4138 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
4139 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
4140 | |
4141 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
4142 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
4143 | |
4144 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4145 (_REMOTE, '/studies/%s/archive' % kneeT1, { | |
4146 'Synchronous' : False | |
4147 })) | |
4148 | |
4149 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4150 self.assertEqual(1, len(z.namelist())) | |
4151 self.assertFalse('DICOMDIR' in z.namelist()) | |
4152 | |
4153 job2 = MonitorJob2(_REMOTE, lambda: DoPost | |
4154 (_REMOTE, '/studies/%s/media' % kneeT1, { | |
4155 'Synchronous' : False | |
4156 })) | |
4157 | |
4158 # The archive from the first job has been replaced by the | |
4159 # archive from second job (as MediaArchiveSize == 1) | |
4160 self.assertRaises(Exception, lambda: GetArchive(_REMOTE, '/jobs/%s/archive' % job)) | |
4161 | |
4162 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job2) | |
4163 self.assertEqual(2, len(z.namelist())) | |
4164 self.assertTrue('DICOMDIR' in z.namelist()) | |
4165 | |
4166 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4167 (_REMOTE, '/tools/create-archive', { | |
4168 'Synchronous' : False, | |
4169 'Resources' : [ kneeT1, kneeT2 ], | |
4170 })) | |
4171 | |
4172 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4173 self.assertEqual(2, len(z.namelist())) | |
4174 self.assertFalse('DICOMDIR' in z.namelist()) | |
4175 | |
4176 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4177 (_REMOTE, '/tools/create-media', { | |
4178 'Synchronous' : False, | |
4179 'Resources' : [ kneeT1, kneeT2 ], | |
4180 })) | |
4181 | |
4182 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4183 self.assertEqual(3, len(z.namelist())) | |
4184 self.assertTrue('DICOMDIR' in z.namelist()) | |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4185 |
187 | 4186 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4187 def test_queries_hierarchy(self): |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4188 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4189 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4190 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4191 tags = { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4192 'NumberOfPatientRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4193 'NumberOfPatientRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4194 'NumberOfPatientRelatedStudies' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4195 'NumberOfStudyRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4196 'NumberOfStudyRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4197 'NumberOfSeriesRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4198 } |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4199 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4200 tags2 = copy.copy(tags) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4201 tags2['PatientID'] = '887' # Only consider the "Knee" patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4202 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4203 patient = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4204 'Level' : 'Patient', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4205 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4206 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4207 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4208 study = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4209 'Level' : 'Study', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4210 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4211 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4212 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4213 series = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4214 'Level' : 'Series', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4215 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4216 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4217 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4218 instance = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4219 'Level' : 'Instance', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4220 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4221 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4222 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4223 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % patient) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4224 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4225 self.assertEqual('887', p[0]['PatientID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4226 self.assertEqual('1', p[0]['NumberOfPatientRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4227 self.assertEqual('1', p[0]['NumberOfPatientRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4228 self.assertEqual('1', p[0]['NumberOfPatientRelatedStudies']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4229 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4230 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4231 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4232 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4233 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4234 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4235 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', p[0]['StudyInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4236 self.assertEqual('1', p[0]['NumberOfStudyRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4237 self.assertEqual('1', p[0]['NumberOfStudyRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4238 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4239 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4240 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4241 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4242 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4243 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4244 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4245 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908564160709', p[0]['SeriesInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4246 self.assertEqual('1', p[0]['NumberOfSeriesRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4247 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4248 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4249 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4250 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4251 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4252 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4253 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4254 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4255 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', p[0]['SOPInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4256 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4257 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-studies' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4258 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4259 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4260 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study)) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4261 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4262 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4263 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4264 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4265 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4266 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4267 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4268 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4269 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4270 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4271 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4272 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4273 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4274 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4275 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4276 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4277 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4278 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4279 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4280 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4281 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4282 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % series, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4283 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4284 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4285 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4286 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4287 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4288 def test_dicom_disk_size(self): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4289 dicomSize = 0 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4290 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4291 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4292 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4293 for i in range(2): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4294 p = 'Knee/T%d/IM-0001-0001.dcm' % (i + 1) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4295 UploadInstance(_REMOTE, p) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4296 dicomSize += os.path.getsize(GetDatabasePath(p)) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4297 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4298 s = DoGet(_REMOTE, '/patients/ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17/statistics') # Consider Knee patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4299 self.assertEqual(2, s['CountInstances']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4300 self.assertEqual(2, s['CountSeries']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4301 self.assertEqual(1, s['CountStudies']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4302 self.assertEqual(dicomSize, int(s['DicomDiskSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4303 self.assertEqual(dicomSize, int(s['DicomUncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4304 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4305 self.assertEqual(s['UncompressedSize'], s['DiskSize']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4306 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4307 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4308 def test_changes_2(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4309 # More consistent behavior since Orthanc 1.5.2 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4310 # https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4311 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4312 # Make sure that this is not the first change |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4313 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4314 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4315 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4316 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4317 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4318 # No more instance, but there were previous changes |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4319 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4320 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4321 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4322 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4323 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4324 seq = c['Last'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4325 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4326 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4327 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4328 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4329 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4330 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4331 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4332 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4333 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4334 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4335 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4336 # Add one instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4337 UploadInstance(_REMOTE, 'DummyCT.dcm') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4338 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4339 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4340 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4341 self.assertEqual(4, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4342 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4343 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4344 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4345 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4346 self.assertEqual(1, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4347 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4348 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4349 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4350 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4351 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4352 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4353 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4354 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4355 # Remove the uploaded instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4356 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4357 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4358 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4359 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4360 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4361 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4362 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4363 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4364 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4365 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4366 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4367 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4368 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4369 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4370 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4371 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4372 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4373 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4374 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4375 def test_bitbucket_issue_124(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4376 a = UploadInstance(_REMOTE, 'Issue124.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4377 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4378 z = GetArchive(_REMOTE, '/patients/%s/media' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4379 self.assertEqual(2, len(z.namelist())) |
207
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4380 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4381 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4382 def test_invalid_findscp(self): |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4383 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4384 findscu = CallFindScu([ '-S', '-k', '8,52=IMAGE', '-k', '8,16', '-k', '2,2' ]) |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4385 self.assertEqual(0, len(re.findall('\(0002,0002\)', findscu))) |
208
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4386 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4387 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4388 def test_bitbucket_issue_90(self): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4389 def CountDicomResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4390 a = CallFindScu([ '-S', '-k', '8,52=STUDY', '-k', sex ]) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4391 return len(re.findall('\(0010,0040\)', a)) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4392 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4393 def CountRestResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4394 a = DoPost(_REMOTE, '/tools/find', |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4395 { 'Level' : 'Study', 'Query' : { 'PatientSex' : sex } }) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4396 return len(a) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4397 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4398 # Just like the "CR000000.dcm" of the issue, the test image |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4399 # "DummyCT.dcm" has the tag PatientSex (0010,0040) unset |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4400 UploadInstance(_REMOTE, 'DummyCT.dcm') |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4401 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4402 # Test that the behavior of DICOM vs. REST API is consistent on missing tags |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4403 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4404 # In wildcard constraints, the patient sex must be set for a match to occur |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4405 self.assertEqual(0, CountDicomResults('PatientSex=*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4406 self.assertEqual(0, CountRestResults('*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4407 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4408 # In single-valued constraints, the patient sex must be set |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4409 self.assertEqual(0, CountDicomResults('PatientSex=F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4410 self.assertEqual(0, CountDicomResults('PatientSex=M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4411 self.assertEqual(0, CountRestResults('F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4412 self.assertEqual(0, CountRestResults('M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4413 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4414 # Empty constraints are only used to ask the actual value of |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4415 # the tag to be added to the *answer*. The tag should not used |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4416 # as a filter in such a situation. |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4417 self.assertEqual(1, CountDicomResults('PatientSex')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4418 self.assertEqual(1, CountDicomResults('PatientSex=')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4419 self.assertEqual(1, CountRestResults('')) # This check fails on Orthanc <= 1.5.2 (issue 90) |
210
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4420 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4421 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4422 def test_rest_modalities_in_study(self): |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4423 # Tests a regression that is present in Orthanc 1.5.2 and 1.5.3 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4424 # https://groups.google.com/d/msg/orthanc-users/7lZyG3wpx-M/uOXzAzVCFwAJ |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4425 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4426 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4427 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4428 'Query' : { 'ModalitiesInStudy' : 'US' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4429 self.assertEqual(0, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4430 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4431 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4432 'Query' : { 'ModalitiesInStudy' : 'US\\CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4433 self.assertEqual(1, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4434 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4435 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4436 'Query' : { 'ModalitiesInStudy' : 'CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4437 self.assertEqual(1, len(a)) |
211 | 4438 |
4439 | |
4440 def test_series_status(self): | |
4441 def HasCompletedInChanges(): | |
4442 for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']: | |
4443 if c['ChangeType'] == 'CompletedSeries': | |
4444 return True; | |
4445 | |
4446 return False | |
4447 | |
4448 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm') | |
4449 series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa' | |
4450 self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4451 self.assertFalse(HasCompletedInChanges()) | |
4452 | |
4453 series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614' | |
4454 | |
4455 for i in range(3): | |
4456 UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1)) | |
4457 self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4458 self.assertFalse(HasCompletedInChanges()) | |
4459 | |
4460 UploadInstance(_REMOTE, 'Series/Lena-4.dcm') | |
4461 self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4462 self.assertTrue(HasCompletedInChanges()) | |
4463 | |
4464 DoDelete(_REMOTE, '/changes') | |
4465 self.assertFalse(HasCompletedInChanges()) | |
4466 | |
4467 UploadInstance(_REMOTE, 'Series/Lena-5.dcm') | |
4468 self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4469 self.assertFalse(HasCompletedInChanges()) | |
4470 | |
215 | 4471 |
4472 def test_dicomweb(self): | |
4473 def Compare(dicom, reference): | |
4474 a = UploadInstance(_REMOTE, dicom) ['ID'] | |
4475 b = DoGet(_REMOTE, '/instances/%s/file' % a, | |
4476 headers = { 'Accept' : 'application/dicom+json' }) | |
4477 with open(GetDatabasePath(reference), 'rb') as c: | |
4478 d = json.load(c) | |
220 | 4479 AssertAlmostEqualRecursive(self, d, b) |
215 | 4480 |
4481 Compare('DummyCT.dcm', 'DummyCT.json') | |
4482 Compare('MarekLatin2.dcm', 'MarekLatin2.json') | |
4483 Compare('HierarchicalAnonymization/StructuredReports/IM0', | |
4484 'HierarchicalAnonymization/StructuredReports/IM0.json') | |
217 | 4485 |
4486 | |
4487 def test_issue_95_encodings(self): | |
4488 # https://bitbucket.org/sjodogne/orthanc/issues/95/server-cant-support-chinese | |
4489 # Check out image: "../Database/Encodings/DavidClunie/charsettests.screenshot.png" | |
4490 | |
4491 # Very useful tool: "file2" from package "file-kanji" | |
4492 | |
4493 def GetPatientName(dicom): | |
4494 i = UploadInstance(_REMOTE, dicom) ['ID'] | |
4495 j = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
4496 return j['PatientName'] | |
4497 | |
4498 def ComparePatientName(name, dicom): | |
4499 self.assertEqual(name, GetPatientName(dicom)) | |
4500 | |
4501 # gdcmraw -t 10,10 -i SCSFREN -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4502 ComparePatientName(u'Buc^Jérôme', 'Encodings/DavidClunie/SCSFREN') | |
4503 | |
4504 # gdcmraw -t 10,10 -i SCSI2 -o /tmp/tag && uconv -f KOREAN -t UTF-8 /tmp/tag && echo | |
4505 ComparePatientName(u'Hong^Gildong=洪^吉洞=홍^길동', 'Encodings/DavidClunie/SCSI2') # Since Orthanc 1.5.5 | |
4506 | |
4507 # gdcmraw -t 10,10 -i SCSX2 -o /tmp/tag && uconv -f GB18030 -t UTF-8 /tmp/tag && echo | |
4508 ComparePatientName(u'Wang^XiaoDong=王^小东=', 'Encodings/DavidClunie/SCSX2') | |
4509 | |
4510 # gdcmraw -t 10,10 -i SCSX1 -o /tmp/tag && cat /tmp/tag && echo | |
4511 ComparePatientName(u'Wang^XiaoDong=王^小東=', 'Encodings/DavidClunie/SCSX1') | |
4512 | |
4513 # gdcmraw -t 10,10 -i SCSH31 -o /tmp/tag && uconv -f JIS -t UTF-8 /tmp/tag && echo | |
4514 ComparePatientName(u'Yamada^Tarou=山田^太郎=やまだ^たろう', 'Encodings/DavidClunie/SCSH31') | |
4515 | |
4516 # gdcmraw -t 10,10 -i SCSGERM -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4517 ComparePatientName(u'Äneas^Rüdiger', 'Encodings/DavidClunie/SCSGERM') | |
4518 | |
4519 # gdcmraw -t 10,10 -i SCSGREEK -o /tmp/tag && uconv -f ISO-IR-126 -t UTF-8 /tmp/tag && echo | |
4520 ComparePatientName(u'Διονυσιος', 'Encodings/DavidClunie/SCSGREEK') | |
4521 | |
4522 # gdcmraw -t 10,10 -i SCSRUSS -o /tmp/tag && uconv -f ISO-IR-144 -t UTF-8 /tmp/tag && echo | |
4523 ComparePatientName(u'Люкceмбypг', 'Encodings/DavidClunie/SCSRUSS') | |
4524 | |
4525 # gdcmraw -t 10,10 -i SCSHBRW -o /tmp/tag && uconv -f ISO-IR-138 -t UTF-8 /tmp/tag && echo | |
4526 # NB: Hebrew is a right-to-left encoding, copying/pasting from | |
4527 # Linux console into Emacs automatically reverse the string | |
4528 ComparePatientName(u'שרון^דבורה', 'Encodings/DavidClunie/SCSHBRW') | |
4529 | |
4530 # gdcmraw -t 10,10 -i SCSARAB -o /tmp/tag && uconv -f ISO-IR-127 -t UTF-8 /tmp/tag && echo | |
4531 # NB: Right-to-left as for Hebrew (SCSHBRW), and the Ubuntu console can't display such | |
4532 # characters by default, but copy/paste works with Emacs | |
4533 ComparePatientName(u'قباني^لنزار', 'Encodings/DavidClunie/SCSARAB') | |
4534 | |
4535 # SCSH32: This SpecificCharacterSet is composed of 2 | |
4536 # codepages: "ISO 2022 IR 13" (i.e. "SHIFT_JIS") until the | |
4537 # first equal, then "ISO 2022 IR 87" (i.e. "JIS") for the | |
4538 # remainer. Orthanc only takes into consideration the first | |
4539 # codepage: This is a limitation. | |
4540 # gdcmraw -t 10,10 -i SCSH32 -o /tmp/tag && cut -d '=' -f 1 /tmp/tag | uconv -f SHIFT_JIS -t UTF-8 | |
4541 self.assertTrue(GetPatientName('Encodings/DavidClunie/SCSH32').startswith(u'ヤマダ^タロウ=')) | |
218
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4542 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4543 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4544 def test_findscu_missing_tags(self): |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4545 # dcmodify -e Rows DummyCTInvalidRows.dcm -gst -gse -gin |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4546 UploadInstance(_REMOTE, 'DummyCT.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4547 UploadInstance(_REMOTE, 'DummyCTInvalidRows.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4548 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4549 i = CallFindScu([ '-k', '0008,0052=IMAGES', '-k', 'Rows', '-k', 'PatientName' ]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4550 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4551 # We have 2 instances... |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4552 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4553 self.assertEqual(2, len(patientNames)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4554 self.assertEqual('KNIX', patientNames[0]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4555 self.assertEqual('KNIX', patientNames[1]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4556 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4557 # ...but only 1 value for the "Rows" tag |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4558 rows = re.findall('\(0028,0010\) US ([0-9]+)', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4559 self.assertEqual(1, len(rows)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4560 self.assertEqual('512', rows[0]) |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4561 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4562 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4563 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4564 def test_bitbucket_issue_131(self): |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4565 # "Orthanc PACS silently fails to C-MOVE due to duplicate |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4566 # StudyInstanceUID in it's database." |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4567 # https://bitbucket.org/sjodogne/orthanc/issues/131/orthanc-pacs-silently-fails-to-c-move-due |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4568 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4569 # Insert 2 instances, with the same StudyInstanceUID, but with |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4570 # different patient IDs. Orthanc will create 2 distincts |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4571 # patients, and the hierarchy of resources above the two |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4572 # instances will be fully disjoint. |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4573 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-a.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4574 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-b.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4575 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4576 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4577 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4578 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4579 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4580 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4581 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4582 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4583 # 1 study is matched |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4584 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4585 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4586 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4587 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4588 (_REMOTE, '/queries/%s/retrieve' % a, | |
4589 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4590 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4591 # The two studies are matched, as we made the request at the |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4592 # Study level, thus the shared StudyInstanceUID is used as the key |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4593 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4594 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4595 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4596 # Match the 2 studies |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4597 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4598 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4599 'Query' : {"StudyInstanceUID": "2.25.123" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4600 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4601 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4602 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4603 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4604 (_REMOTE, '/queries/%s/retrieve' % a, | |
4605 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4606 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4607 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4608 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4609 # Same test, at the patient level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4610 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4611 'Level' : 'Patient', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4612 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4613 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4614 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4615 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4616 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4617 (_REMOTE, '/queries/%s/retrieve' % a, | |
4618 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4619 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4620 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4621 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4622 # Same test, at the series level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4623 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4624 'Level' : 'Series', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4625 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4626 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4627 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4628 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4629 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4630 (_REMOTE, '/queries/%s/retrieve' % a, | |
4631 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4632 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4633 |
233
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4634 |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4635 def test_bitbucket_issue_136(self): |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4636 UploadInstance(_REMOTE, 'Issue137.dcm') |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4637 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0010,0010', '-k', '0028,0010', '-k', '0040,0275' ]) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4638 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4639 self.assertEqual(1, len(patientNames)) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4640 self.assertEqual('John Doe', patientNames[0]) |
234
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4641 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4642 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4643 def test_anonymize_relationships_4(self): |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4644 # https://groups.google.com/d/msg/orthanc-users/UkcsqyTpszE/bXUpzU0vAAAJ |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4645 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/CR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4646 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/PR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4647 study = '0c923249-d52121a9-2b7167f7-6b85534f-0943697e' |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4648 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4649 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, '{}', |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4650 'application/json')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4651 series = DoGet(_REMOTE, '/studies/%s/series' % anonymized) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4652 self.assertEqual(2, len(series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4653 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4654 cr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4655 pr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'PR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4656 self.assertEqual(1, len(cr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4657 self.assertEqual(1, len(pr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4658 self.assertEqual(1, len(cr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4659 self.assertEqual(1, len(pr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4660 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4661 crinstance = DoGet(_REMOTE, '/instances/%s' % cr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4662 tags = DoGet(_REMOTE, '/instances/%s/tags?short' % pr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4663 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4664 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1155'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4665 crinstance['MainDicomTags']['SOPInstanceUID']) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4666 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1150'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4667 '1.2.840.10008.5.1.4.1.1.1') # SOP class for CR Image Storage |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4668 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4669 # This fails on Orthanc <= 1.5.6 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4670 self.assertEqual(tags['0008,1115'][0]['0020,000e'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4671 cr[0]['MainDicomTags']['SeriesInstanceUID']) |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4672 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4673 |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4674 def test_anonymize_relationships_5(self): |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4675 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4676 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4677 oStudyId = ct1['ParentStudy'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4678 oCtInstanceId = ct1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4679 oRtInstanceId = rt1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4680 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4681 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4682 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4683 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4684 # first validate the relationships in the source data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4685 oStudyUID = oCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4686 oRtSeriesUID = oRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4687 oRtInstanceUID = oRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4688 oRtFrameOfReferenceUID = oRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4689 oCtSeriesUID = oCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4690 oCtInstanceUID = oCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4691 oCtFrameOfReferenceUID = oCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4692 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4693 oContourSequenceCount = len(oRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4694 self.assertEqual(oCtFrameOfReferenceUID, oRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4695 self.assertEqual(oStudyUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4696 self.assertEqual(oCtSeriesUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4697 self.assertEqual(oCtInstanceUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4698 self.assertEqual(oCtInstanceUID, oRtTags['ROIContourSequence'][0]['ContourSequence'][oContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4699 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4700 ### anonymize |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4701 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4702 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{}', |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4703 'application/json')['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4704 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4705 ### validate |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4706 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4707 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4708 self.assertEqual(2, len(aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4709 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4710 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4711 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4712 aCtInstanceId = aCt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4713 aRtInstanceId = aRt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4714 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4715 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4716 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4717 # now validate the relationships in the anonymized data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4718 aStudyUID = aCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4719 aRtSeriesUID = aRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4720 aRtInstanceUID = aRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4721 aRtFrameOfReferenceUID = aRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4722 aCtSeriesUID = aCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4723 aCtInstanceUID = aCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4724 aCtFrameOfReferenceUID = aCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4725 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4726 aContourSequenceCount = len(aRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4727 # make sure all UIDs have been updated |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4728 self.assertNotEqual(oStudyUID, aStudyUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4729 self.assertNotEqual(oRtSeriesUID, aRtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4730 self.assertNotEqual(oRtInstanceUID, aRtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4731 self.assertNotEqual(oRtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4732 self.assertNotEqual(oCtSeriesUID, aCtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4733 self.assertNotEqual(oCtInstanceUID, aCtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4734 self.assertNotEqual(oCtFrameOfReferenceUID, aCtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4735 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4736 # validate the relationships |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4737 self.assertEqual(oContourSequenceCount, aContourSequenceCount) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4738 self.assertEqual(aCtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
256 | 4739 self.assertEqual(aStudyUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
4740 self.assertEqual(aCtSeriesUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4741 self.assertEqual(aCtInstanceUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4742 self.assertEqual(aCtInstanceUID, aRtTags['ROIContourSequence'][0]['ContourSequence'][aContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4743 |
256 | 4744 def test_anonymize_relationships_5b(self): |
4745 # same test as previous one but, this time, we force the StudyInstanceUID | |
4746 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') | |
4747 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') | |
4748 oStudyId = ct1['ParentStudy'] | |
4749 oCtInstanceId = ct1['ID'] | |
4750 oRtInstanceId = rt1['ID'] | |
4751 | |
4752 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) | |
4753 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) | |
4754 | |
4755 ### anonymize while forcing the StudyInstanceUID | |
4756 | |
4757 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{ "Replace" : { "StudyInstanceUID" : "1.2.3.4"}, "Force": true}', | |
4758 'application/json')['ID'] | |
4759 | |
4760 ### validate | |
4761 | |
4762 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) | |
4763 self.assertEqual(2, len(aSeries)) | |
4764 | |
4765 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) | |
4766 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) | |
4767 aCtInstanceId = aCt[0]['Instances'][0] | |
4768 aRtInstanceId = aRt[0]['Instances'][0] | |
4769 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) | |
4770 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) | |
4771 | |
4772 self.assertEqual("1.2.3.4", aCtTags['StudyInstanceUID']) | |
4773 self.assertEqual("1.2.3.4", aRtTags['StudyInstanceUID']) | |
4774 self.assertEqual("1.2.3.4", aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4775 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4776 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4777 def test_bitbucket_issue_140(self): |
266 | 4778 # "Modifying private tags with REST API changes VR from LO to |
267 | 4779 # UN." This test fails if DCMTK <= 3.6.1 (e.g. fails on Ubuntu 16.04). |
266 | 4780 # https://bitbucket.org/sjodogne/orthanc/issues/140 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4781 source = UploadInstance(_REMOTE, 'Issue140.dcm') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4782 series = DoGet(_REMOTE, '/instances/%s' % source) ['ParentSeries'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4783 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4784 target = DoPost(_REMOTE, '/series/%s/modify' % series, { |
266 | 4785 'Replace' : { 'RadioButton3' : 'aaabbbccc' }, |
4786 'PrivateCreator' : 'RadioLogic', # <= the trick is here | |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4787 }, 'application/json') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4788 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4789 instances = DoGet(_REMOTE, '/series/%s/instances' % target) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4790 self.assertEqual(1, len(instances)) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4791 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4792 tags = DoGet(_REMOTE, '/instances/%s/tags' % source) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4793 t = tags['4321,1012'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4794 self.assertEqual('String', t['Type']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4795 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4796 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4797 self.assertEqual('jklmopq', t['Value']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4798 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4799 tags = DoGet(_REMOTE, '/instances/%s/tags' % instances[0]['ID']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4800 t = tags['4321,1012'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4801 self.assertEqual('String', t['Type']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4802 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4803 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4804 self.assertEqual('aaabbbccc', t['Value']) |
236
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4805 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4806 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4807 def test_find_normalize(self): |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4808 # https://groups.google.com/d/msg/orthanc-users/AIwooGjsh94/YL28MNY4AgAJ |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4809 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4810 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4811 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4812 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4813 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4814 'Query' : { 'Rows' : '42' } |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4815 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4816 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4817 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4818 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4819 self.assertFalse('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4820 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4821 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4822 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4823 'Query' : { 'Rows' : '42' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4824 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4825 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4826 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4827 b = DoGet(_REMOTE, '/queries/%s/answers' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4828 self.assertEqual(0, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4829 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4830 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4831 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4832 'Query' : { 'Rows' : '512' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4833 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4834 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4835 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4836 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4837 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4838 self.assertTrue('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4839 self.assertEqual('512', b[0]['Rows']) |
237 | 4840 |
4841 a = DoPost(_REMOTE, '/modalities/self/query', { | |
4842 'Level' : 'Instance', | |
4843 'Query' : { 'Rows' : '' }, | |
4844 'Normalize' : False | |
4845 }) ['ID'] | |
4846 | |
4847 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) | |
4848 self.assertEqual(1, len(b)) | |
4849 self.assertTrue('Rows' in b[0]) | |
4850 self.assertEqual('512', b[0]['Rows']) | |
4851 | |
4852 self.assertRaises(Exception, lambda: DoPost( | |
4853 _REMOTE, '/modalities/self/query', { | |
4854 'Level' : 'Instance', | |
4855 'Query' : { 'Rows' : '*' }, # Out-of-range value | |
4856 'Normalize' : False | |
4857 })) | |
243
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4858 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4859 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4860 def test_bitbucket_issue_141(self): |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4861 # https://bitbucket.org/sjodogne/orthanc/issues/141/ |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4862 a = UploadInstance(_REMOTE, 'Issue141.dcm') ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4863 study = '494c8037-b237f263-d8f15075-c8cb2280-daf39bd1' |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4864 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4865 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4866 pdf = f.read() |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4867 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4868 b = DoPost(_REMOTE, '/tools/create-dicom', { |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4869 'Parent' : study, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4870 'Tags' : {}, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4871 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4872 }) ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4873 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4874 tagsA = DoGet(_REMOTE, '/instances/%s/tags?short' % a) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4875 tagsB = DoGet(_REMOTE, '/instances/%s/tags?short' % b) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4876 self.assertEqual(tagsA['0008,0005'], tagsB['0008,0005']) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4877 self.assertEqual(tagsA['0008,1030'], tagsB['0008,1030']) |
247
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4878 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4879 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4880 def test_modifying_missing_patientid(self): |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4881 # https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4882 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm') |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4883 DoPost(_REMOTE, '/studies/0c4aca1d-c107a241-6659d6aa-594c674a-a468b94a/modify', {}) |
262 | 4884 |
4885 | |
4886 def test_log_level(self): | |
4887 # https://bitbucket.org/sjodogne/orthanc/issues/65/ | |
4888 original = DoGet(_REMOTE, '/tools/log-level') | |
4889 | |
4890 DoPut(_REMOTE, '/tools/log-level', 'default') | |
4891 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level')) | |
4892 DoGet(_REMOTE, '/system') | |
4893 | |
4894 DoPut(_REMOTE, '/tools/log-level', 'verbose') | |
4895 self.assertEqual('verbose', DoGet(_REMOTE, '/tools/log-level')) | |
4896 DoGet(_REMOTE, '/system') | |
4897 | |
4898 DoPut(_REMOTE, '/tools/log-level', 'trace') | |
4899 self.assertEqual('trace', DoGet(_REMOTE, '/tools/log-level')) | |
4900 DoGet(_REMOTE, '/system') | |
4901 | |
4902 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level', 'nope')) | |
4903 | |
4904 # Switch back to the original log level | |
4905 DoPut(_REMOTE, '/tools/log-level', original) | |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4906 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4907 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4908 def test_upload_compressed(self): |
265 | 4909 # New in Orthanc 1.6.0 |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4910 with open(GetDatabasePath('DummyCT.dcm.gz'), 'rb') as f: |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4911 d = f.read() |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4912 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4913 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom')) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4914 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4915 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4916 headers = { 'Content-Encoding' : 'nope' })) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4917 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4918 a = DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4919 headers = { 'Content-Encoding' : 'gzip' }) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4920 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a['ID']) |
262 | 4921 |
4922 | |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4923 def test_study_series_find_inconsistency(self): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4924 # https://groups.google.com/forum/#!topic/orthanc-users/bLv6Z11COy0 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4925 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4926 def CountAnswers(query): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4927 a = DoPost(_REMOTE, 'modalities/self/query', query) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4928 return len(DoGet(_REMOTE, '%s/answers' % a['Path'])) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4929 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4930 # This instance has "SeriesDescription" (0008,103e) tag, but no |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4931 # "ProtocolName" (0018,1030). Both of those tags are part of |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4932 # the "main DICOM tags" of Orthanc. |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4933 UploadInstance(_REMOTE, 'Issue137.dcm') |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4934 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4935 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4936 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4937 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4938 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4939 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4940 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4941 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4942 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4943 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4944 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4945 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4946 ## "SeriesDescription" is present, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4947 ## http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.4.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4948 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4949 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4950 # At the study level, the "SeriesDescription" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4951 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4952 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4953 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4954 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4955 'SeriesDescription' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4956 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4957 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4958 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4959 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4960 # This test fails on Orthanc <= 1.5.8 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4961 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4962 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4963 'SeriesDescription' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4964 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4965 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4966 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4967 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4968 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4969 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4970 'SeriesDescription' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4971 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4972 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4973 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4974 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4975 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4976 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4977 'SeriesDescription' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4978 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4979 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4980 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4981 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4982 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4983 # At the series level, the "SeriesDescription" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4984 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4985 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4986 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4987 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4988 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4989 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4990 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4991 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4992 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4993 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4994 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4995 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4996 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4997 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4998 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4999 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5000 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5001 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5002 'SeriesDescription' : '*' # Wildcard matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5003 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5004 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5005 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5006 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5007 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5008 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5009 'SeriesDescription' : '*model*' # The actual value is "STL model: intraop Report" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5010 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5011 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5012 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5013 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5014 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5015 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5016 'SeriesDescription' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5017 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5018 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5019 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5020 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5021 # Universal matching matches any instance, even if the |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5022 # query is at the study-level, and thus if "SeriesDescription" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5023 # makes no sense |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5024 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5025 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5026 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5027 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5028 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5029 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5030 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5031 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5032 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5033 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5034 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5035 ## "ProtocolName" is absent, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5036 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5037 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5038 # At the study level, the "ProtocolName" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5039 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5040 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5041 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5042 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5043 'ProtocolName' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5044 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5045 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5046 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5047 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5048 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5049 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5050 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5051 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5052 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5053 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5054 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5055 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5056 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5057 'ProtocolName' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5058 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5059 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5060 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5061 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5062 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5063 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5064 'ProtocolName' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5065 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5066 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5067 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5068 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5069 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5070 # At the series level, the "ProtocolName" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5071 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5072 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5073 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5074 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5075 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5076 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5077 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5078 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5079 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5080 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5081 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5082 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5083 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5084 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5085 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5086 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5087 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5088 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5089 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5090 'ProtocolName' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5091 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5092 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5093 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5094 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5095 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5096 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5097 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5098 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5099 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5100 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5101 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5102 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5103 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5104 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5105 ## "StudyInstanceUID" is present, and has VR "UI" => wildcard is not allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5106 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5107 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5108 for level in [ 'Study', 'Series' ] : |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5109 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5110 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5111 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5112 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5113 'StudyInstanceUID' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5114 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5115 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5116 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5117 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5118 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5119 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5120 'StudyInstanceUID' : 'MISMATCHED^VALUE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5121 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5122 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5123 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5124 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5125 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5126 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5127 'StudyInstanceUID' : '4.5.6' # This is the actual value |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5128 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5129 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5130 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5131 |
269 | 5132 # Wildcard matching is not allowed for this VR |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5133 # This test fails on Orthanc <= 1.5.8 |
269 | 5134 self.assertRaises(Exception, lambda: CountAnswers({ |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5135 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5136 'Query' : { |
269 | 5137 'StudyInstanceUID' : '*' |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5138 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5139 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5140 })) |
265 | 5141 |
5142 | |
5143 def test_rendered(self): | |
5144 # New in Orthanc 1.6.0 | |
5145 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
5146 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5147 self.assertEqual("RGB", im.mode) | |
5148 self.assertEqual(41, im.size[0]) | |
5149 self.assertEqual(41, im.size[1]) | |
5150 | |
5151 # http://effbot.org/zone/pil-comparing-images.htm | |
5152 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) | |
5153 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) | |
5154 | |
5155 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10' % i) | |
5156 self.assertEqual("RGB", im.mode) | |
5157 self.assertEqual(10, im.size[0]) | |
5158 self.assertEqual(10, im.size[1]) | |
5159 | |
5160 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10' % i) | |
5161 self.assertEqual("RGB", im.mode) | |
5162 self.assertEqual(10, im.size[0]) | |
5163 self.assertEqual(10, im.size[1]) | |
5164 | |
5165 im = GetImage(_REMOTE, '/instances/%s/rendered?height=128' % i) | |
5166 self.assertEqual("RGB", im.mode) | |
5167 self.assertEqual(128, im.size[0]) | |
5168 self.assertEqual(128, im.size[1]) | |
5169 | |
5170 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=0' % i) | |
5171 self.assertEqual("RGB", im.mode) | |
5172 self.assertEqual(10, im.size[0]) | |
5173 self.assertEqual(10, im.size[1]) | |
5174 | |
5175 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=1' % i) | |
5176 self.assertEqual("RGB", im.mode) | |
5177 self.assertEqual(10, im.size[0]) | |
5178 self.assertEqual(10, im.size[1]) | |
5179 | |
5180 im = GetImage(_REMOTE, '/instances/%s/rendered?height=5&width=10' % i) | |
5181 self.assertEqual("RGB", im.mode) | |
5182 self.assertEqual(5, im.size[0]) | |
5183 self.assertEqual(5, im.size[1]) | |
5184 | |
5185 | |
5186 # Grayscale image | |
5187 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
5188 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5189 self.assertEqual("L", im.mode) | |
5190 self.assertEqual(288, im.size[0]) | |
5191 self.assertEqual(288, im.size[1]) | |
5192 self.assertEqual(0, im.getpixel((0, 0))) | |
5193 | |
5194 # Those are the original windowing parameters that are written | |
5195 # inside the DICOM file | |
5196 im2 = GetImage(_REMOTE, '/instances/%s/rendered?window-center=248.009544468547&window-width=431.351843817788' % i) | |
5197 self.assertEqual("L", im2.mode) | |
5198 self.assertEqual(288, im2.size[0]) | |
5199 self.assertEqual(288, im2.size[1]) | |
5200 self.assertTrue(ImageChops.difference(im, im2).getbbox() is None) | |
5201 | |
5202 im = GetImage(_REMOTE, '/instances/%s/rendered?width=512&smooth=0' % i) | |
5203 self.assertEqual("L", im.mode) | |
5204 self.assertEqual(512, im.size[0]) | |
5205 self.assertEqual(512, im.size[1]) | |
5206 | |
5207 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=0' % i) | |
5208 self.assertEqual("L", im.mode) | |
5209 self.assertEqual(10, im.size[0]) | |
5210 self.assertEqual(10, im.size[1]) | |
5211 | |
5212 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=1' % i) | |
5213 self.assertEqual("L", im.mode) | |
5214 self.assertEqual(10, im.size[0]) | |
5215 self.assertEqual(10, im.size[1]) | |
5216 | |
5217 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=-1000' % i) | |
5218 self.assertEqual("L", im.mode) | |
5219 self.assertEqual(1, im.size[0]) | |
5220 self.assertEqual(1, im.size[1]) | |
5221 self.assertEqual(255, im.getpixel((0, 0))) | |
5222 | |
5223 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=1000' % i) | |
5224 self.assertEqual("L", im.mode) | |
5225 self.assertEqual(1, im.size[0]) | |
5226 self.assertEqual(1, im.size[1]) | |
5227 self.assertEqual(0, im.getpixel((0, 0))) | |
5228 | |
5229 | |
5230 # Test monochrome 1 | |
5231 i = UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm')['ID'] | |
5232 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5233 self.assertEqual("L", im.mode) | |
5234 self.assertEqual(2010, im.size[0]) | |
5235 self.assertEqual(2446, im.size[1]) | |
5236 self.assertEqual(0, im.getpixel((0, 0))) | |
5237 im = GetImage(_REMOTE, '/instances/%s/rendered?width=20' % i) | |
5238 self.assertEqual("L", im.mode) | |
5239 self.assertEqual(20, im.size[0]) | |
5240 self.assertEqual(24, im.size[1]) | |
5241 im = GetImage(_REMOTE, '/instances/%s/rendered?height=24' % i) | |
5242 self.assertEqual("L", im.mode) | |
5243 self.assertEqual(20, im.size[0]) | |
5244 self.assertEqual(24, im.size[1]) | |
5245 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&height=24' % i) | |
5246 self.assertEqual("L", im.mode) | |
5247 self.assertEqual(10, im.size[0]) | |
5248 self.assertEqual(12, im.size[1]) | |
5249 im = GetImage(_REMOTE, '/instances/%s/rendered?width=40&height=24' % i) | |
5250 self.assertEqual("L", im.mode) | |
5251 self.assertEqual(20, im.size[0]) | |
5252 self.assertEqual(24, im.size[1]) | |
268
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5253 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5254 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5255 def test_bitbucket_issue_154(self): |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5256 # "Matching against list of UID-s by C-MOVE" |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5257 # https://bitbucket.org/sjodogne/orthanc/issues/154/ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5258 a = UploadInstance(_REMOTE, 'Issue154-d1.dcm') ['ID'] |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5259 b = UploadInstance(_REMOTE, 'Issue154-d2.dcm') ['ID'] |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5260 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5261 study = '1.2.826.0.1.3680043.8.498.35214236271657363033644818354280454731' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5262 series1 = '1.2.826.0.1.3680043.8.498.12243321927795467590791662266352305113' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5263 series2 = '1.2.826.0.1.3680043.8.498.43769499931624584079690260699536473555' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5264 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5265 # C-FIND is working on list of UIDs |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5266 i = CallFindScu([ '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5267 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5268 '-k', 'SeriesInstanceUID=%s\\%s' % (series1, series2) ]) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5269 series = re.findall('\(0020,000e\).*?\[(.*?)\]', i) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5270 self.assertEqual(2, len(series)) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5271 self.assertTrue(series1 in series) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5272 self.assertTrue(series2 in series) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5273 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5274 # Individual retrieval is working in Orthanc < 1.6.0 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5275 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5276 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5277 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5278 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5279 '-k', 'SeriesInstanceUID=%s' % series1, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5280 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5281 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5282 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5283 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5284 '-k', 'SeriesInstanceUID=%s' % series2, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5285 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5286 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5287 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5288 DropOrthanc(_LOCAL) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5289 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5290 # But list matching is working only in Orthanc >= 1.6.0 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5291 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5292 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5293 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5294 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5295 '-k', 'SeriesInstanceUID=%s\\%s' % (series1, series2), |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5296 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5297 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5298 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5299 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5300 def test_storage_commitment_api(self): |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5301 # Storage commitment is available since Orthanc 1.6.0 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5302 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5303 def WaitTransaction(uid): |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5304 while True: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5305 s = DoGet(_REMOTE, '/storage-commitment/%s' % uid) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5306 if s['Status'] != 'Pending': |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5307 return s |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5308 else: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5309 time.sleep(0.1) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5310 |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5311 UploadInstance(_REMOTE, 'DummyCT.dcm') |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5312 sopClassUid = '1.2.840.10008.5.1.4.1.1.4' |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5313 sopInstanceUid = '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5314 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5315 # Against self |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5316 transaction = DoPost(_REMOTE, '/modalities/self/storage-commitment', [ |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5317 [ sopClassUid, sopInstanceUid ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5318 ]) ['ID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5319 self.assertTrue(transaction.startswith('2.25.')) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5320 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5321 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5322 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5323 self.assertEqual('Success', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5324 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5325 self.assertEqual(0, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5326 self.assertEqual(sopClassUid, result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5327 self.assertEqual(sopInstanceUid, result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5328 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5329 tmp = DoPost(_REMOTE, '/modalities/self/storage-commitment', [ |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5330 { 'SOPClassUID' : sopClassUid, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5331 'SOPInstanceUID' : sopInstanceUid }, |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5332 ]) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5333 self.assertEqual(tmp['Path'], '/storage-commitment/%s' % tmp['ID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5334 self.assertEqual(result, WaitTransaction(transaction)) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5335 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5336 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5337 transaction = DoPost(_REMOTE, '/modalities/self/storage-commitment', [ |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5338 [ 'nope', 'nope2' ], |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5339 [ sopClassUid, sopInstanceUid ], |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5340 ]) ['ID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5341 self.assertTrue(transaction.startswith('2.25.')) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5342 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5343 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5344 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5345 self.assertEqual('Failure', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5346 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5347 self.assertEqual(1, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5348 self.assertEqual(sopClassUid, result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5349 self.assertEqual(sopInstanceUid, result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5350 self.assertEqual('nope', result['Failures'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5351 self.assertEqual('nope2', result['Failures'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5352 self.assertEqual(274, result['Failures'][0]['FailureReason']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5353 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5354 # Cannot remove items from a failed storage commitment transaction |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5355 self.assertRaises(Exception, lambda: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5356 DoPost(_REMOTE, '/storage-commitment/%s/remove' % transaction)) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5357 |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5358 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5359 # Against Orthanc 0.8.6, that does not support storage commitment |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5360 self.assertRaises(Exception, lambda: |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5361 DoPost(_REMOTE, '/modalities/orthanctest/storage-commitment', [ |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5362 [ sopClassUid, sopInstanceUid ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5363 ])) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5364 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5365 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5366 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5367 def test_storage_commitment_store(self): |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5368 # Storage commitment is available since Orthanc 1.6.0 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5369 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5370 def WaitTransaction(uid): |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5371 while True: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5372 s = DoGet(_REMOTE, '/storage-commitment/%s' % uid) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5373 if s['Status'] != 'Pending': |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5374 return s |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5375 else: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5376 time.sleep(0.1) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5377 |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5378 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5379 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5380 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5381 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5382 # The Orthanc 0.8.6 from "_LOCAL" does not support storage commitment |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5383 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/orthanctest/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5384 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5385 'StorageCommitment' : True, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5386 })) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5387 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5388 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5389 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5390 'StorageCommitment' : False, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5391 }) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5392 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5393 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5394 j = DoPost(_REMOTE, '/modalities/self/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5395 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5396 'StorageCommitment' : True, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5397 }) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5398 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5399 transaction = j['StorageCommitmentTransactionUID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5400 self.assertTrue(transaction.startswith('2.25.')) |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5401 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5402 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5403 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5404 self.assertEqual('Success', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5405 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5406 self.assertEqual(0, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5407 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5408 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5409 result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5410 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5411 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5412 DoPost(_REMOTE, '/storage-commitment/%s/remove' % transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5413 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |