def __init__(self, serialno, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Date Entry Dialog"))

        self.pt = BriefPatient(serialno)
        self.patient_label = QtWidgets.QLabel(self.pt.name_id)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        year_button = QtWidgets.QPushButton(_("Change Year"))
        last_check = localsettings.formatDate(self.pt.mh_form_date)
        if not last_check:
            last_check = _("NEVER")
        self.date_checked_label = WarningLabel(
            "%s<hr />(%s %s)" %
            (_('Please enter the date that this patient has completed '
               'a medical history form.'), _('Last recorded check was'),
             last_check))
        self.date_checked_label.setMaximumHeight(120)

        self.calendar = yearCalendar(self)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(year_button)
        self.insertWidget(self.calendar)

        year_button.clicked.connect(self.select_year)
        self.calendar.selected_date_signal.connect(self.accept)

        self.enableApply()
Ejemplo n.º 2
0
class CloseCourseDialog(BaseDialog):

    def __init__(self, ftr=False, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Close Course Dialog"))

        self.patient_label = QtWidgets.QLabel("")
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        self.tx_complete_label = WarningLabel(
            _('You have no further treatment proposed for this patient, '
              'yet they are deemed to be "under treatment".'))
        self.tx_complete_label.setMaximumHeight(120)

        self.date_edit = QtWidgets.QDateEdit()
        self.date_edit.setDate(QtCore.QDate.currentDate())
        self.date_edit.setMaximumDate(QtCore.QDate().currentDate())
        self.date_edit.setCalendarPopup(True)

        frame = QtWidgets.QFrame(self)
        layout = QtWidgets.QFormLayout(frame)
        layout.addRow(_("Suggested Completion Date"), self.date_edit)

        question_label = QtWidgets.QLabel(
            "<b>%s</b>" %
            _("Close this course now?"))
        question_label.setAlignment(QtCore.Qt.AlignCenter)

        self.ftr_checkbox = QtWidgets.QCheckBox(_("Pt failed to return"))
        self.ftr_checkbox.setChecked(ftr)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.tx_complete_label)
        self.insertWidget(frame)
        self.insertWidget(question_label)

        if ftr:
            self.layout().insertStretch(4, 200)
            self.insertWidget(self.ftr_checkbox)

        self.enableApply()

    def set_minimum_date(self, date_):
        self.date_edit.setMinimumDate(date_)

    def set_date(self, date_):
        self.date_edit.setDate(date_)

    @property
    def completion_date(self):
        return self.date_edit.date().toPyDate()

    @property
    def ftr(self):
        return self.ftr_checkbox.isChecked()
Ejemplo n.º 3
0
class CloseCourseDialog(BaseDialog):

    def __init__(self, ftr=False, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Close Course Dialog"))

        self.patient_label = QtGui.QLabel("")
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        self.tx_complete_label = WarningLabel(
            _('You have no further treatment proposed for this patient, '
              'yet they are deemed to be "under treatment".'))
        self.tx_complete_label.setMaximumHeight(120)

        self.date_edit = QtGui.QDateEdit()
        self.date_edit.setDate(QtCore.QDate.currentDate())
        self.date_edit.setMaximumDate(QtCore.QDate().currentDate())
        self.date_edit.setCalendarPopup(True)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Suggested Completion Date"), self.date_edit)

        question_label = QtGui.QLabel(
            "<b>%s</b>" %
            _("Close this course now?"))
        question_label.setAlignment(QtCore.Qt.AlignCenter)

        self.ftr_checkbox = QtGui.QCheckBox(_("Pt failed to return"))
        self.ftr_checkbox.setChecked(ftr)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.tx_complete_label)
        self.insertWidget(frame)
        self.insertWidget(question_label)

        if ftr:
            self.layout().insertStretch(4, 200)
            self.insertWidget(self.ftr_checkbox)

        self.enableApply()

    def set_minimum_date(self, date_):
        self.date_edit.setMinimumDate(date_)

    def set_date(self, date_):
        self.date_edit.setDate(date_)

    @property
    def completion_date(self):
        return self.date_edit.date().toPyDate()

    @property
    def ftr(self):
        return self.ftr_checkbox.isChecked()
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)

        self.setWindowTitle(_("User choice"))

        label = WarningLabel(_("Set the Appointment Viewing Mode"))
        self.insertWidget(label)

        for mode, description, value in (
            (_("Browsing"), "", self.VIEW_MODE),
            (_("Scheduling"), _("make appointments for a patient"),
             self.SCHEDULING_MODE),
            (_("Blocking"), _("block time periods. eg. lunch times etc."),
             self.BLOCKING_MODE), (_("Note Checking"),
                                   _("check notes for today's patients"),
                                   self.NOTES_MODE)):

            but = QtWidgets.QPushButton(mode)
            but.setToolTip(description)

            but.appt_mode = value
            but.clicked.connect(self.but_clicked)
            self.insertWidget(but)

        self.apply_but.hide()
Ejemplo n.º 5
0
    def __init__(self, message, changes, parent=None):
        '''
        offers a choiced of save discard cancel, but allows for examination
        of what has changed.
        changes should be a function, which returns a string list
        '''
        ExtendableDialog.__init__(self, parent)
        self.set_advanced_but_text(_("What's changed?"))
        self.apply_but.setText("&Save")
        self.enableApply()
        self.save_on_exit = True

        label = WarningLabel(message)
        self.insertWidget(label)

        self.discard_but = self.button_box.addButton(
            QtGui.QDialogButtonBox.Discard)
        self.discard_but.setToolTip(_("Discard All Changes"))

        self.cancel_but.setToolTip(_("Cancel and Continue Editing"))

        self.changes = changes
        self.changes_list_widget = QtGui.QListWidget()
        self.add_advanced_widget(self.changes_list_widget)

        self.result = self.SAVE
Ejemplo n.º 6
0
    def __init__(self, check=False, parent=None):
        BaseDialog.__init__(self, parent)
        self.check = check
        self.enableApply()

        label = WarningLabel(_("Who is Browsing the Forum?"))
        self.insertWidget(label)
        other_ops = localsettings.allowed_logins[:]
        logged_in_ops = localsettings.operator.split("/")
        for op in logged_in_ops:
            if op in localsettings.allowed_logins:
                other_ops.remove(op)
                but = QtWidgets.QPushButton(op)
                but.clicked.connect(self.but_clicked)
                self.insertWidget(but)

        label2 = QtWidgets.QLabel(_("Or choose another user"))

        self.cb = QtWidgets.QComboBox()
        self.cb.addItem("--")
        self.cb.addItems(sorted(other_ops))

        self.cb.currentTextChanged.connect(self.cb_interaction)
        self.insertWidget(label2)
        self.insertWidget(self.cb)
