def get_data(self):
        '''
        poll the database for appointment data
        '''

        self.appts = appointments.get_pts_appts(self.pt, True)
        self.set_label_text()

        print_today_issue = False
        for appt in self.appts:
            print_today_issue = print_today_issue or appt.today

        self.check_box.setVisible(print_today_issue)

        self.enableApply()
Beispiel #2
0
    def get_data(self):
        '''
        poll the database for appointment data
        '''

        self.appts = appointments.get_pts_appts(self.pt, True)
        self.set_label_text()

        print_today_issue = False
        for appt in self.appts:
            print_today_issue = print_today_issue or appt.today

        self.check_box.setVisible(print_today_issue)

        self.enableApply()
    def layout_ptDiary(self):
        '''
        populates the patient's diary model
        '''
        if self.pt is None or self.pt.serialno == 0:
            self.clear()
        else:
            LOGGER.debug("layout patient diary")
            self.ui.appt_memo_lineEdit.setText(self.pt.appt_memo)

            appts = appointments.get_pts_appts(self.pt)
            LOGGER.debug("%s appointments found from apr table", len(appts))
            self.diary_model.addAppointments(appts)
            LOGGER.debug("appointments added to model")
            self.adjustDiaryColWidths()
            LOGGER.debug("layout_ptDiary concluded")
Beispiel #4
0
    def layout_ptDiary(self):
        '''
        populates the patient's diary model
        '''
        if self.pt is None or self.pt.serialno == 0:
            self.clear()
        else:
            LOGGER.debug("layout patient diary")
            self.ui.appt_memo_lineEdit.setText(self.pt.appt_memo)

            appts = appointments.get_pts_appts(self.pt)
            LOGGER.debug("%s appointments found from apr table", len(appts))
            self.diary_model.addAppointments(appts)
            LOGGER.debug("appointments added to model")
            self.adjustDiaryColWidths()
            LOGGER.debug("layout_ptDiary concluded")
Beispiel #5
0
    def get_data(self):
        '''
        poll the database for appointment data
        '''

        self.appts = appointments.get_pts_appts(self.pt, True)
        self.set_label_text()

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

        print_today_issue = False
        for appt in self.appts:
            print_today_issue = print_today_issue or appt.today

        self.check_box.setVisible(print_today_issue)

        self.enableApply()
    def get_data(self):
        '''
        poll the database for appointment data
        '''

        self.appts = appointments.get_pts_appts(self.pt, True)
        self.set_label_text()

        if self.appts == []:
            mb = QtWidgets.QMessageBox(self)
            mb.setWindowTitle(_("message"))
            mb.setText(_("No appointments to print!"))
            self.rejected.connect(mb.accept)  # useful for Unittest
            mb.exec_()
            self.reject()

        print_today_issue = False
        for appt in self.appts:
            print_today_issue = print_today_issue or appt.today

        self.check_box.setVisible(print_today_issue)

        self.enableApply()
    def get_data(self):
        '''
        poll the database for appointment data
        '''

        self.appts = appointments.get_pts_appts(self.pt, True)
        self.set_label_text()

        if self.appts == []:
            mb = QtWidgets.QMessageBox(self)
            mb.setWindowTitle(_("message"))
            mb.setText(_("No appointments to print!"))
            self.rejected.connect(mb.accept)  # useful for Unittest
            mb.exec_()
            self.reject()

        print_today_issue = False
        for appt in self.appts:
            print_today_issue = print_today_issue or appt.today

        self.check_box.setVisible(print_today_issue)

        self.enableApply()
Beispiel #8
0
    def layout_ptDiary(self):
        '''
        populates the patient's diary model
        '''
        self.ui.appt_memo_lineEdit.setText(self.pt.appt_memo)

        appts = appointments.get_pts_appts(self.pt)
        self.diary_model.addAppointments(appts)
        self.ui.pt_diary_treeView.clearSelection()
        self.ui.pt_diary_treeView.expandAll()
        index = self.diary_model.parents.get(1, None)

        ##collapse past appointments
        past_index = self.diary_model.createIndex(0, 0, index)
        self.ui.pt_diary_treeView.collapse(past_index)

        appt = self.diary_model.selectedAppt
        if appt != None:
            self.select_apr_ix(appt.aprix)

        self.adjustDiaryColWidths()

        ## now emit a signal to update the drag/drop controller
        self.appointment_selected.emit(appt)
    def layout_ptDiary(self):
        '''
        populates the patient's diary model
        '''
        self.ui.appt_memo_lineEdit.setText(self.pt.appt_memo)

        appts = appointments.get_pts_appts(self.pt)
        self.diary_model.addAppointments(appts)
        self.ui.pt_diary_treeView.clearSelection()
        self.ui.pt_diary_treeView.expandAll()
        index = self.diary_model.parents.get(1, None)

        # collapse past appointments
        past_index = self.diary_model.createIndex(0, 0, index)
        self.ui.pt_diary_treeView.collapse(past_index)

        appt = self.diary_model.selectedAppt
        if appt is not None:
            self.select_apr_ix(appt.aprix)

        self.adjustDiaryColWidths()

        # now emit a signal to update the drag/drop controller
        self.appointment_selected.emit(appt)
