示例#1
0
 def update_diags(self):
     assert self.report_id
     updated = False
     curs = db.cursor()
     try:
         for td in self.test_diags:
             for i, c in enumerate(td.counts):
                 diagnosis = TestDiags.diagnoses[i][0]
                 if c:
                     try:
                         td.counts[i] = c = int(c)
                     except ValueError:
                         raise ReportError('%s, %s count must be an integer'
                                             % (td.name, diagnosis))
                 else:
                     td.counts[i] = c = None
                 if c == td.load_counts[i]:
                     continue
                 execute(curs, 'UPDATE lab_diags SET count=%s WHERE'
                               ' report_id=%s AND test=%s AND diagnosis=%s',
                             (c, self.report_id, td.name, diagnosis))
                 if not curs.rowcount:
                     execute(curs, 'INSERT INTO lab_diags'
                                   ' VALUES (%s,%s,%s,%s)',
                             (self.report_id, td.name, diagnosis, c))
                 updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         self.diag_set_initial()
示例#2
0
 def update_diags(self):
     assert self.report_id
     updated = False
     curs = db.cursor()
     try:
         for td in self.test_diags:
             for i, c in enumerate(td.counts):
                 diagnosis = TestDiags.diagnoses[i][0]
                 if c:
                     try:
                         td.counts[i] = c = int(c)
                     except ValueError:
                         raise ReportError(
                             '%s, %s count must be an integer' %
                             (td.name, diagnosis))
                 else:
                     td.counts[i] = c = None
                 if c == td.load_counts[i]:
                     continue
                 execute(
                     curs, 'UPDATE lab_diags SET count=%s WHERE'
                     ' report_id=%s AND test=%s AND diagnosis=%s',
                     (c, self.report_id, td.name, diagnosis))
                 if not curs.rowcount:
                     execute(
                         curs, 'INSERT INTO lab_diags'
                         ' VALUES (%s,%s,%s,%s)',
                         (self.report_id, td.name, diagnosis, c))
                 updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         self.diag_set_initial()
示例#3
0
 def update_totals(self):
     assert self.report_id
     updated = False
     curs = db.cursor()
     try:
         for tt in self.test_totals:
             if tt.count:
                 try:
                     tt.count = int(tt.count)
                 except ValueError:
                     raise ReportError('%s count must be an integer' %
                                       tt.label)
             else:
                 tt.count = None
             if tt.count == tt.load_count:
                 continue
             execute(curs, 'UPDATE lab_totals SET count=%s'
                           ' WHERE report_id=%s AND test=%s',
                           (tt.count, self.report_id, tt.name))
             if not curs.rowcount:
                 execute(curs, 'INSERT INTO lab_totals VALUES (%s,%s,%s)',
                         (self.report_id, tt.name, tt.count))
             updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         self.totals_set_initial()
示例#4
0
 def update_totals(self):
     assert self.report_id
     updated = False
     curs = db.cursor()
     try:
         for tt in self.test_totals:
             if tt.count:
                 try:
                     tt.count = int(tt.count)
                 except ValueError:
                     raise ReportError('%s count must be an integer' %
                                       tt.label)
             else:
                 tt.count = None
             if tt.count == tt.load_count:
                 continue
             execute(
                 curs, 'UPDATE lab_totals SET count=%s'
                 ' WHERE report_id=%s AND test=%s',
                 (tt.count, self.report_id, tt.name))
             if not curs.rowcount:
                 execute(curs, 'INSERT INTO lab_totals VALUES (%s,%s,%s)',
                         (self.report_id, tt.name, tt.count))
             updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         self.totals_set_initial()
示例#5
0
 def update_report(self):
     assert self.report_id
     if self.__monitor.check():
         curs = db.cursor()
         try:
             execute(curs, 'UPDATE lab_reports SET completed=%s, notes=%s'
                         ' WHERE report_id=%s',
                     self.completed, self.notes, self.report_id)
         finally:
             curs.close()
         db.commit()
         self.__monitor.clear()
示例#6
0
 def update_report(self):
     assert self.report_id
     if self.__monitor.check():
         curs = db.cursor()
         try:
             execute(
                 curs, 'UPDATE lab_reports SET completed=%s, notes=%s'
                 ' WHERE report_id=%s', self.completed, self.notes,
                 self.report_id)
         finally:
             curs.close()
         db.commit()
         self.__monitor.clear()
示例#7
0
 def update_positive_cases(self):
     assert self.report_id
     curs = db.cursor()
     try:
         updated = False
         for case in self.positive_cases:
             if case.monitor.check():
                 case.update(curs, self.report_id)
                 updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         for case in self.positive_cases:
             case.monitor.clear()
示例#8
0
 def update_positive_cases(self):
     assert self.report_id
     curs = db.cursor()
     try:
         updated = False
         for case in self.positive_cases:
             if case.monitor.check():
                 case.update(curs, self.report_id)
                 updated = True
     finally:
         curs.close()
     if updated:
         db.commit()
         for case in self.positive_cases:
             case.monitor.clear()
示例#9
0
 def new(self):
     self.new_report()
     db.commit()
示例#10
0
 def new(self):
     self.new_report()
     db.commit()