Ejemplo n.º 1
0
 def changePt(self):
     dl = FindPatientDialog(self.om_gui)
     if dl.exec_():
         serialno = dl.chosen_sno
         try:
             self.setPatient(patient_class.patient(serialno))
         except localsettings.PatientNotFoundError:
             QtWidgets.QMessageBox.information(
                 self, _("Error"), _("patient not found"))
             self.setPatient(patient_class.patient(0))
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def test_exec(self):
        pt = patient_class.patient(20862)
        if self.exec_(pt):
            for Form in self.dl.chosen_forms:
                form = Form()
                form.set_data(self.dl.data)

                form.set_testing_mode(self.dl.print_boxes)
                form.set_background_mode(self.dl.print_background)
                form.controlled_print()
Ejemplo n.º 4
0
 def test_exec(self):
     mw = QtWidgets.QWidget()
     mw.pt = patient_class.patient(1)
     self.exec_(mw)
     for att, item in self.dl.deleted_plan_items:
         print("%spl %s deleted" % (att, item))
     for att, item in self.dl.deleted_cmp_items:
         print("%scmp %s deleted" % (att, item))
     for att, item in self.dl.new_plan_items:
         print("%spl %s added" % (att, item))
     for att, item in self.dl.new_cmp_items:
         print("%scmp %s added" % (att, item))
     for att, item in self.dl.completed_items:
         print("%s %s was completed" % (att, item))
     for att, item in self.dl.reversed_items:
         print("%s %s was reveresed" % (att, item))
