Example #1
0
    def getAge(self, on_date=None):
        '''
        return the age in form (year(int), months(int), isToday(bool))
        '''
        if on_date is None:
            # use today
            on_date = localsettings.currentDay()

        try:
            nextbirthday = datetime.date(on_date.year, self.dob.month,
                                         self.dob.day)
        except ValueError:
            # catch leap years!!
            nextbirthday = datetime.date(on_date.year, self.dob.month,
                                         self.dob.day - 1)

        ageYears = on_date.year - self.dob.year

        if nextbirthday > on_date:
            ageYears -= 1
            months = (12 - self.dob.month) + on_date.month
        else:
            months = on_date.month - self.dob.month
        if self.dob.day > on_date.day:
            months -= 1

        isToday = nextbirthday == localsettings.currentDay()

        return (ageYears, months, isToday)
Example #2
0
    def showOptions(self):
        '''
        user is wishing to change some default setting
        currently the only option is the date
        '''
        def enableDate(checked):
            '''
            only enable the date Edit if customRadio button is checked
            '''
            dl.dateEdit.setEnabled(checked)

        dialog = QtGui.QDialog(self.om_gui)
        dl = Ui_bulkmail_options.Ui_Dialog()
        dl.setupUi(dialog)
        dl.dateEdit.setDate(localsettings.currentDay())
        dialog.connect(dl.custDate_radioButton,
                       QtCore.SIGNAL("toggled (bool)"), enableDate)
        if dialog.exec_():
            if dl.custDate_radioButton.isChecked():
                self.adate = dl.dateEdit.date().toPyDate()
            if dl.today_radioButton.isChecked():
                self.adate = localsettings.currentDay()
            self.use_given_recall_date = dl.recd_radioButton.isChecked()
            self.LONGDATE = dl.fullDate_radioButton.isChecked()

            self.om_gui.advise(_("options set"), 1)
Example #3
0
    def fee_table(self):
        '''
        logic to determine which feeTable should be used for standard items
        '''
        if self._fee_table is None:
            if self.treatment_course.accd is None:
                cse_accd = localsettings.currentDay()
            else:
                cse_accd = self.treatment_course.accd
            for table in reversed(localsettings.FEETABLES.tables.values()):
                LOGGER.debug(
                    "checking feescale %s to see if suitable a feetable",
                    table)

                start, end = table.startDate, table.endDate
                LOGGER.debug("categories, start, end = %s, %s, %s",
                             table.categories, start, end)
                if end is None:
                    end = localsettings.currentDay()

                if self.cset in table.categories and start <= cse_accd <= end:
                    self._fee_table = table

            if self._fee_table is None:
                # - no matching table found, use the default.
                LOGGER.warning("NO SUITABLE FEETABLE FOUND, RETURNING DEFAULT")
                self._fee_table = localsettings.FEETABLES.default_table

        return self._fee_table
Example #4
0
    def getAge(self, on_date=None):
        '''
        return the age in form (year(int), months(int), isToday(bool))
        '''
        if on_date is None:
            # use today
            on_date = localsettings.currentDay()

        try:
            nextbirthday = datetime.date(on_date.year, self.dob.month,
                                         self.dob.day)
        except ValueError:
            # catch leap years!!
            nextbirthday = datetime.date(on_date.year, self.dob.month,
                                         self.dob.day - 1)

        ageYears = on_date.year - self.dob.year

        if nextbirthday > on_date:
            ageYears -= 1
            months = (12 - self.dob.month) + on_date.month
        else:
            months = on_date.month - self.dob.month
        if self.dob.day > on_date.day:
            months -= 1

        isToday = nextbirthday == localsettings.currentDay()

        return (ageYears, months, isToday)
Example #5
0
    def fee_table(self):
        '''
        logic to determine which feeTable should be used for standard items
        '''
        if self._fee_table is None:
            if self.treatment_course.accd is None:
                cse_accd = localsettings.currentDay()
            else:
                cse_accd = self.treatment_course.accd
            for table in reversed(localsettings.FEETABLES.tables.values()):
                LOGGER.debug(
                    "checking feescale %s to see if suitable a feetable",
                    table)

                start, end = table.startDate, table.endDate
                LOGGER.debug("categories, start, end = %s, %s, %s",
                             table.categories, start, end)
                if end is None:
                    end = localsettings.currentDay()

                if self.cset in table.categories and start <= cse_accd <= end:
                    self._fee_table = table

            if self._fee_table is None:
                # - no matching table found, use the default.
                LOGGER.warning("NO SUITABLE FEETABLE FOUND, RETURNING DEFAULT")
                self._fee_table = localsettings.FEETABLES.default_table

        return self._fee_table
Example #6
0
    def showOptions(self):
        '''
        user is wishing to change some default setting
        currently the only option is the date
        '''
        def enableDate(checked):
            '''
            only enable the date Edit if customRadio button is checked
            '''
            dl.dateEdit.setEnabled(checked)
        dialog = QtGui.QDialog(self.om_gui)
        dl = Ui_bulkmail_options.Ui_Dialog()
        dl.setupUi(dialog)
        dl.dateEdit.setDate(localsettings.currentDay())
        dialog.connect(dl.custDate_radioButton,
                       QtCore.SIGNAL("toggled (bool)"), enableDate)
        if dialog.exec_():
            if dl.custDate_radioButton.isChecked():
                self.adate = dl.dateEdit.date().toPyDate()
            if dl.today_radioButton.isChecked():
                self.adate = localsettings.currentDay()
            self.use_given_recall_date = dl.recd_radioButton.isChecked()
            self.LONGDATE = dl.fullDate_radioButton.isChecked()

            self.om_gui.advise(_("options set"), 1)
