def printLetter(om_gui): ''' prints a letter to the patient ''' if om_gui.pt.serialno == 0: om_gui.advise(_("no patient selected"), 1) return html = standard_letter.getHtml(om_gui.pt) dl = CorrespondenceDialog(html, om_gui.pt, parent=None) dl.show() if dl.exec_(): letter = letterprint.letter(dl.text) if letter.printpage(): docsprinted.add(dl.pt.serialno, "%s (html)" % dl.letter_description, dl.text) dl.pt.addHiddenNote("printed", "%s %s" % (_("letter"), dl.letter_description) ) if dl.pt == om_gui.pt: if om_gui.ui.prevCorres_treeWidget.isVisible(): om_gui.docsPrintedInit() om_gui.updateHiddenNotesLabel() else: patient_write_changes.toNotes(dl.pt.serialno, dl.pt.HIDDENNOTES)
def printReferral(om_gui): ''' prints a referal letter ''' if om_gui.pt.serialno == 0: om_gui.advise("no patient selected", 1) return desc = om_gui.ui.referralLettersComboBox.currentText() html = referral.getHtml(desc, om_gui.pt) dl = CorrespondenceDialog(html, om_gui.pt, preformatted=False, parent=None) dl.show() if dl.exec_(): letter = letterprint.letter(dl.text) if letter.printpage(): docsprinted.add(dl.pt.serialno, "%s referral (html)" % desc, dl.text) dl.pt.addHiddenNote("printed", "referral") if dl.pt == om_gui.pt: if om_gui.ui.prevCorres_treeWidget.isVisible(): om_gui.docsPrintedInit() om_gui.updateHiddenNotesLabel() else: patient_write_changes.toNotes(dl.pt.serialno, dl.pt.HIDDENNOTES) return True
def printLetter(om_gui): ''' prints a letter to the patient ''' if om_gui.pt.serialno == 0: om_gui.advise(_("no patient selected"), 1) return html = standard_letter.getHtml(om_gui.pt) dl = CorrespondenceDialog(html, om_gui.pt, parent=None) dl.show() if dl.exec_(): letter = letterprint.letter(dl.text) if letter.printpage(): docsprinted.add(dl.pt.serialno, "%s (html)" % dl.letter_description, dl.text) dl.pt.addHiddenNote("printed", "%s %s" % (_("letter"), dl.letter_description)) if dl.pt == om_gui.pt: if om_gui.ui.prevCorres_treeWidget.isVisible(): om_gui.docsPrintedInit() om_gui.updateHiddenNotesLabel() else: patient_write_changes.toNotes(dl.pt.serialno, dl.pt.HIDDENNOTES)
def printSelectedAccounts(om_gui): ''' iterate over te accounts table, and print letters to those who have been selected to get an invoice ''' if om_gui.ui.accounts_tableWidget.rowCount() == 0: om_gui.advise("Please load the table first", 1) return firstPage = True no_printed = 0 for row in range(om_gui.ui.accounts_tableWidget.rowCount()): for col in range(11, 14): item = om_gui.ui.accounts_tableWidget.item(row, col) if item.checkState(): tone = ("A", "B", "C")[col - 11] sno = int(om_gui.ui.accounts_tableWidget.item(row, 1).text()) LOGGER.info("Account tone %s letter to %s", tone, sno) printpt = patient_class.patient(sno) doc = AccountLetter(printpt.title, printpt.fname, printpt.sname, (printpt.addr1, printpt.addr2, printpt.addr3, printpt.town, printpt.county), printpt.pcde, printpt.fees) doc.setTone(tone) if firstPage: # -raise a print dialog for the first letter of the run # -only if not doc.dialogExec(): # - user has abandoned the print run return chosenPrinter = doc.printer chosenPageSize = doc.printer.pageSize() firstPage = False else: doc.printer = chosenPrinter doc.printer.setPaperSize(chosenPageSize) doc.requireDialog = False if tone == "B": doc.setPreviousCorrespondenceDate(printpt.billdate) if doc.print_(): printpt.updateBilling(tone) printpt.addHiddenNote( "printed", "account - tone %s" % tone) patient_write_changes.discreet_changes( printpt, ("billct", "billdate", "billtype")) patient_write_changes.toNotes(sno, printpt.HIDDENNOTES) commitPDFtoDB(om_gui, "Account tone%s" % tone, printpt.serialno) no_printed += 1 om_gui.advise("%d letters printed" % no_printed, 1)
def apply_changed(self): lines = unicode(self.text_edit.toPlainText()).strip(" \n)").split("\n") short_lines = [] for note in lines: while len(note) > 79: if " " in note[:79]: pos = note[:79].rindex(" ") #--try to split nicely elif "," in note[:79]: pos = note[:79].rindex(",") #--try to split nicely else: pos = 79 #--ok, no option (unlikely to happen though) short_lines.append(note[:pos]) note = note[pos + 1:] short_lines.append(note.strip(" \n") + "\n") values = [] i = 0 for ix, note in self.notes: try: values.append((short_lines[i], ix)) except IndexError: # a line has been deleted. values.append(("", ix)) i += 1 query = 'update formatted_notes set note=%s where ix=%s' db = connect.connect() cursor = db.cursor() cursor.executemany(query, tuple(values)) cursor.close() if len(short_lines) > i: patient_write_changes.toNotes( self.sno, [("newNOTE", n) for n in short_lines[i:]] )
def apply_changed(self): notes = str(self.text_edit.toPlainText()).rstrip(" \n") short_lines = list(patient_write_changes.note_splitter(notes, "\n")) LOGGER.debug(short_lines) values = [] i = 0 for ix, note in self.notes: try: values.append((short_lines[i], ix)) except IndexError: # a line has been deleted. values.append(("", ix)) i += 1 db = connect.connect() cursor = db.cursor() cursor.executemany(UPDATE_QUERY, values) cursor.close() if len(short_lines) > i: patient_write_changes.toNotes(self.sno, [("newNOTE", line) for line in short_lines[i:]])
def apply_changed(self): lines = (unicode(self.text_edit.toPlainText())).split("\n") short_lines = [] for note in lines: while len(note) > 79: if " " in note[:79]: pos = note[:79].rindex(" ") #--try to split nicely elif "," in note[:79]: pos = note[:79].rindex(",") #--try to split nicely else: pos = 79 #--ok, no option (unlikely to happen though) short_lines.append(note[:pos]) note = note[pos + 1:] short_lines.append(note + "\n") values = [] i = 0 for ix, note in self.notes: try: values.append((short_lines[i], ix)) except IndexError: # a line has been deleted. values.append(("", ix)) i += 1 query = 'update formatted_notes set note=%s where ix=%s' db = connect.connect() cursor = db.cursor() cursor.executemany(query, tuple(values)) cursor.close() if len(short_lines) > i: patient_write_changes.toNotes(self.sno, [("newNOTE", n) for n in short_lines[i:]])
def apply_changed(self): notes = str(self.text_edit.toPlainText()).rstrip(" \n") short_lines = list(patient_write_changes.note_splitter(notes, "\n")) LOGGER.debug(short_lines) values = [] i = 0 for ix, note in self.notes: try: values.append((short_lines[i], ix)) except IndexError: # a line has been deleted. values.append(("", ix)) i += 1 db = connect.connect() cursor = db.cursor() cursor.executemany(UPDATE_QUERY, values) cursor.close() if len(short_lines) > i: patient_write_changes.toNotes( self.sno, [("newNOTE", line) for line in short_lines[i:]] )
def takePayment(om_gui): ''' raise a dialog, and take some money ''' if om_gui.pt.serialno == 0: om_gui.advise("No patient Selected <br />Monies will be " + "allocated to Other Payments, and no receipt offered") dl = PaymentDialog(om_gui) dl.set_treatment_default_amount(om_gui.pt.fees) dl.hide_treatment(om_gui.pt.serialno == 0) if dl.exec_(): if om_gui.pt.serialno == 0: paymentPt = patient_class.patient(22963) else: paymentPt = om_gui.pt name = "%s %s" % (paymentPt.sname, paymentPt.fname[:1]) if paymentPt.dnt2 != 0: dent = paymentPt.dnt2 else: dent = paymentPt.dnt1 LOGGER.debug("TAKING PAYMENT for patient %s" % paymentPt.serialno) if cashbook.paymenttaken(paymentPt.serialno, name, dent, paymentPt.cset, dl.tx_cash, dl.tx_cheque, dl.tx_card, dl.sundry_cash, dl.sundry_cheque, dl.sundry_card, dl.hdp, dl.other, dl.refund): paymentPt.addHiddenNote( "payment", " treatment %s sundries %s" % (dl.tx_total_text, dl.sundry_total_text)) om_gui.updateHiddenNotesLabel() if om_gui.pt.serialno != 0: LOGGER.debug("loaded patient == payment patient") om_printing.printReceipt(om_gui, { "Treatments and Services": dl.tx_total_text, "Sundry Items": dl.sundry_total_text, "Unspecified Items": dl.other_text, "REFUND": dl.refund_text }, total=dl.grand_total_text) #-- always refer to money in terms of pence print "adjusting money" if om_gui.pt.cset[:1] == "N": om_gui.pt.money2 += dl.tx_total else: om_gui.pt.money3 += dl.tx_total om_gui.pt.money11 -= dl.refund else: LOGGER.debug( "Payment patient is not loaded. skipping receipt offer.") patient_write_changes.toNotes(paymentPt.serialno, paymentPt.HIDDENNOTES) LOGGER.debug("writing payment notes") if patient_write_changes.discreet_changes( paymentPt, ("money2", "money3", "money11")) and om_gui.pt.serialno != 0: LOGGER.debug("updating patient's stored money values") om_gui.pt.dbstate.money2 = om_gui.pt.money2 om_gui.pt.dbstate.money3 = om_gui.pt.money3 om_gui.pt.dbstate.money11 = om_gui.pt.money11 paymentPt.clearHiddenNotes() om_gui.updateDetails() om_gui.updateHiddenNotesLabel() LOGGER.info("PAYMENT ALL DONE!") else: LOGGER.warning("payment failed to write to database!") message = "%s<br />%s" % ( _("error applying payment.... sorry!"), _("This shouldn't happen - please report as an urgent bug")) om_gui.advise(message, 2)
def takePayment(om_gui): ''' raise a dialog, and take some money ''' if om_gui.pt.serialno == 0: om_gui.advise("No patient Selected <br />Monies will be "+ \ "allocated to Other Payments, and no receipt offered") dl = PaymentDialog(om_gui) dl.set_treatment_default_amount(om_gui.pt.fees) dl.hide_treatment(om_gui.pt.serialno == 0) if dl.exec_(): if om_gui.pt.serialno == 0: paymentPt = patient_class.patient(22963) else: paymentPt = om_gui.pt name = "%s %s"% (paymentPt.sname, paymentPt.fname[:1]) if paymentPt.dnt2 != 0: dent = paymentPt.dnt2 else: dent = paymentPt.dnt1 LOGGER.debug("TAKING PAYMENT for patient %s"% paymentPt.serialno) if cashbook.paymenttaken(paymentPt.serialno, name, dent,paymentPt.cset, dl.tx_cash, dl.tx_cheque, dl.tx_card, dl.sundry_cash, dl.sundry_cheque, dl.sundry_card, dl.hdp, dl.other, dl.refund): paymentPt.addHiddenNote("payment", " treatment %s sundries %s"% ( dl.tx_total_text, dl.sundry_total_text)) om_gui.updateHiddenNotesLabel() if om_gui.pt.serialno != 0: LOGGER.debug("loaded patient == payment patient") om_printing.printReceipt(om_gui,{ "Treatments and Services" : dl.tx_total_text, "Sundry Items" : dl.sundry_total_text, "Unspecified Items" : dl.other_text, "REFUND" : dl.refund_text}, total=dl.grand_total_text) #-- always refer to money in terms of pence print "adjusting money" if om_gui.pt.cset[:1] == "N": om_gui.pt.money2 += dl.tx_total else: om_gui.pt.money3 += dl.tx_total om_gui.pt.money11 -= dl.refund else: LOGGER.debug( "Payment patient is not loaded. skipping receipt offer.") patient_write_changes.toNotes(paymentPt.serialno, paymentPt.HIDDENNOTES) LOGGER.debug("writing payment notes") if patient_write_changes.discreet_changes(paymentPt, ("money2", "money3", "money11")) and om_gui.pt.serialno != 0: LOGGER.debug("updating patient's stored money values") om_gui.pt.dbstate.money2 = om_gui.pt.money2 om_gui.pt.dbstate.money3 = om_gui.pt.money3 om_gui.pt.dbstate.money11 = om_gui.pt.money11 paymentPt.clearHiddenNotes() om_gui.updateDetails() om_gui.updateHiddenNotesLabel() LOGGER.info("PAYMENT ALL DONE!") else: LOGGER.warning("payment failed to write to database!") message = "%s<br />%s"% ( _("error applying payment.... sorry!"), _("This shouldn't happen - please report as an urgent bug") ) om_gui.advise(message, 2)