Ejemplo n.º 5
0
def takePayment(om_gui):
    '''
    raise a dialog, and take some money
    '''
    if om_gui.pt.serialno == 0:
        try:
            paymentPt = patient_class.patient(22963)
        except PatientNotFoundError:
            om_gui.advise(_("Please choose a patient"), 1)
            return
        om_gui.advise(
            "%s <br />%s" %
            (_("No patient Selected"),
             _("Monies will be allocated to Other Payments, and no receipt "
               "offered")), 1)
    else:
        paymentPt = om_gui.pt

    dl = PaymentDialog(om_gui)
    dl.set_treatment_default_amount(paymentPt.fees)
    dl.hide_treatment(om_gui.pt.serialno == 0)
    payment_taken = False
    name = "%s %s" % (paymentPt.sname, paymentPt.fname[:1])
    if paymentPt.dnt2 != 0:
        dent = paymentPt.dnt2
    else:
        dent = paymentPt.dnt1

    while not payment_taken:
        if not dl.exec_():
            break
        if (dl.tx_total > paymentPt.fees and QtWidgets.QMessageBox.question(
                dl, _("Confirm"),
                _("Overpayment of treatment fees, is this correct?"),
                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.No):
            continue

        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
                LOGGER.debug("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.")

            LOGGER.debug("writing payment notes")
            om_gui.pt.reset_billing()
            if patient_write_changes.discreet_changes(
                    paymentPt,
                ("money2", "money3", "money11", "billdate", "billct",
                 "billtype")) 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
                om_gui.pt.dbstate.reset_billing()

            om_gui.updateDetails()
            om_gui.updateHiddenNotesLabel()
            LOGGER.info("PAYMENT ALL DONE!")
            payment_taken = True
Ejemplo n.º 6
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.pt = patient_class.patient(1)
Ejemplo n.º 7
0
                    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 historyPrint(om_gui):
    html = om_gui.ui.debugBrowser.toHtml()
    myclass = bookprint.printBook(html)
    myclass.printpage()


if __name__ == "__main__":
    import os
    os.chdir(os.path.expanduser("~"))  # for printing to pdf
    app = QtGui.QApplication([])
    widg = QtGui.QWidget()
    widg.pt = patient_class.patient(1)
    printLetter(widg)
Ejemplo n.º 8
0
    if not plandata.retrieved:
        return "There was an error retrieving this information"

    retarg = '''<html><body><center>
    <h3>PLAN DETAILS</h3>
    <table width ="100%" border="1">
    '''
    retarg += "<tr><td>PLAN TYPE</td><td>%s</td></tr>" % plandata.plantype
    retarg += "<tr><td>BAND</td><td>%s</td></tr>" % plandata.band
    retarg += "<tr><td>GROSS CHARGE</td><td>%s</td></tr>" % (
        localsettings.formatMoney(plandata.grosschg))
    retarg += "<tr><td>DISCOUNT</td><td>%s&#37;</td></tr>" % plandata.discount
    retarg += "<tr><td>NET CHARGE</td><td>%s</td></tr>" % (
        localsettings.formatMoney(plandata.netchg))
    retarg += "<tr><td>CATEGORY</td><td>%s</td></tr>" % plandata.catcode
    retarg += "<tr><td>DATE JOINED</td><td>%s</td></tr>" % plandata.planjoin
    retarg += \
        "<tr><td>REGISTRATION NUMBER</td><td>%s</td></tr>" % plandata.regno

    retarg += '</table></body></html>'

    return retarg


if __name__ == "__main__":
    from openmolar.dbtools import patient_class
    localsettings.initiate()

    pt = patient_class.patient(1)
    print(toHtml(pt.plandata))
Ejemplo n.º 9
0
 def test_exec(self):
     pt = patient_class.patient(10781)
     self.exec_(pt, None)
Ejemplo n.º 10
0
                if appt.today:
                    self.appts.remove(appt)
                    self.set_label_text()
        else:
            self.enableApply(False)
            self.get_data()

    def accept(self):
        if self.appts == []:
            QtGui.QMessageBox.information(self, "warning",
                                          _("No appointments to print!"))
            self.reject()

        card = apptcardPrint.Card()
        card.setProps(self.pt, self.appts)

        card.print_()
        self.pt.addHiddenNote("printed", "appt card")
        BaseDialog.accept(self)

if __name__ == "__main__":
    localsettings.initiate()
    from openmolar.qt4gui import resources_rc
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(20862)

    app = QtGui.QApplication([])

    dl = AppointmentCardDialog(pt, None)
    dl.exec_()
Ejemplo n.º 11
0
def _test():
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(1)
    return getHtml(pt)
Ejemplo n.º 12
0
    retarg += newline
    retarg += '</table></div></body></html>'

    return retarg


def todays_notes(serialno):
    html = notes(get_notes_dict(serialno, True))
    if not _("Today") in html:
        html = HEADER
        html += "%s <a href='edit_notes?%s'>%s</a></body></html>" % (
            _("No notes found"), serialno, _("Add a note"))

    return  html.replace("||SNO||", str(serialno))


if __name__ == "__main__":
    import datetime
    LOGGER.setLevel(logging.DEBUG)
    from openmolar.dbtools import patient_class
    try:
        serialno = int(sys.argv[len(sys.argv) - 1])
    except:
        serialno = 303  # 1

    notes_ = notes(patient_class.patient(serialno).notes_dict)
    print notes_.encode("ascii", "replace")
    notes_ = rec_notes(
        patient_class.patient(serialno).notes_dict, datetime.date(2015, 10, 1))
    print notes_.encode("ascii", "replace")
 def test_exec(self):
     pt = patient(1)
     pt.HIDDENNOTES = [('COURSE OPENED', '= = = = = '), ('TC: EXAM', 'CE')]
     self.exec_(pt, None)
Ejemplo n.º 14
0
            break
        i += 1


def tooth(data):
    # return str(data.split("\t"))
    retarg = ""
    for c in data:
        i = char(c)
        if i in CHART:
            retarg += CHART[i] + " "
        else:
            retarg += c
    return retarg


if __name__ == "__main__":
    sys.path.append("/home/neil/openmolar")
    from openmolar.dbtools import patient_class
    try:
        serialno = int(sys.argv[len(sys.argv) - 1])
    except:
        serialno = 1
    if "-v" in sys.argv:
        verbose = True
    else:
        verbose = False
    # print "getting notes"
    # print rec_notes(patient_class.patient(serialno).notes_dict)
    print(notes(patient_class.patient(serialno).notes_dict, verbose))
Ejemplo n.º 15
0
 def test_exec(self):
     pt = patient_class.patient(1)
     self.exec_(pt)
Ejemplo n.º 16
0
            newline += '\n</tr>\n'
    retarg += newline
    retarg += '</table></div></body></html>'

    return retarg


def todays_notes(serialno):
    html = notes(get_notes_dict(serialno, True))
    if not _("Today") in html:
        html = HEADER
        html += "%s <a href='edit_notes?%s'>%s</a></body></html>" % (
            _("No notes found"), serialno, _("Add a note"))

    return html.replace("||SNO||", str(serialno))


if __name__ == "__main__":
    import datetime
    LOGGER.setLevel(logging.DEBUG)
    from openmolar.dbtools import patient_class
    try:
        serialno = int(sys.argv[len(sys.argv) - 1])
    except:
        serialno = 303  # 1
    notes_ = notes(patient_class.patient(serialno).notes_dict)
    print(notes_)
    notes_ = rec_notes(
        patient_class.patient(serialno).notes_dict, datetime.date(2015, 10, 1))
    print(notes_)
Ejemplo n.º 17
0
 def test_exec(self):
     pt = patient_class.patient(11932)
     if self.exec_(pt):
         print(self.dl.result)
Ejemplo n.º 18
0
                form = Form()
                form.set_data(dl.data)
                form.printer.setDocName(form.NAME)
                form.set_testing_mode(dl.print_boxes)
                form.set_background_mode(dl.print_background)
                if form.controlled_print() and not test:
                    commitPDFtoDB(self.om_gui, form.NAME)

                    self.om_gui.pt.addHiddenNote(
                        "printed", "%s %s"% (form.NAME, dl.dent_inits))
                    self.om_gui.updateHiddenNotesLabel()


if __name__ == "__main__":
    from openmolar.settings import localsettings
    from openmolar.qt4gui import maingui
    from openmolar.dbtools import patient_class

    os.chdir(os.path.expanduser("~")) #for save pdf

    localsettings.initiate()
    localsettings.station="reception" #prevent no clinician popup

    app = QtGui.QApplication([])

    om_gui = maingui.OpenmolarGui()

    om_gui.pt = patient_class.patient(2981)

    p = GP17Printer(om_gui)
    p.test_print()
Ejemplo n.º 19
0
            font = QtGui.QFont("Helvetica", 7)
            font.setItalic(True)
            painter.setFont(font)
            option = QtGui.QTextOption(QtCore.Qt.AlignCenter)
            option.setWrapMode(QtGui.QTextOption.WordWrap)
            painter.drawText(
                QtCore.QRectF(0, y, pageRect.width(), 31),
                _("Please note, this estimate may be subject to change if "
                  "clinical circumstances dictate."), option)
        return True


if __name__ == "__main__":

    localsettings.initiate(False)
    from openmolar.dbtools import patient_class
    from openmolar.ptModules import estimates
    pt = patient_class.patient(23664)

    app = QtWidgets.QApplication([])

    myreceipt = EstimateLetter()

    myreceipt.title = pt.title
    myreceipt.fname = pt.fname
    myreceipt.sname = pt.sname
    myreceipt.ourref = pt.serialno
    myreceipt.estItems = estimates.sorted_estimates(pt.estimates)

    myreceipt.print_()
Ejemplo n.º 20
0
            alert = ""
        if pt.fees > 0:
            amount = localsettings.formatMoney(pt.fees)
            retarg += '<hr /><h3 class="debt">Account = %s %s</h3>'% (
            amount, alert)
        if pt.fees < 0:
            amount = localsettings.formatMoney(-pt.fees)
            retarg += '<hr /><h3>%s in credit %s</h3>'% (amount, alert)

        if pt.underTreatment:
            retarg += '<hr /><h2 class="ut_label">UNDER TREATMENT</h2><hr />'

        return '''%s\n</div></body></html>'''% retarg
    except Exception as exc:
        LOGGER.exception("error in patientDetails.details")
        return "error displaying details, sorry <br />%s"% exc

if __name__ == '__main__':
    localsettings.initiate()
    localsettings.loadFeeTables()
    try:
        serialno = int(sys.argv[len(sys.argv)-1])
    except:
        serialno = 4792
    if '-v' in sys.argv:
        verbose = True
    else:
         verbose = False
    print details(patient_class.patient(serialno))

Ejemplo n.º 21
0
def print_mh_forms(serialnos, om_gui):
    for serialno in serialnos:
        pt = patient_class.patient(serialno)
        LOGGER.info("print MH form for %s" % pt.serialno)
        mh_printer = MHPrint(pt, om_gui)
        mh_printer.print_()
Ejemplo n.º 22
0
    '''
    get daybook history for this tooth
    '''
    tooth = tooth.upper()
    hist = ""
    for tdate, apptix, items in pt.dayBookHistory:
        regex = "%s (.*)" % tooth
        for item in items.split("  "):
            for tx in re.findall(regex, item):
                hist += "<li>%s - %s - %s</li>" % (
                    localsettings.formatDate(tdate),
                    localsettings.ops.get(int(apptix)),
                    tx)
    if hist == "":
        hist = "None Found"
    else:
        hist = "<ul>%s</ul>" % hist
    return "History for %s<hr />%s" % (tooth, hist)

if __name__ == "__main__":
    import sys
    from openmolar.dbtools import patient_class
    localsettings.initiate()
    try:
        serialno = int(sys.argv[len(sys.argv) - 1])
    except:
        serialno = 11283
    pt = patient_class.patient(serialno)
    print pt.dayBookHistory
    print getHistory(pt, "lr5")
Ejemplo n.º 23
0
def _test():
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(1)
    return getHtml(pt)
Ejemplo n.º 24
0
            but = QtGui.QPushButton(crown_button.description)
            but.setToolTip(crown_button.tooltip)
            but.clicked.connect(
                partial(self.but_clicked, crown_button.shortcut))
            self.but_layout.addWidget(but, row // 2, row % 2)
        self.but_layout.setRowStretch((row + 2) // 2, 100)

    def _show_all_crowns(self):
        self.add_buttons(localsettings.FEETABLES.ui_crown_chart_buttons)
        self.hide_extension()

    def but_clicked(self, shortcut):
        self.chosen_shortcut = shortcut
        self.accept()


if __name__ == "__main__":
    from gettext import gettext as _
    from openmolar.dbtools.patient_class import patient

    app = QtGui.QApplication([])
    mw = QtGui.QWidget()
    mw.pt = patient(11956)
    dl = CrownChoiceDialog(True, mw)
    if dl.exec_():
        print dl.chosen_shortcut
    localsettings.loadFeeTables()
    dl = CrownChoiceDialog(False, mw)
    if dl.exec_():
        print dl.chosen_shortcut
Ejemplo n.º 25
0
        i += 1


def tooth(data):
    # return str(data.split("\t"))
    retarg = ""
    for c in data:
        i = char(c)
        if i in CHART:
            retarg += CHART[i] + " "
        else:
            retarg += c
    return retarg


if __name__ == "__main__":
    sys.path.append("/home/neil/openmolar")
    from openmolar.dbtools import patient_class

    try:
        serialno = int(sys.argv[len(sys.argv) - 1])
    except:
        serialno = 1
    if "-v" in sys.argv:
        verbose = True
    else:
        verbose = False
    # print "getting notes"
    # print rec_notes(patient_class.patient(serialno).notes_dict)
    print(notes(patient_class.patient(serialno).notes_dict, verbose))
Ejemplo n.º 26
0
                    self.appts.remove(appt)
                    self.set_label_text()
        else:
            self.enableApply(False)
            self.get_data()

    def accept(self):
        if self.appts == []:
            QtGui.QMessageBox.information(self, "warning",
                                          _("No appointments to print!"))
            self.reject()

        card = apptcardPrint.Card()
        card.setProps(self.pt, self.appts)

        card.print_()
        self.pt.addHiddenNote("printed", "appt card")
        BaseDialog.accept(self)


if __name__ == "__main__":
    localsettings.initiate()
    from openmolar.qt4gui import resources_rc
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(20862)

    app = QtGui.QApplication([])

    dl = AppointmentCardDialog(pt, None)
    dl.exec_()
Ejemplo n.º 27
0
                form.set_data(dl.data)
                form.printer.setDocName(form.NAME)
                form.set_testing_mode(dl.print_boxes)
                form.set_background_mode(dl.print_background)
                if form.controlled_print() and not test:
                    commitPDFtoDB(self.om_gui, form.NAME)

                    self.om_gui.pt.addHiddenNote(
                        "printed", "%s %s" % (form.NAME, dl.dent_inits))
                    self.om_gui.updateHiddenNotesLabel()


if __name__ == "__main__":
    from openmolar.settings import localsettings
    from openmolar.qt4gui import maingui
    from openmolar.dbtools import patient_class

    os.chdir(os.path.expanduser("~"))  # for save pdf

    localsettings.initiate()
    localsettings.station = "reception"  # prevent no clinician popup

    app = QtGui.QApplication([])

    om_gui = maingui.OpenmolarGui()

    om_gui.pt = patient_class.patient(2981)

    p = GP17Printer(om_gui)
    p.test_print()
Ejemplo n.º 28
0
        if self.mh and self.mh.other:
            y += line_height
            bold_off()
            italic_on()
            print_text(self.mh.other.lower(), y, rowspan=4)
            italic_off()
            bold_on()

        y = self.printer.pageRect().height() - MARGIN_BOTTOM

        print_text(_("Patient's Signature"), y, 0, 3)
        print_line(y, 3, 6)

        print_text(self.date_text, y, 10, 2)


if __name__ == "__main__":
    import os
    os.chdir(os.path.expanduser("~"))

    localsettings.initiate()
    app = QtGui.QApplication([])
    from openmolar.dbtools.patient_class import patient

    mw = QtGui.QWidget()
    mw.include_mh = True
    pt = patient(29833)

    mh_print = MHPrint(pt, mw)
    mh_print.print_()
        myreceipt.setProps(self.pt.title, self.pt.fname, self.pt.sname,
                           self.pt.addr1, self.pt.addr2, self.pt.addr3, self.pt.town,
                           self.pt.county, self.pt.pcde)

        myreceipt.total = amount * 100

        myreceipt.receivedDict = {_("Professional Services"): amount * 100}
        myreceipt.isDuplicate = True
        myreceipt.dupdate = self.dup_date_edit.date()

        if myreceipt.print_():
            self.pt.addHiddenNote("printed", "%s %.02f" % (
                                  _("duplicate receipt for"), amount))

            self.duplicate_printed = True
            self.accept()

    def apply_changed(self):
        print "applying changes"

if __name__ == "__main__":
    localsettings.initiate()
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(10781)

    app = QtGui.QApplication([])

    dl = DuplicateReceiptDialog(pt, None)
    dl.exec_()
Ejemplo n.º 30
0
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)
Ejemplo n.º 31
0
        return (self.has_money_changes or
                self.has_date_changes or
                self.has_hidden_note_changes)

    def _check_enable(self):
        self.enableApply(self.has_changes)

    def apply(self):
        LOGGER.warning("advanced record management dialog applying changes")
        self.changeMoney()
        self.changeDates()
        self.changeHidden_notes()

if __name__ == "__main__":
    localsettings.initiate()
    localsettings.loadFeeTables()
    LOGGER.setLevel(logging.DEBUG)

    from openmolar.dbtools.patient_class import patient
    pt = patient(1)

    app = QtGui.QApplication([])
    pt.HIDDENNOTES = [
        ('COURSE OPENED', '= = = = = '),
        ('TC: EXAM', 'CE')
    ]

    dl = AdvancedRecordManagementDialog(pt, None)
    if dl.exec_():
        dl.apply()
Ejemplo n.º 32
0
            adate = localsettings.longDate(appt.date)

            text = "%s - %s with %s" % (atime, adate, appt.dent_inits)

            rect = QtCore.QRectF(0, y, pageRect.width(), fontLineHeight * 1.5)

            painter.drawText(rect, text, option)

        y = pageRect.height() * 2 / 3

        painter.drawLine(0, int(y), int(pageRect.width()), int(y))
        font.setItalic(True)
        painter.setFont(font)

        rect = QtCore.QRectF(0, y, pageRect.width(), pageRect.height() * 1 / 3)
        painter.drawText(rect, localsettings.APPOINTMENT_CARD_FOOTER, option)


if __name__ == "__main__":
    import sys
    localsettings.initiate(False)
    app = QtWidgets.QApplication(sys.argv)
    mycard = Card()
    print(mycard.printer.getPageMargins(QtPrintSupport.QPrinter.Millimeter))
    from openmolar.dbtools import patient_class
    from openmolar.dbtools import appointments
    pt = patient_class.patient(11956)
    appts = appointments.get_pts_appts(pt, True)
    mycard.setProps(pt, appts)
    mycard.print_()
Ejemplo n.º 33
0
            font = QtGui.QFont("Helvetica", 7)
            font.setItalic(True)
            painter.setFont(font)
            option = QtGui.QTextOption(QtCore.Qt.AlignCenter)
            option.setWrapMode(QtGui.QTextOption.WordWrap)
            painter.drawText(
                QtCore.QRectF(0, y, pageRect.width(), 31),
                _("Please note, this estimate may be subject to change if "
                  "clinical circumstances dictate."), option)
        return True


if __name__ == "__main__":

    localsettings.initiate(False)
    from openmolar.dbtools import patient_class
    from openmolar.ptModules import estimates
    pt = patient_class.patient(23664)

    app = QtGui.QApplication([])

    myreceipt = estimate()

    myreceipt.title = pt.title
    myreceipt.fname = pt.fname
    myreceipt.sname = pt.sname
    myreceipt.ourref = pt.serialno
    myreceipt.estItems = estimates.sorted_estimates(pt.estimates)

    myreceipt.print_()
Ejemplo n.º 34
0
 def setUp(self):
     super().setUp()
     localsettings.initiateUsers()
     localsettings.initiate()
     self.mw = QtWidgets.QWidget()
     self.mw.pt = patient_class.patient(11956)
Ejemplo n.º 35
0
 def test_exec(self):
     self.mw.pt = patient_class.patient(1)
     if self.exec_(self.mw):
         print(self.dl.chosen_treatments)
Ejemplo n.º 36
0
    return html_


def treatment_html(pt):
    return u"<h4>Treatments (courseno %s)</h4>%s" % (
        pt.courseno0, estimate_synopsis.html(pt.courseno0))


def payments_html(pt):
    return u'''<h4>Payments Since this course began (excluding Sundries)</h4>
        %s ''' % paymentHistory.summary_details(
        pt.serialno, pt.treatment_course.accd)


def html(pt):
    html_ = HTML_TEMPLATE.replace("{{TREATMENTS}}", treatment_html(pt))
    html_ = html_.replace("{{PAYMENTS}}", payments_html(pt))
    html_ = html_.replace("{{HEADER}}", header_html(pt))

    return html_

if __name__ == '__main__':
    from openmolar.dbtools.patient_class import patient
    localsettings.initiate()

    pt = patient(1314)
    html = html(pt)
    html = html.encode("ascii", "replace")
    print html
Ejemplo n.º 37
0
            y += line_height
            bold_off()
            italic_on()
            print_text(self.mh.other.lower(), y, rowspan=4)
            italic_off()
            bold_on()

        y = self.printer.pageRect().height() - MARGIN_BOTTOM

        print_text(_("Patient's Signature"), y, 0, 3)
        print_line(y, 3, 6)

        print_text(self.date_text, y, 10, 2)


if __name__ == "__main__":
    import os

    os.chdir(os.path.expanduser("~"))

    localsettings.initiate()
    app = QtWidgets.QApplication([])
    from openmolar.dbtools.patient_class import patient

    mw = QtWidgets.QWidget()
    mw.include_mh = True
    pt = patient(29833)

    mh_print = MHPrint(pt, mw)
    mh_print.print_()
Ejemplo n.º 38
0
    def getInput(self):
        '''
        yields selected usercodes (allowing multiple selections)
        '''
        if self.exec_():
            for item_widg in self.itemWidgets:
                number = item_widg.spinBox.value()
                if number != 0:
                    for n in range(number):
                        yield item_widg.usercode

if __name__ == "__main__":
    import sys
    localsettings.initiate()
    localsettings.loadFeeTables()
    app = QtGui.QApplication(sys.argv)

    from openmolar.dbtools import patient_class
    pt = patient_class.patient(11956)
    items = (
            ("exam", "CE"),
            ("xray", "M"),
            ("perio", "SP")
    )

    dl = AddTreatmentDialog(items, pt)
    dl.use_completed_messages()
    for att, shortcut in dl.getInput():
        print "chosen item = %s %s" % (att, shortcut)
Ejemplo n.º 39
0
        content += "<li><b>%s</b> - %s</li>" % (key, value)
    content += "</ul>"
    html_ = HTML_TEMPLATE.replace("{{CONTENT}}", content)

    return html_


def finished_today_html(pt):
    return active_course_html(pt).replace(
        "<!-- HEADER -->",
        _("COMPLETED COURSE TODAY")
        )


def html(pt, summary=True):
    if summary:
        return summary_html(pt)

    if pt.last_treatment_date == localsettings.currentDay():
        return finished_today_html(pt)
    return active_course_html(pt)


if __name__ == '__main__':
    from openmolar.dbtools.patient_class import patient
    localsettings.initiate()

    pt = patient(26041)
    html = html(pt)
    print(html)
Ejemplo n.º 40
0
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)
Ejemplo n.º 41
0
 def test_exec(self):
     mw = QtWidgets.QWidget()
     mw.pt = patient_class.patient(3)
     self.exec_(mw)
                    self.new_plan_items.remove(item)
                except ValueError:
                    pass

            return True

        return False


if __name__ == "__main__":
    from gettext import gettext as _
    from openmolar.dbtools.patient_class import patient

    app = QtGui.QApplication([])
    mw = QtGui.QWidget()
    mw.pt = patient(11956)
    dl = AdvancedTxPlanningDialog(mw)
    if dl.exec_():
        for att, item in dl.deleted_plan_items:
            print("%spl %s deleted" % (att, item))
        for att, item in dl.deleted_cmp_items:
            print("%scmp %s deleted" % (att, item))
        for att, item in dl.new_plan_items:
            print("%spl %s added" % (att, item))
        for att, item in dl.new_cmp_items:
            print("%scmp %s added" % (att, item))
        for att, item in dl.completed_items:
            print("%s %s was completed" % (att, item))
        for att, item in dl.reversed_items:
            print("%s %s was reveresed" % (att, item))
Ejemplo n.º 43
0
        myreceipt.setProps(self.pt.title, self.pt.fname, self.pt.sname,
                           self.pt.addr1, self.pt.addr2, self.pt.addr3,
                           self.pt.town, self.pt.county, self.pt.pcde)

        myreceipt.total = amount * 100

        myreceipt.receivedDict = {_("Professional Services"): amount * 100}
        myreceipt.isDuplicate = True
        myreceipt.dupdate = self.dup_date_edit.date()

        if myreceipt.print_():
            self.pt.addHiddenNote(
                "printed", "%s %.02f" % (_("duplicate receipt for"), amount))

            self.duplicate_printed = True
            self.accept()

    def apply_changed(self):
        print "applying changes"


if __name__ == "__main__":
    localsettings.initiate()
    from openmolar.dbtools import patient_class
    pt = patient_class.patient(10781)

    app = QtGui.QApplication([])

    dl = DuplicateReceiptDialog(pt, None)
    dl.exec_()
Ejemplo n.º 44
0
def print_mh_forms(serialnos, om_gui):
    for serialno in serialnos:
        pt = patient_class.patient(serialno)
        dl = MHFormDialog(pt, om_gui)
        if dl.exec_():
            dl.apply()
Ejemplo n.º 45
0
        self.insertWidget(self.patient_label)
        self.insertWidget(self.warning_label)

        self.enableApply()

    def sizeHint(self):
        return QtCore.QSize(400, 200)

    def _clicked(self, but):
        if but == self.ignore_but:
            self.result = self.IGNORE
            self.accept()
            return
        BaseDialog._clicked(self, but)

    def reject(self):
        self.result = self.CANCEL
        BaseDialog.reject(self)


if __name__ == "__main__":
    LOGGER.setLevel(logging.DEBUG)
    app = QtGui.QApplication([])
    from openmolar.dbtools.patient_class import patient

    dl = RecallPromptDialog(patient(11932))

    dl.exec_()
    print dl.result
Ejemplo n.º 46
0
        if currentMax:
            newSerialno = currentMax+1
        else:
            newSerialno = 1
        try:
            cursor.execute(sqlcommand, tuple(values + [newSerialno]))
            cursor.close()
            db.commit()
            break

        except connect.IntegrityError, e:
            print "error saving new patient, will retry with new serialno"
            print e
            newSerialno = -1

        Attempts += 1
        if Attemps > 20:
            break
    #db.close()
    return newSerialno

if __name__ == "__main__":
    global pt
    from openmolar.dbtools import patient_class
    import copy
    pt= patient_class.patient(0)
    pt.fname="Norman"
    pt.sname="Wisdom"
    #ok - so a trivial change has been made - now write to the database
    print commit(pt)
Ejemplo n.º 47
0
    retarg += newline
    retarg += '</table></div></body></html>'

    return retarg

def todays_notes(serialno):
    html = notes(get_notes_dict(serialno, True))
    if not _("Today") in html:
        html = HEADER
        html += "%s <a href='edit_notes?%s'>%s</a></body></html>"% (
            _("No notes found"), serialno, _("Add a note"))

    name = db_patients.name(serialno)
    header = "<h3>%s %s</h3>"% (_("Todays notes for"), name)
    html = html.replace("<!HEADER>", header)
    html = html.replace("||SNO||", str(serialno))

    return html

if __name__ == "__main__":
    LOGGER.setLevel(logging.DEBUG)
    from openmolar.dbtools import patient_class
    try:
        serialno = int(sys.argv[len(sys.argv)-1])
    except:
        serialno = 1

    notes_ = notes(patient_class.patient(serialno).notes_dict)
    print notes_.encode("ascii", "replace")