Beispiel #10
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_()
Beispiel #11
0
 def load_from_database(self, pt):
     LOGGER.debug(
         "loading apps from database, selected = %s", self.selectedAppts)
     appts = appointments.get_pts_appts(pt)
     self.set_appointments(appts, self.selectedAppts)
 def test_exec(self):
     pt = BriefPatient(1)
     appts = appointments.get_pts_appts(pt)
     self.exec_(appts[0])
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Drag Drop Test")
        self.pt = duckPt()

        layout = QtGui.QGridLayout(self)

        self.model = SimpleListModel()

        appts = appointments.get_pts_appts(duckPt())

        self.model.set_appointments(appts, appts[1])

        self.appt_listView = DraggableList(True)
        self.appt_listView.setModel(self.model)

        self.block_model = BlockListModel()
        self.blockView = DraggableList(False)
        self.blockView.setModel(self.block_model)

        self.book = appointmentwidget.AppointmentWidget("1000", "1200", self)
        self.book.setDentist(1)
        self.book.setStartTime(1015)
        self.book.setEndTime(1145)
        for appoint in (
            (1, 1030, 1045, 'MCDONALD I', 6155, 'EXAM', '', '', '', 1, 73, 0,
             0, datetime.datetime.now()), (1, 1115, 1130, 'EMERGENCY', 0, '', '', '', '', -128, 0, 0,
                                           0, datetime.datetime.now())):
            self.book.setAppointment(appoint)

        self.OVbook = AppointmentOverviewWidget("1000", "1200", 15, 2, self)

        d1 = appointments.DentistDay(1)
        d1.start = 1015
        d1.end = 1145
        d1.memo = "hello"

        d2 = appointments.DentistDay(4)
        d2.start = 1015
        d2.end = 1145

        self.OVbook.dents = [d1, d2]
        self.OVbook.clear()
        self.OVbook.init_dicts()

        for d in (d1, d2):
            self.OVbook.setStartTime(d)
            self.OVbook.setEndTime(d)
            self.OVbook.setMemo(d)
            self.OVbook.setFlags(d)

        slot = appointments.FreeSlot(datetime.datetime(2009, 2, 2, 10, 45),
                                     1, 20)
        slot2 = appointments.FreeSlot(datetime.datetime(2009, 2, 2, 11, 0o5),
                                      4, 60)

        self.OVbook.addSlot(slot)
        self.OVbook.addSlot(slot2)

        appt = appointments.WeekViewAppointment()
        appt.mpm = 10 * 60 + 30
        appt.length = 15
        appt.dent = 1
        self.OVbook.appts[1] = (appt,)

        emerg = appointments.WeekViewAppointment()
        emerg.mpm = 11 * 60 + 15
        emerg.length = 15
        emerg.reason = "emergency"
        self.OVbook.eTimes[1] = (emerg,)
        self.OVbook.setMinimumWidth(200)

        self.tw = QtGui.QTabWidget(self)
        self.tw.addTab(self.book, "day")
        self.tw.addTab(self.OVbook, "week")

        layout.addWidget(self.appt_listView, 0, 0)
        layout.addWidget(self.blockView, 2, 0)

        layout.addWidget(self.tw, 0, 1, 3, 1)
        # self.tw.setCurrentIndex(1)

        self.model.appointment_selected.connect(slot_catcher)
Beispiel #14
0
 def load_from_database(self, pt):
     app = self.currentAppt
     appts = appointments.get_pts_appts(pt)
     self.set_appointments(appts, None)
     self.set_current_appt(app)
