示例#1
0
 def length(self):
     '''
     return the length of the working day (in minutes)
     '''
     time1 = localsettings.minutesPastMidnight(self.start)
     time2 = localsettings.minutesPastMidnight(self.end)
     return time2 - time1
示例#2
0
 def length(self):
     '''
     returns the appointment length (in minutes)
     '''
     time1 = localsettings.minutesPastMidnight(self.start)
     time2 = localsettings.minutesPastMidnight(self.end)
     return time2 - time1
示例#3
0
 def length(self):
     '''
     return the length of the working day (in minutes)
     '''
     time1 = localsettings.minutesPastMidnight(self.start)
     time2 = localsettings.minutesPastMidnight(self.end)
     return time2 - time1
示例#4
0
 def length(self):
     '''
     returns the appointment length (in minutes)
     '''
     time1 = localsettings.minutesPastMidnight(self.start)
     time2 = localsettings.minutesPastMidnight(self.end)
     return time2 - time1
示例#5
0
    def add_appointment(self, adate, appt):

        dent = appt[0]
        date_time = datetime.datetime.combine(
            adate, localsettings.wystimeToPyTime(appt[1]))

        length = (localsettings.minutesPastMidnight(appt[2]) -
                  localsettings.minutesPastMidnight(appt[1]))
        ag_appt = AgendaAppointment(date_time, dent, length)
        ag_appt.text = "%s %s %s %s %s %s" % appt[3:9]
        self._items.append(ag_appt)
示例#6
0
    def add_appointment(self, adate, appt):

        dent = appt[0]
        date_time = datetime.datetime.combine(adate,
            localsettings.wystimeToPyTime(appt[1]))

        length = (localsettings.minutesPastMidnight(appt[2]) -
            localsettings.minutesPastMidnight(appt[1]))
        ag_appt = AgendaAppointment(date_time, dent, length)
        ag_appt.text = "%s %s %s %s %s %s" % appt[3:9]
        self._items.append(ag_appt)
    def __init__(self, sTime, fTime, slotLength, textDetail, om_gui):
        '''
        useage is (day, startTime,finishTime,slotLength, textDetail, parent)
        startTime,finishTime in format HHMM or HMM or HH:MM or H:MM
        slotLength is the minimum slot length - typically 5 minutes
        textDetail is the number of slots to draw before writing the time text
        parentWidget =optional
        textDetail determines how many slots before a time is printed,
        I like 15minutes
        '''

        super(AppointmentOverviewWidget, self).__init__(om_gui)
        self.om_gui = om_gui
        self.setMinimumSize(self.minimumSizeHint())

        self.setSizePolicy(QtGui.QSizePolicy(
            QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))

        self.font = QtGui.QFont()
        self.font.setPointSize(10)
        fm = QtGui.QFontMetrics(self.font)
        self.timeOffset = fm.width(" 88:88 ")
        self.headingHeight = fm.height()
        # convert times to "minutes past midnight"
        self.startTime = localsettings.minutesPastMidnight(sTime)
        self.endTime = localsettings.minutesPastMidnight(fTime)
        self.slotLength = slotLength
        self.slotCount = (self.endTime - self.startTime) // slotLength
        self.slotHeight = ((self.height() - self.headingHeight) /
                           self.slotCount)
        self.textDetail = textDetail

        self.date = None
        self.dents = []
        self.daystart = {}
        self.dayend = {}
        self.memoDict = {}
        self.flagDict = {}
        self.highlightedRect = None
        self.setMouseTracking(True)
        self.clear()
        self.init_dicts()
        self.setAcceptDrops(True)
        self.drag_appt = None
        self.dropPos = None
        self.enabled_clinicians = ()
        self._mouse_drag_rects = None
        self.mouse_drag_rect = None

        self.blink_on = True  # for flashing effect
        self.blink_timer = QtCore.QTimer()
        self.blink_timer.timeout.connect(self.toggle_blink)
        self.blink_timer.start(1000)
