Browse Source

Merge to head

Andrej 4 years ago
parent
commit
fdca6cabcf
3 changed files with 18 additions and 4 deletions
  1. 5 1
      orthancDatabaseBrowser.py
  2. 0 1
      orthancInterface.py
  3. 13 2
      pythonScripts/scanOrthanc.py

+ 5 - 1
orthancDatabaseBrowser.py

@@ -67,7 +67,11 @@ class orthancDB:
         url+='/instances'
         fobj=open (f, 'rb')
         response=self.net.post(url,'octet-stream',fobj.read())
-        encoding=chardet.detect(response.data)["encoding"]
+        try:
+            encoding=chardet.detect(response.data)["encoding"]
+        except AttributeError:
+            print(response)
+            return json.loads('{"status":"BAD"}')
         return json.loads(response.data.decode(encoding))
 
     def remove(self,level,orthancId):

+ 0 - 1
orthancInterface.py

@@ -17,7 +17,6 @@ class orthancInterface:
         
         self.http=urllib3.PoolManager()
 
-        
         if 'SSL' in self.connectionConfig['orthanc']:
             sslConfig=self.connectionConfig['orthanc']['SSL']
             self.http = urllib3.PoolManager(\

+ 13 - 2
pythonScripts/scanOrthanc.py

@@ -1,3 +1,6 @@
+#scans orthanc database and updates Demographics datataset and 
+#series list in project Imaging dataset
+
 import os
 import json
 import re
@@ -5,11 +8,16 @@ import sys
 
 
 fhome=os.path.expanduser('~')
-sys.path.insert(1,fhome+'/software/src/labkeyInterface')
+fsetup=os.path.join(fhome,'.labkey','setup.json')
+
+with open(fsetup,'r') as f:
+    setup=json.load(f)
+
+sys.path.insert(0,setup['paths']['labkeyInterface'])
 import labkeyInterface
 import labkeyDatabaseBrowser
 
-sys.path.insert(1,fhome+'/software/src/orthancInterface')
+sys.path.insert(0,setup['paths']['orthancInterface'])
 import orthancInterface
 import orthancDatabaseBrowser
 
@@ -49,12 +57,15 @@ for p in patients:
             row['PatientName']=dicom['PatientName']
         except KeyError:
             pass
+    
+
         row['OrthancId']=p
         db.modifyRows('insert',project,'study','Demographics',[row])
 
     for s in pdata['Studies']:
         sdata=odb.getStudyData(s)
         sdicom=sdata['MainDicomTags']
+
         sdate='19700101'
         try:
             sid=sdicom['StudyInstanceUID']