Ejemplo n.º 7
0
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Add User Dialog"))

        self.top_label = WarningLabel("%s<br />%s<hr />%s" % (
            _('Add a new user to the system?'),
            _("This is done using initials or a short nickname."),
            _("Must be unique and Maximum allowed in 5 characters")))

        self.line_edit = UpperCaseLineEdit()

        frame = QtWidgets.QFrame(self)
        layout = QtWidgets.QFormLayout(frame)
        layout.addRow(_("User Initials or nickname"), self.line_edit)

        self.insertWidget(self.top_label)
        self.insertWidget(frame)

        self.line_edit.textChanged.connect(self._check_enable)
        self.line_edit.setFocus()

        list_widget = QtWidgets.QListWidget()
        list_widget.addItems(sorted(localsettings.allowed_logins))
        self.add_advanced_widget(list_widget)
        self.set_advanced_but_text(_("view existing users"))
Ejemplo n.º 8
0
    def __init__(self, pt, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Recall Prompt Dialog"))

        pt_details = "<b>%s %s %s</b>" % (pt.title, pt.fname, pt.sname)
        self.patient_label = QtWidgets.QLabel(pt_details)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)

        message = _("There is a problem with the recall date of this patient.")
        action = _("Would you like to fix this now?")

        self.warning_label = WarningLabel("%s<hr />%s" % (message, action))

        self.apply_but.setText(_("Fix"))

        self.ignore_but = self.button_box.addButton(
            QtWidgets.QDialogButtonBox.Discard)
        self.ignore_but.setText(_("Ignore Recall Date"))
        self.ignore_but.setToolTip(_("Ignore this for now."))

        self.cancel_but.setToolTip(_("Cancel and Continue Editing"))

        self.insertWidget(self.patient_label)
        self.insertWidget(self.warning_label)

        self.enableApply()
Ejemplo n.º 9
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent, remove_stretch=True)

        title = _("Confgure Feescales Dialog")
        self.setWindowTitle(title)
        label = WarningLabel(
            "%s<hr />%s" %
            (_("This dialog enables you to modify the metadata which "
               "determines the order feescales are loaded."),
             _("You can also archive a feescale by unchecking 'in use'.")))
        self.insertWidget(label)
        self.configurer = FeescaleConfigurer()
        LOGGER.debug(
            "Feescales to config\n%s",
            "\n".join(["  %s" % f for f in self.configurer.feescales]))

        frame = QtWidgets.QFrame()
        self.fs_layout = QtWidgets.QVBoxLayout(frame)
        self.fs_layout.setContentsMargins(0, 0, 0, 0)
        self.fs_layout.setSpacing(0)
        for feescale in self.configurer.feescales:
            widg = FeescaleWidget(feescale)
            widg.promote_signal.connect(self.promote_widget)
            widg.demote_signal.connect(self.demote_widget)
            widg.check_required_signal.connect(self.check_enable)
            self.fs_layout.addWidget(widg)

        scroll_area = QtWidgets.QScrollArea(self)
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)
        self.insertWidget(scroll_area)

        self.enable_buttons()
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Login Dialog"))

        header_label = WarningLabel(_('Login Required'))

        self.password_lineEdit = QtWidgets.QLineEdit()
        self.password_lineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
        self.user1_lineEdit = UpperCaseLineEdit()
        self.user1_lineEdit.setMaximumWidth(50)
        self.user2_lineEdit = UpperCaseLineEdit()
        self.user2_lineEdit.setMaximumWidth(50)

        self.reception_radioButton = QtWidgets.QRadioButton(
            _("Reception Machine"))
        self.surgery_radioButton = QtWidgets.QRadioButton(_("Surgery Machine"))
        self.surgery_radioButton.setChecked(True)

        frame = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(frame)

        form_layout.addRow(_("System Password"), self.password_lineEdit)

        form_layout.addRow(_("User 1 (Required)"), self.user1_lineEdit)
        form_layout.addRow(_("User 2 (Optional)"), self.user2_lineEdit)

        but_group = QtWidgets.QButtonGroup(self)
        but_group.addButton(self.surgery_radioButton)
        but_group.addButton(self.reception_radioButton)

        self.insertWidget(header_label)
        self.insertWidget(frame)
        self.insertWidget(self.surgery_radioButton)
        self.insertWidget(self.reception_radioButton)
        self.enableApply()

        # grab any stored information
        PASSWORD, USER1, USER2 = localsettings.autologin()
        self.password_lineEdit.setText(PASSWORD)
        self.user1_lineEdit.setText(USER1)
        self.user2_lineEdit.setText(USER2)
        self.autoreception(USER1)
        self.autoreception(USER2)

        self.parse_conf_file()

        self.alternate_servers_widget = AlternateServersWidget(self)
        if self.alternate_servers_widget.has_options:
            self.more_but.setText(_("Database choice"))
            self.add_advanced_widget(self.alternate_servers_widget)
        else:
            self.more_but.hide()

        self.user1_lineEdit.textEdited.connect(self.autoreception)
        self.user2_lineEdit.textEdited.connect(self.autoreception)

        self.dirty = True
        self.set_check_on_cancel(True)

        QtCore.QTimer.singleShot(1000, self._developer_login)
    def __init__(self, serialno, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Date Entry Dialog"))

        self.pt = BriefPatient(serialno)
        self.patient_label = QtGui.QLabel(self.pt.name_id)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        year_button = QtGui.QPushButton(_("Change Year"))
        last_check = localsettings.formatDate(self.pt.mh_form_date)
        if not last_check:
            last_check = _("NEVER")
        self.date_checked_label = WarningLabel(
            "%s<hr />(%s %s)" % (
                _('Please enter the date that this patient has completed '
                  'a medical history form.'),
                _('Last recorded check was'), last_check)
        )
        self.date_checked_label.setMaximumHeight(120)

        self.calendar = yearCalendar(self)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(year_button)
        self.insertWidget(self.calendar)

        year_button.clicked.connect(self.select_year)
        self.calendar.selected_date_signal.connect(self.accept)

        self.enableApply()
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Edit Practice Address Dialog"))

        self.top_label = WarningLabel("%s<hr />%s" % (
            _('Edit the Practice Name and/or address.'),
            _("This information is used on receipts and appointment slips."),
        ))

        self.practice_line_edit = QtGui.QLineEdit()
        self.practice_line_edit.setText(localsettings.PRACTICE_NAME)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Practice Name"), self.practice_line_edit)

        self.addr_line_edits = []
        for i in range(7):
            le = QtGui.QLineEdit()
            self.addr_line_edits.append(le)
            layout.addRow("%s %d" % (_("Address Line"), i + 1), le)

            try:
                le.setText(localsettings.PRACTICE_ADDRESS[i + 1])
            except IndexError:
                pass

        self.insertWidget(self.top_label)
        self.insertWidget(frame)

        self.enableApply()
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Confirm"))

        label = WarningLabel(_("Clear ALL Patient Locations?"))
        self.insertWidget(label)
        self.enableApply()
Ejemplo n.º 14
0
    def __init__(self, om_gui=None):
        ExtendableDialog.__init__(self, om_gui)

        self.chosen_properties = {}
        self.om_gui = om_gui
        message = (_("Chart/Plan a Bridge"))
        self.setWindowTitle(message)
        self.header_label = WarningLabel(message)

        self.wizard_widget = QtWidgets.QStackedWidget()

        page0 = PageZero(self)
        page1 = PageOne(self)
        page2 = PageTwo(self)
        page3 = PageThree(self)
        page4 = PageFour(self)
        accept_page = AcceptPage(self)

        self.wizard_widget.addWidget(page0)
        self.wizard_widget.addWidget(page1)
        self.wizard_widget.addWidget(page2)
        self.wizard_widget.addWidget(page3)
        self.wizard_widget.addWidget(page4)
        self.wizard_widget.addWidget(accept_page)

        self.insertWidget(self.header_label)
        self.insertWidget(self.wizard_widget)

        self.advanced_label = QtWidgets.QLabel("self.advanced_label")
        self.add_advanced_widget(self.advanced_label)

        self.next_but = self.button_box.addButton(_("Next"),
                                                  self.button_box.ActionRole)

        self.apply_but.hide()
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
    def add_widgets(self):
        self.header_label = WarningLabel(
            _("Checking for updates.... please wait."))
        self.result_label = QtWidgets.QLabel("")
        self.result_label.setAlignment(QtCore.Qt.AlignCenter)
        self.result_label.setOpenExternalLinks(True)

        self.insertWidget(self.header_label)
        self.insertWidget(self.result_label)

        self.cancel_but.hide()
        self.apply_but.setText(_("OK"))
        self.enableApply()

        self.options_widget = OptionsWidget(self)
        self.options_widget.set_chosen_option(self.config.update_option)
        self.set_advanced_but_text(_("Options"))
        self.add_advanced_widget(self.options_widget)
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("First Run Dialog"))

        self.top_label = WarningLabel("FirstRun")

        self.wizard_widget = QtWidgets.QStackedWidget()

        page0 = PageZero(self)
        self.page1 = PageOne(self)
        self.page2 = PageTwo(self)
        self.page3 = PageThree(self)
        self.page4 = PageFour(self)
        self.page5 = PageFive(self)
        page6 = PageSix(self)
        page7 = PageSeven(self)
        self.page8 = PageEight(self)
        self.page9 = PageNine(self)

        self.wizard_widget.addWidget(page0)
        self.wizard_widget.addWidget(self.page1)
        self.wizard_widget.addWidget(self.page2)
        self.wizard_widget.addWidget(self.page3)
        self.wizard_widget.addWidget(self.page4)
        self.wizard_widget.addWidget(self.page5)
        self.wizard_widget.addWidget(page6)
        self.wizard_widget.addWidget(page7)
        self.wizard_widget.addWidget(self.page8)
        self.wizard_widget.addWidget(self.page9)

        self.insertWidget(self.top_label)
        self.insertWidget(self.wizard_widget)

        self.next_but = self.button_box.addButton(_("Next"),
                                                  self.button_box.ActionRole)
        self.back_but = self.button_box.addButton(_("Back"),
                                                  self.button_box.ActionRole)

        self.apply_but.hide()
        self.back_but.hide()
        self.cancel_but.setText(_("Quit OpenMolar"))

        self.set_labels()
