def addnewBioEntry(self, data): """add new DB entry""" query = """ insert into patient.patient (file_number, surname, first_names, birth_date, gender, nationalid, nationality, note, callname, language, occupation, marital_status, ethnicity, employer) values(%(file_number)d, '%(surname)s', '%(first_names)s', '%(birth_date)s', '%(gender)s', '%(nationalid)s', '%(nationality)s', '%(note)s', '%(callname)s', '%(language)s', '%(occupation)s', '%(marital_status)s', '%(ethnicity)s', '%(employer)s') """ % data # print query try: cursor = self.conn.cursor() cursor.execute(query) self.conn.commit() except psycopg.IntegrityError, x: msg = "Failed to Add entry,\nFile Number %d already in use" % data['file_number'] from Dialogs.Utils import displayMessage displayMessage(msg) BARWRITER.write(msg) return
def OnKeyDown(self, evt): """ sss""" evt.Skip() i = self.visitListCtrl.GetSelection() if i == -1: msg = "Select a visit" BARWRITER.write(msg) else: st = self.visitListCtrl.GetString(i) if st[0] != "*": nst = "*"+st self.currentdate = nst self.visitListCtrl.SetString(i, nst) self.visits[nst] = copy.copy(self.visits[st]) del self.visits[st]
def search(self, data): """search database """ self.lastSearchData = data query = """ select * from patient.patient where """ filenoquery = "file_number=%(folderno)s" % data surnamequery = "surname ~* '%(surname)s'" % data firstnamequery = "first_names ~* '%(name)s'" % data bdatequery = "birth_date ~* '%(bdate)s'" % data post = """ order by surname desc limit 50 """ qlist = [] if data["folderno"]: qlist.append(filenoquery) if data["surname"]: qlist.append(surnamequery) if data["name"]: qlist.append(firstnamequery) if data["bdate"]: qlist.append(bdatequery) if len(qlist) > 1: mq = " and ".join(qlist) elif len(qlist) != 0: mq = qlist[0] else: BARWRITER.write("No Matches Found") return [] q = query + mq + post cursor = self.conn.cursor() cursor.execute(q) # set the rusult Result.setResult(cursor.dictfetchall()) BARWRITER.write("Save Completed at %s" % time.ctime())
try: cursor = self.conn.cursor() cursor.execute(query) self.conn.commit() except psycopg.IntegrityError, x: msg = "Failed to Add entry,\nFile Number %d already in use" % data['file_number'] from Dialogs.Utils import displayMessage displayMessage(msg) BARWRITER.write(msg) return if self.lastSearchData: res = self.search(self.lastSearchData) Registry.get("SEARCH").presentResult() BARWRITER.write("New Entry Added at %s" % time.ctime()) def deleteEntry(self, folderNo): """ delete the folder from the database""" query = """ delete from patient.contact where file_number='%(file_number)d'; delete from patient.visit where file_number='%(file_number)d'; delete from patient.patient where file_number='%(file_number)d'; """ % {"file_number":folderNo} cursor = self.conn.cursor() cursor.execute(query) self.conn.commit() def saveContacts(self, file_number, data):