示例#8
0
    def __init__(self, sTime, fTime, slotLength, textDetail, diary_widget):
        '''
        useage is (day, startTime,finishTime,slotLength, textDetail, parent)
        startTime,finishTime in format HHMM or HMM or HH:MM or H:MM
        slotLength is the minimum slot length - typically 5 minutes
        textDetail is the number of slots to draw before writing the time text
        parentWidget =optional
        textDetail determines how many slots before a time is printed,
        I like 15minutes
        '''

        super(AppointmentOverviewWidget, self).__init__(diary_widget)
        self.diary_widget = diary_widget
        self.setMinimumSize(self.minimumSizeHint())

        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        self.font = QtGui.QFont()
        self.font.setPointSize(10)
        fm = QtGui.QFontMetrics(self.font)
        self.timeOffset = fm.width(" 88:88 ")
        self.headingHeight = fm.height()
        # convert times to "minutes past midnight"
        self.startTime = localsettings.minutesPastMidnight(sTime)
        self.endTime = localsettings.minutesPastMidnight(fTime)
        self.slotLength = slotLength
        self.slotCount = (self.endTime - self.startTime) // slotLength
        self.slotHeight = ((self.height() - self.headingHeight) /
                           self.slotCount)
        self.textDetail = textDetail

        self.date = None
        self.dents = []
        self.daystart = {}
        self.dayend = {}
        self.memoDict = {}
        self.flagDict = {}
        self.selected_rect = None
        self.setMouseTracking(True)
        self.clear()
        self.init_dicts()
        self.setAcceptDrops(True)
        self.drag_appt = None
        self.dropPos = None
        self.enabled_clinicians = ()
        self._mouse_drag_rects = None
        self.mouse_drag_rect = None

        self.blink_on = True  # for flashing effect
        self.blink_timer = BlinkTimer()
        self.blink_timer.timeout.connect(self.toggle_blink)
示例#9
0
def slots(adate, apptix, start, apdata, fin):
    '''
    takes data like  830 ((830, 845), (900, 915), (1115, 1130), (1300, 1400),
    (1400, 1420), (1600, 1630)) 1800
    and returns a tuple of results like (FreeSlot, FreeSlot, ....)
    '''
    #--slotlength is required appt  length, in minutes

    #-- modified this on 18_11_2009, for the situation when a clinician's day
    #-- start may be later than any first appointment in that book
    #-- this facilitates having lunch etc.. already in place for a non used
    #-- day.
    aptstart = localsettings.minutesPastMidnight(start)
    dayfin = localsettings.minutesPastMidnight(fin)
    if dayfin <= aptstart:
        return ()
    results = []
    for ap in apdata:
        sMin = localsettings.minutesPastMidnight(ap[0])
        fMin = localsettings.minutesPastMidnight(ap[1])
        slength = sMin - aptstart
        if slength > 0:
            date_time = datetime.datetime.combine(
                adate, localsettings.minutesPastMidnightToPyTime(aptstart))

            slot = FreeSlot(date_time, apptix, slength)
            results.append(slot)

        if fMin > aptstart:
            aptstart = fMin
        if aptstart >= dayfin:
            break

    slength = dayfin - aptstart
    if slength > 0:
        date_time = datetime.datetime.combine(
            adate, localsettings.minutesPastMidnightToPyTime(aptstart))

        slot = FreeSlot(date_time, apptix, slength)
        results.append(slot)

    return results