def xrayDates(om_gui, arg):
    '''
    update the patient's "last xray" dates
    '''
    if "M" in arg or "S" in arg:
        om_gui.pt.pd9 = localsettings.currentDay()
    if "P" in arg:
        om_gui.pt.pd8 = localsettings.currentDay()
Example #8
0
def xrayDates(om_gui, arg):
    '''
    update the patient's "last xray" dates
    '''
    if "M" in arg or "S" in arg:
        om_gui.pt.pd9 = localsettings.currentDay()
    if "P" in arg:
        om_gui.pt.pd8 = localsettings.currentDay()
Example #9
0
 def first_note_date(self):
     '''
     returns teh first date found in the patient notes
     '''
     if self._first_note_date is None:
         min_date = localsettings.currentDay()
         db = connect.connect()
         cursor = db.cursor()
         query = 'select min(ndate) from formatted_notes where serialno=%s'
         if cursor.execute(query, (self.serialno,)):
             min_date = cursor.fetchone()[0]
         cursor.close()
         self._first_note_date = min_date if min_date else localsettings.currentDay()
     return self._first_note_date
Example #10
0
 def first_note_date(self):
     '''
     returns teh first date found in the patient notes
     '''
     if self._first_note_date is None:
         min_date = localsettings.currentDay()
         db = connect.connect()
         cursor = db.cursor()
         query = 'select min(ndate) from formatted_notes where serialno=%s'
         if cursor.execute(query, (self.serialno, )):
             min_date = cursor.fetchone()[0]
         cursor.close()
         self._first_note_date = min_date \
             if min_date else localsettings.currentDay()
     return self._first_note_date
 def exec_(self):
     """
     raise the dialog
     """
     if not BaseDialog.exec_(self):
         return False
     if self.check_date > localsettings.currentDay():
         QtWidgets.QMessageBox.warning(self, _("Error!"), _("That date is in the future!"))
         return self.exec_()
     if (
         QtWidgets.QMessageBox.question(
             self,
             _("Confirm Action"),
             "%s<hr />%s <b>%s</b><br />%s"
             % (
                 self.pt.name_id,
                 _("Date Checked"),
                 localsettings.readableDate(self.check_date),
                 _("Confirm this date now?"),
             ),
             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
             QtWidgets.QMessageBox.Yes,
         )
         == QtWidgets.QMessageBox.Yes
     ):
         return True
     else:
         return self.exec_()
     return False
Example #12
0
def getHtml(description, pt):
    """
    get the HTML for a letter to
    referral_centre identified by description about this pt
    """
    db = connect()
    cursor = db.cursor()
    cursor.execute(ADDRESS_QUERY, (description,))
    row = cursor.fetchone()
    cursor.close()
    if not row:
        return HTML

    greeting, addr1, addr2, addr3, addr4, addr5, addr6, addr7 = row

    tel = _("Telephone") + " :- "
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val != "":
            tel += "%s %s " % ((_("home"), _("work "), _("mobile "))[i], val)

    return HTML % (
        "<br />".join([a for a in (addr1, addr2, addr3, addr4, addr5, addr6, addr7) if a != ""]),
        localsettings.longDate(localsettings.currentDay()),
        greeting,
        pt.title.title(),
        pt.fname.title(),
        pt.sname.title(),
        _("D.O.B."),
        localsettings.formatDate(pt.dob),
        ",".join([a for a in (pt.addr1, pt.addr2, pt.addr3, pt.town, pt.county, pt.pcde) if a != ""]),
        tel,
        _("Yours Sincerely"),
    )
Example #13
0
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)
Example #14
0
def getHtml(description, pt):
    '''
    get the HTML for a letter to
    referral_centre identified by description about this pt
    '''
    db = connect()
    cursor = db.cursor()
    cursor.execute(ADDRESS_QUERY, (description, ))
    row = cursor.fetchone()
    cursor.close()
    if not row:
        return HTML

    greeting, addr1, addr2, addr3, addr4, addr5, addr6, addr7 = row

    tel = _("Telephone") + " :- "
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val != "":
            tel += "%s %s " % ((_("home"), _("work "), _("mobile "))[i], val)

    return HTML % ("<br />".join([
        a for a in (addr1, addr2, addr3, addr4, addr5, addr6, addr7) if a != ""
    ]), localsettings.longDate(localsettings.currentDay()), greeting,
                   pt.title.title(), pt.fname.title(), pt.sname.title(),
                   _("D.O.B."), localsettings.formatDate(pt.dob), ",".join([
                       a for a in (pt.addr1, pt.addr2, pt.addr3, pt.town,
                                   pt.county, pt.pcde) if a != ""
                   ]), tel, _("Yours Sincerely"))
Example #15
0
 def updateBilling(self, tone):
     '''
     update the last billdate and tone of invoice
     '''
     self.billdate = localsettings.currentDay()
     self.billct += 1
     self.billtype = tone
    def dragMoveEvent(self, event):
        self.mouse_drag_rect = None
        if (self.date >= localsettings.currentDay() and
           event.mimeData().hasFormat("application/x-appointment")):

            self.dropPos = QtCore.QPointF(event.pos())
            for dent_ix, rect_f in self.mouse_drag_rects:
                if rect_f.contains(self.dropPos):
                    self.mouse_drag_rect = (dent_ix, rect_f)

                    # now handle the situation where the drag lower border
                    # is outwith the slot
                    height = (self.drag_appt.length / self.slotLength) \
                        * self.slotHeight
                    if self.dropPos.y() + height >= rect_f.bottom():
                        self.dropPos = QtCore.QPointF(
                            self.dropPos.x(), rect_f.bottom() - height)

                    break

            if self.is_dragging:
                event.accept()
            else:
                event.ignore()
            self.update()
        else:
            event.ignore()