Ejemplo n.º 18
0
    def __init__(self, date_, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)
        self.date = date_
        label = WarningLabel(
            "%s %s" % (_("Edit Memos for"), localsettings.longDate(date_)))

        self.bank_hol_label = QtWidgets.QLabel("")
        font = self.font()
        font.setBold(True)
        font.setItalic(True)
        self.bank_hol_label.setFont(font)
        self.bank_hol_label.setAlignment(QtCore.Qt.AlignCenter)
        self.bank_hol_label.hide()

        self.global_lineedit = QtWidgets.QLineEdit()

        frame = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(frame)
        form_layout.addRow(_("Global Memo"), self.global_lineedit)

        frame2 = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(frame2)

        self.le_dict = {}
        for apptix in \
                localsettings.activedent_ixs + localsettings.activehyg_ixs:
            le = QtWidgets.QLineEdit()
            form_layout.addRow(localsettings.apptix_reverse.get(apptix), le)
            self.le_dict[apptix] = le

        scroll_area = QtWidgets.QScrollArea()
        scroll_area.setWidget(frame2)
        scroll_area.setWidgetResizable(True)

        clinician_groupbox = QtWidgets.QGroupBox()
        clinician_groupbox.setTitle(_("Clinician Memos"))
        layout = QtWidgets.QVBoxLayout(clinician_groupbox)
        layout.addWidget(scroll_area)

        self.public_holiday_le = QtWidgets.QLineEdit()
        public_holiday_widget = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(public_holiday_widget)
        form_layout.addRow(_("Public Holiday Text"), self.public_holiday_le)
        self.add_advanced_widget(public_holiday_widget)
        self.set_advanced_but_text(_("Edit Public Holiday Text"))

        self.insertWidget(label)
        self.insertWidget(self.bank_hol_label)
        self.insertWidget(frame)
        self.insertWidget(clinician_groupbox)

        self.setMinimumSize(self.sizeHint())
        self.check_before_reject_if_dirty = True
        QtCore.QTimer.singleShot(100, self.load_values)
Ejemplo n.º 19
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.ix = None
        self.setWindowTitle(_("New Feescale Dialog"))

        self.insertWidget(
            WarningLabel(
                _('Click Apply to create a new local feescale file'
                  ' which can be modified and then inserted into the database')
            ))

        self.enableApply()
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Connection Progress Dialog"))

        self.top_label = WarningLabel(
            _("Establishing a database connection... please wait!"))
        wait_widget = WaitWidget(self)

        self.insertWidget(self.top_label)
        self.insertWidget(wait_widget)
        self.apply_but.hide()
        self.cancel_but.setText(_("Quit OpenMolar"))
        connect.params.signaller.connection_signal.connect(self.is_connected)
