Example #1
0
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)
Example #2
0
def printaccount(om_gui, tone="A"):
    if om_gui.pt.serialno == 0:
        om_gui.advise("no patient selected", 1)
    else:
        doc = AccountLetter(
            om_gui.pt.title, om_gui.pt.fname, om_gui.pt.sname,
            (om_gui.pt.addr1, om_gui.pt.addr2, om_gui.pt.addr3,
             om_gui.pt.town, om_gui.pt.county),
            om_gui.pt.pcde, om_gui.pt.fees
        )
        doc.setTone(tone)
        if tone == "B":
            doc.setPreviousCorrespondenceDate(om_gui.pt.billdate)
            # TODO unsure if this is correct date!
            # please print one and try it!
        if doc.print_():
            om_gui.pt.updateBilling(tone)
            om_gui.pt.addHiddenNote("printed", "account - tone %s" % tone)
            om_gui.addNewNote("Account Printed")
            commitPDFtoDB(om_gui, "Account tone%s" % tone)
            om_gui.updateHiddenNotesLabel()