Example #17
0
 def mh_form_required(self):
     if self.serialno < 1:
         return False
     if not self.mh_form_check_date:
         return True
     return (localsettings.currentDay() - self.mh_form_check_date).days > \
         localsettings.MH_FORM_PERIOD
Example #18
0
    def dragMoveEvent(self, event):
        self.mouse_drag_rect = None
        if (self.date >= localsettings.currentDay()
                and event.mimeData().hasFormat("application/x-appointment")):

            self.dropPos = QtCore.QPointF(event.pos())
            for dent_ix, rect_f in self.mouse_drag_rects:
                if rect_f.contains(self.dropPos):
                    self.mouse_drag_rect = (dent_ix, rect_f)

                    # now handle the situation where the drag lower border
                    # is outwith the slot
                    height = (self.drag_appt.length / self.slotLength) \
                        * self.slotHeight
                    if self.dropPos.y() + height >= rect_f.bottom():
                        self.dropPos = QtCore.QPointF(self.dropPos.x(),
                                                      rect_f.bottom() - height)

                    break

            if self.is_dragging:
                event.accept()
            else:
                event.ignore()
            self.update()
        else:
            event.ignore()
Example #19
0
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)
Example #20
0
    def has_issues(self):
        example_name = _("Example Dental Practice")
        has_issues = (len(localsettings.cashbookCodesDict) < 1
                      or len(localsettings.activedents) < 1
                      or localsettings.PRACTICE_NAME == example_name)

        if not has_issues:
            return False

        if not localsettings.activedents:
            but = QtWidgets.QPushButton(_("How do I Fix This?"))
            but.clicked.connect(self.show_add_clinician_advise)
            message = _("Your database contains no dentists")
            self.form_layout.addRow(message, but)

        if localsettings.PRACTICE_NAME == example_name:
            but = QtWidgets.QPushButton(_("How do I Fix This?"))
            but.clicked.connect(self.show_edit_practice)
            message = "%s <b>'%s'</b>" % (_("Your practice name is"),
                                          example_name)
            self.form_layout.addRow(message, but)

        if len(
                appointments.future_slots(localsettings.currentDay(),
                                          localsettings.BOOKEND,
                                          list(localsettings.apptix.values()),
                                          override_emergencies=True)) == 0:
            but = QtWidgets.QPushButton(_("Why is this?"))
            but.clicked.connect(self.show_appt_space)
            message = _("You have no appointment space in your diary!")
            self.form_layout.addRow(message, but)

        return True
Example #21
0
 def updateBilling(self, tone):
     '''
     update the last billdate and tone of invoice
     '''
     self.billdate = localsettings.currentDay()
     self.billct += 1
     self.billtype = tone
    def execute_menu(self, index, point):
        appt = self.diary_model.data(index, QtCore.Qt.UserRole)
        if appt == QtCore.QVariant():
            return
        qmenu = QtGui.QMenu(self)
        modify_action = QtGui.QAction(_("Modify Appointment"), self)
        modify_action.triggered.connect(self.modifyAppt_clicked)
        if self.diary_model.appt_2 is not None:
            action = QtGui.QAction(_("Schedule these appointments"), self)
            action.triggered.connect(self.scheduleAppt_pushButton_clicked)
            qmenu.addAction(action)
        else:
            if appt.date is None:
                action = QtGui.QAction(_("Schedule this appointment"), self)
                action.triggered.connect(self.scheduleAppt_pushButton_clicked)
                qmenu.addAction(action)
                qmenu.addAction(modify_action)
                qmenu.addSeparator()
                action = QtGui.QAction(
                    _("Delete this (unscheduled) appointment"), self)
                action.triggered.connect(self.clearApptButton_clicked)
                qmenu.addAction(action)
            else:
                action = QtGui.QAction(_("Show in Book"), self)
                action.triggered.connect(self.findApptButton_clicked)
                qmenu.addAction(action)
                qmenu.addSeparator()
                if appt.date >= localsettings.currentDay():
                    qmenu.addAction(modify_action)
                    action = QtGui.QAction(_("Cancel this appointment"), self)
                    action.triggered.connect(self.clearApptButton_clicked)
                    qmenu.addAction(action)

        qmenu.setDefaultAction(qmenu.actions()[0])
        qmenu.exec_(self.ui.pt_diary_treeView.mapToGlobal(point))
Example #23
0
def recall_check(om_gui):
    '''
    presently this just checks the status of the DENTIST recall
    (ie. ignores hygienist)
    '''
    if not om_gui.pt.recall_active or om_gui.pt.has_exam_booked:
        return True
    if (om_gui.pt.appt_prefs.recdent_period
            and om_gui.pt.recd > localsettings.currentDay()):
        return True
    if not om_gui.ui.actionCheck_Recall_Date_on_Exit_Record.isChecked():
        om_gui.advise(_("ignoring recall date as per preferences"))
        return True
    else:
        dl = RecallPromptDialog(om_gui.pt, om_gui)
        if dl.exec_():
            if dl.result == dl.IGNORE:
                return True
            else:
                dl2 = ApptPrefsDialog(om_gui.pt, om_gui)
                if dl2.exec_():
                    om_gui.pt.appt_prefs.commit_changes()
                    om_gui.updateDetails()
                    om_gui.advise(_("Appointment Preferences Applied"))
                    return True
    return False