Ejemplo n.º 21
0
    def __init__(self, parent):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Checked Dialog"))

        self.pt = parent.pt
        self.patient_label = QtGui.QLabel(self.pt.name)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        self.date_checked_label = WarningLabel(
            _('You are about to confirm that the patient has completed '
              'a medical history form.'))
        self.date_checked_label.setMaximumHeight(120)

        self.date_edit = QtGui.QDateEdit()
        self.date_edit.setDate(QtCore.QDate.currentDate())
        self.date_edit.setMaximumDate(QtCore.QDate().currentDate())
        self.date_edit.setCalendarPopup(True)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Date Checked"), self.date_edit)

        question_label = QtGui.QLabel("<b>%s</b>" %
                                      _("Confirm this date now?"))
        question_label.setAlignment(QtCore.Qt.AlignCenter)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(frame)
        self.insertWidget(question_label)

        self.correction_widget = CorrectionWidget(self.pt, self)
        self.add_advanced_widget(self.correction_widget)

        self.enableApply()
Ejemplo n.º 22
0
    def __init__(self, om_gui=None):
        ExtendableDialog.__init__(self, om_gui)

        self.om_gui = om_gui
        message = (_("Add A New Denture To The Treatment Plan"))
        self.setWindowTitle(message)
        self.header_label = WarningLabel(message)

        self.ndu_le = UpperCaseLineEdit()
        self.ndl_le = UpperCaseLineEdit()

        self.set_default_lineedit(self.ndl_le)

        self.wizard_widget = QtWidgets.QStackedWidget()

        page0 = PageZero(self)
        page0.finished_signal.connect(self.next_widget)
        page1 = PageOne(self)
        page2 = PageTwo(self)
        page3 = PageThree(self)
        page4 = PageFour(self)
        accept_page = AcceptPage(self)

        self.wizard_widget.addWidget(page0)
        self.wizard_widget.addWidget(page1)
        self.wizard_widget.addWidget(page2)
        self.wizard_widget.addWidget(page3)
        self.wizard_widget.addWidget(page4)
        self.wizard_widget.addWidget(accept_page)

        self.insertWidget(self.header_label)
        self.insertWidget(self.wizard_widget)

        frame = QtWidgets.QFrame()
        layout = QtWidgets.QFormLayout(frame)
        layout.addRow(_("Upper Denture"), self.ndu_le)
        layout.addRow(_("Lower Denture"), self.ndl_le)

        self.add_advanced_widget(frame)

        self.next_but = self.button_box.addButton(
            _("Next"), self.button_box.ActionRole)

        self.apply_but.hide()

        self.ndu_le.textChanged.connect(self.enable_apply)
        self.ndl_le.textChanged.connect(self.enable_apply)

        self.ndu_le.editingFinished.connect(self.advanced_apply)
        self.ndl_le.editingFinished.connect(self.advanced_apply)
Ejemplo n.º 23
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Bookend Dialog"))

        label = WarningLabel(
            _("Change the last date where appointments are searched for?"))
        self.date_edit = QtWidgets.QDateEdit()
        self.date_edit.setDate(localsettings.BOOKEND)
        self.date_edit.setCalendarPopup(True)

        self.insertWidget(label)
        self.insertWidget(self.date_edit)

        self.date_edit.dateChanged.connect(self.check_enable)
Ejemplo n.º 24
0
 def __init__(self, parent=None):
     BaseDialog.__init__(self, parent)
     self.setWindowTitle(_("Restore Default Settings"))
     label = WarningLabel("%s<hr />%s" % (
         _("Appointment search does not have default settings"),
         _("Would You like to reset these now?")))
     self.insertWidget(label)
     self.show_dialog_but = self.button_box.addButton(
         QtGui.QDialogButtonBox.Apply)
     self.show_dialog_but.setText(_("Show Settings Dialog"))
     self.cancel_but.setText(_("Keep Custom Settings"))
     self.apply_but.setText(_("Yes"))
     self.enableApply()
     self.apply_but.setFocus(True)
Ejemplo n.º 25
0
    def __init__(self, serialno, courseno, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)
        self.setWindowTitle(_("Edit Treatment Dialog"))

        self.serialno = serialno
        self.courseno = courseno

        self._treatment_course = None
        self.widgets = {}
        self.orig_values = {}

        frame = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(frame)

        self.header_label = WarningLabel("")

        tooth_atts = []

        for att in treatment_course.CURRTRT_ROOT_ATTS:
            widg = UpperCaseLineEdit()
            self.widgets[att] = widg
            if re.match("[ul][lr][1-8]", att):
                tooth_atts.append(att)
            else:
                form_layout.addRow(att, widg)
        for att in sorted(tooth_atts):
            form_layout.addRow(att.upper(), self.widgets[att])

        scroll_area = QtWidgets.QScrollArea()
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)

        self.insertWidget(self.header_label)
        self.insertWidget(scroll_area)

        self.add_advanced_widget(QtWidgets.QLabel(_("No Advanced Options")))
        QtCore.QTimer.singleShot(100, self.load_values)
Ejemplo n.º 26
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Update Account Letter Settings"))

        label = WarningLabel(_("The following fields can be edited."))
        self.debt_collector_lineedit = QtWidgets.QLineEdit()
        self.footer_textedit = QtWidgets.QTextEdit()

        frame = QtWidgets.QFrame()
        layout = QtWidgets.QFormLayout(frame)
        layout.addRow(_("Debt Collector"), self.debt_collector_lineedit)
        layout.addRow(_("Footer"), self.footer_textedit)

        self.insertWidget(label)
        self.insertWidget(frame)
Ejemplo n.º 27
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Advanced Names Dialog"))

        label = WarningLabel(
            _("Previous Surnames, Nicknames, and alternate "
              "spelling can help when searching for patients"))

        self.browser = OMWebView(self)
        self.browser.linkClicked.connect(self.link_clicked)

        self.insertWidget(label)
        self.insertWidget(self.browser)

        self.cancel_but.hide()
        self.enableApply()
Ejemplo n.º 28
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        label = WarningLabel(_("Please enter the reason for your alterations"))
        self.insertWidget(label)
        self.rbs = []
        for note in (_("Updated Medical Notes"), _("Corrected Medical Notes"),
                     self.NO_NOTE):
            rb = QtWidgets.QRadioButton(note)
            self.rbs.append(rb)
            self.insertWidget(rb)

        if "REC" in localsettings.operator:
            self.rbs[-1].setChecked(True)
        else:
            self.rbs[0].setChecked(True)
        self.enableApply()
        self.cancel_but.hide()
