Example #1
0
 def add_patient_clicked(self):
     text, ok = QtGui.QInputDialog.getText(self, '', 'Enter patient name:')
     if ok:
         new_file_name = os.path.join(PATIENT_DIR, str(text) + '.pkl')
         if os.path.exists(new_file_name):
             QtGui.QMessageBox.about(self, 'Error', 'Name already exists!')
         else:
             new_patient = Patient(str(text))
     else:
         return
     text, ok = QtGui.QInputDialog.getInt(self, '', 'Enter patient age:')
     if ok:
         new_patient.age = int(text)
     else:
         return
     text, ok = QtGui.QInputDialog.getText(self, '', 'Enter patient diagnosis:')
     if ok:
         new_patient.diagnosis = str(text)
     else:
         return
     text, ok = QtGui.QInputDialog.getItem(self, '', 'Enter patient gender:', ['Female', 'Male', 'Other'])
     if ok:
         new_patient.gender = str(text)
     else:
         return
     pickle.dump(new_patient, open(new_file_name, 'wb'))
     self.update_patient_list()
 def load_demographics(self, file):
     f = codecs.open(file, 'r', 'utf-8')
     reader = csv.reader(f)
     line_ctr = 0
     for row in reader:
         # table title
         if line_ctr < 1:
             table_ttl = dict(zip(row, range(len(row))))
             line_ctr += 1
             continue
         if len(row) == 0:
             continue
         pval = Patient()
         pid = row[table_ttl['ID']]
         pval.age = row[table_ttl['AGE']]
         pval.gender = row[table_ttl['GENDER']]
         pval.edu_year = row[table_ttl['EDUCATION YEAR']]
         pval.duration = row[table_ttl['DURATION(MONTH)']]
         self.patient_info[pid] = pval
         line_ctr += 1
     f.close()