Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 718:e1b7654fb58d attach-custom-data tip
merged find-refactoring -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Wed, 09 Oct 2024 11:07:09 +0200 |
parents | f2d3d7c701ec |
children |
comparison
equal
deleted
inserted
replaced
705:beb7bd0fdf47 | 718:e1b7654fb58d |
---|---|
8089 tags2021b = GetTags(study, { 'DicomVersion' : '2021b' }) | 8089 tags2021b = GetTags(study, { 'DicomVersion' : '2021b' }) |
8090 tags2023b = GetTags(study, { 'DicomVersion' : '2023b' }) | 8090 tags2023b = GetTags(study, { 'DicomVersion' : '2023b' }) |
8091 tagsDefault = GetTags(study, {}) | 8091 tagsDefault = GetTags(study, {}) |
8092 | 8092 |
8093 orthancVersion = DoGet(_REMOTE, '/system') ['Version'] | 8093 orthancVersion = DoGet(_REMOTE, '/system') ['Version'] |
8094 if orthancVersion.startswith('mainline-'): # happens in unstable orthancteam/orthanc images | |
8095 orthancVersion = 'mainline' | |
8096 | |
8094 self.assertEqual('Orthanc %s - PS 3.15-2008 Table E.1-1' % orthancVersion, tags2008['0012,0063']) | 8097 self.assertEqual('Orthanc %s - PS 3.15-2008 Table E.1-1' % orthancVersion, tags2008['0012,0063']) |
8095 self.assertEqual('Orthanc %s - PS 3.15-2017c Table E.1-1 Basic Profile' % orthancVersion, tags2017c['0012,0063']) | 8098 self.assertEqual('Orthanc %s - PS 3.15-2017c Table E.1-1 Basic Profile' % orthancVersion, tags2017c['0012,0063']) |
8096 self.assertEqual('Orthanc %s - PS 3.15-2021b Table E.1-1 Basic Profile' % orthancVersion, tags2021b['0012,0063']) | 8099 self.assertEqual('Orthanc %s - PS 3.15-2021b Table E.1-1 Basic Profile' % orthancVersion, tags2021b['0012,0063']) |
8097 self.assertEqual('Orthanc %s - PS 3.15-2023b Table E.1-1 Basic Profile' % orthancVersion, tags2023b['0012,0063']) | 8100 self.assertEqual('Orthanc %s - PS 3.15-2023b Table E.1-1 Basic Profile' % orthancVersion, tags2023b['0012,0063']) |
8098 self.assertEqual(tagsDefault['0012,0063'], tags2023b['0012,0063']) | 8101 self.assertEqual(tagsDefault['0012,0063'], tags2023b['0012,0063']) |
10779 self.assertEqual(4, len(a[0]['RequestedTags'].keys())) | 10782 self.assertEqual(4, len(a[0]['RequestedTags'].keys())) |
10780 self.assertEqual(1, int(a[0]['RequestedTags']['NumberOfStudyRelatedSeries'])) | 10783 self.assertEqual(1, int(a[0]['RequestedTags']['NumberOfStudyRelatedSeries'])) |
10781 self.assertEqual(1, int(a[0]['RequestedTags']['NumberOfStudyRelatedInstances'])) | 10784 self.assertEqual(1, int(a[0]['RequestedTags']['NumberOfStudyRelatedInstances'])) |
10782 self.assertEqual('CT', a[0]['RequestedTags']['ModalitiesInStudy']) | 10785 self.assertEqual('CT', a[0]['RequestedTags']['ModalitiesInStudy']) |
10783 self.assertEqual('', a[0]['RequestedTags']['PatientComments']) | 10786 self.assertEqual('', a[0]['RequestedTags']['PatientComments']) |
10787 | |
10788 | |
10789 def test_extended_find_order_by(self): | |
10790 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
10791 | |
10792 # Upload 12 instances | |
10793 for i in range(3): | |
10794 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
10795 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
10796 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
10797 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
10798 | |
10799 kneeT2SeriesId = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
10800 kneeT1SeriesId = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
10801 brainixFlairSeriesId = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
10802 brainixEpiSeriesId = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
10803 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT2SeriesId, 'kneeT2') | |
10804 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT1SeriesId, 'kneeT1') | |
10805 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixFlairSeriesId, 'brainixFlair') | |
10806 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixEpiSeriesId, 'brainixEpi') | |
10807 | |
10808 # order by resource tag | |
10809 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
10810 'Expand': True, | |
10811 'Query' : { | |
10812 'PatientName' : '*' | |
10813 }, | |
10814 'OrderBy' : [ | |
10815 { | |
10816 'Type': 'DicomTag', | |
10817 'Key': 'PatientName', | |
10818 'Direction': 'ASC' | |
10819 } | |
10820 ] | |
10821 }) | |
10822 self.assertEqual(2, len(a)) | |
10823 self.assertEqual("BRAINIX", a[0]['PatientMainDicomTags']['PatientName']) | |
10824 | |
10825 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
10826 'Expand': True, | |
10827 'Query' : { | |
10828 'PatientName' : '*' | |
10829 }, | |
10830 'OrderBy' : [ | |
10831 { | |
10832 'Type': 'DicomTag', | |
10833 'Key': 'PatientName', | |
10834 'Direction': 'DESC' | |
10835 } | |
10836 ] | |
10837 }) | |
10838 | |
10839 self.assertEqual("BRAINIX", a[1]['PatientMainDicomTags']['PatientName']) | |
10840 | |
10841 # order by parent tag | |
10842 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
10843 'Expand': False, | |
10844 'Query' : { | |
10845 'SeriesDescription' : '*' | |
10846 }, | |
10847 'OrderBy' : [ | |
10848 { | |
10849 'Type': 'DicomTag', | |
10850 'Key': 'StudyDate', | |
10851 'Direction': 'ASC' | |
10852 } | |
10853 ] | |
10854 }) | |
10855 # knee StudyDate = 20080819 | |
10856 # brainix StudyDate = 20061201 | |
10857 self.assertEqual(4, len(a)) | |
10858 self.assertTrue(a[0] == brainixEpiSeriesId or a[0] == brainixFlairSeriesId) | |
10859 self.assertTrue(a[3] == kneeT1SeriesId or a[3] == kneeT2SeriesId) | |
10860 | |
10861 # order by parent tag and resource tag | |
10862 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
10863 'Expand': False, | |
10864 'Query' : { | |
10865 'SeriesDescription' : '*' | |
10866 }, | |
10867 'OrderBy' : [ | |
10868 { | |
10869 'Type': 'DicomTag', | |
10870 'Key': 'StudyDate', | |
10871 'Direction': 'ASC' | |
10872 }, | |
10873 { | |
10874 'Type': 'DicomTag', | |
10875 'Key': 'SeriesTime', | |
10876 'Direction': 'ASC' | |
10877 } | |
10878 ] | |
10879 }) | |
10880 # knee StudyDate = 20080819 | |
10881 # brainix StudyDate = 20061201 | |
10882 self.assertEqual(4, len(a)) | |
10883 self.assertEqual(brainixFlairSeriesId, a[0]) | |
10884 self.assertEqual(brainixEpiSeriesId, a[1]) | |
10885 self.assertEqual(kneeT1SeriesId, a[2]) | |
10886 self.assertEqual(kneeT2SeriesId, a[3]) | |
10887 | |
10888 # order by grandparent tag and resource tag | |
10889 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
10890 'Expand': False, | |
10891 'Query' : { | |
10892 'SeriesDescription' : '*' | |
10893 }, | |
10894 'OrderBy' : [ | |
10895 { | |
10896 'Type': 'DicomTag', | |
10897 'Key': 'PatientBirthDate', | |
10898 'Direction': 'ASC' | |
10899 }, | |
10900 { | |
10901 'Type': 'DicomTag', | |
10902 'Key': 'SeriesTime', | |
10903 'Direction': 'ASC' | |
10904 } | |
10905 ] | |
10906 }) | |
10907 # knee PatientBirthDate = 20080822 | |
10908 # brainix PatientBirthDate = 19490301 | |
10909 self.assertEqual(4, len(a)) | |
10910 self.assertEqual(brainixFlairSeriesId, a[0]) | |
10911 self.assertEqual(brainixEpiSeriesId, a[1]) | |
10912 self.assertEqual(kneeT1SeriesId, a[2]) | |
10913 self.assertEqual(kneeT2SeriesId, a[3]) | |
10914 | |
10915 # order by grandgrandparent tag and resource tag | |
10916 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
10917 'Expand': True, | |
10918 'Query' : { | |
10919 }, | |
10920 'OrderBy' : [ | |
10921 { | |
10922 'Type': 'DicomTag', | |
10923 'Key': 'PatientBirthDate', | |
10924 'Direction': 'ASC' | |
10925 }, | |
10926 { | |
10927 'Type': 'DicomTag', | |
10928 'Key': 'InstanceNumber', | |
10929 'Direction': 'ASC' | |
10930 }, | |
10931 { | |
10932 'Type': 'DicomTag', | |
10933 'Key': 'SeriesTime', | |
10934 'Direction': 'ASC' | |
10935 } | |
10936 ], | |
10937 'RequestedTags' : ['PatientBirthDate', 'InstanceNumber', 'SeriesTime'] | |
10938 }) | |
10939 self.assertEqual(12, len(a)) | |
10940 for i in range(1, len(a)-1): | |
10941 self.assertTrue(a[i-1]['RequestedTags']['PatientBirthDate'] <= a[i]['RequestedTags']['PatientBirthDate']) | |
10942 if a[i-1]['RequestedTags']['PatientBirthDate'] == a[i]['RequestedTags']['PatientBirthDate']: | |
10943 self.assertTrue(a[i-1]['RequestedTags']['InstanceNumber'] <= a[i]['RequestedTags']['InstanceNumber']) | |
10944 if a[i-1]['RequestedTags']['InstanceNumber'] == a[i]['RequestedTags']['InstanceNumber']: | |
10945 self.assertTrue(a[i-1]['RequestedTags']['SeriesTime'] <= a[i]['RequestedTags']['SeriesTime']) | |
10946 | |
10947 # order by grandgrandparent tag and resource tag (2) | |
10948 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
10949 'Expand': True, | |
10950 'Query' : { | |
10951 }, | |
10952 'OrderBy' : [ | |
10953 { | |
10954 'Type': 'DicomTag', | |
10955 'Key': 'InstanceNumber', | |
10956 'Direction': 'DESC' | |
10957 }, | |
10958 { | |
10959 'Type': 'DicomTag', | |
10960 'Key': 'PatientBirthDate', | |
10961 'Direction': 'ASC' | |
10962 }, | |
10963 { | |
10964 'Type': 'DicomTag', | |
10965 'Key': 'SeriesTime', | |
10966 'Direction': 'ASC' | |
10967 } | |
10968 ], | |
10969 'RequestedTags' : ['InstanceNumber', 'PatientBirthDate', 'SeriesTime' ] | |
10970 }) | |
10971 self.assertEqual(12, len(a)) | |
10972 for i in range(1, len(a)-1): | |
10973 self.assertTrue(a[i-1]['RequestedTags']['InstanceNumber'] >= a[i]['RequestedTags']['InstanceNumber']) | |
10974 if a[i-1]['RequestedTags']['InstanceNumber'] == a[i]['RequestedTags']['InstanceNumber']: | |
10975 self.assertTrue(a[i-1]['RequestedTags']['PatientBirthDate'] <= a[i]['RequestedTags']['PatientBirthDate']) | |
10976 if a[i-1]['RequestedTags']['PatientBirthDate'] == a[i]['RequestedTags']['PatientBirthDate']: | |
10977 self.assertTrue(a[i-1]['RequestedTags']['SeriesTime'] <= a[i]['RequestedTags']['SeriesTime']) | |
10978 | |
10979 # order by resource tag on a tag that is missing in one of the resources -> it should be listed | |
10980 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
10981 'Expand': False, | |
10982 'Query' : { | |
10983 }, | |
10984 | |
10985 'OrderBy' : [ | |
10986 { | |
10987 'Type': 'DicomTag', | |
10988 'Key': 'BodyPartExamined', # in Knee but not in Brainix => Brainix is last because NULL are pushed at the end | |
10989 'Direction': 'ASC' | |
10990 } | |
10991 ] | |
10992 }) | |
10993 self.assertTrue(a[0] == kneeT1SeriesId or a[0] == kneeT2SeriesId) | |
10994 self.assertTrue(a[3] == brainixEpiSeriesId or a[3] == brainixFlairSeriesId) | |
10995 | |
10996 # order by metadata | |
10997 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
10998 'Query' : { | |
10999 'SeriesDescription' : '*' | |
11000 }, | |
11001 'OrderBy' : [ | |
11002 { | |
11003 'Type': 'Metadata', | |
11004 'Key': 'my-metadata', | |
11005 'Direction': 'ASC' | |
11006 } | |
11007 ] | |
11008 }) | |
11009 self.assertEqual(brainixEpiSeriesId, a[0]) | |
11010 self.assertEqual(brainixFlairSeriesId, a[1]) | |
11011 self.assertEqual(kneeT1SeriesId, a[2]) | |
11012 self.assertEqual(kneeT2SeriesId, a[3]) | |
11013 | |
11014 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11015 'Query' : { | |
11016 'SeriesDescription' : '*' | |
11017 }, | |
11018 'OrderBy' : [ | |
11019 { | |
11020 'Type': 'Metadata', | |
11021 'Key': 'my-metadata', | |
11022 'Direction': 'DESC' | |
11023 } | |
11024 ] | |
11025 }) | |
11026 self.assertEqual(brainixEpiSeriesId, a[3]) | |
11027 self.assertEqual(brainixFlairSeriesId, a[2]) | |
11028 self.assertEqual(kneeT1SeriesId, a[1]) | |
11029 self.assertEqual(kneeT2SeriesId, a[0]) | |
11030 | |
11031 # combined ordering (DicomTag + metadata) | |
11032 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11033 'Query' : { | |
11034 'SeriesDescription' : '*' | |
11035 }, | |
11036 'OrderBy' : [ | |
11037 { | |
11038 'Type': 'DicomTag', | |
11039 'Key': 'PatientName', | |
11040 'Direction': 'ASC' | |
11041 }, | |
11042 { | |
11043 'Type': 'Metadata', | |
11044 'Key': 'my-metadata', | |
11045 'Direction': 'DESC' | |
11046 } | |
11047 ] | |
11048 }) | |
11049 self.assertEqual(brainixFlairSeriesId, a[0]) | |
11050 self.assertEqual(brainixEpiSeriesId, a[1]) | |
11051 self.assertEqual(kneeT2SeriesId, a[2]) | |
11052 self.assertEqual(kneeT1SeriesId, a[3]) | |
11053 | |
11054 | |
11055 def test_extended_find_parent(self): | |
11056 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
11057 # Upload 12 instances | |
11058 for i in range(3): | |
11059 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
11060 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
11061 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
11062 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
11063 | |
11064 kneeT2SeriesId = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
11065 kneeT1SeriesId = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
11066 kneeStudyId = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
11067 kneePatientId = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
11068 | |
11069 # retrieve only the series from a study | |
11070 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11071 'Query' : { | |
11072 'SeriesDescription' : 'T*' | |
11073 }, | |
11074 'ParentStudy' : kneeStudyId | |
11075 }) | |
11076 | |
11077 self.assertEqual(2, len(a)) | |
11078 self.assertTrue(a[0] == kneeT1SeriesId or a[0] == kneeT2SeriesId) | |
11079 | |
11080 # retrieve only the series from a patient | |
11081 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11082 'Query' : { | |
11083 'SeriesDescription' : 'T*' | |
11084 }, | |
11085 'ParentPatient' : kneePatientId | |
11086 }) | |
11087 | |
11088 self.assertEqual(2, len(a)) | |
11089 self.assertTrue(a[0] == kneeT1SeriesId or a[0] == kneeT2SeriesId) | |
11090 | |
11091 # retrieve only the instances from a patient | |
11092 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
11093 'Query' : { | |
11094 'SeriesDescription' : 'T*' | |
11095 }, | |
11096 'ParentPatient' : kneePatientId | |
11097 }) | |
11098 | |
11099 self.assertEqual(6, len(a)) | |
11100 | |
11101 | |
11102 def test_extended_find_filter_metadata(self): | |
11103 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
11104 | |
11105 # Upload 12 instances | |
11106 for i in range(3): | |
11107 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
11108 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
11109 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
11110 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
11111 | |
11112 kneeT2SeriesId = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
11113 kneeT1SeriesId = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
11114 brainixFlairSeriesId = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
11115 brainixEpiSeriesId = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
11116 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT2SeriesId, 'kneeT2') | |
11117 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT1SeriesId, 'kneeT1') | |
11118 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixFlairSeriesId, 'brainixFlair') | |
11119 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixEpiSeriesId, 'brainixEpi') | |
11120 | |
11121 # filter on metadata | |
11122 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11123 'Query' : { | |
11124 'SeriesDescription' : 'T*' | |
11125 }, | |
11126 'QueryMetadata' : { | |
11127 'my-metadata': '*2*' | |
11128 } | |
11129 }) | |
11130 | |
11131 self.assertEqual(1, len(a)) | |
11132 self.assertEqual(kneeT2SeriesId, a[0]) | |
11133 | |
11134 def test_extended_find_expand(self): | |
11135 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
11136 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
11137 | |
11138 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11139 'Query' : { | |
11140 'SeriesDescription' : 'T*' | |
11141 }, | |
11142 'Expand': True, | |
11143 'RequestedTags': ['StudyDate'] | |
11144 }) | |
11145 | |
11146 # backward compat for Expand = True | |
11147 self.assertIn('ExpectedNumberOfInstances', a[0]) | |
11148 self.assertIn('ID', a[0]) | |
11149 self.assertIn('Instances', a[0]) | |
11150 self.assertIn('Labels', a[0]) | |
11151 self.assertIn('LastUpdate', a[0]) | |
11152 self.assertIn('MainDicomTags', a[0]) | |
11153 self.assertIn('ParentStudy', a[0]) | |
11154 self.assertIn('RequestedTags', a[0]) | |
11155 self.assertIn('Status', a[0]) | |
11156 self.assertIn('Type', a[0]) | |
11157 self.assertIn('IsStable', a[0]) | |
11158 self.assertNotIn('Attachments', a[0]) | |
11159 self.assertNotIn('Metadata', a[0]) | |
11160 | |
11161 | |
11162 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11163 'Query' : { | |
11164 'SeriesDescription' : 'T*' | |
11165 }, | |
11166 'ResponseContent': ["MainDicomTags"], | |
11167 'RequestedTags': ['StudyDate'] | |
11168 }) | |
11169 | |
11170 self.assertIn('ID', a[0]) # the ID is always in the response | |
11171 self.assertIn('Type', a[0]) # the Type is always in the response | |
11172 self.assertIn('RequestedTags', a[0]) # the RequestedTags are always in the response as soon as you have requested them | |
11173 self.assertIn('MainDicomTags', a[0]) | |
11174 self.assertNotIn('ExpectedNumberOfInstances', a[0]) | |
11175 self.assertNotIn('Instances', a[0]) | |
11176 self.assertNotIn('Labels', a[0]) | |
11177 self.assertNotIn('LastUpdate', a[0]) | |
11178 self.assertNotIn('ParentStudy', a[0]) | |
11179 self.assertNotIn('Status', a[0]) | |
11180 self.assertNotIn('IsStable', a[0]) | |
11181 self.assertNotIn('Attachments', a[0]) | |
11182 self.assertNotIn('Metadata', a[0]) | |
11183 | |
11184 | |
11185 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11186 'Query' : { | |
11187 'SeriesDescription' : 'T*' | |
11188 }, | |
11189 'ResponseContent': ["MainDicomTags", "Children", "Parent", "IsStable", "Status", "Labels", "Metadata"], | |
11190 'RequestedTags': ['StudyDate'] | |
11191 }) | |
11192 | |
11193 self.assertIn('ID', a[0]) # the ID is always in the response | |
11194 self.assertIn('Type', a[0]) # the Type is always in the response | |
11195 self.assertIn('RequestedTags', a[0]) # the RequestedTags are always in the response as soon as you have requested them | |
11196 self.assertIn('MainDicomTags', a[0]) | |
11197 self.assertIn('Metadata', a[0]) | |
11198 self.assertIn('LastUpdate', a[0]['Metadata']) | |
11199 self.assertIn('Instances', a[0]) | |
11200 self.assertIn('Labels', a[0]) | |
11201 self.assertIn('ParentStudy', a[0]) | |
11202 self.assertIn('Status', a[0]) | |
11203 self.assertIn('IsStable', a[0]) | |
11204 self.assertNotIn('Attachments', a[0]) | |
11205 | |
11206 | |
11207 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instances', | |
11208 'Query' : { | |
11209 'SeriesDescription' : 'T*' | |
11210 }, | |
11211 'Expand': True, | |
11212 'RequestedTags': ['StudyDate'] | |
11213 }) | |
11214 | |
11215 # backward compat for Expand = True at instance level | |
11216 self.assertIn('ID', a[0]) # the ID is always in the response | |
11217 self.assertIn('Type', a[0]) # the Type is always in the response | |
11218 self.assertIn('RequestedTags', a[0]) # the RequestedTags are always in the response as soon as you have requested them | |
11219 self.assertIn('FileSize', a[0]) | |
11220 self.assertIn('FileUuid', a[0]) | |
11221 self.assertIn('IndexInSeries', a[0]) | |
11222 self.assertIn('ParentSeries', a[0]) | |
11223 self.assertIn('Labels', a[0]) | |
11224 self.assertNotIn('Attachments', a[0]) | |
11225 self.assertNotIn('Metadata', a[0]) | |
11226 | |
11227 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instances', | |
11228 'Query' : { | |
11229 'SeriesDescription' : 'T*' | |
11230 }, | |
11231 'ResponseContent' : ['Attachments'], | |
11232 'RequestedTags': ['StudyDate'] | |
11233 }) | |
11234 | |
11235 self.assertIn('ID', a[0]) # the ID is always in the response | |
11236 self.assertIn('Type', a[0]) # the Type is always in the response | |
11237 self.assertIn('RequestedTags', a[0]) # the RequestedTags are always in the response as soon as you have requested them | |
11238 self.assertIn('Attachments', a[0]) | |
11239 self.assertIn('Uuid', a[0]['Attachments'][0]) | |
11240 self.assertIn('UncompressedSize', a[0]['Attachments'][0]) | |
11241 | |
11242 | |
11243 # 'internal check': make sure we get the SOPClassUID even when we do not request the Metadata | |
11244 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instances', | |
11245 'Query' : { | |
11246 'SeriesDescription' : 'T*' | |
11247 }, | |
11248 'ResponseContent' : [], | |
11249 'RequestedTags': ['SOPClassUID'] | |
11250 }) | |
11251 | |
11252 self.assertIn('ID', a[0]) # the ID is always in the response | |
11253 self.assertIn('Type', a[0]) # the Type is always in the response | |
11254 self.assertIn('RequestedTags', a[0]) # the RequestedTags are always in the response as soon as you have requested them | |
11255 self.assertIn('SOPClassUID', a[0]['RequestedTags']) | |
11256 | |
11257 | |
11258 def test_extended_find_full(self): | |
11259 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
11260 | |
11261 # Upload 12 instances | |
11262 for i in range(3): | |
11263 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
11264 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
11265 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
11266 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
11267 | |
11268 kneeT2SeriesId = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
11269 kneeT1SeriesId = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
11270 brainixFlairSeriesId = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
11271 brainixEpiSeriesId = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
11272 kneeStudyId = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
11273 kneePatientId = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
11274 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT2SeriesId, 'kneeT2') | |
11275 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % kneeT1SeriesId, 'kneeT1') | |
11276 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixFlairSeriesId, 'brainixFlair') | |
11277 DoPut(_REMOTE, '/series/%s/metadata/my-metadata' % brainixEpiSeriesId, 'brainixEpi') | |
11278 | |
11279 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
11280 'Query' : { | |
11281 'PatientName' : '*' | |
11282 }, | |
11283 'RequestedTags': ['StudyDate'], | |
11284 'QueryMetadata' : { | |
11285 'my-metadata': "*nee*" | |
11286 }, | |
11287 'OrderBy' : [ | |
11288 { | |
11289 'Type': 'DicomTag', | |
11290 'Key': 'SeriesDescription', | |
11291 'Direction': 'ASC' | |
11292 }, | |
11293 { | |
11294 'Type': 'Metadata', | |
11295 'Key': 'my-metadata', | |
11296 'Direction': 'DESC' | |
11297 } | |
11298 ], | |
11299 'ParentPatient': kneePatientId, | |
11300 'ResponseContent' : ['Parent', 'Children', 'MainDicomTags', 'Metadata'] | |
11301 }) | |
11302 | |
11303 self.assertEqual(2, len(a)) | |
11304 self.assertEqual(kneeT1SeriesId, a[0]['ID']) | |
11305 self.assertEqual(kneeT2SeriesId, a[1]['ID']) | |
11306 self.assertEqual(kneeStudyId, a[0]['ParentStudy']) | |
11307 self.assertEqual(3, len(a[0]['Instances'])) | |
11308 self.assertEqual('', a[0]['Metadata']['RemoteAET']) |