# HG changeset patch # User Sebastien Jodogne # Date 1715247018 -7200 # Node ID 0daf680aa3ccb6f052de76b8abd461fadb3e5154 # Parent aa11ab24ff3cf38d467dd50d31ce7f5248613dfd added test_requested_tags diff -r aa11ab24ff3c -r 0daf680aa3cc Tests/Tests.py --- a/Tests/Tests.py Thu Apr 11 19:03:42 2024 +0200 +++ b/Tests/Tests.py Thu May 09 11:30:18 2024 +0200 @@ -9465,7 +9465,6 @@ a = UploadInstance(_REMOTE, '2023-04-21-RLEPlanarConfigurationYBR_FULL.dcm') ['ID'] uri = '/instances/%s/preview' % a im = GetImage(_REMOTE, uri) - pprint.pprint(im) self.assertEqual('RGB', im.mode) self.assertEqual(1260, im.size[0]) self.assertEqual(910, im.size[1]) @@ -10149,3 +10148,142 @@ # print(i) s = re.findall('\(0008,0000\).*?\[(.*?)\]', i) self.assertEqual(0, len(s)) + + def test_requested_tags(self): + u = UploadInstance(_REMOTE, 'DummyCT.dcm') + + def CheckPatientContent(patient): + self.assertEqual(u['ParentPatient'], patient['ID']) + self.assertEqual('Patient', patient['Type']) + self.assertFalse(patient['IsStable']) + self.assertEqual(0, len(patient['Labels'])) + self.assertTrue('LastUpdate' in patient) + self.assertEqual(2, len(patient['MainDicomTags'])) + self.assertEqual('ozp00SjY2xG', patient['MainDicomTags']['PatientID']) + self.assertEqual('KNIX', patient['MainDicomTags']['PatientName']) + self.assertEqual(1, len(patient['Studies'])) + self.assertEqual(u['ParentStudy'], patient['Studies'][0]) + + def CheckStudyContent(study): + self.assertEqual(u['ParentStudy'], study['ID']) + self.assertEqual(u['ParentPatient'], study['ParentPatient']) + self.assertEqual('Study', study['Type']) + self.assertFalse(study['IsStable']) + self.assertEqual(0, len(study['Labels'])) + self.assertTrue('LastUpdate' in study) + self.assertEqual(7, len(study['MainDicomTags'])) + self.assertEqual('0ECJ52puWpVIjTuhnBA0um', study['MainDicomTags']['InstitutionName']) + self.assertEqual('1', study['MainDicomTags']['ReferringPhysicianName']) + self.assertEqual('20070101', study['MainDicomTags']['StudyDate']) + self.assertEqual('Knee (R)', study['MainDicomTags']['StudyDescription']) + self.assertEqual('1', study['MainDicomTags']['StudyID']) + self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', study['MainDicomTags']['StudyInstanceUID']) + self.assertEqual('120000.000000', study['MainDicomTags']['StudyTime']) + self.assertEqual(2, len(study['PatientMainDicomTags'])) + self.assertEqual('ozp00SjY2xG', study['PatientMainDicomTags']['PatientID']) + self.assertEqual('KNIX', study['PatientMainDicomTags']['PatientName']) + self.assertEqual(1, len(study['Series'])) + self.assertEqual(u['ParentSeries'], study['Series'][0]) + + def CheckSeriesContent(series): + self.assertEqual(None, series['ExpectedNumberOfInstances']) + self.assertEqual('Unknown', series['Status']) + self.assertEqual(u['ParentSeries'], series['ID']) + self.assertEqual(u['ParentStudy'], series['ParentStudy']) + self.assertEqual('Series', series['Type']) + self.assertFalse(series['IsStable']) + self.assertEqual(0, len(series['Labels'])) + self.assertTrue('LastUpdate' in series) + self.assertEqual(13, len(series['MainDicomTags'])) + self.assertEqual('0', series['MainDicomTags']['CardiacNumberOfImages']) + self.assertEqual('0.999841\\0.000366209\\0.0178227\\-0.000427244\\0.999995\\0.00326545', series['MainDicomTags']['ImageOrientationPatient']) + self.assertEqual('24', series['MainDicomTags']['ImagesInAcquisition']) + self.assertEqual('GE MEDICAL SYSTEMS', series['MainDicomTags']['Manufacturer']) + self.assertEqual('MR', series['MainDicomTags']['Modality']) + self.assertEqual('ca', series['MainDicomTags']['OperatorsName']) + self.assertEqual('324-58-2995/6', series['MainDicomTags']['ProtocolName']) + self.assertEqual('20070101', series['MainDicomTags']['SeriesDate']) + self.assertEqual('AX. FSE PD', series['MainDicomTags']['SeriesDescription']) + self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', series['MainDicomTags']['SeriesInstanceUID']) + self.assertEqual('5', series['MainDicomTags']['SeriesNumber']) + self.assertEqual('120000.000000', series['MainDicomTags']['SeriesTime']) + self.assertEqual('TWINOW', series['MainDicomTags']['StationName']) + self.assertEqual(1, len(series['Instances'])) + self.assertEqual(u['ID'], series['Instances'][0]) + + def CheckInstanceContent(instance): + self.assertEqual(2472, instance['FileSize']) + self.assertTrue('FileUuid' in instance) + self.assertEqual(u['ID'], instance['ID']) + self.assertEqual(u['ParentSeries'], instance['ParentSeries']) + self.assertEqual('Instance', instance['Type']) + self.assertEqual(1, instance['IndexInSeries']) + self.assertEqual(0, len(instance['Labels'])) + self.assertEqual(7, len(instance['MainDicomTags'])) + self.assertEqual('1', instance['MainDicomTags']['AcquisitionNumber']) + self.assertEqual('0.999841\\0.000366209\\0.0178227\\-0.000427244\\0.999995\\0.00326545', instance['MainDicomTags']['ImageOrientationPatient']) + self.assertEqual('-149.033\\-118.499\\-61.0464', instance['MainDicomTags']['ImagePositionPatient']) + self.assertEqual('20070101', instance['MainDicomTags']['InstanceCreationDate']) + self.assertEqual('120000.000000', instance['MainDicomTags']['InstanceCreationTime']) + self.assertEqual('1', instance['MainDicomTags']['InstanceNumber']) + self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', instance['MainDicomTags']['SOPInstanceUID']) + + def CheckRequestedTags(resource): + self.assertEqual(6, len(resource['RequestedTags'])) + self.assertEqual('ozp00SjY2xG', resource['RequestedTags']['PatientID']) + self.assertEqual('Knee (R)', resource['RequestedTags']['StudyDescription']) + self.assertEqual('AX. FSE PD', resource['RequestedTags']['SeriesDescription']) + self.assertEqual('1.2.840.10008.5.1.4.1.1.4', resource['RequestedTags']['SOPClassUID']) + self.assertEqual('2800', resource['RequestedTags']['RepetitionTime']) + self.assertEqual(3, len(resource['RequestedTags']['DerivationCodeSequence'][0])) + self.assertEqual('121327', resource['RequestedTags']['DerivationCodeSequence'][0]['CodeValue']) + + requestedTags = 'PatientID;StudyDescription;SeriesDescription;SOPClassUID;RepetitionTime;DerivationCodeSequence' + + a = DoGet(_REMOTE, '/patients?expand') + self.assertEqual(1, len(a)) + self.assertEqual(7, len(a[0])) + CheckPatientContent(a[0]) + self.assertFalse('RequestedTags' in a[0]) + + a = DoGet(_REMOTE, '/patients?expand&requestedTags=%s' % requestedTags) + self.assertEqual(1, len(a)) + self.assertEqual(8, len(a[0])) + CheckPatientContent(a[0]) + CheckRequestedTags(a[0]) + + a = DoGet(_REMOTE, '/studies?expand') + self.assertEqual(1, len(a)) + self.assertEqual(9, len(a[0])) + CheckStudyContent(a[0]) + self.assertFalse('RequestedTags' in a[0]) + + a = DoGet(_REMOTE, '/studies?expand&requestedTags=%s' % requestedTags) + self.assertEqual(1, len(a)) + self.assertEqual(10, len(a[0])) + CheckStudyContent(a[0]) + CheckRequestedTags(a[0]) + + a = DoGet(_REMOTE, '/series?expand') + self.assertEqual(1, len(a)) + self.assertEqual(10, len(a[0])) + CheckSeriesContent(a[0]) + self.assertFalse('RequestedTags' in a[0]) + + a = DoGet(_REMOTE, '/series?expand&requestedTags=%s' % requestedTags) + self.assertEqual(1, len(a)) + self.assertEqual(11, len(a[0])) + CheckSeriesContent(a[0]) + CheckRequestedTags(a[0]) + + a = DoGet(_REMOTE, '/instances?expand') + self.assertEqual(1, len(a)) + self.assertEqual(8, len(a[0])) + CheckInstanceContent(a[0]) + self.assertFalse('RequestedTags' in a[0]) + + a = DoGet(_REMOTE, '/instances?expand&requestedTags=%s' % requestedTags) + self.assertEqual(1, len(a)) + self.assertEqual(9, len(a[0])) + CheckInstanceContent(a[0]) + CheckRequestedTags(a[0])