changeset 442:af57603438b3

added tests for patient names with square brackets
author Alain Mazy <am@osimis.io>
date Tue, 30 Nov 2021 10:33:47 +0100
parents 21a45ddc9256
children 97fca09bf849
files Tests/Tests.py
diffstat 1 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Sat Nov 27 12:26:43 2021 +0100
+++ b/Tests/Tests.py	Tue Nov 30 10:33:47 2021 +0100
@@ -8314,3 +8314,64 @@
         self.assertEqual((512, 512, 1), c.shape)
         self.assertEqual(-2000, c.min())
         self.assertEqual(3398, c.max())
+
+
+    def test_find_patient_name_with_brackets_and_star(self):
+        u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID']
+
+        modified = DoPost(_REMOTE, '/instances/%s/modify' % u, json.dumps({
+            "Replace" : {
+                "PatientName" : "MyName[*]",
+                "PatientID": "test_brackets"
+                },
+            "Force": True
+            }),
+            'application/json')
+
+        m = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID']
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series',
+                                             'Query' : { 'PatientName' : 'MyName[*]' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient',
+                                             'Query' : { 'PatientName' : 'MyName[*]' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study',
+                                             'Query' : { 'PatientName' : 'MyName*' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient',
+                                             'Query' : { 'PatientName' : 'MyName*' }})
+        self.assertEqual(1, len(a))
+
+    def test_find_patient_name_with_brackets_only(self):
+        u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID']
+
+        modified = DoPost(_REMOTE, '/instances/%s/modify' % u, json.dumps({
+            "Replace" : {
+                "PatientName" : "MyName2[]",
+                "PatientID": "test_brackets2"
+                },
+            "Force": True
+            }),
+            'application/json')
+
+        m = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID']
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series',
+                                             'Query' : { 'PatientName' : 'MyName2[*]' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient',
+                                             'Query' : { 'PatientName' : 'MyName2[*]' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study',
+                                             'Query' : { 'PatientName' : 'MyName2*' }})
+        self.assertEqual(1, len(a))
+
+        a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient',
+                                             'Query' : { 'PatientName' : 'MyName2*' }})
+        self.assertEqual(1, len(a))