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()
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()
Beispiel #3
0
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")
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")
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 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