Ejemplo n.º 29
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Account Dialog"))
        label = WarningLabel(_("Please Choose the tone of this letter"))
        self.radio_button_a = QtWidgets.QRadioButton(
            _("Normal Account - Very Polite"))
        self.radio_button_b = QtWidgets.QRadioButton(
            _("Mildly assertive request"))
        self.radio_button_c = QtWidgets.QRadioButton(
            _("Threaten with Debt Collector"))

        self.insertWidget(label)
        self.insertWidget(self.radio_button_a)
        self.insertWidget(self.radio_button_b)
        self.insertWidget(self.radio_button_c)

        self.radio_button_a.setChecked(True)
        self.enableApply()
Ejemplo n.º 30
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Raise Permissions Dialog"))
        label = WarningLabel(
            "%s<hr />%s" %
            (_("Supervisor privileges required to perform this action"),
             _("Please enter the supervisor password")))

        frame = QtGui.QFrame()
        self.form_layout = QtGui.QFormLayout(frame)
        self.line_edit = QtGui.QLineEdit()
        self.line_edit.setEchoMode(QtGui.QLineEdit.Password)
        self.form_layout.addRow(_("Supervisor Password"), self.line_edit)

        self.insertWidget(label)
        self.insertWidget(frame)
        self.enableApply()
        self.line_edit.setFocus(True)
Ejemplo n.º 31
0
    def add_widgets(self):
        self.header_label = WarningLabel(
            _("Checking for updates.... please wait."))
        self.result_label = QtWidgets.QLabel("")
        self.result_label.setAlignment(QtCore.Qt.AlignCenter)
        self.result_label.setOpenExternalLinks(True)

        self.insertWidget(self.header_label)
        self.insertWidget(self.result_label)

        self.cancel_but.hide()
        self.apply_but.setText(_("OK"))
        self.enableApply()

        self.options_widget = OptionsWidget(self)
        self.options_widget.set_chosen_option(self.config.update_option)
        self.set_advanced_but_text(_("Options"))
        self.add_advanced_widget(self.options_widget)
Ejemplo n.º 32
0
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Initial Check Dialog"))

        top_label = WarningLabel(
            _('OpenMolar has found the following issues with your database.'))

        frame = QtWidgets.QFrame(self)
        self.form_layout = QtWidgets.QFormLayout(frame)

        self.add_advanced_widget(QtWidgets.QLabel(_("No Advanced options")))
        self.enableApply(True)

        self.insertWidget(top_label)
        self.insertWidget(frame)

        self.apply_but.setText(_("Proceed"))
        self.cancel_but.hide()
Ejemplo n.º 33
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.dent_cbs = []

        self.setWindowTitle(_("Load Accounts"))
        label = WarningLabel(
            _("Please select criteria for loading patients in debt or credit"))
        self.debt_rb = QtWidgets.QRadioButton(_("Debt"))
        self.debt_rb.setChecked(True)
        credit_rb = QtWidgets.QRadioButton(_("Credit"))

        self.dent_gb = QtWidgets.QGroupBox(
            _("Dentist choice (leave unchecked for all)"))
        self.dent_gb.setCheckable(True)
        self.dent_gb.setChecked(False)
        layout = QtWidgets.QVBoxLayout(self.dent_gb)

        for i, dent in enumerate(localsettings.activedents):
            cb = QtWidgets.QCheckBox()
            cb.setChecked(True)
            cb.setText(dent)
            cb.dent = localsettings.activedent_ixs[i]
            layout.addWidget(cb)
            self.dent_cbs.append(cb)

        self.amount_spin_box = QtWidgets.QDoubleSpinBox()
        self.bad_debts_cb = QtWidgets.QCheckBox()

        rb_frame = QtWidgets.QFrame()
        radio_but_layout = QtWidgets.QHBoxLayout(rb_frame)
        radio_but_layout.addWidget(self.debt_rb)
        radio_but_layout.addWidget(credit_rb)

        amount_frame = QtWidgets.QFrame()
        amount_layout = QtWidgets.QFormLayout(amount_frame)
        amount_layout.addRow(_("Ignore amounts less than"),
                             self.amount_spin_box)
        amount_layout.addRow(_("Include Bad Debts"), self.bad_debts_cb)

        self.insertWidget(label)
        self.insertWidget(rb_frame)
        self.insertWidget(amount_frame)
        self.insertWidget(self.dent_gb)
        self.enableApply()
Ejemplo n.º 34
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("First Run Dialog"))

        self.top_label = WarningLabel("FirstRun")

        self.wizard_widget = QtWidgets.QStackedWidget()

        page0 = PageZero(self)
        self.page1 = PageOne(self)
        self.page2 = PageTwo(self)
        self.page3 = PageThree(self)
        self.page4 = PageFour(self)
        self.page5 = PageFive(self)
        page6 = PageSix(self)
        self.page7 = PageSeven(self)
        # accept_page = AcceptPage(self)

        self.wizard_widget.addWidget(page0)
        self.wizard_widget.addWidget(self.page1)
        self.wizard_widget.addWidget(self.page2)
        self.wizard_widget.addWidget(self.page3)
        self.wizard_widget.addWidget(self.page4)
        self.wizard_widget.addWidget(self.page5)
        self.wizard_widget.addWidget(page6)
        self.wizard_widget.addWidget(self.page7)
        # self.wizard_widget.addWidget(accept_page)

        self.insertWidget(self.top_label)
        self.insertWidget(self.wizard_widget)

        self.next_but = self.button_box.addButton(
            _("Next"), self.button_box.ActionRole)
        self.back_but = self.button_box.addButton(
            _("Back"), self.button_box.ActionRole)

        self.apply_but.hide()
        self.back_but.hide()
        self.cancel_but.setText(_("Quit OpenMolar"))

        self.set_labels()
    def __init__(self, parent):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Checked Dialog"))

        self.pt = parent.pt
        self.patient_label = QtGui.QLabel(self.pt.name)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        self.date_checked_label = WarningLabel(
            _('You are about to confirm that the patient has completed '
              'a medical history form.'))
        self.date_checked_label.setMaximumHeight(120)

        self.date_edit = QtGui.QDateEdit()
        self.date_edit.setDate(QtCore.QDate.currentDate())
        self.date_edit.setMaximumDate(QtCore.QDate().currentDate())
        self.date_edit.setCalendarPopup(True)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Date Checked"), self.date_edit)

        question_label = QtGui.QLabel(
            "<b>%s</b>" %
            _("Confirm this date now?"))
        question_label.setAlignment(QtCore.Qt.AlignCenter)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(frame)
        self.insertWidget(question_label)

        self.correction_widget = CorrectionWidget(self.pt, self)
        self.add_advanced_widget(self.correction_widget)

        self.enableApply()
