Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 504:16ff0375835d
new tests and modified tests for new DicomModificationJob features
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 18 Jan 2023 17:59:43 +0100 |
parents | 1b1bb8621021 |
children | 9f28cb3d7979 |
comparison
equal
deleted
inserted
replaced
501:1b1bb8621021 | 504:16ff0375835d |
---|---|
3848 | 3848 |
3849 def test_reconstruct(self): | 3849 def test_reconstruct(self): |
3850 def CompareMainDicomTag(expected, instance, level, tag): | 3850 def CompareMainDicomTag(expected, instance, level, tag): |
3851 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip()) | 3851 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip()) |
3852 | 3852 |
3853 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | 3853 originalInstanceId = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
3854 | 3854 |
3855 studies = DoGet(_REMOTE, '/studies/') | 3855 studies = DoGet(_REMOTE, '/studies/') |
3856 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) | 3856 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
3857 self.assertEqual(1, len(studies)) | 3857 self.assertEqual(1, len(studies)) |
3858 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) | 3858 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
3873 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) | 3873 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
3874 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) | 3874 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
3875 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) | 3875 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
3876 self.assertEqual(2, len(instances)) | 3876 self.assertEqual(2, len(instances)) |
3877 | 3877 |
3878 b = instances[0] if instances[1] == a else instances[1] | 3878 modifiedInstanceId = instances[0] if instances[1] == originalInstanceId else instances[1] |
3879 | 3879 |
3880 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') | 3880 # in 1.11.3, we have added an automatic reconstruction at the end of the modification |
3881 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') | 3881 if not IsOrthancVersionAbove(_REMOTE, 1, 11, 3): |
3882 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') | 3882 CompareMainDicomTag('Knee (R)', originalInstanceId, 'study', 'StudyDescription') |
3883 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') | 3883 CompareMainDicomTag('AX. FSE PD', originalInstanceId, 'series', 'SeriesDescription') |
3884 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % a).strip()) | 3884 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', originalInstanceId, '', 'SOPInstanceUID') |
3885 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % b).strip()) | 3885 CompareMainDicomTag('myid', modifiedInstanceId, '', 'SOPInstanceUID') |
3886 | 3886 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % originalInstanceId).strip()) |
3887 if IsOrthancVersionAbove(_REMOTE, 1, 11, 0): | 3887 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % modifiedInstanceId).strip()) |
3888 # metadata before reconstruct | 3888 |
3889 mba = DoGet(_REMOTE, '/instances/%s/metadata?expand' % a) | 3889 if IsOrthancVersionAbove(_REMOTE, 1, 11, 0): |
3890 mbb = DoGet(_REMOTE, '/instances/%s/metadata?expand' % a) | 3890 # metadata before reconstruct |
3891 | 3891 mba = DoGet(_REMOTE, '/instances/%s/metadata?expand' % originalInstanceId) |
3892 # reconstruct by taking the new instance as the reference -> should repopulate study fields from this instance tags | 3892 mbb = DoGet(_REMOTE, '/instances/%s/metadata?expand' % originalInstanceId) |
3893 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) | 3893 |
3894 | 3894 # reconstruct by taking the new instance as the reference -> should repopulate study fields from this instance tags |
3895 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') | 3895 DoPost(_REMOTE, '/instances/%s/reconstruct' % modifiedInstanceId, {}) |
3896 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') | 3896 |
3897 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') | 3897 CompareMainDicomTag('hello', originalInstanceId, 'study', 'StudyDescription') |
3898 | 3898 CompareMainDicomTag('world', originalInstanceId, 'series', 'SeriesDescription') |
3899 if IsOrthancVersionAbove(_REMOTE, 1, 11, 0): | 3899 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', originalInstanceId, '', 'SOPInstanceUID') |
3900 # metadata after reconstruct should have been preserved | 3900 |
3901 maa = DoGet(_REMOTE, '/instances/%s/metadata?expand' % a) | 3901 if not IsOrthancVersionAbove(_REMOTE, 1, 11, 3): |
3902 mab = DoGet(_REMOTE, '/instances/%s/metadata?expand' % a) | 3902 if IsOrthancVersionAbove(_REMOTE, 1, 11, 0): |
3903 | 3903 # metadata after reconstruct should have been preserved |
3904 self.assertEqual(mba, maa) | 3904 maa = DoGet(_REMOTE, '/instances/%s/metadata?expand' % originalInstanceId) |
3905 self.assertEqual(mbb, mab) | 3905 mab = DoGet(_REMOTE, '/instances/%s/metadata?expand' % originalInstanceId) |
3906 | |
3907 self.assertEqual(mba, maa) | |
3908 self.assertEqual(mbb, mab) | |
3906 | 3909 |
3907 | 3910 |
3908 def test_httpClient_lua(self): | 3911 def test_httpClient_lua(self): |
3909 retries = 4 | 3912 retries = 4 |
3910 result = '' | 3913 result = '' |
6323 Modify('studies', i['ParentStudy'], {'PatientID': 'NEW'}, force=True, keepSource=True) | 6326 Modify('studies', i['ParentStudy'], {'PatientID': 'NEW'}, force=True, keepSource=True) |
6324 Modify('series', i['ParentSeries'], {'StudyInstanceUID': '1.3'}, force=True, keepSource=True) | 6327 Modify('series', i['ParentSeries'], {'StudyInstanceUID': '1.3'}, force=True, keepSource=True) |
6325 Modify('instances', i['ID'], {'SeriesInstanceUID': '1.2'}, force=True, keepSource=True) | 6328 Modify('instances', i['ID'], {'SeriesInstanceUID': '1.2'}, force=True, keepSource=True) |
6326 | 6329 |
6327 | 6330 |
6331 def test_modify_study_module_reconstruction(self): | |
6332 if IsOrthancVersionAbove(_REMOTE, 1, 11, 3): | |
6333 def UploadAndModify(level, resourceId, replaceTags, force, keepSource, dropOrthanc=True): | |
6334 | |
6335 if dropOrthanc: | |
6336 DropOrthanc(_REMOTE) | |
6337 | |
6338 UploadFolder(_REMOTE, 'Knee/T1') | |
6339 UploadFolder(_REMOTE, 'Knee/T2') | |
6340 | |
6341 if dropOrthanc: | |
6342 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
6343 | |
6344 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % (level, resourceId), { | |
6345 'Replace' : replaceTags, | |
6346 'Force': force, | |
6347 'KeepSource' : keepSource | |
6348 }) | |
6349 modifiedResource = DoGet(_REMOTE, '/%s/%s' % (level, modifyResponse['ID'])) | |
6350 return (modifyResponse, modifiedResource) | |
6351 | |
6352 kneeSeriesT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
6353 kneeSeriesT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
6354 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
6355 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
6356 kneeStudyInstanceUID = '2.16.840.1.113669.632.20.121711.10000160881' | |
6357 kneeSeriesInstanceUIDT1 = '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' | |
6358 kneeSeriesInstanceUIDT2 = '1.3.46.670589.11.17521.5.0.3124.2008081909090037350' | |
6359 | |
6360 ####### study level tests ####### | |
6361 | |
6362 # modify study description and make sure the MainDicomTags are updated | |
6363 modifyResponse, modifiedResource = UploadAndModify('studies', kneeStudy, replaceTags={ | |
6364 'StudyInstanceUID': kneeStudyInstanceUID, | |
6365 'StudyDescription': 'TOTO' | |
6366 }, force=True, keepSource=True) | |
6367 self.assertEqual(kneeStudy, modifyResponse['ID']) | |
6368 self.assertEqual('TOTO', modifiedResource['MainDicomTags']['StudyDescription']) | |
6369 | |
6370 # modify patient name at study level and make sure the PatientMainDicomTags are updated + the patient has been updated | |
6371 modifyResponse, modifiedResource = UploadAndModify('studies', kneeStudy, replaceTags={ | |
6372 'StudyInstanceUID': kneeStudyInstanceUID, | |
6373 'PatientName': 'TOTO' | |
6374 }, force=True, keepSource=True) | |
6375 self.assertEqual(kneeStudy, modifyResponse['ID']) | |
6376 self.assertEqual('TOTO', modifiedResource['PatientMainDicomTags']['PatientName']) | |
6377 patient = DoGet(_REMOTE, '/patients/%s' % kneePatient) | |
6378 self.assertEqual('TOTO', patient['MainDicomTags']['PatientName']) | |
6379 | |
6380 # modify patient name and patient id at study level and make sure the PatientMainDicomTags are updated + a new patient has been created + the old one does not exist anymore | |
6381 modifyResponse, modifiedResource = UploadAndModify('studies', kneeStudy, replaceTags={ | |
6382 'StudyInstanceUID': kneeStudyInstanceUID, | |
6383 'PatientID': 'TOTO_ID', | |
6384 'PatientName': 'TOTO' | |
6385 }, force=True, keepSource=True) | |
6386 self.assertNotEqual(kneeStudy, modifyResponse['ID']) # the study has changed since the PatientID has changed | |
6387 self.assertEqual('TOTO', modifiedResource['PatientMainDicomTags']['PatientName']) | |
6388 self.assertEqual('TOTO_ID', modifiedResource['PatientMainDicomTags']['PatientID']) | |
6389 patient = DoGet(_REMOTE, '/patients/%s' % modifyResponse['PatientID']) | |
6390 self.assertEqual('TOTO', patient['MainDicomTags']['PatientName']) | |
6391 self.assertEqual('TOTO_ID', patient['MainDicomTags']['PatientID']) | |
6392 | |
6393 ####### series level tests ####### | |
6394 # modify series description and make sure the MainDicomTags are updated | |
6395 modifyResponse, modifiedResource = UploadAndModify('series', kneeStudy, replaceTags={ | |
6396 'SeriesInstanceUID': kneeSeriesInstanceUIDT1, | |
6397 'StudyInstanceUID': kneeStudyInstanceUID, | |
6398 'SeriesDescription': 'TOTO' | |
6399 }, force=True, keepSource=True) | |
6400 self.assertEqual(kneeSeriesT1, modifyResponse['ID']) | |
6401 self.assertEqual('TOTO', modifiedResource['MainDicomTags']['SeriesDescription']) | |
6402 self.assertEqual(kneeStudy, modifyResponse['ParentResources'][0]) | |
6403 | |
6404 | |
6405 def test_rename_patient_with_multiple_studies(self): | |
6406 if IsOrthancVersionAbove(_REMOTE, 1, 11, 3): | |
6407 | |
6408 patientOrthancId = '5436938e-7ae68340-5ea6ad3c-4e6e09bd-1bd335de' | |
6409 patientDicomId = 'TEST_1' | |
6410 patientName = 'Test' | |
6411 study1234 = '72de3b86-da4b2556-bb33f32f-d1d84f80-fb017059' | |
6412 study2345 = '3594f32b-dcf60e81-58252b67-66222714-c09fca81' | |
6413 | |
6414 DropOrthanc(_REMOTE) | |
6415 UploadFolder(_REMOTE, 'PatientWith2studies') | |
6416 | |
6417 # each sub-test is in a dedicated 'if' for clarity | |
6418 | |
6419 if True: | |
6420 # it shall be impossible to rename a patient when modifying a study if that patient already has other studies | |
6421 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/%s/%s/modify' % ('studies', study1234), { | |
6422 'Replace' : {'PatientName': "TOTO"}, | |
6423 'Force': True, | |
6424 'KeepSource' : True | |
6425 })) | |
6426 | |
6427 if True: | |
6428 # rename the patient (at patient level) | |
6429 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('patients', patientOrthancId), { | |
6430 'Replace' : { | |
6431 'PatientName': 'TOTO' | |
6432 }, | |
6433 'Force': True, | |
6434 'KeepSource' : False | |
6435 }) | |
6436 modifiedPatient = DoGet(_REMOTE, '/%s/%s' % ('patients', modifyResponse['ID'])) | |
6437 # make sure the patient name has been edited at patient level | |
6438 self.assertEqual('TOTO', modifiedPatient['MainDicomTags']['PatientName']) | |
6439 | |
6440 # there should only be 2 studies since we have set KeepSource=False | |
6441 self.assertEqual(2, len(modifiedPatient['Studies'])) | |
6442 modifiedStudy1 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][0])) | |
6443 modifiedStudy2 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][1])) | |
6444 self.assertEqual('TOTO', modifiedStudy1['PatientMainDicomTags']['PatientName']) | |
6445 self.assertEqual('TOTO', modifiedStudy2['PatientMainDicomTags']['PatientName']) | |
6446 | |
6447 if True: | |
6448 # rename the patient (at patient level) and don't keep sources and preserve StudyInstanceUID | |
6449 DropOrthanc(_REMOTE) | |
6450 UploadFolder(_REMOTE, 'PatientWith2studies') | |
6451 | |
6452 # rename the patient (at patient level) and don't keep sources and preserve StudyInstanceUID, SeriesInstanceUID | |
6453 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('patients', patientOrthancId), { | |
6454 'Replace' : { | |
6455 'PatientName': 'TOTO' | |
6456 }, | |
6457 'Keep': ['StudyInstanceUID', 'SeriesInstanceUID'], | |
6458 'Force': True, | |
6459 'KeepSource' : False | |
6460 }) | |
6461 modifiedPatient = DoGet(_REMOTE, '/%s/%s' % ('patients', modifyResponse['ID'])) | |
6462 # make sure tha patient name has been edited at patient level | |
6463 self.assertEqual('TOTO', modifiedPatient['MainDicomTags']['PatientName']) | |
6464 | |
6465 # there should only be 2 studies since we have set KeepSource=False | |
6466 self.assertEqual(2, len(modifiedPatient['Studies'])) | |
6467 modifiedStudy1 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][0])) | |
6468 modifiedStudy2 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][1])) | |
6469 # the StudyInstanceUID shall not have changed | |
6470 self.assertIn(modifiedStudy1['MainDicomTags']['StudyInstanceUID'], ['1.2.3', '2.3.4']) | |
6471 self.assertIn(modifiedStudy2['MainDicomTags']['StudyInstanceUID'], ['1.2.3', '2.3.4']) | |
6472 # the DB model of parent shall have been reconstructed | |
6473 self.assertEqual('TOTO', modifiedStudy1['PatientMainDicomTags']['PatientName']) | |
6474 self.assertEqual('TOTO', modifiedStudy2['PatientMainDicomTags']['PatientName']) | |
6475 | |
6476 if True: | |
6477 # it shall not be possible to keep all dicom UID and have KeepSource at False since the modified instances | |
6478 # would have the same orthanc ids as the source ids -> they would be deleted | |
6479 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/%s/%s/modify' % ('patients', study1234), { | |
6480 'Replace' : {'PatientName': "TOTO"}, | |
6481 'Force': True, | |
6482 'Keep': ['StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID'], | |
6483 'KeepSource' : False | |
6484 })) | |
6485 | |
6486 if True: | |
6487 # rename the patient (at patient level) and don't keep sources and preserve all DicomID | |
6488 DropOrthanc(_REMOTE) | |
6489 UploadFolder(_REMOTE, 'PatientWith2studies') | |
6490 | |
6491 # rename the patient (at patient level) and don't keep sources and preserve StudyInstanceUID | |
6492 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('patients', patientOrthancId), { | |
6493 'Replace' : { | |
6494 'PatientName': 'TOTO' | |
6495 }, | |
6496 'Keep': ['StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID'], | |
6497 'Force': True, | |
6498 'KeepSource' : True | |
6499 }) | |
6500 modifiedPatient = DoGet(_REMOTE, '/%s/%s' % ('patients', modifyResponse['ID'])) | |
6501 # make sure tha patient name has been edited at patient level | |
6502 self.assertEqual('TOTO', modifiedPatient['MainDicomTags']['PatientName']) | |
6503 | |
6504 # there should only be 2 studies since we have set KeepSource=False | |
6505 self.assertEqual(2, len(modifiedPatient['Studies'])) | |
6506 modifiedStudy1 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][0])) | |
6507 modifiedStudy2 = DoGet(_REMOTE, '/%s/%s' % ('studies', modifiedPatient['Studies'][1])) | |
6508 # the StudyInstanceUID shall not have changed | |
6509 self.assertIn(modifiedStudy1['MainDicomTags']['StudyInstanceUID'], ['1.2.3', '2.3.4']) | |
6510 self.assertIn(modifiedStudy2['MainDicomTags']['StudyInstanceUID'], ['1.2.3', '2.3.4']) | |
6511 # the DB model of parent shall have been reconstructed | |
6512 self.assertEqual('TOTO', modifiedStudy1['PatientMainDicomTags']['PatientName']) | |
6513 self.assertEqual('TOTO', modifiedStudy2['PatientMainDicomTags']['PatientName']) | |
6514 | |
6515 | |
6516 if True: | |
6517 # try to attach the knee study to an existing patient | |
6518 DropOrthanc(_REMOTE) | |
6519 UploadFolder(_REMOTE, 'PatientWith2studies') | |
6520 UploadFolder(_REMOTE, 'Knee/T1') | |
6521 | |
6522 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
6523 | |
6524 # try to change the PatientID at study level. This only works if we specify all Patient Tags and if they are identical to the existing Patient in DB | |
6525 | |
6526 # this should fail if only specifying the PatientID | |
6527 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6528 'Replace' : { | |
6529 'PatientID': 'TEST_1' | |
6530 }, | |
6531 'Force': True, | |
6532 'KeepSource' : False | |
6533 })) | |
6534 | |
6535 # this should fail if specifying all tags but one of them is not correct | |
6536 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6537 'Replace' : { | |
6538 'PatientID': 'TEST_1', | |
6539 'PatientName': 'Test', | |
6540 'PatientBirthDate': '19000101', | |
6541 'PatientSex': 'F' # this is wrong ! | |
6542 }, | |
6543 'Force': True, | |
6544 'KeepSource' : False | |
6545 })) | |
6546 | |
6547 # this should fail if specifying a tag that is not defined in DB for that patient | |
6548 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6549 'Replace' : { | |
6550 'PatientID': 'TEST_1', | |
6551 'PatientName': 'Test', | |
6552 'PatientBirthDate': '19000101', | |
6553 'PatientSex': 'M', | |
6554 '0010,1000': 'TUTU' # this does not exist in DB | |
6555 }, | |
6556 'Force': True, | |
6557 'KeepSource' : False | |
6558 })) | |
6559 | |
6560 # this should now work with all correct tags | |
6561 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6562 'Replace' : { | |
6563 'PatientID': 'TEST_1', | |
6564 'PatientName': 'Test', | |
6565 'PatientBirthDate': '19000101', | |
6566 'PatientSex': 'M' | |
6567 }, | |
6568 'Force': True, | |
6569 'KeepSource' : False | |
6570 }) | |
6571 modifiedStudy = DoGet(_REMOTE, '/%s/%s' % ('studies', modifyResponse['ID'])) | |
6572 self.assertEqual('Test', modifiedStudy['PatientMainDicomTags']['PatientName']) | |
6573 patient = DoGet(_REMOTE, '/%s/%s' % ('patients', patientOrthancId)) | |
6574 # make sure tha patient name remains the same at patient level | |
6575 self.assertEqual('Test', patient['MainDicomTags']['PatientName']) | |
6576 | |
6577 | |
6578 if True: | |
6579 # try to edit patient in Knee (only study from this patient) | |
6580 DropOrthanc(_REMOTE) | |
6581 UploadFolder(_REMOTE, 'PatientWith2studies') | |
6582 UploadFolder(_REMOTE, 'Knee/T1') | |
6583 | |
6584 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
6585 originalKneePatientId = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
6586 | |
6587 originalKneePatient = DoGet(_REMOTE, '/%s/%s' % ('patients', originalKneePatientId)) | |
6588 | |
6589 # try to change the PatientName and StudyDescription at study level. | |
6590 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6591 'Replace' : { | |
6592 'PatientName': 'Test Knee', | |
6593 'StudyDescription': 'Knee study' | |
6594 }, | |
6595 'Keep': ['StudyInstanceUID'], | |
6596 'Force': True, | |
6597 'KeepSource' : False | |
6598 }) | |
6599 modifiedStudy = DoGet(_REMOTE, '/%s/%s' % ('studies', modifyResponse['ID'])) | |
6600 self.assertEqual('Test Knee', modifiedStudy['PatientMainDicomTags']['PatientName']) | |
6601 # reload the patient, it shall have been updated as well (and kept the same ID since we did not change the PatientID) | |
6602 modifiedPatient = DoGet(_REMOTE, '/%s/%s' % ('patients', originalKneePatientId)) | |
6603 self.assertEqual('Test Knee', modifiedPatient['MainDicomTags']['PatientName']) | |
6604 | |
6605 # try to change the PatientID and PatientName and StudyDescription at study level. Since we use a new PatientID, we can modify its name too | |
6606 modifyResponse = DoPost(_REMOTE, '/%s/%s/modify' % ('studies', kneeStudy), { | |
6607 'Replace' : { | |
6608 'PatientName': 'Test Knee 2', | |
6609 'PatientID': 'TEST_KNEE_2', | |
6610 'StudyDescription': 'Knee study 2' | |
6611 }, | |
6612 'Force': True, | |
6613 'KeepSource' : False | |
6614 }) | |
6615 modifiedStudy = DoGet(_REMOTE, '/%s/%s' % ('studies', modifyResponse['ID'])) | |
6616 self.assertEqual('Test Knee 2', modifiedStudy['PatientMainDicomTags']['PatientName']) | |
6617 self.assertEqual('Knee study 2', modifiedStudy['MainDicomTags']['StudyDescription']) | |
6618 # reload the patient, now, its orthanc id has changed | |
6619 modifiedPatient = DoGet(_REMOTE, '/%s/%s' % ('patients', modifiedStudy['ParentPatient'])) | |
6620 self.assertEqual('Test Knee 2', modifiedPatient['MainDicomTags']['PatientName']) | |
6621 # the previous patient shall not exist anymore | |
6622 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/%s/%s' % ('patients', originalKneePatientId))) | |
6328 | 6623 |
6329 def test_store_peer_transcoding(self): | 6624 def test_store_peer_transcoding(self): |
6330 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | 6625 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
6331 | 6626 |
6332 SYNTAXES = [ | 6627 SYNTAXES = [ |