示例#10
0
def slots(adate, apptix, start, apdata, fin):
    '''
    takes data like  830 ((830, 845), (900, 915), (1115, 1130), (1300, 1400),
    (1400, 1420), (1600, 1630)) 1800
    and returns a tuple of results like (FreeSlot, FreeSlot, ....)
    '''
    #--slotlength is required appt  length, in minutes

    #-- modified this on 18_11_2009, for the situation when a clinician's day
    #-- start may be later than any first appointment in that book
    #-- this facilitates having lunch etc.. already in place for a non used
    #-- day.
    aptstart = localsettings.minutesPastMidnight(start)
    dayfin = localsettings.minutesPastMidnight(fin)
    if dayfin <= aptstart:
        return ()
    results = []
    for ap in apdata:
        sMin = localsettings.minutesPastMidnight(ap[0])
        fMin = localsettings.minutesPastMidnight(ap[1])
        slength = sMin - aptstart
        if slength > 0:
            date_time = datetime.datetime.combine(adate,
            localsettings.minutesPastMidnightToPyTime(aptstart))

            slot = FreeSlot(date_time, apptix, slength)
            results.append(slot)

        if fMin > aptstart:
            aptstart = fMin
        if aptstart >= dayfin:
            break

    slength = dayfin - aptstart
    if slength > 0:
        date_time = datetime.datetime.combine(adate,
        localsettings.minutesPastMidnightToPyTime(aptstart))

        slot = FreeSlot(date_time, apptix, slength)
        results.append(slot)

    return results
    def apply(self):
        """
        user has entered a good sequence, so write it to the DB now
        """
        sdate = self.start_dateedit.date()
        fdate = self.end_dateedit.date()
        n_days = sdate.daysTo(fdate)

        start = localsettings.humanTimetoWystime(self.time_edit.time().toString("h:mm"))
        end = localsettings.minutesPastMidnighttoWystime(
            localsettings.minutesPastMidnight(start) + self.duration_spinbox.value()
        )

        # print sdate, fdate, n_days, start, end

        p_dl = QtGui.QProgressDialog(self)
        p_dl.show()
        days = list(self.chosen_days)
        n_attempts, n_inserted = 0, 0
        for clinician in self.chosen_clinicians:
            p_dl.setLabelText("%s %s" % (_("applying changes for"), clinician))
            dt = sdate
            while dt <= fdate:
                progress = int(100 * (n_days - dt.daysTo(fdate)) / n_days)
                p_dl.setValue(progress)
                if dt.dayOfWeek() in days:
                    n_attempts += 1
                    n_inserted += appointments.make_appt(
                        dt.toPyDate(),
                        localsettings.apptix[clinician],
                        start,
                        end,
                        self.block_text,
                        0,
                        "",
                        "",
                        "",
                        "",
                        -128,
                        0,
                        0,
                        0,
                    )
                dt = dt.addDays(1)

        message = "%d/%d %s" % (n_inserted, n_attempts, _("Appointment(s) inserted"))

        if n_inserted != n_attempts:
            message += "<hr />%s" % _(
                "Some were rejected by the database as they clashed" " with existing appointments or blocks"
            )
        QtGui.QMessageBox.information(self, _("Information"), message)
示例#12
0
def convertResults(results):
    '''
    changes
    (830, 845) OR
    (830, 845, serialno, "exam") or
    (1300,1400, "LUNCH")
    to and WeekViewAppointment object
    '''
    aptlist = []
    for start, end, serialno, name, cset, trt in results:
        aow = WeekViewAppointment()
        aow.mpm = localsettings.minutesPastMidnight(start)
        aow.length = localsettings.minutesPastMidnight(end) - aow.mpm
        aow.serialno = serialno
        aow.cset = cset
        aow.name = name
        aow.isBlock = (cset == "block")
        aow.isEmergency = (aow.isBlock and
            aow.name.lower() == _("emergency").lower())
        aow.trt = trt.strip(" ")
        aptlist.append(aow)

    return tuple(aptlist)