Ejemplo n.º 36
0
class FirstRunDialog(BaseDialog):

    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("First Run Dialog"))

        self.top_label = WarningLabel("FirstRun")

        self.wizard_widget = QtWidgets.QStackedWidget()

        page0 = PageZero(self)
        self.page1 = PageOne(self)
        self.page2 = PageTwo(self)
        self.page3 = PageThree(self)
        self.page4 = PageFour(self)
        self.page5 = PageFive(self)
        page6 = PageSix(self)
        self.page7 = PageSeven(self)
        # accept_page = AcceptPage(self)

        self.wizard_widget.addWidget(page0)
        self.wizard_widget.addWidget(self.page1)
        self.wizard_widget.addWidget(self.page2)
        self.wizard_widget.addWidget(self.page3)
        self.wizard_widget.addWidget(self.page4)
        self.wizard_widget.addWidget(self.page5)
        self.wizard_widget.addWidget(page6)
        self.wizard_widget.addWidget(self.page7)
        # self.wizard_widget.addWidget(accept_page)

        self.insertWidget(self.top_label)
        self.insertWidget(self.wizard_widget)

        self.next_but = self.button_box.addButton(
            _("Next"), self.button_box.ActionRole)
        self.back_but = self.button_box.addButton(
            _("Back"), self.button_box.ActionRole)

        self.apply_but.hide()
        self.back_but.hide()
        self.cancel_but.setText(_("Quit OpenMolar"))

        self.set_labels()

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

    def wait(self, waiting=True):
        if waiting:
            QtWidgets.QApplication.instance().setOverrideCursor(
                QtCore.Qt.WaitCursor)
        else:
            QtWidgets.QApplication.instance().restoreOverrideCursor()

    def set_labels(self):
        self.top_label.setText(self.current_page.header_text)
        self.cancel_but.setVisible(self.current_index == 0)
        self.back_but.setVisible(self.current_index != 0)

        if self.current_index == 5:
            self.next_but.setText(_("Create Database Now!"))
        elif self.current_index == 7:
            self.next_but.setText(_("Write Config File and Proceed"))
        else:
            self.next_but.setText(_("Next"))

    def __next__(self):
        '''
        0 = intro
        1 = application password
        2 = host and port
        3 = database option (create new or use existing)
        4 = database details (dbname, user and password)
        5 = enter privileged user
        6 = create database
        7 = test connection, write config and exit.
        '''
        i = self.wizard_widget.currentIndex()
        if not self.current_page.is_completed:
            QtWidgets.QMessageBox.warning(self,
                                          _("error"),
                                          self.current_page.error_message)
            new_i = i
        elif i == 4 and not self.page3.create_new:
            new_i = i + 3
        elif i == 7:
            self.finish()
            return
        else:
            new_i = i + 1
        self.wizard_widget.setCurrentIndex(new_i)
        self.set_labels()

    def back(self):
        i = self.wizard_widget.currentIndex()
        if i == 0:
            new_i = 0
        elif i == 7:  # shouldn't happen?
            new_i = 0  # don't create a database by hitting "back"
        else:
            new_i = i - 1
        self.wizard_widget.setCurrentIndex(new_i)
        self.set_labels()

    def database_exists_already(self):
        self.wizard_widget.setCurrentIndex(4)
        self.set_labels()

    def finish(self):
        dom = minidom.parseString(XML_TEMPLATE)
        #  hash the password (twice) and save it
        sha1 = hashlib.sha1(("diqug_ADD_SALT_3i2some%s" %
                             self.sys_password).encode("utf8")).hexdigest()
        PSWORD = hashlib.md5(sha1.encode("utf8")).hexdigest()
        dom.getElementsByTagName(
            "system_password")[0].firstChild.replaceWholeText(PSWORD)
        #  server settings
        xmlnode = dom.getElementsByTagName("server")[0]
        #  host
        xmlnode.getElementsByTagName(
            "location")[0].firstChild.replaceWholeText(self.host)
        # port
        xmlnode.getElementsByTagName(
            "port")[0].firstChild.replaceWholeText(str(self.port))
        #  database settings
        xmlnode = dom.getElementsByTagName("database")[0]
        # user
        xmlnode.getElementsByTagName(
            "user")[0].firstChild.replaceWholeText(self.db_user)
        # password
        xmlnode.getElementsByTagName(
            "password")[0].firstChild.replaceWholeText(
            base64.b64encode(self.db_pass.encode("utf8")).decode("utf8"))
        # db name
        xmlnode.getElementsByTagName(
            "dbname")[0].firstChild.replaceWholeText(self.db_name)

        settings_dir = os.path.dirname(localsettings.global_cflocation)
        successful_save = False
        try:
            if not os.path.exists(settings_dir):
                LOGGER.info("creating settings directory '%s'", settings_dir)
                os.mkdir(settings_dir)
            LOGGER.info(
                'writing settings to %s', localsettings.global_cflocation)
            f = open(localsettings.global_cflocation, "w")
            f.write(dom.toxml())
            f.close()
            localsettings.cflocation = localsettings.global_cflocation
            successful_save = True
        except OSError:
            pass
        except IOError:
            pass

        if not successful_save:
            message = (
                "unable to write to '%s' "
                "we need root privileges for that\n"
                "will resort to putting settings into a local file '%s'")
            LOGGER.warning(message, settings_dir, localsettings.cflocation)
            settings_dir = os.path.dirname(localsettings.cflocation)
            if not os.path.exists(settings_dir):
                os.mkdir(settings_dir)
            LOGGER.info("putting a local settings file in '%s'", settings_dir)
            f = open(localsettings.cflocation, "w")
            f.write(dom.toxml())
            f.close()
            localsettings.cflocation = localsettings.cflocation

        conf_text = "[login]\nPASSWORD=\nUSER1=\nUSER2="
        if self.page3.create_new:
            conf_text = conf_text.replace("USER1=", "USER1=USER")
        f = open(localsettings.LOGIN_CONF, "w")
        f.write(conf_text)
        f.close()

        self.accept()

    def _clicked(self, but):
        '''
        "private" function called when button box is clicked
        '''
        if but == self.next_but:
            next(self)
        elif but == self.back_but:
            self.back()
        else:
            BaseDialog._clicked(self, but)

    @property
    def current_index(self):
        return self.wizard_widget.currentIndex()

    @property
    def current_page(self):
        return self.wizard_widget.currentWidget()

    @property
    def sys_password(self):
        return str(self.page1.line_edit1.text())

    @property
    def host(self):
        return str(self.page2.line_edit1.text())

    @property
    def port(self):
        return int(str(self.page2.line_edit2.text()))

    @property
    def db_name(self):
        return str(self.page4.line_edit1.text())

    @property
    def db_user(self):
        return str(self.page4.line_edit2.text())

    @property
    def db_pass(self):
        return str(self.page4.line_edit3.text())

    @property
    def privileged_user(self):
        return str(self.page5.line_edit1.text())

    @property
    def privileged_user_pass(self):
        return str(self.page5.line_edit2.text())
