Browse Source

Removing error when no items was found for pariticipant; ordering participant by Id, setting combobox to editable mode for simplifed patient search

Andrej Studen 2 years ago
parent
commit
35d95e0c6c
1 changed files with 17 additions and 4 deletions
  1. 17 4
      slicerModules/imageBrowser.py

+ 17 - 4
slicerModules/imageBrowser.py

@@ -97,6 +97,8 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
 
         self.patientList=qt.QComboBox()
         self.patientList.currentIndexChanged.connect(self.onPatientListChanged)
+        self.patientList.setEditable(True)
+        self.patientList.setInsertPolicy(qt.QComboBox.NoInsert)
         patientsFormLayout.addRow("Patient:",self.patientList)
             
 
@@ -260,7 +262,11 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         except KeyError:
             pass
 
-        self.updatePatientList(status['ids'])
+        #sort ids
+        ids=status['ids']
+        ids.sort()
+
+        self.updatePatientList(ids)
         self.onPatientListChanged(0)
  
     def onServerListChanged(self,i):
@@ -279,6 +285,10 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         self.serverList.setStyleSheet('background-color: green')
 
     def onPatientListChanged(self,i):
+        self.visitList.clear()   
+        self.petCode.setText("")
+        self.ctCode.setText("")
+        
         #add potential filters from setup to dbFilter
         ds=self.logic.getDataset(dbFilter={'participant':self.patientList.currentText})
        
@@ -286,10 +296,14 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         dt=datetime.datetime
         
         #label is a combination of sequence number and date of imaging
-        seq={row['SequenceNum']:
+        try:
+            seq={row['SequenceNum']:
                 {'label':row[visitVar],
                 'date': dt.strptime(row['studyDate'],'%Y/%m/%d %H:%M:%S')}
-            for row in ds['rows']}
+                for row in ds['rows']}
+        except TypeError:
+            #if studyDate is empty, this will return no possible visits
+            return
 
         #apply lookup to visitVar if available
         try:
@@ -304,7 +318,6 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         seq={x:'{} ({})'.format(seq[x]['label'],dt.strftime(seq[x]['date'],'%d-%b-%Y')) 
             for x in seq}
 
-        self.visitList.clear()   
             
         for s in seq:
             #onVisitListChanged is called for every addItem