Example #24
0
    def getAge(self):
        '''
        return the age in form (year(int), months(int), isToday(bool))
        '''
        today = localsettings.currentDay()

        day = self.dob.day

        try:
            nextbirthday = datetime.date(today.year, self.dob.month,
                                         self.dob.day)
        except ValueError:
            # catch leap years!!
            nextbirthday = datetime.date(today.year, self.dob.month,
                                         self.dob.day - 1)

        ageYears = today.year - self.dob.year

        if nextbirthday > today:
            ageYears -= 1
            months = (12 - self.dob.month) + today.month
        else:
            months = today.month - self.dob.month
        if self.dob.day > today.day:
            months -= 1

        isToday = nextbirthday == today

        return (ageYears, months, isToday)
    def getAge(self):
        '''
        return the age in form (year(int), months(int), isToday(bool))
        '''
        today = localsettings.currentDay()

        day = self.dob.day

        try:
            nextbirthday = datetime.date(today.year, self.dob.month,
                                         self.dob.day)
        except ValueError:
            # catch leap years!!
            nextbirthday = datetime.date(today.year, self.dob.month,
                                         self.dob.day - 1)

        ageYears = today.year - self.dob.year

        if nextbirthday > today:
            ageYears -= 1
            months = (12 - self.dob.month) + today.month
        else:
            months = today.month - self.dob.month
        if self.dob.day > today.day:
            months -= 1

        isToday = nextbirthday == today

        return (ageYears, months, isToday)
 def setAccd(self, accd):
     '''
     set the acceptance date (with a pydate)
     '''
     if accd is None:
         accd = localsettings.currentDay()
     self.accd = accd
