Пример #1
0
        def applyApptWizard(arg):
            i=0
            for appt in arg:
                apr_ix = appointments.add_pt_appt(self.pt.serialno,
                appt.get("clinician"), appt.get("length"), appt.get("trt1"),
                -1, appt.get("trt2"), appt.get("trt3"), appt.get("memo"),
                appt.get("datespec"), self.pt.cset)

                if i == 0:
                    i = apr_ix
            if i:
                self.layout_ptDiary()
                self.select_apr_ix(i)
Пример #2
0
        def applyApptWizard(arg):
            i = 0
            for appt in arg:
                apr_ix = appointments.add_pt_appt(
                    self.pt.serialno,
                    appt.get("clinician"),
                    appt.get("length"), appt.get("trt1"), -1, appt.get("trt2"),
                    appt.get("trt3"), appt.get("memo"),
                    appt.get("datespec"), self.pt.cset)

                if i == 0:
                    i = apr_ix
            if i:
                self.layout_ptDiary()
                self.select_apr_ix(i)
Пример #3
0
    def newAppt_pushButton_clicked(self):
        '''
        user has asked for a new appointment
        '''
        # -check there is a patient attached to this request!
        if not self.pt.serialno:
            self.advise(
                "You need to select a patient before performing this action.",
                1)
            return

        # -a sub proc for a subsequent dialog
        def makeNow():
            dl.makeNow = True

        def oddLength(i):
            # - last item of the appointment length combobox is "other length"
            if i == dl.apptlength_comboBox.count() - 1:
                ol = self.oddApptLength()
                if ol:
                    dl.apptlength_comboBox.currentIndexChanged.disconnect(
                        oddLength)

                    self.addApptLength(dl, ol[0], ol[1])
                    dl.apptlength_comboBox.currentIndexChanged.connect(
                        oddLength)

        # -initiate a custom dialog
        Dialog = QtGui.QDialog(self)
        dl = Ui_specify_appointment.Ui_Dialog()
        dl.setupUi(Dialog)
        # -add an attribute to the dialog
        dl.makeNow = False

        # -add active appointment dentists to the combobox
        dents = localsettings.apptix.keys()
        for dent in dents:
            s = QtCore.QString(dent)
            dl.practix_comboBox.addItem(s)
        # -and select the patient's dentist
        if self.pt.dnt1 in localsettings.apptix_reverse:
            if localsettings.apptix_reverse[self.pt.dnt1] in dents:
                pos = dents.index(localsettings.apptix_reverse[self.pt.dnt1])
                dl.practix_comboBox.setCurrentIndex(pos)
        else:
            dl.practix_comboBox.setCurrentIndex(-1)

        # -add appointment treatment types
        for apptType in localsettings.apptTypes:
            s = QtCore.QString(apptType)
            dl.trt1_comboBox.addItem(s)
            # -only offer exam as treatment1
            if apptType != "EXAM":
                dl.trt2_comboBox.addItem(s)
                dl.trt3_comboBox.addItem(s)
        # -default appt length is 15 minutes
        dl.apptlength_comboBox.setCurrentIndex(2)

        # -connect the dialogs "make now" buttons to the procs just coded
        dl.apptlength_comboBox.currentIndexChanged.connect(oddLength)
        dl.scheduleNow_pushButton.clicked.connect(makeNow)

        inputting = True
        while inputting:
            result = Dialog.exec_()
            if result:
                # -practitioner
                py_inits = str(dl.practix_comboBox.currentText())
                practix = localsettings.apptix.get(py_inits)
                if not practix:
                    self.advise(_("Please specify a clinician"), 1)
                else:
                    # -length
                    lengthText = str(dl.apptlength_comboBox.currentText())
                    if "hour" in lengthText and "hours " not in lengthText:
                        lengthText = lengthText.replace("hour", "hours ")
                    if "hour" in lengthText:
                        hour_index = lengthText.index("hour")
                        length = 60 * int(lengthText[:hour_index])
                        lengthText = lengthText[
                            lengthText.index(" ", hour_index):]
                    else:
                        length = 0
                    if "minute" in lengthText:
                        length += int(lengthText[:lengthText.index("minute")])
                    # -treatments
                    code0 = dl.trt1_comboBox.currentText()
                    code1 = dl.trt2_comboBox.currentText()
                    code2 = dl.trt3_comboBox.currentText()
                    # -memo
                    note = str(dl.lineEdit.text().toAscii())

                    # TODO - add datespec and joint appointment options

                    # -attempt WRITE appointement to DATABASE
                    apr_ix = appointments.add_pt_appt(
                        self.pt.serialno, practix, length,
                        code0, -1, code1, code2, note, "", self.pt.cset)
                    if apr_ix:
                        self.layout_ptDiary()
                        self.select_apr_ix(apr_ix)
                        if dl.makeNow:
                            self.start_scheduling.emit()
                    else:
                        # -commit failed
                        self.advise("Error saving appointment", 2)
                    inputting = False
            else:
                break
