def header_html(pt): if pt.underTreatment: html_ = u"<h3>Patient is under Treatment</h3>course started %s" % ( localsettings.readableDate(pt.treatment_course.accd)) else: html_ = u"<h3>Last course of treatment</h3>completed %s" % ( localsettings.readableDate(pt.treatment_course.cmpd)) return html_
def setDate(self, date): ''' update the class with data for date ''' self.date = date workingDents = [] self.inOffice = {} self.memos = {} self.startTimes = {} self.endTimes = {} self.earliest_start = 2359 self.latest_end = 0 self.memo = "%s %s" % (localsettings.readableDate(date), self.header()) for dent in getWorkingDents(self.date): self.memos[dent.ix] = dent.memo self.startTimes[dent.ix] = dent.start self.endTimes[dent.ix] = dent.end self.inOffice[dent.ix] = dent.flag if dent.flag != 0: workingDents.append(dent.ix) if dent.start < self.earliest_start: self.earliest_start = dent.start if dent.end > self.latest_end: self.latest_end = dent.end self.workingDents = tuple(workingDents)
def clearApptButton_clicked(self): ''' user is deleting an appointment ''' def delete_appt(): if appointments.delete_appt_from_apr(appt): self.advise(_("Sucessfully removed appointment")) else: self.advise(_("Error removing proposed appointment"), 2) appt = self.diary_model.selectedAppt if appt is None: self.advise(_("No appointment selected")) return if appt.date is None: if QtGui.QMessageBox.question( self, _("Confirm"), _("Delete Unscheduled Appointment?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: delete_appt() elif appt.past: delete_appt() else: message = _("Confirm Delete appointment at") message += " %s %s " % (appt.atime, localsettings.readableDate(appt.date)) message += _("with") + " %s?" % appt.dent_inits if QtGui.QMessageBox.question( self, _("Confirm"), message, QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: if appointments.delete_appt_from_aslot(appt): # todo - if we deleted from the appt book, # we should add to notes print "future appointment deleted - add to notes!!" appointments.made_appt_to_proposed(appt) self.layout_ptDiary() #--keep in the patient's diary? if QtGui.QMessageBox.question( self, _("Question"), _("Removed from appointment book - keep for rescheduling?" ), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: # remove from the patients diary if appointments.delete_appt_from_apr(appt): self.advise(_("Sucessfully removed appointment")) else: self.advise(_("Error removing from patient diary"), 2) self.layout_ptDiary()
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
def clearApptButton_clicked(self): ''' user is deleting an appointment ''' def delete_appt(): if appointments.delete_appt_from_apr(appt): self.advise(_("Sucessfully removed appointment")) else: self.advise(_("Error removing proposed appointment"), 2) appt = self.diary_model.selectedAppt if appt is None: self.advise(_("No appointment selected")) return if appt.date is None: if QtGui.QMessageBox.question(self, _("Confirm"), _("Delete Unscheduled Appointment?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: delete_appt() elif appt.past: delete_appt() else: message = _("Confirm Delete appointment at") message += " %s %s " % (appt.atime, localsettings.readableDate(appt.date)) message += _("with") + " %s?" % appt.dent_inits if QtGui.QMessageBox.question(self, _("Confirm"), message, QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: if appointments.delete_appt_from_aslot(appt): # todo - if we deleted from the appt book, # we should add to notes print "future appointment deleted - add to notes!!" appointments.made_appt_to_proposed(appt) self.layout_ptDiary() #--keep in the patient's diary? if QtGui.QMessageBox.question(self, _("Question"), _( "Removed from appointment book - keep for rescheduling?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: # remove from the patients diary if appointments.delete_appt_from_apr(appt): self.advise(_("Sucessfully removed appointment")) else: self.advise(_("Error removing from patient diary"), 2) self.layout_ptDiary()
def update_highlighted_appointment(self): ''' the diary widget selected appointment has changed. ''' app = self.diary_widget.highlighted_appointment LOGGER.debug("appointment highlighted %s", app) if app is None: self.reset_browsing_webview() return if self.mode == self.NOTES_MODE: self.notes_label.setText( "<h3>%s</h3>%s<br />%s" % ( _("View/edit today's notes for "), app.name, app.serialno ) ) return self.notes_label.setText("") if self.mode != self.BROWSE_MODE: return feedback = FEEDBACK % ( app.name, app.serialno, localsettings.readableDate( self.diary_widget.selected_date().toPyDate()), "%02d:%02d" % (app.start // 100, app.start % 100), "%02d:%02d" % (app.end // 100, app.end % 100), '</li><li class="trt">'.join( [val for val in (app.trt1, app.trt2, app.trt3) if val != ""]) ) if app.memo != "": feedback += "<hr />%s<br /><i>%s</i>" % (_("Memo"), app.memo) try: datestamp = app.timestamp.date() feedback += \ "<hr />%s<br />%s (%s %s)" % ( _("Made"), localsettings.formatDate(datestamp), _("at"), localsettings.pyTimeToHumantime( app.timestamp)) except AttributeError: pass if app.mh_form_check_date or app.mh_form_required: feedback += "<hr />" if app.mh_form_check_date: feedback += "%s %s<br />" % ( _("last mh form"), localsettings.formatDate( app.mh_form_check_date) ) if app.mh_form_required: feedback += "%s" % _("MH CHECK REQUIRED") feedback = "%s<body></html>" % feedback self.browsing_webview.setHtml(feedback)
def updateLabels(self): day = localsettings.readableDate(self.date.toPyDate()).replace( ",", "<br />") if self.memo != "": str = "<center><b>%s</b><br />%s</center>" % (day, self.memo) else: str = "<center><b>%s</b></center>" % day self.setText(str)
def updateLabels(self): day = localsettings.readableDate(self.date.toPyDate()).replace( ",", "<br />") if self.memo != "": str = "<center><b>%s</b><br />%s</center>" % (day, self.memo) else: str = "<center><b>%s</b></center>" % day self.setText(str) self.setToolTip('''<center>Left click to go to<br />%s<br /> <br />Right click for admin options</center>''' % day)
def update_highlighted_appointment(self): ''' the diary widget selected appointment has changed. ''' app = self.diary_widget.highlighted_appointment LOGGER.debug("appointment highlighted %s", app) if app is None: self.reset_browsing_webview() return if self.mode == self.NOTES_MODE: self.notes_label.setText( "<h3>%s</h3>%s<br />%s" % (_("View/edit today's notes for "), app.name, app.serialno)) return self.notes_label.setText("") if self.mode != self.BROWSE_MODE: return feedback = FEEDBACK % ( app.name, app.serialno, localsettings.readableDate( self.diary_widget.selected_date().toPyDate()), "%02d:%02d" % (app.start // 100, app.start % 100), "%02d:%02d" % (app.end // 100, app.end % 100), '</li><li class="trt">'.join( [val for val in (app.trt1, app.trt2, app.trt3) if val != ""])) if app.memo != "": feedback += "<hr />%s<br /><i>%s</i>" % (_("Memo"), app.memo) try: datestamp = app.timestamp.date() feedback += \ "<hr />%s<br />%s (%s %s)" % ( _("Made"), localsettings.formatDate(datestamp), _("at"), localsettings.pyTimeToHumantime( app.timestamp)) except AttributeError: pass if app.mh_form_check_date or app.mh_form_required: feedback += "<hr />" if app.mh_form_check_date: feedback += "%s %s<br />" % (_("last mh form"), localsettings.formatDate( app.mh_form_check_date)) if app.mh_form_required: feedback += "%s" % _("MH CHECK REQUIRED") feedback = "%s<body></html>" % feedback self.browsing_webview.setHtml(feedback)
def __init__(self, category, appointment, parent=None, index=0): self.appointment = appointment self.isAppointment = True try: if appointment.date: self.headerCol = "%s\t%s" % ( localsettings.wystimeToHumanTime(appointment.atime), localsettings.readableDate(appointment.date)) else: self.headerCol = "TBA" # used to be "TBA" except AttributeError: self.headerCol = category self.isAppointment = False self.parentItem = parent self.myindex = index self.childItems = []
def __init__(self, category, appointment, parent=None, index=0): self.appointment = appointment self.isAppointment = True try: if appointment.date: self.headerCol = ( localsettings.wystimeToHumanTime(appointment.atime) + "\t" + localsettings.readableDate(appointment.date)) else: self.headerCol = "TBA" # used to be "TBA" except AttributeError: self.headerCol = category self.isAppointment = False self.parentItem = parent self.myindex = index self.childItems = []
def show_all_prev_receipts(self): dl = BaseDialog(self) scroll_area = QtGui.QScrollArea() frame = QtGui.QFrame() layout = QtGui.QVBoxLayout(frame) for ix in sorted(self.prev_receipts.keys())[3:]: printdate = self.prev_receipts[ix] but = QtGui.QPushButton(localsettings.readableDate(printdate)) but.ix = ix but.clicked.connect(self.print_existing) layout.addWidget(but) scroll_area.setWidgetResizable(True) scroll_area.setWidget(frame) dl.insertWidget(scroll_area) dl.exec_()
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
def __init__(self, appt, parent=None): ExtendableDialog.__init__(self, parent) # self.set_advanced_but_text(_("What's changed?")) self.button_box.removeButton(self.more_but) self.apply_but.setText(_("&Yes")) self.apply_but.setToolTip(_("Cancel the appointment")) self.enableApply() self.postpone_but = self.button_box.addButton( QtWidgets.QDialogButtonBox.Discard) self.postpone_but.setText(_("Yes, but &Keep for re-scheduling")) # self.postpone_but.setToolTip(_("Discard All Changes")) pt = BriefPatient(appt.serialno) if appt.date is None: message = "%s<hr />%s<br />%s" % ( _("Delete unscheduled appointment?"), pt.name_id, " ".join((appt.trt1, appt.trt2, appt.trt3)) ) self.postpone_but.hide() else: message = "%s<hr />%s - %s <b>%s</b><br />%s<hr />%s %s %s" % ( _("Delete this appointment?"), pt.name_id, _("with"), appt.dent_inits, " ".join((appt.trt1, appt.trt2, appt.trt3)), localsettings.readableDate(appt.date), _("at"), "%d:%02d" % (appt.atime // 100, appt.atime % 100) ) label = WarningLabel(message) self.insertWidget(label) self.cancel_but.setText(_("&No")) self.cancel_but.setToolTip(_("Close this dialog, making no changes")) self.appt = appt LOGGER.debug("appt type = %s", type(appt))
def add_buttons(self): self.prev_receipts_groupbox.setVisible(self.prev_receipts != {}) self.no_receipts_found_label.setVisible(self.prev_receipts == {}) for ix in sorted(self.prev_receipts.keys())[:3]: printdate = self.prev_receipts[ix] but = QtGui.QPushButton(localsettings.readableDate(printdate)) but.ix = ix but.clicked.connect(self.print_existing) self.prev_buts_layout.addWidget(but) no_receipts = len(self.prev_receipts) if no_receipts > 3: widget = QtGui.QWidget(self) label = QtGui.QLabel("%d more receipts" % (no_receipts - 3)) but = QtGui.QPushButton(_("show")) but.clicked.connect(self.show_all_prev_receipts) layout = QtGui.QHBoxLayout(widget) layout.addWidget(label) layout.addWidget(but) self.prev_buts_layout.addWidget(widget)
def mouseMoveEvent(self, event): y = event.y() yOffset = self.height() / self.slotNo row = int(y // yOffset) if not (self.firstSlot - 1) < row < self.lastSlot: self.selected_rows = (0, 0) self.update() QtGui.QToolTip.showText(event.globalPos(), "") return if self.mouse_over_freeslot(event.pos()): startcell, endcell = self.mouse_freeslot feedback = ''' <html><div align="center"> <b>SLOT with %s</b><br /> <b>%s</b><br /> (%d mins) </div></html> ''' % ( self.pWidget.dentist, self.getTime_from_Cell(startcell).strftime("%H:%M"), (endcell - startcell) * self.slotDuration, ) x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, feedback) elif row in self.rows: sno_list = self.rows[row] self.selected_rows = self.getApptBounds(row, sno_list) self.update() feedback = "<html>" for sno in sno_list: for app in self.appts + self.doubleAppts: if app.serialno == sno: feedback += '''%s %s (%s)<br /><b>%s - %s</b>''' % ( app.name, " " * 4, app.serialno, app.start, app.end) for val in (app.trt1, app.trt2, app.trt3): if val != "": feedback += ''' <br /><font color="red">%s</font>''' % val if app.memo != "": feedback += "<br /><i>%s</i>" % app.memo try: datestamp = app.timestamp.date() moddate = localsettings.readableDate(datestamp) if datestamp == localsettings.currentDay(): feedback += \ "<br /><i>%s %s %s %s</i><hr />" % ( _("Made"), moddate, _("at"), localsettings.pyTimeToHumantime( app.timestamp)) else: feedback += "<br /><i>%s<br />%s</i><hr />" % ( _("Made on"), moddate) except AttributeError: feedback += "<hr />" if app.mh_form_required: feedback += "%s<hr />" % _("MH CHECK REQUIRED") if feedback != "<html>": feedback = feedback[:feedback.rindex("<hr />")] + "</html>" x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, feedback) else: QtGui.QToolTip.showText(event.globalPos(), "") else: newSelection = (self.getPrev(row), self.getNext(row)) if self.selected_rows != newSelection: self.selected_rows = newSelection self.update() start = int( self.dayStartTime + self.selected_rows[ 0] * self.slotDuration) finish = int( self.dayStartTime + self.selected_rows[ 1] * self.slotDuration) x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, "SLOT %s minutes" % (finish - start))
def showEvent(self, event=None): self.clear() for date_ in self.pt.mh_form_dates(): but = QtGui.QPushButton(_("Delete")) but.clicked.connect(partial(self.delete_date, date_)) self.frame_layout.addRow(localsettings.readableDate(date_), but)
def mouseMoveEvent(self, event): y = event.y() yOffset = self.height() / self.slotNo row = int(y // yOffset) if not (self.firstSlot - 1) < row < self.lastSlot: self.selected_rows = (0, 0) self.update() QtGui.QToolTip.showText(event.globalPos(), "") return if self.mouse_over_freeslot(event.pos()): startcell, endcell = self.mouse_freeslot feedback = ''' <html><div align="center"> <b>SLOT with %s</b><br /> <b>%s</b><br /> (%d mins) </div></html> ''' % ( self.pWidget.dentist, self.getTime_from_Cell(startcell).strftime("%H:%M"), (endcell - startcell) * self.slotDuration, ) x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, feedback) elif row in self.rows: selectedPatients = self.rows[row] self.selected_rows = self.getApptBounds(row, selectedPatients) self.update() feedback = "<html>" for patient in selectedPatients: for appt in self.appts + self.doubleAppts: if appt[5] == patient: feedback += '''%s<br /><b>%s - %s</b>''' % ( appt[4], appt[2], appt[3]) for val in (appt[6], appt[7], appt[8]): if val != "": feedback += ''' <br /><font color="red">%s</font>''' % val if appt[9] != "": feedback += "<br /><i>%s</i>" % appt[9] try: timestamp = appt[12] datestamp = timestamp.date() moddate = localsettings.readableDate(datestamp) if datestamp == localsettings.currentDay(): feedback += "<br /><i>%s %s %s %s</i><hr />" % ( _("Made"), moddate, _("at"), localsettings.pyTimeToHumantime(timestamp)) else: feedback += "<br /><i>%s<br />%s</i><hr />" % ( _("Made on"), moddate) except AttributeError: feedback += "<hr />" pass if feedback != "<html>": feedback = feedback[:feedback.rindex("<hr />")] + "</html>" x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, feedback) else: QtGui.QToolTip.showText(event.globalPos(), "") else: newSelection = (self.getPrev(row), self.getNext(row)) if self.selected_rows != newSelection: self.selected_rows = newSelection self.update() start = int(self.dayStartTime + self.selected_rows[0] * self.slotDuration) finish = int(self.dayStartTime + self.selected_rows[1] * self.slotDuration) x_pos = self.mapToGlobal(self.pos()).x() pos = QtCore.QPoint(x_pos, event.globalPos().y()) QtGui.QToolTip.showText(pos, "SLOT %s minutes" % (finish - start))