Mercurial > hg > orthanc-tests
changeset 48:e4352463ff74
test_patient_ids_collision
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Oct 2015 15:56:32 +0200 |
parents | f610491f74c3 |
children | e7f9b8199545 |
files | Database/PatientIdsCollision/Generate.sh Database/PatientIdsCollision/Image1.dcm Database/PatientIdsCollision/Image1.dump Database/PatientIdsCollision/Image2.dcm Database/PatientIdsCollision/Image2.dump Database/PatientIdsCollision/Image3.dcm Database/PatientIdsCollision/Image3.dump Tests/Tests.py |
diffstat | 8 files changed, 62 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/PatientIdsCollision/Generate.sh Tue Oct 06 15:56:32 2015 +0200 @@ -0,0 +1,8 @@ +#!/bin/bash + +rm *.dcm + +for i in `seq 1 3` +do + dump2dcm +Ug --write-xfer-little Image$i.dump Image$i.dcm +done
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/PatientIdsCollision/Image1.dump Tue Oct 06 15:56:32 2015 +0200 @@ -0,0 +1,4 @@ +(0008,0016) UI 1.2.840.10008.5.1.4.1.1.4 +(0010,0020) LO COMMON # Patient ID +(0010,0010) PN HELLO # Patient Name +(0008,1030) LO HELLO^SERIES # Study description
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/PatientIdsCollision/Image2.dump Tue Oct 06 15:56:32 2015 +0200 @@ -0,0 +1,4 @@ +(0008,0016) UI 1.2.840.10008.5.1.4.1.1.4 +(0010,0020) LO COMMON # Patient ID +(0010,0010) PN WORLD # Patient Name +(0008,1030) LO WORLD^SERIES # Study description
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/PatientIdsCollision/Image3.dump Tue Oct 06 15:56:32 2015 +0200 @@ -0,0 +1,4 @@ +(0008,0016) UI 1.2.840.10008.5.1.4.1.1.4 +(0010,0020) LO COMMON # Patient ID +(0010,0010) PN FOO # Patient Name +(0008,1030) LO FOO^SERIES # Study description
--- a/Tests/Tests.py Wed Sep 23 12:43:20 2015 +0200 +++ b/Tests/Tests.py Tue Oct 06 15:56:32 2015 +0200 @@ -2242,3 +2242,45 @@ self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) self.assertEqual(encoded, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID'])[0:-1]) + + + def test_patient_ids_collision(self): + # Upload 3 instances from 3 different studies, but with the + # same PatientID + for i in range(3): + UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) + + a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', + 'Query' : { 'PatientName' : '*' }}) + self.assertEqual(1, len(a)) + self.assertEqual('COMMON', DoGet(_REMOTE, '/patients/%s' % a[0]) ['MainDicomTags']['PatientID']) + + a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', + 'CaseSensitive' : True, + 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) + self.assertEqual(2, len(a)) + + a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', + 'CaseSensitive' : False, + 'Query' : { 'PatientName' : 'Foo' }}) + self.assertEqual(1, len(a)) + self.assertEqual('FOO^SERIES', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['MainDicomTags']['StudyDescription']) + self.assertEqual('FOO', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientName']) + self.assertEqual('COMMON', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientID']) + + a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', + 'Query' : { 'PatientName' : '*' }}) + self.assertEqual(3, len(a)) + d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['MainDicomTags']['StudyDescription'], a) + self.assertTrue('FOO^SERIES' in d) + self.assertTrue('HELLO^SERIES' in d) + self.assertTrue('WORLD^SERIES' in d) + + d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['PatientMainDicomTags']['PatientID'], a) + self.assertEqual(1, len(set(d))) + self.assertEqual('COMMON', d[0]) + + for i in a: + d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] + p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] + self.assertEqual('%s^SERIES' % p, d)