Example #27
0
def course_should_be_resumed(om_gui):
    '''
    see if it would make more sense to resume a course rather than start a new
    one.
    '''

    if not om_gui.pt.treatment_course.cmpd:
        return False
    elapsed = localsettings.currentDay() - om_gui.pt.treatment_course.cmpd
    if elapsed > datetime.timedelta(days=7):
        return False
    elif elapsed == datetime.timedelta(days=0):
        message = _("A course was closed earlier today.")
    elif elapsed == datetime.timedelta(days=1):
        message = _("A course was closed yesterday.")
    else:
        message = _("A course was closed less than a week ago.")

    if QtWidgets.QMessageBox.question(
        om_gui,
        _("Question"),
        "%s<hr />%s" % (message, _("Would you like to resume this course?")),
        QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes,
            QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.Yes:
            return resumeCourse(om_gui)
    return False
Example #28
0
 def setAccd(self, accd):
     '''
     set the acceptance date (with a pydate)
     '''
     if accd is None:
         accd = localsettings.currentDay()
     self.accd = accd
Example #29
0
    def execute_menu(self, index, point):
        appt = self.diary_model.data(index, QtCore.Qt.UserRole)
        if appt == QtCore.QVariant():
            return
        qmenu = QtGui.QMenu(self)
        modify_action = QtGui.QAction(_("Modify Appointment"), self)
        modify_action.triggered.connect(self.modifyAppt_clicked)
        if self.diary_model.appt_2 is not None:
            action = QtGui.QAction(_("Schedule these appointments"), self)
            action.triggered.connect(self.scheduleAppt_pushButton_clicked)
            qmenu.addAction(action)
        else:
            if appt.date is None:
                action = QtGui.QAction(_("Schedule this appointment"), self)
                action.triggered.connect(self.scheduleAppt_pushButton_clicked)
                qmenu.addAction(action)
                qmenu.addAction(modify_action)
                qmenu.addSeparator()
                action = QtGui.QAction(
                    _("Delete this (unscheduled) appointment"), self)
                action.triggered.connect(self.clearApptButton_clicked)
                qmenu.addAction(action)
            else:
                action = QtGui.QAction(_("Show in Book"), self)
                action.triggered.connect(self.findApptButton_clicked)
                qmenu.addAction(action)
                qmenu.addSeparator()
                if appt.date >= localsettings.currentDay():
                    qmenu.addAction(modify_action)
                    action = QtGui.QAction(_("Cancel this appointment"), self)
                    action.triggered.connect(self.clearApptButton_clicked)
                    qmenu.addAction(action)

        qmenu.setDefaultAction(qmenu.actions()[0])
        qmenu.exec_(self.ui.pt_diary_treeView.mapToGlobal(point))
Example #30
0
def course_should_be_resumed(om_gui):
    '''
    see if it would make more sense to resume a course rather than start a new
    one.
    '''

    if not om_gui.pt.treatment_course.cmpd:
        return False
    elapsed = localsettings.currentDay() - om_gui.pt.treatment_course.cmpd
    if elapsed > datetime.timedelta(days=7):
        return False
    elif elapsed == datetime.timedelta(days=0):
        message = _("A course was closed earlier today.")
    elif elapsed == datetime.timedelta(days=1):
        message = _("A course was closed yesterday.")
    else:
        message = _("A course was closed less than a week ago.")

    if QtWidgets.QMessageBox.question(
            om_gui, _("Question"), "%s<hr />%s" %
        (message, _("Would you like to resume this course?")),
            QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes,
            QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.Yes:
        return resumeCourse(om_gui)
    return False
    def __init__(self, ftr=False, parent=None):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Add User Dialog"))

        self.top_label = WarningLabel(_('Add a new clinician to the system?'))

        self.user_id_comboBox = QtGui.QComboBox()
        but = QtGui.QPushButton(_("Add New Login"))

        self.name_lineedit = QtGui.QLineEdit()
        self.f_name_lineedit = QtGui.QLineEdit()
        self.quals_lineedit = QtGui.QLineEdit()
        self.type_comboBox = QtGui.QComboBox()
        self.type_comboBox.addItems([
            _("Dentist"),
            _("Hygienist"),
            _("Therapist")
            ])
        self.speciality_lineedit = QtGui.QLineEdit()
        self.date_edit = QtGui.QDateEdit()
        self.date_edit.setDate(localsettings.currentDay())
        self.data_lineedit = QtGui.QLineEdit()
        self.new_diary_checkbox = QtGui.QCheckBox(
            _("Create a new diary for this clinician "
              "(uncheck to map to an existing diary)"))
        self.new_diary_checkbox.setChecked(True)

        row1 = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(row1)
        layout.setMargin(0)
        layout.addWidget(self.user_id_comboBox)
        layout.addWidget(but)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Initials/Nickname (must be an existing Login)"), row1)
        layout.addRow(_("Name eg. Fred Smith"), self.name_lineedit)
        layout.addRow(_("Formal Name eg. Dr.F. Smith"), self.f_name_lineedit)
        layout.addRow(_("Qualifications"), self.quals_lineedit)
        layout.addRow(_("Speciality"), self.speciality_lineedit)
        layout.addRow(_("Clinician Type"), self.type_comboBox)
        layout.addRow(_("Start Date"), self.date_edit)
        layout.addRow(_("Additional Data"), self.data_lineedit)
        layout.addRow(self.new_diary_checkbox)
        self.insertWidget(self.top_label)
        self.insertWidget(frame)

        for le in (self.name_lineedit, self.f_name_lineedit):
            le.textChanged.connect(self._check_enable)
        self.name_lineedit.setFocus()

        list_widget = QtGui.QListWidget()
        list_widget.addItems(
            [str(val) for val in sorted(localsettings.dentDict.values())])
        self.add_advanced_widget(list_widget)
        self.set_advanced_but_text(_("view existing dentists"))

        self.load_logins()
        but.clicked.connect(self.add_user)
Example #32
0
    def __init__(self, ftr=False, parent=None):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Add User Dialog"))

        self.top_label = WarningLabel(_('Add a new clinician to the system?'))

        self.user_id_comboBox = QtWidgets.QComboBox()
        but = QtWidgets.QPushButton(_("Add New Login"))

        self.name_lineedit = QtWidgets.QLineEdit()
        self.f_name_lineedit = QtWidgets.QLineEdit()
        self.quals_lineedit = QtWidgets.QLineEdit()
        self.type_comboBox = QtWidgets.QComboBox()
        self.type_comboBox.addItems([
            _("Dentist"),
            _("Hygienist"),
            _("Therapist")
            ])
        self.speciality_lineedit = QtWidgets.QLineEdit()
        self.date_edit = QtWidgets.QDateEdit()
        self.date_edit.setDate(localsettings.currentDay())
        self.data_lineedit = QtWidgets.QLineEdit()
        self.new_diary_checkbox = QtWidgets.QCheckBox(
            _("Create a new diary for this clinician "
              "(uncheck to map to an existing diary)"))
        self.new_diary_checkbox.setChecked(True)

        row1 = QtWidgets.QWidget()
        layout = QtWidgets.QHBoxLayout(row1)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.user_id_comboBox)
        layout.addWidget(but)

        frame = QtWidgets.QFrame(self)
        layout = QtWidgets.QFormLayout(frame)
        layout.addRow(_("Initials/Nickname (must be an existing Login)"), row1)
        layout.addRow(_("Name eg. Fred Smith"), self.name_lineedit)
        layout.addRow(_("Formal Name eg. Dr.F. Smith"), self.f_name_lineedit)
        layout.addRow(_("Qualifications"), self.quals_lineedit)
        layout.addRow(_("Speciality"), self.speciality_lineedit)
        layout.addRow(_("Clinician Type"), self.type_comboBox)
        layout.addRow(_("Start Date"), self.date_edit)
        layout.addRow(_("Additional Data"), self.data_lineedit)
        layout.addRow(self.new_diary_checkbox)
        self.insertWidget(self.top_label)
        self.insertWidget(frame)

        for le in (self.name_lineedit, self.f_name_lineedit):
            le.textChanged.connect(self._check_enable)
        self.name_lineedit.setFocus()

        list_widget = QtWidgets.QListWidget()
        list_widget.addItems(
            [str(val) for val in sorted(localsettings.dentDict.values())])
        self.add_advanced_widget(list_widget)
        self.set_advanced_but_text(_("view existing dentists"))

        self.load_logins()
        but.clicked.connect(self.add_user)
def getHtml(pt):
    return TEMPLATE % (pt.name,
                       pt.address.replace("\n", "<br />"),
                       localsettings.longDate(localsettings.currentDay()),
                       _("Dear"),
                       pt.name.title(),
                       _("Yours Sincerely")
                       )
Example #34
0
 def date_text(self):
     '''
     the date to be printed on the form.
     '''
     if not self.date_:
         return localsettings.formatDate(localsettings.currentDay())
     else:
         return localsettings.formatDate(self.date_)
Example #35
0
 def date_text(self):
     """
     the date to be printed on the form.
     """
     if not self.date_:
         return localsettings.formatDate(localsettings.currentDay())
     else:
         return localsettings.formatDate(self.date_)
Example #36
0
def update_chkdate(ix):
    LOGGER.debug("marking mh %s as checked today", ix)
    db = connect()
    cursor = db.cursor()
    result = cursor.execute(
        UPDATE_CHKDATE_QUERY,
        (localsettings.currentDay(), localsettings.operator, ix))
    cursor.close()
    return result
Example #37
0
def update_chkdate(ix):
    LOGGER.debug("marking mh %s as checked today", ix)
    db = connect()
    cursor = db.cursor()
    result = cursor.execute(
        UPDATE_CHKDATE_QUERY,
        (localsettings.currentDay(), localsettings.operator, ix))
    cursor.close()
    return result
 def select_year(self):
     current_year = localsettings.currentDay().year
     year, result = QtWidgets.QInputDialog.getInt(
         self, _("Input"), _("Please select a year"), self.check_date.year, 2000, current_year
     )
     if result:
         LOGGER.debug("User chose year %s", year)
         new_date = QtCore.QDate(self.check_date).addYears(year - current_year)
         self.calendar.setSelectedDate(new_date.toPyDate())
         self.calendar.update()
Example #39
0
def summary_html(pt):
    key_values = []
    key_values.append((
        _("Contract Dentist"),
        localsettings.dentDict.get(pt.dnt1, UNKNOWN_DENT)[1]
        ))

    days = (localsettings.currentDay() - pt.first_note_date).days
    if days < 7:
        duration = _("this week")
    elif days < 365:
        duration = _("recently")
    elif days < 730:
        duration = _("last year")
    else:
        duration = "%s %s" % (days//365, _("years ago."))

    key_values.append((
        _("Joined the practice"),
        duration
        ))

    key_values.append((
        _("Last Treatment"),
        localsettings.formatDate(pt.last_treatment_date)
        ))

    key_values.append((
        _("Exam Due"),
        _("YES!") if pt.exam_due else _("No")
        ))

    key_values.append((
        _("Has seen hygienist on"),
        "%s %s" % (pt.n_hyg_visits, _("Occasions"))
        ))

    phone = False
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val:
            key = (_("Telephone (Home)"),
                   _("Telephone (Work)"),
                   _("Mobile"))[i]
            key_values.append((key, val))
            phone = True
    if not phone:
        key_values.append((_("Telephone"), _("Please get a phone number")))

    content = "<ul>"
    for key, value in key_values:
        content += "<li><b>%s</b> - %s</li>" % (key, value)
    content += "</ul>"
    html_ = HTML_TEMPLATE.replace("{{CONTENT}}", content)

    return html_
Example #40
0
 def __init__(self, om_gui):
     self.om_gui = om_gui
     self.printer = QtGui.QPrinter()
     self.printer.setPageSize(QtGui.QPrinter.A4)
     self.headers = (_("no data loaded"),)
     self.recipients = ()
     self.bulk_model = treeModel(self.headers, self.recipients)
     self.adate = localsettings.currentDay()
     self.expanded = False
     self.use_given_recall_date = False
     self.LONGDATE = True
Example #41
0
 def __init__(self, om_gui):
     self.om_gui = om_gui
     self.printer = QtGui.QPrinter()
     self.printer.setPageSize(QtGui.QPrinter.A4)
     self.headers = (_("no data loaded"), )
     self.recipients = ()
     self.bulk_model = treeModel(self.headers, self.recipients)
     self.adate = localsettings.currentDay()
     self.expanded = False
     self.use_given_recall_date = False
     self.LONGDATE = True
Example #42
0
 def past_or_present(self):
     '''
     perform logic to decide if past/present future
     '''
     today = localsettings.currentDay()
     if not self.unscheduled:
         self.today = self.date == today
         self.past = self.date < today
         if self.today:
             self.future = self.atime > localsettings.int_timestamp()
         else:
             self.future = self.date > today
Example #43
0
 def past_or_present(self):
     '''
     perform logic to decide if past/present future
     '''
     today = localsettings.currentDay()
     if not self.unscheduled:
         self.today = self.date == today
         self.past = self.date < today
         if self.today:
             self.future = self.atime > localsettings.int_timestamp()
         else:
             self.future = self.date > today
 def select_year(self):
     current_year = localsettings.currentDay().year
     year, result = QtWidgets.QInputDialog.getInt(self, _("Input"),
                                                  _("Please select a year"),
                                                  self.check_date.year,
                                                  2000, current_year)
     if result:
         LOGGER.debug("User chose year %s", year)
         new_date = QtCore.QDate(self.check_date).addYears(year -
                                                           current_year)
         self.calendar.setSelectedDate(new_date.toPyDate())
         self.calendar.update()
Example #45
0
    def age(self):
        '''
        return the age in string form
        '''

        today = localsettings.currentDay()
        try:
            nextbirthday = date(today.year, self._dob.month, self._dob.day)
        except ValueError:  # leap year!
            nextbirthday = date(today.year, self._dob.month, self._dob.day - 1)
        ageYears = today.year - self._dob.year
        if nextbirthday > today:
            ageYears -= 1
        return ageYears
Example #46
0
def todays_patients(dents):
    '''
    get todays patients for dents supplied as a tuple such as (4,5)
    or (0,) for all
    used to populate the combobox on the front page
    '''
    db = connect()
    cursor = db.cursor()

    if 0 in dents:
        cond = ""
        values = (localsettings.currentDay(),)
    else:
        cond = "and (" + "apptix=%s or " * (len(dents) - 1) + "apptix=%s )"
        values = (localsettings.currentDay(),) + dents

    query = 'SELECT serialno,name FROM aslot WHERE adate=%s ' + cond + \
        ' and serialno!=0 ORDER BY name'

    cursor.execute(query, values)
    rows = cursor.fetchall()
    cursor.close()
    return rows
Example #47
0
 def last_treatment_date(self):
     max_date = localsettings.currentDay()
     if self.treatment_course.cmp_txs != \
             self.dbstate.treatment_course.cmp_txs:
         return max_date
     if self._most_recent_daybook_entry is None:
         db = connect.connect()
         cursor = db.cursor()
         query = 'select max(date) from daybook where serialno=%s'
         if cursor.execute(query, (self.serialno, )):
             max_date = cursor.fetchone()[0]
         cursor.close()
         self._most_recent_daybook_entry = max_date
     return self._most_recent_daybook_entry
Example #48
0
def todays_patients(dents):
    '''
    get todays patients for dents supplied as a tuple such as (4,5)
    or (0,) for all
    used to populate the combobox on the front page
    '''
    db = connect()
    cursor = db.cursor()

    if 0 in dents:
        cond = ""
        values = (localsettings.currentDay(), )
    else:
        cond = "and (" + "apptix=%s or " * (len(dents) - 1) + "apptix=%s )"
        values = (localsettings.currentDay(), ) + dents

    query = 'SELECT serialno,name FROM aslot WHERE adate=%s ' + cond + \
        ' and serialno!=0 ORDER BY name'

    cursor.execute(query, values)
    rows = cursor.fetchall()
    cursor.close()
    return rows
Example #49
0
    def age(self):
        '''
        return the age in string form
        '''

        today = localsettings.currentDay()
        try:
            nextbirthday = date(today.year, self._dob.month, self._dob.day)
        except ValueError:  # leap year!
            nextbirthday = date(today.year, self._dob.month, self._dob.day - 1)
        ageYears = today.year - self._dob.year
        if nextbirthday > today:
            ageYears -= 1
        return ageYears
Example #50
0
def printDupReceipt(om_gui):
    '''
    print a duplicate receipt
    '''
    dupdate = localsettings.currentDay()
    amount = om_gui.ui.receiptDoubleSpinBox.value()

    printReceipt(om_gui, {_("Professional Services"): amount * 100},
                 total=amount * 100, duplicate=True, dupdate=dupdate)

    om_gui.pt.addHiddenNote("printed", "%s %.02f" % (
        _("duplicate receipt for"),
        amount))
    om_gui.updateHiddenNotesLabel()
Example #51
0
 def last_treatment_date(self):
     max_date = localsettings.currentDay()
     if self.treatment_course.cmp_txs != \
             self.dbstate.treatment_course.cmp_txs:
         return max_date
     if self._most_recent_daybook_entry is None:
         db = connect.connect()
         cursor = db.cursor()
         query = 'select max(date) from daybook where serialno=%s'
         if cursor.execute(query, (self.serialno,)):
             max_date = cursor.fetchone()[0]
         cursor.close()
         self._most_recent_daybook_entry = max_date
     return self._most_recent_daybook_entry
 def get_new_mh(self, rejecting=False):
     '''
     checks what has been entered, and saves it to self.new_mh
     returns (result, checked_only)
     result = whether any changes have been applied.
     checked_only = bool
     '''
     result = True
     if not rejecting:
         result = self.check_new_meds()
     meds_dict = {}
     for med in self.meds:
         meds_dict[med] = ""
         if med not in self.mh.medications:
             LOGGER.debug("new medication %s", med)
     for med in self.unknown_meds:
         if med not in self.mh.medications:
             LOGGER.debug("unknown new medication found %s", med)
             meds_dict[med] = ""
     for med in self.mh.medications:
         if med not in self.meds:
             LOGGER.debug("deleted medication %s", med)
     self.new_mh = medhist.MedHist(
         None,  # ix
         unicode(self.warning_line_edit.text().toUtf8()),
         meds_dict,
         unicode(self.meds_line_edit.text().toUtf8()),
         unicode(self.allergies_line_edit.text().toUtf8()),
         unicode(self.respiratory_line_edit.text().toUtf8()),
         unicode(self.heart_line_edit.text().toUtf8()),
         unicode(self.diabetes_line_edit.text().toUtf8()),
         unicode(self.arthritis_line_edit.text().toUtf8()),
         unicode(self.bleeding_line_edit.text().toUtf8()),
         unicode(self.infection_line_edit.text().toUtf8()),
         unicode(self.endocarditis_line_edit.text().toUtf8()),
         unicode(self.liver_line_edit.text().toUtf8()),
         unicode(self.anaesthetic_line_edit.text().toUtf8()),
         unicode(self.joint_line_edit.text().toUtf8()),
         unicode(self.heart_surgery_line_edit.text().toUtf8()),
         unicode(self.brain_surgery_line_edit.text().toUtf8()),
         unicode(self.hospitalised_line_edit.text().toUtf8()),
         unicode(self.cjd_line_edit.text().toUtf8()),
         unicode(self.other_text_edit.toPlainText().toUtf8()),
         self.med_alert_cb.isChecked(),
         localsettings.currentDay(),
         None,
         None
     )
     return result
 def get_new_mh(self, rejecting=False):
     """
     checks what has been entered, and saves it to self.new_mh
     returns (result, checked_only)
     result = whether any changes have been applied.
     checked_only = bool
     """
     result = True
     if not rejecting:
         result = self.check_new_meds()
     meds_dict = {}
     for med in self.meds:
         meds_dict[med] = ""
         if med not in self.mh.medications:
             LOGGER.debug("new medication %s", med)
     for med in self.unknown_meds:
         if med not in self.mh.medications:
             LOGGER.debug("unknown new medication found %s", med)
             meds_dict[med] = ""
     for med in self.mh.medications:
         if med not in self.meds:
             LOGGER.debug("deleted medication %s", med)
     self.new_mh = medhist.MedHist(
         None,  # ix
         str(self.warning_line_edit.text()),
         meds_dict,
         str(self.meds_line_edit.text()),
         str(self.allergies_line_edit.text()),
         str(self.respiratory_line_edit.text()),
         str(self.heart_line_edit.text()),
         str(self.diabetes_line_edit.text()),
         str(self.arthritis_line_edit.text()),
         str(self.bleeding_line_edit.text()),
         str(self.infection_line_edit.text()),
         str(self.endocarditis_line_edit.text()),
         str(self.liver_line_edit.text()),
         str(self.anaesthetic_line_edit.text()),
         str(self.joint_line_edit.text()),
         str(self.heart_surgery_line_edit.text()),
         str(self.brain_surgery_line_edit.text()),
         str(self.hospitalised_line_edit.text()),
         str(self.cjd_line_edit.text()),
         str(self.other_text_edit.toPlainText()),
         self.med_alert_cb.isChecked(),
         localsettings.currentDay(),
         None,
         None,
     )
     return result
Example #54
0
def printDupReceipt(om_gui):
    '''
    print a duplicate receipt
    '''
    dupdate = localsettings.currentDay()
    amount = om_gui.ui.receiptDoubleSpinBox.value()

    printReceipt(om_gui, {_("Professional Services"): amount * 100},
                 total=amount * 100,
                 duplicate=True,
                 dupdate=dupdate)

    om_gui.pt.addHiddenNote("printed",
                            "%s %.02f" % (_("duplicate receipt for"), amount))
    om_gui.updateHiddenNotesLabel()
 def dragEnterEvent(self, event):
     self._mouse_drag_rects is None
     self.mouse_drag_rect = None
     self.drag_appt = None
     if event.mimeData().hasFormat("application/x-appointment"):
         data = event.mimeData()
         bstream = data.retrieveData("application/x-appointment", QtCore.QVariant.ByteArray)
         appt = pickle.loads(bstream.toByteArray())
         if self.date >= localsettings.currentDay():
             self.drag_appt = appt
             event.accept()
         else:
             event.ignore()
     else:
         event.ignore()
Example #56
0
 def dragEnterEvent(self, event):
     self._mouse_drag_rects = None
     self.mouse_drag_rect = None
     self.drag_appt = None
     if event.mimeData().hasFormat("application/x-appointment"):
         data = event.mimeData()
         bstream = data.retrieveData("application/x-appointment",
                                     QtCore.QVariant.ByteArray)
         appt = pickle.loads(bstream)
         if self.date >= localsettings.currentDay():
             self.drag_appt = appt
             event.accept()
         else:
             event.ignore()
     else:
         event.ignore()
Example #57
0
def recall_check(om_gui):
    if (not om_gui.pt.recall_active
            or om_gui.pt.recd > localsettings.currentDay()
            or om_gui.pt.has_exam_booked):
        return True
    dl = RecallPromptDialog(om_gui.pt, om_gui)
    if dl.exec_():
        if dl.result == dl.IGNORE:
            return True
        else:
            dl = ApptPrefsDialog(om_gui.pt, om_gui)
            if dl.exec_():
                om_gui.pt.appt_prefs.commit_changes()
                om_gui.updateDetails()
                om_gui.advise(_("Appointment Preferences Applied"))
                return True
    return False
def recall_check(om_gui):
    if (not om_gui.pt.recall_active or
       om_gui.pt.recd > localsettings.currentDay() or
       om_gui.pt.has_exam_booked):
        return True
    dl = RecallPromptDialog(om_gui.pt, om_gui)
    if dl.exec_():
        if dl.result == dl.IGNORE:
            return True
        else:
            dl = ApptPrefsDialog(om_gui.pt, om_gui)
            if dl.exec_():
                om_gui.pt.appt_prefs.commit_changes()
                om_gui.updateDetails()
                om_gui.advise(_("Appointment Preferences Applied"))
                return True
    return False
Example #59
0
def summary_html(pt):
    key_values = []
    key_values.append((_("Contract Dentist"),
                       localsettings.dentDict.get(pt.dnt1, UNKNOWN_DENT)[1]))

    days = (localsettings.currentDay() - pt.first_note_date).days
    if days < 7:
        duration = _("this week")
    elif days < 365:
        duration = _("recently")
    elif days < 730:
        duration = _("last year")
    else:
        duration = "%s %s" % (days // 365, _("years ago."))

    key_values.append((_("Joined the practice"), duration))

    key_values.append((_("Last Treatment"),
                       localsettings.formatDate(pt.last_treatment_date)))

    key_values.append((_("Exam Due"), _("YES!") if pt.exam_due else _("No")))

    key_values.append((_("Has seen hygienist on"),
                       "%s %s" % (pt.n_hyg_visits, _("Occasions"))))

    phone = False
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val:
            key = (_("Telephone (Home)"), _("Telephone (Work)"),
                   _("Mobile"))[i]
            key_values.append((key, val))
            phone = True
    if not phone:
        key_values.append((_("Telephone"), _("Please get a phone number")))

    content = "<ul>"
    for key, value in key_values:
        content += "<li><b>%s</b> - %s</li>" % (key, value)
    content += "</ul>"
    html_ = HTML_TEMPLATE.replace("{{CONTENT}}", content)

    return html_
 def exec_(self):
     '''
     raise the dialog
     '''
     if not BaseDialog.exec_(self):
         return False
     if self.check_date > localsettings.currentDay():
         QtWidgets.QMessageBox.warning(self, _("Error!"),
                                       _("That date is in the future!"))
         return self.exec_()
     if QtWidgets.QMessageBox.question(
             self, _("Confirm Action"), "%s<hr />%s <b>%s</b><br />%s" %
         (self.pt.name_id, _("Date Checked"),
          localsettings.readableDate(
              self.check_date), _("Confirm this date now?")),
             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
             QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes:
         return True
     else:
         return self.exec_()
     return False