Пример #4
0
    def newAppt_pushButton_clicked(self):
        '''
        user has asked for a new appointment
        '''
        # -check there is a patient attached to this request!
        if not self.pt.serialno:
            self.advise(
                "You need to select a patient before performing this action.",
                1)
            return

        # -a sub proc for a subsequent dialog
        def makeNow():
            dl.makeNow = True

        def oddLength(i):
            # - last item of the appointment length combobox is "other length"
            if i == dl.apptlength_comboBox.count() - 1:
                ol = self.oddApptLength()
                if ol:
                    dl.apptlength_comboBox.currentIndexChanged.disconnect(
                        oddLength)

                    self.addApptLength(dl, ol[0], ol[1])
                    dl.apptlength_comboBox.currentIndexChanged.connect(
                        oddLength)

        # -initiate a custom dialog
        Dialog = QtGui.QDialog(self)
        dl = Ui_specify_appointment.Ui_Dialog()
        dl.setupUi(Dialog)
        # -add an attribute to the dialog
        dl.makeNow = False

        # -add active appointment dentists to the combobox
        dents = localsettings.apptix.keys()
        for dent in dents:
            s = QtCore.QString(dent)
            dl.practix_comboBox.addItem(s)
        # -and select the patient's dentist
        if self.pt.dnt1 in localsettings.apptix_reverse:
            if localsettings.apptix_reverse[self.pt.dnt1] in dents:
                pos = dents.index(localsettings.apptix_reverse[self.pt.dnt1])
                dl.practix_comboBox.setCurrentIndex(pos)
        else:
            dl.practix_comboBox.setCurrentIndex(-1)

        # -add appointment treatment types
        for apptType in localsettings.apptTypes:
            s = QtCore.QString(apptType)
            dl.trt1_comboBox.addItem(s)
            # -only offer exam as treatment1
            if apptType != "EXAM":
                dl.trt2_comboBox.addItem(s)
                dl.trt3_comboBox.addItem(s)
        # -default appt length is 15 minutes
        dl.apptlength_comboBox.setCurrentIndex(2)

        # -connect the dialogs "make now" buttons to the procs just coded
        dl.apptlength_comboBox.currentIndexChanged.connect(oddLength)
        dl.scheduleNow_pushButton.clicked.connect(makeNow)

        inputting = True
        while inputting:
            result = Dialog.exec_()
            if result:
                # -practitioner
                py_inits = str(dl.practix_comboBox.currentText())
                practix = localsettings.apptix.get(py_inits)
                if not practix:
                    self.advise(_("Please specify a clinician"), 1)
                else:
                    # -length
                    lengthText = str(dl.apptlength_comboBox.currentText())
                    if "hour" in lengthText and "hours " not in lengthText:
                        lengthText = lengthText.replace("hour", "hours ")
                    if "hour" in lengthText:
                        hour_index = lengthText.index("hour")
                        length = 60 * int(lengthText[:hour_index])
                        lengthText = lengthText[
                            lengthText.index(" ", hour_index):]
                    else:
                        length = 0
                    if "minute" in lengthText:
                        length += int(lengthText[:lengthText.index("minute")])
                    # -treatments
                    code0 = dl.trt1_comboBox.currentText()
                    code1 = dl.trt2_comboBox.currentText()
                    code2 = dl.trt3_comboBox.currentText()
                    # -memo
                    note = str(dl.lineEdit.text().toAscii())

                    # TODO - add datespec and joint appointment options

                    # -attempt WRITE appointement to DATABASE
                    apr_ix = appointments.add_pt_appt(
                        self.pt.serialno, practix, length,
                        code0, -1, code1, code2, note, "", self.pt.cset)
                    if apr_ix:
                        self.layout_ptDiary()
                        self.select_apr_ix(apr_ix)
                        if dl.makeNow:
                            self.start_scheduling.emit()
                    else:
                        # -commit failed
                        self.advise("Error saving appointment", 2)
                    inputting = False
            else:
                break