class MedFormDateEntryDialog(BaseDialog):
    """
    Updates the medform table when a patient has completed an mh form.
    """

    def __init__(self, serialno, parent=None):
        BaseDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Date Entry Dialog"))

        self.pt = BriefPatient(serialno)
        self.patient_label = QtWidgets.QLabel(self.pt.name_id)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        year_button = QtWidgets.QPushButton(_("Change Year"))
        last_check = localsettings.formatDate(self.pt.mh_form_date)
        if not last_check:
            last_check = _("NEVER")
        self.date_checked_label = WarningLabel(
            "%s<hr />(%s %s)"
            % (
                _("Please enter the date that this patient has completed " "a medical history form."),
                _("Last recorded check was"),
                last_check,
            )
        )
        self.date_checked_label.setMaximumHeight(120)

        self.calendar = yearCalendar(self)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(year_button)
        self.insertWidget(self.calendar)

        year_button.clicked.connect(self.select_year)
        self.calendar.selected_date_signal.connect(self.accept)

        self.enableApply()

    @property
    def check_date(self):
        """
        the date chosen by the user (default = today)
        """
        return self.calendar.selectedDate

    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()

    def apply(self):
        """
        commit changes to database
        """
        LOGGER.info("applying date for mh form check")
        try:
            medform_check.insert(self.pt.serialno, self.check_date)
            LOGGER.debug("insertion OK")
        except medform_check.connect.IntegrityError:
            LOGGER.info("date already present in medforms table")
        QtWidgets.QMessageBox.information(
            self,
            _("Success!"),
            "%s %s %s %s"
            % (_("Sucessfully saved "), localsettings.formatDate(self.check_date), _("for patient"), self.pt.serialno),
        )

    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
class MedFormCheckDialog(ExtendableDialog):
    '''
    Updates the medform table when a patient has completed an mh form.
    '''
    def __init__(self, parent):
        ExtendableDialog.__init__(self, parent)
        self.setWindowTitle(_("Medical Form Checked Dialog"))

        self.pt = parent.pt
        self.patient_label = QtGui.QLabel(self.pt.name)
        self.patient_label.setAlignment(QtCore.Qt.AlignCenter)
        f = self.patient_label.font()
        f.setBold(True)
        self.patient_label.setFont(f)

        self.date_checked_label = WarningLabel(
            _('You are about to confirm that the patient has completed '
              'a medical history form.'))
        self.date_checked_label.setMaximumHeight(120)

        self.date_edit = QtGui.QDateEdit()
        self.date_edit.setDate(QtCore.QDate.currentDate())
        self.date_edit.setMaximumDate(QtCore.QDate().currentDate())
        self.date_edit.setCalendarPopup(True)

        frame = QtGui.QFrame(self)
        layout = QtGui.QFormLayout(frame)
        layout.addRow(_("Date Checked"), self.date_edit)

        question_label = QtGui.QLabel(
            "<b>%s</b>" %
            _("Confirm this date now?"))
        question_label.setAlignment(QtCore.Qt.AlignCenter)

        self.insertWidget(self.patient_label)
        self.insertWidget(self.date_checked_label)
        self.insertWidget(frame)
        self.insertWidget(question_label)

        self.correction_widget = CorrectionWidget(self.pt, self)
        self.add_advanced_widget(self.correction_widget)

        self.enableApply()

    @property
    def check_date(self):
        '''
        the date chosen by the user (default = today)
        '''
        return self.date_edit.date().toPyDate()

    def apply(self):
        '''
        commit changes to database
        '''
        LOGGER.info("applying date for mh form check")
        self.pt.mh_form_date = self.check_date
        try:
            medform_check.insert(self.pt.serialno, self.check_date)
            LOGGER.debug("insertion OK")
            if self.date_edit.date() == QtCore.QDate.currentDate():
                self.pt.addHiddenNote(
                    "mednotes",
                    _("Medical Form Completed"),
                    one_only=True
                    )
        except medform_check.connect.IntegrityError:
            LOGGER.info("date already present in medforms table")
Ejemplo n.º 39
0
class EditTreatmentDialog(ExtendableDialog):

    def __init__(self, serialno, courseno, parent=None):
        ExtendableDialog.__init__(self, parent, remove_stretch=True)
        self.setWindowTitle(_("Edit Treatment Dialog"))

        self.serialno = serialno
        self.courseno = courseno

        self._treatment_course = None
        self.widgets = {}
        self.orig_values = {}

        frame = QtWidgets.QFrame()
        form_layout = QtWidgets.QFormLayout(frame)

        self.header_label = WarningLabel("")

        tooth_atts = []

        for att in treatment_course.CURRTRT_ROOT_ATTS:
            widg = UpperCaseLineEdit()
            self.widgets[att] = widg
            if re.match("[ul][lr][1-8]", att):
                tooth_atts.append(att)
            else:
                form_layout.addRow(att, widg)
        for att in sorted(tooth_atts):
            form_layout.addRow(att.upper(), self.widgets[att])

        scroll_area = QtWidgets.QScrollArea()
        scroll_area.setWidget(frame)
        scroll_area.setWidgetResizable(True)

        self.insertWidget(self.header_label)
        self.insertWidget(scroll_area)

        self.add_advanced_widget(QtWidgets.QLabel(_("No Advanced Options")))
        QtCore.QTimer.singleShot(100, self.load_values)

    @property
    def treatment_course(self):
        if self._treatment_course is None:
            self._treatment_course = treatment_course.TreatmentCourse(
                self.serialno, self.courseno)
        return self._treatment_course

    def load_values(self):
        mb = QtWidgets.QMessageBox(self)
        mb.setWindowTitle(_("Option"))
        mb.setIcon(mb.Question)
        mb.setStandardButtons(mb.Yes | mb.No)
        mb.setText("%s<hr /><em>%s</em>" % (
            _("Edit Completed items?"),
            _("Choosing 'NO' will offer edit of planned items")))
        self.rejected.connect(mb.accept)  # for Unittests
        mb.exec_()

        if mb.result() == mb.No:
            self.header_label.setText(_("Planned Items"))
            suffix = "pl"
        else:
            self.header_label.setText(_("Completed Items"))
            suffix = "cmp"
        for att in treatment_course.CURRTRT_ROOT_ATTS:
            val = self.treatment_course.__dict__[att + suffix]
            widg = self.widgets[att]
            self.orig_values[att] = val
            widg.setText(val)
            widg.editingFinished.connect(self.check_appliable)

    def new_value(self, att):
        return str(self.widgets[att].text()).strip(" ") + " "

    def check_appliable(self):
        for att in treatment_course.CURRTRT_ROOT_ATTS:
            if self.new_value(att) != self.orig_values[att]:
                self.enableApply()
                return
        self.enableApply(False)

    def sizeHint(self):
        return QtCore.QSize(350, 600)

    def update_db(self):
        changes = ""
        values = []
        for att in treatment_course.CURRTRT_ROOT_ATTS:
            if self.new_value(att) != self.orig_values[att]:
                changes += "%s%s=%%s ," % (att, self.suffix)
                values.append(self.new_value(att))

        treatment_course.update_course(
            changes.rstrip(","),
            values,
            self.serialno,
            self.courseno)