示例#13
0
def convertResults(results):
    '''
    changes
    (830, 845) OR
    (830, 845, serialno, "exam") or
    (1300,1400, "LUNCH")
    to and WeekViewAppointment object
    '''
    aptlist = []
    for start, end, serialno, name, cset, trt in results:
        aow = WeekViewAppointment()
        aow.mpm = localsettings.minutesPastMidnight(start)
        aow.length = localsettings.minutesPastMidnight(end) - aow.mpm
        aow.serialno = serialno
        aow.cset = cset
        aow.name = name
        aow.isBlock = (cset == "block")
        aow.isEmergency = (aow.isBlock
                           and aow.name.lower() == _("emergency").lower())
        aow.trt = trt.strip(" ")
        aptlist.append(aow)

    return tuple(aptlist)
    def apply(self):
        '''
        user has entered a good sequence, so write it to the DB now
        '''
        sdate = self.start_dateedit.date()
        fdate = self.end_dateedit.date()
        n_days = sdate.daysTo(fdate)

        start = localsettings.humanTimetoWystime(
            self.time_edit.time().toString("h:mm"))
        end = localsettings.minutesPastMidnighttoWystime(
            localsettings.minutesPastMidnight(start) +
            self.duration_spinbox.value())

        p_dl = QtGui.QProgressDialog(self)
        p_dl.show()
        days = list(self.chosen_days)
        n_attempts, n_inserted = 0, 0
        for clinician in self.chosen_clinicians:
            p_dl.raise_()
            p_dl.setLabelText("%s %s" % (_("applying changes for"), clinician))
            dt = sdate
            while dt <= fdate:
                progress = int(100 * (n_days - dt.daysTo(fdate)) / n_days)
                p_dl.setValue(progress)
                if dt.dayOfWeek() in days:
                    n_attempts += 1
                    n_inserted += appointments.make_appt(
                        dt.toPyDate(),
                        localsettings.apptix[clinician],
                        start, end, self.block_text,
                        0, "", "", "", "", -128, 0, 0, 0)
                dt = dt.addDays(1)
                QtGui.QApplication.instance().processEvents()

        message = "%d/%d %s" % (n_inserted,
                                n_attempts,
                                _("Appointment(s) inserted"))

        if n_inserted != n_attempts:
            message += \
                "<hr /><b>%s</b>" % _(
                    "Some were rejected by the database as they clashed"
                    " with existing appointments or blocks")
        QtGui.QMessageBox.information(self, _("Information"), message)
示例#15
0
    def writeToDB(self, arg):
        '''
        user has entered a good sequence, so write it to the DB now
        '''
        if self.buttonBox.buttonRole(arg) == (
                QtGui.QDialogButtonBox.RejectRole):
            self.dialog.reject()
            return
        sdate = self.start_dateEdit.date()
        fdate = self.end_dateEdit.date()

        total = sdate.daysTo(fdate)

        start = localsettings.humanTimetoWystime(
            self.start_timeEdit.time().toString("h:mm"))
        end = localsettings.minutesPastMidnighttoWystime(
            localsettings.minutesPastMidnight(start) + self.spinBox.value())

        self.progressBar.show()
        for clinician in self.clinicianDict.keys():
            if self.clinicianDict[clinician].isChecked():
                self.progress_label.setText("%s %s" % (
                                            _("applying changes for"), clinician))

                dt = sdate

                while dt <= fdate:
                    progress = int(100 * (total - dt.daysTo(fdate)) / total)
                    if self.progressBar.value() != progress:
                        self.progressBar.setValue(progress)
                    if self.dayDict[dt.dayOfWeek() - 1].isChecked():
                        appointments.make_appt(dt.toPyDate(),
                                               localsettings.apptix[clinician],
                                               start, end, self.lineEdit.text(
                                               ).toAscii(),
                                               0, "", "", "", "", -128, 0, 0, 0)

                    dt = dt.addDays(1)

        self.dialog.accept()
 def setStartTime(self, dent):
     self.daystart[dent.ix] = localsettings.minutesPastMidnight(dent.start)
示例#17
0
 def end_mpm(self):
     return localsettings.minutesPastMidnight(self.end)
示例#18
0
 def start_mpm(self):
     return localsettings.minutesPastMidnight(self.start)
示例#19
0
 def start_mpm(self):
     return localsettings.minutesPastMidnight(self.start)
示例#20
0
 def end_mpm(self):
     return localsettings.minutesPastMidnight(self.end)
 def setEndTime(self, dent):
     self.dayend[dent.ix] = localsettings.minutesPastMidnight(dent.end)
示例#22
0
 def setEndTime(self, dent):
     self.dayend[dent.ix] = localsettings.minutesPastMidnight(dent.end)
示例#23
0
 def setStartTime(self, dent):
     self.daystart[dent.ix] = localsettings.minutesPastMidnight(dent.start)