Beispiel #15
0
            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 = QtGui.QApplication(sys.argv)
    mycard = Card()
    print mycard.printer.getPageMargins(QtGui.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_()

        print index,
        print tv.model().data(index, QtCore.Qt.UserRole)

    def but_clicked():
        appoint_number = int(mw.sender().text())
        result, index = model.findItem(appoint_number)
        if result:
            if index:
                tv.setCurrentIndex(index)
                return
        tv.clearSelection()

    app = QtGui.QApplication([])
    localsettings.initiate()

    appts = appointments.get_pts_appts(duckPt())

    model = treeModel()
    model.addAppointments(appts)
    mw = QtGui.QMainWindow()

    mw.setMinimumSize(800, 300)
    frame = QtGui.QFrame(mw)
    layout = QtGui.QVBoxLayout(frame)

    tv = QtGui.QTreeView()
    tv.setModel(model)
    tv.setAlternatingRowColors(True)
    layout.addWidget(tv)
    tv.expandAll()
Beispiel #17
0
        print index,
        print tv.model().data(index, QtCore.Qt.UserRole)

    def but_clicked():
        appoint_number = int(mw.sender().text())
        result, index = model.findItem(appoint_number)
        if result:
            if index:
                tv.setCurrentIndex(index)
                return
        tv.clearSelection()

    app = QtGui.QApplication([])
    localsettings.initiate()

    appts = appointments.get_pts_appts(duckPt())

    model = treeModel()
    model.addAppointments(appts)
    mw = QtGui.QMainWindow()

    mw.setMinimumSize(800, 300)
    frame = QtGui.QFrame(mw)
    layout = QtGui.QVBoxLayout(frame)

    tv = QtGui.QTreeView()
    tv.setModel(model)
    tv.setAlternatingRowColors(True)
    layout.addWidget(tv)
    tv.expandAll()
Beispiel #18
0
 def load_from_database(self, pt):
     LOGGER.debug("loading apps from database, selected = %s",
                  self.selectedAppts)
     appts = appointments.get_pts_appts(pt)
     self.set_appointments(appts, self.selectedAppts)
def _test():
    from openmolar.dbtools import appointments

    class DuckPt(object):
        '''
        a mock of the patient class
        '''
        def __init__(self):
            self.serialno = 1
            self.sname = "Neil"
            self.fname = "Wallace"
            self.cset = "P"

    def resize(arg=None):
        for col in range(model.columnCount(arg)):
            tv.resizeColumnToContents(col)

    def appt_clicked(index):
        LOGGER.debug("appointment clicked %s",
                     tv.model().data(index, QtCore.Qt.UserRole))

    def but_clicked():
        LOGGER.debug("Button clicked, will search for appointment %s",
                     mw.sender().text())
        appoint_number = int(mw.sender().text())
        result, index = model.findItem(appoint_number)
        if result:
            if index:
                tv.setCurrentIndex(index)
                return
        LOGGER.debug("NOT FOUND!")
        tv.clearSelection()

    localsettings.initiate()

    appts = appointments.get_pts_appts(DuckPt())

    model = PatientDiaryTreeModel()
    model.addAppointments(appts)
    mw = QtGui.QMainWindow()

    mw.setMinimumSize(800, 300)
    frame = QtGui.QFrame(mw)
    layout = QtGui.QVBoxLayout(frame)

    tv = QtGui.QTreeView()
    tv.setModel(model)
    tv.setAlternatingRowColors(True)
    tv.setSelectionMode(tv.ContiguousSelection)
    tv.setSelectionModel(model.selection_model)
    layout.addWidget(tv)
    tv.expandAll()

    buts = []
    but_frame = QtGui.QFrame()
    layout2 = QtGui.QHBoxLayout(but_frame)
    for appt in sorted(appts, key=lambda a: a.aprix)[-20:]:
        but = QtGui.QPushButton(str(appt.aprix), mw)
        buts.append(but)
        layout2.addWidget(but)
        but.clicked.connect(but_clicked)

    layout.addWidget(but_frame)

    index = model.parents.get(1, None)
    if index:
        tv.collapse(model.createIndex(0, 0, index))
    resize()

    tv.expanded.connect(resize)
    tv.clicked.connect(appt_clicked)

    but = QtGui.QPushButton("Clear Selection")
    layout.addWidget(but)
    but.clicked.connect(tv.clearSelection)

    mw.setCentralWidget(frame)
    mw.show()
Beispiel #20
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Drag Drop Test")
        self.pt = duckPt()

        layout = QtGui.QGridLayout(self)

        self.model = SimpleListModel()

        appts = appointments.get_pts_appts(duckPt())

        self.model.set_appointments(appts, appts[1])

        self.appt_listView = DraggableList(True)
        self.appt_listView.setModel(self.model)

        self.block_model = BlockListModel()
        self.blockView = DraggableList(False)
        self.blockView.setModel(self.block_model)

        self.book = appointmentwidget.AppointmentWidget("1000", "1200", self)
        self.book.setDentist(1)
        self.book.setStartTime(1015)
        self.book.setEndTime(1145)
        for appoint in ((1, 1030, 1045, 'MCDONALD I', 6155, 'EXAM', '', '', '',
                         1, 73, 0, 0, datetime.datetime.now()),
                        (1, 1115, 1130, 'EMERGENCY', 0, '', '', '', '', -128,
                         0, 0, 0, datetime.datetime.now())):
            self.book.setAppointment(appoint)

        self.OVbook = AppointmentOverviewWidget("1000", "1200", 15, 2, self)

        d1 = appointments.DentistDay(1)
        d1.start = 1015
        d1.end = 1145
        d1.memo = "hello"

        d2 = appointments.DentistDay(4)
        d2.start = 1015
        d2.end = 1145

        self.OVbook.dents = [d1, d2]
        self.OVbook.clear()
        self.OVbook.init_dicts()

        for d in (d1, d2):
            self.OVbook.setStartTime(d)
            self.OVbook.setEndTime(d)
            self.OVbook.setMemo(d)
            self.OVbook.setFlags(d)

        slot = appointments.FreeSlot(datetime.datetime(2009, 2, 2, 10, 45), 1,
                                     20)
        slot2 = appointments.FreeSlot(datetime.datetime(2009, 2, 2, 11, 0o5),
                                      4, 60)

        self.OVbook.addSlot(slot)
        self.OVbook.addSlot(slot2)

        appt = appointments.WeekViewAppointment()
        appt.mpm = 10 * 60 + 30
        appt.length = 15
        appt.dent = 1
        self.OVbook.appts[1] = (appt, )

        emerg = appointments.WeekViewAppointment()
        emerg.mpm = 11 * 60 + 15
        emerg.length = 15
        emerg.reason = "emergency"
        self.OVbook.eTimes[1] = (emerg, )
        self.OVbook.setMinimumWidth(200)

        self.tw = QtGui.QTabWidget(self)
        self.tw.addTab(self.book, "day")
        self.tw.addTab(self.OVbook, "week")

        layout.addWidget(self.appt_listView, 0, 0)
        layout.addWidget(self.blockView, 2, 0)

        layout.addWidget(self.tw, 0, 1, 3, 1)
        # self.tw.setCurrentIndex(1)

        self.model.appointment_selected.connect(slot_catcher)
 def test_exec(self):
     pt = BriefPatient(1)
     appts = appointments.get_pts_appts(pt)
     self.exec_(appts[0])
Beispiel #22
0
def _test():
    from openmolar.dbtools import appointments

    class DuckPt(object):
        '''
        a mock of the patient class
        '''
        def __init__(self):
            self.serialno = 1
            self.sname = "Neil"
            self.fname = "Wallace"
            self.cset = "P"

    def resize(arg=None):
        for col in range(model.columnCount(arg)):
            tv.resizeColumnToContents(col)

    def appt_clicked(index):
        LOGGER.debug("appointment clicked %s",
                     tv.model().data(index, QtCore.Qt.UserRole))

    def but_clicked():
        LOGGER.debug("Button clicked, will search for appointment %s",
                     mw.sender().text())
        appoint_number = int(mw.sender().text())
        result, index = model.findItem(appoint_number)
        if result:
            if index:
                tv.setCurrentIndex(index)
                return
        LOGGER.debug("NOT FOUND!")
        tv.clearSelection()

    localsettings.initiate()

    appts = appointments.get_pts_appts(DuckPt())

    model = PatientDiaryTreeModel()
    model.addAppointments(appts)
    mw = QtGui.QMainWindow()

    mw.setMinimumSize(800, 300)
    frame = QtGui.QFrame(mw)
    layout = QtGui.QVBoxLayout(frame)

    tv = QtGui.QTreeView()
    tv.setModel(model)
    tv.setAlternatingRowColors(True)
    tv.setSelectionMode(tv.ContiguousSelection)
    tv.setSelectionModel(model.selection_model)
    layout.addWidget(tv)
    tv.expandAll()

    buts = []
    but_frame = QtGui.QFrame()
    layout2 = QtGui.QHBoxLayout(but_frame)
    for appt in sorted(appts, key=lambda a: a.aprix)[-20:]:
        but = QtGui.QPushButton(str(appt.aprix), mw)
        buts.append(but)
        layout2.addWidget(but)
        but.clicked.connect(but_clicked)

    layout.addWidget(but_frame)

    index = model.parents.get(1, None)
    if index:
        tv.collapse(model.createIndex(0, 0, index))
    resize()

    tv.expanded.connect(resize)
    tv.clicked.connect(appt_clicked)

    but = QtGui.QPushButton("Clear Selection")
    layout.addWidget(but)
    but.clicked.connect(tv.clearSelection)

    mw.setCentralWidget(frame)
    mw.show()