Ejemplo n.º 40
0
class CheckVersionDialog(ExtendableDialog, Options):
    '''
    A dialog which informs the user of any updates to the openmolar application
    There are 2 ways of calling this dialog.
    exec_() = show the dialog before polling the wesbite for releases
    background_exec() = only show the result if there is a new version.
    '''
    result = None
    _new_version = None
    _next_check_date = None
    polling = False

    def __init__(self, parent=None):
        LOGGER.debug("initiating CheckVersionDialog")
        ExtendableDialog.__init__(self, parent)
        self.data_fetcher = DataFetcher(parent)
        self.config = MyConfigParser()

    def add_widgets(self):
        self.header_label = WarningLabel(
            _("Checking for updates.... please wait."))
        self.result_label = QtWidgets.QLabel("")
        self.result_label.setAlignment(QtCore.Qt.AlignCenter)
        self.result_label.setOpenExternalLinks(True)

        self.insertWidget(self.header_label)
        self.insertWidget(self.result_label)

        self.cancel_but.hide()
        self.apply_but.setText(_("OK"))
        self.enableApply()

        self.options_widget = OptionsWidget(self)
        self.options_widget.set_chosen_option(self.config.update_option)
        self.set_advanced_but_text(_("Options"))
        self.add_advanced_widget(self.options_widget)

    def show_result(self):
        LOGGER.debug("CheckVersionDialog show result")
        self.result = self.data_fetcher.result()
        if self.result is None:
            self.result_label.setText(
                "%s<br /><a href='%s'>%s</a>" % (_("Unable to connect to"),
                                                 INFORMATION_URL,
                                                 INFORMATION_URL))
            return
        if self.update_available:
            header_text = _("A newer version of OpenMolar is available")
            self.header_label.label.setStyleSheet("color: red")
        else:
            header_text = _("You are running the latest version - thankyou")

        self.header_label.setText(header_text)
        self.result_label.setText(MESSAGE % (self.new_version))

    def lookup_due(self):
        '''
        check the config file for user preferences on update check
        '''
        LOGGER.debug("checking user preferences for application update check")
        if self.config.update_option == self.NEVER:
            return False
        if self.config.update_option == self.MONTHLY:
            delta = timedelta(days=30)
        elif self.config.update_option == self.WEEKLY:
            delta = timedelta(days=7)
        elif self.config.update_option == self.DAILY:
            delta = timedelta(days=1)
        else:
            delta = timedelta(days=0)
        if self.config.last_check_date + delta > date.today():
            LOGGER.debug("update check not due yet")
            return False
        return True

    def hit_website(self):
        if not self.polling:
            LOGGER.info("polling website for latest release")
            self.polling = True
            self.data_fetcher.get_webdata()

    @property
    def update_available(self):
        '''
        a boolean to lookup whether a new version is available.
        '''
        LOGGER.debug("getting property update_available")
        try:
            if self.new_version[0] > localsettings.VERSION:
                LOGGER.info("There is a newer version available upstream")
                return True
            else:
                LOGGER.info("You are running the latest version - thankyou")
                return False
        except:
            LOGGER.exception("unknown error getting update available "
                             "perhaps the website returned garbage???")
            return False

    @property
    def new_version(self):
        if self._new_version is None:
            scp = configparser.ConfigParser()
            scp.read_string(self.result)
            version, release_date, message = "", None, ""
            try:
                try:
                    version = scp.get("RELEASE", "VERSION")
                except configparser.NoOptionError:
                    pass
                try:
                    release_date_string = scp.get("RELEASE", "DATE")
                    m = re.match(r"(\d+),(\d+),(\d+)", release_date_string)
                    if m:
                        release_date = date(int(m.groups()[0]),
                                            int(m.groups()[1]),
                                            int(m.groups()[2]))
                        self.checked_today = True
                    else:
                        LOGGER.warning("release date not in form 2016,03,09")
                except configparser.NoOptionError:
                    pass
                except ValueError:  # this will fire if a bad date is passed.
                    logging.exception("error parsing date field")
                try:
                    message = scp.get("RELEASE", "MESSAGE")
                except configparser.NoOptionError:
                    pass
            except configparser.NoSectionError:
                LOGGER.warning("unable to parse result of version checking")
            except configparser.MissingSectionHeaderError:
                pass
            self._new_version = (version,
                                 localsettings.formatDate(release_date),
                                 message.replace("\n", "<br />"))
        return self._new_version

    def background_exec(self):
        if self.lookup_due():
            self.data_fetcher.finished_signal.connect(self.exec_)
            self.hit_website()

    def exec_(self):
        LOGGER.debug("exec_ called by %s", self.sender())
        self.add_widgets()
        if self.sender() == self.data_fetcher:
            self.show_result()
            # lookup has been performed discreetly, only bother the user if
            # there is an update available
            if not self.update_available:
                return False
        else:
            self.data_fetcher.finished_signal.connect(self.show_result)
            QtCore.QTimer.singleShot(5000, self.hit_website)
        if ExtendableDialog.exec_(self):
            self.config.user_chosen_option = self.options_widget.chosen_option
            self.config.checked_today = self.checked_today
            self.config.write_config()