Beispiel #1
0
    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)
Beispiel #2
0
 def date_text(self):
     """
     the date to be printed on the form.
     """
     if not self.date_:
         return localsettings.formatDate(localsettings.currentDay())
     else:
         return localsettings.formatDate(self.date_)
Beispiel #3
0
 def date_text(self):
     '''
     the date to be printed on the form.
     '''
     if not self.date_:
         return localsettings.formatDate(localsettings.currentDay())
     else:
         return localsettings.formatDate(self.date_)
Beispiel #4
0
def html_history(serialno):
    db = connect()
    cursor = db.cursor()
    cursor.execute(QUERY_ALL, (serialno, ))
    rows = cursor.fetchall()
    cursor.close()

    if not rows:
        return u'''
        <html>
            <body>
                <h1>%s</h1>
            </body>
        </html>''' % _("No memo history found")

    html = u'''<html>
        <body>
            <h1>%s</h1>
            <table width = '100%%' border="1">
    ''' % _("Memo History")

    html += u'''<tr>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
            </tr>''' % (_("Author"), _("Location"), _("Date"), _("Expires"),
                        _("Deleted?"), _("Message"))

    for row in rows:
        ix = row[0]
        serialno = row[1]
        author = row[2]
        type = row[3]
        mdate = row[4]
        message = row[5]
        open_ = row[6]
        expiry_date = row[7]
        html += u'''<tr>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            </tr>''' % (author, type, localsettings.formatDate(mdate),
                        localsettings.formatDate(expiry_date),
                        _("Yes") if not open_ else _("No"), message)

    return html + "</table></body></html>"
Beispiel #5
0
    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)
Beispiel #6
0
def summary(pt):
    '''
    returns html set showing a summary of planned or completed treatment
    '''

    if pt.treatment_course is None or pt.treatment_course.accd is None:
        return ""

    retarg = '''<html><head>
    <link rel="stylesheet" href="%s" type="text/css">
    </head>\n<body>''' % localsettings.stylesheet

    if not pt.underTreatment:
        retarg += "<H4>%s</H4>" % _("Previous Course")
    if pt.treatment_course.accd is not None:
        retarg += '%s %s<br />' % (
            _("Start"),
            localsettings.formatDate(pt.treatment_course.accd))
        if pt.treatment_course.cmpd is not None:
            retarg += '%s %s<br />' % (
                _('End'),
                localsettings.formatDate(pt.treatment_course.cmpd))
        else:
            retarg += '<b>%s</b><br />' % _("ONGOING")

    if pt.treatment_course.ftr:
        retarg += '<font color="red">%s</font><br />' % _(
            "Patient Failed to Return")

    plan = ""
    for item in plannedItems(pt):
        plan += '%s - %s<br />' % (item)
    if plan != "":
        plan = "<h5>%s</h5>%s" % (_("PLAN"), plan)

    comp = ""
    for item in completedItems(pt):
        comp += '%s - %s<br />' % (item)
    if comp != "":
        comp = "<h5>%s</h5>%s" % (_("COMPLETED"), comp)
        if plan != "":
            plan = "<hr />" + plan

    if plan == "" and comp == "":
        return "%s%s</body></html>" % (retarg, _("No treatment"))
    else:
        return '%s%s%s</body></html>' % (retarg, plan, comp)

    return retarg
Beispiel #7
0
def summary(pt):
    '''
    returns html set showing a summary of planned or completed treatment
    '''

    if pt.treatment_course is None or pt.treatment_course.accd is None:
        return ""

    retarg = '''<html><head>
    <link rel="stylesheet" href="%s" type="text/css">
    </head>\n<body>''' % localsettings.stylesheet

    if not pt.underTreatment:
        retarg += "<H4>%s</H4>" % _("Previous Course")
    if pt.treatment_course.accd is not None:
        retarg += '%s %s<br />' % (
            _("Start"),
            localsettings.formatDate(pt.treatment_course.accd))
        if pt.treatment_course.cmpd is not None:
            retarg += '%s %s<br />' % (
                _('End'),
                localsettings.formatDate(pt.treatment_course.cmpd))
        else:
            retarg += '<b>%s</b><br />' % _("ONGOING")

    if pt.treatment_course.ftr:
        retarg += '<font color="red">%s</font><br />' % _(
            "Patient Failed to Return")

    plan = ""
    for item in plannedItems(pt):
        plan += '%s - %s<br />' % (item)
    if plan != "":
        plan = "<h5>%s</h5>%s" % (_("PLAN"), plan)

    comp = ""
    for item in completedItems(pt):
        comp += '%s - %s<br />' % (item)
    if comp != "":
        comp = "<h5>%s</h5>%s" % (_("COMPLETED"), comp)
        if plan != "":
            plan = "<hr />" + plan

    if plan == "" and comp == "":
        return "%s%s</body></html>" % (retarg, _("No treatment"))
    else:
        return '%s%s%s</body></html>' % (retarg, plan, comp)

    return retarg
Beispiel #8
0
 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]))
                 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
Beispiel #9
0
def getHtml(description, pt):
    """
    get the HTML for a letter to
    referral_centre identified by description about this pt
    """
    db = connect()
    cursor = db.cursor()
    cursor.execute(ADDRESS_QUERY, (description,))
    row = cursor.fetchone()
    cursor.close()
    if not row:
        return HTML

    greeting, addr1, addr2, addr3, addr4, addr5, addr6, addr7 = row

    tel = _("Telephone") + " :- "
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val != "":
            tel += "%s %s " % ((_("home"), _("work "), _("mobile "))[i], val)

    return HTML % (
        "<br />".join([a for a in (addr1, addr2, addr3, addr4, addr5, addr6, addr7) if a != ""]),
        localsettings.longDate(localsettings.currentDay()),
        greeting,
        pt.title.title(),
        pt.fname.title(),
        pt.sname.title(),
        _("D.O.B."),
        localsettings.formatDate(pt.dob),
        ",".join([a for a in (pt.addr1, pt.addr2, pt.addr3, pt.town, pt.county, pt.pcde) if a != ""]),
        tel,
        _("Yours Sincerely"),
    )
Beispiel #10
0
def rec_notes(notes_dict, startdate=None):
    '''
    returns an html string of notes, designed to fit into the
    reception notes panel (ie. vertical)
    '''

    retarg = HEADER
    if startdate:
        retarg += "<h4>%s</h4>\n" % _("Course Activity")

    keys = notes_dict.keys()
    # keys.sort()

    for key in keys:
        date, op = key
        if startdate and date >= startdate:
            lines = notes_dict[key]
            note = get_rec_summary(op, lines)
            if note:
                retarg += '<p>\n  &nbsp;&nbsp;%s\n  <br />\n%s</p>\n' % (
                    localsettings.formatDate(date), note)

    retarg += '</body>\n</html>'

    return retarg
Beispiel #11
0
def bpe_table(om_gui, arg):
    '''
    updates the BPE chart on the clinical summary page
    '''
    if om_gui.pt.bpe != []:
        last_bpe_date = localsettings.formatDate(om_gui.pt.bpe[-1][0])
        om_gui.ui.bpe_groupBox.setTitle("BPE " + last_bpe_date)
        l = copy.deepcopy(om_gui.pt.bpe)
        l.reverse()
        bpestring = l[arg][1]
        bpe_html = '<table width="100%" border="1"><tr>'
        for i in range(len(bpestring)):
            if i == 3:
                bpe_html += "</tr><tr>"
            bpe_html += '<td align="center">%s</td>' % bpestring[i]
        for i in range(i + 1, 6):
            if i == 3:
                bpe_html += "</tr><tr>"
            bpe_html += '<td align="center">_</td>'
        bpe_html += '</tr></table>'
        om_gui.ui.bpe_textBrowser.setHtml(bpe_html)
    else:
        # necessary in case of the "NO DATA FOUND" option
        om_gui.ui.bpe_groupBox.setTitle(_("BPE"))
        om_gui.ui.bpe_textBrowser.setHtml("")
    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()
Beispiel #13
0
    def extendBooks(self):
        print "extending books"
        
        message = "%s %s %s %s"%( _("Books Currently end on"), 
        localsettings.formatDate(localsettings.bookEnd),"<br />",
          _("extend the books now?"))

        result = QtGui.QMessageBox.question(self.parent, _("Confirm"), 
        message,QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
        QtGui.QMessageBox.Yes )
    
        if result == QtGui.QMessageBox.No:
            return
        else:
            months, result = QtGui.QInputDialog.getInteger(self.parent, 
            _("Extend Books"), _("How many months?"))
        
        if result:
            
            newBookEnd = QtCore.QDate(
            localsettings.bookEnd).addMonths(months).toPyDate()
        
            if extend_books.extend(localsettings.apptix.values(),
            localsettings.bookEnd, newBookEnd):
                #now put this date into the settings database.
                
                db_format= "%s,%s,%s"% newBookEnd.timetuple()[:3]
                db_settings.insertData(
                "bookend", db_format, localsettings.operator)
Beispiel #14
0
def bpe_table(om_gui, arg):
    """
    updates the BPE chart on the clinical summary page
    """
    if om_gui.pt.bpe != []:
        last_bpe_date = localsettings.formatDate(om_gui.pt.bpe[-1][0])
        om_gui.ui.bpe_groupBox.setTitle("BPE " + last_bpe_date)
        l = copy.deepcopy(om_gui.pt.bpe)
        l.reverse()
        bpestring = l[arg][1]
        bpe_html = '<table width="100%" border="1"><tr>'
        for i in range(len(bpestring)):
            if i == 3:
                bpe_html += "</tr><tr>"
            bpe_html += '<td align="center">%s</td>' % bpestring[i]
        for i in range(i + 1, 6):
            if i == 3:
                bpe_html += "</tr><tr>"
            bpe_html += '<td align="center">_</td>'
        bpe_html += "</tr></table>"
        om_gui.ui.bpe_textBrowser.setHtml(bpe_html)
    else:
        # --necessary in case of the "NO DATA FOUND" option
        om_gui.ui.bpe_groupBox.setTitle(_("BPE"))
        om_gui.ui.bpe_textBrowser.setHtml("")
    def load_values(self):
        rows = families.get_address_matches(self.address)

        self.table_widget.clear()
        self.table_widget.setSortingEnabled(False)
        #--good practice to disable this while loading
        self.table_widget.setRowCount(len(rows))
        self.table_widget.setColumnCount(len(HEADERS))
        self.table_widget.setHorizontalHeaderLabels(HEADERS)
        self.table_widget.horizontalHeader().setStretchLastSection(True)
        # table.verticalHeader().hide()
        for row, result in enumerate(rows):
            for col, field in enumerate(result):
                if field is None:
                    continue
                if col == 5:
                    item = QtGui.QTableWidgetItem(
                        localsettings.formatDate(field))
                elif col == 0:  # match
                    item = QtGui.QTableWidgetItem("%04d" % field)
                elif col == 1:  # serialno
                    item = QtGui.QTableWidgetItem("%d" % field)
                else:
                    item = QtGui.QTableWidgetItem(field)
                self.table_widget.setItem(row, col, item)

        self.table_widget.resizeColumnsToContents()
        # hide match and serialno column
        self.table_widget.setColumnWidth(0, 0)
        self.table_widget.setColumnWidth(1, 0)
        self.table_widget.setSortingEnabled(True)
        self.table_widget.sortItems(0, QtCore.Qt.DescendingOrder)
Beispiel #16
0
    def load_values(self):
        rows = families.get_address_matches(self.address)

        self.table_widget.clear()
        self.table_widget.setSortingEnabled(False)
        self.table_widget.setRowCount(len(rows))
        self.table_widget.setColumnCount(len(HEADERS))
        self.table_widget.setHorizontalHeaderLabels(HEADERS)
        self.table_widget.horizontalHeader().setStretchLastSection(True)
        for row, result in enumerate(rows):
            for col, field in enumerate(result):
                if field is None:
                    continue
                if col == 5:
                    item = QtWidgets.QTableWidgetItem(
                        localsettings.formatDate(field))
                elif col == 0:  # match
                    item = QtWidgets.QTableWidgetItem("%04d" % field)
                elif col == 1:  # serialno
                    item = QtWidgets.QTableWidgetItem("%d" % field)
                else:
                    item = QtWidgets.QTableWidgetItem(field)
                self.table_widget.setItem(row, col, item)

        self.table_widget.resizeColumnsToContents()
        # hide match and serialno column
        self.table_widget.setColumnWidth(0, 0)
        self.table_widget.setColumnWidth(1, 0)
        self.table_widget.setSortingEnabled(True)
        self.table_widget.sortItems(0, QtCore.Qt.DescendingOrder)
Beispiel #17
0
def rec_notes(notes_dict, startdate=None):
    '''
    returns an html string of notes, designed to fit into the
    reception notes panel (ie. vertical)
    '''

    retarg = HEADER + '<table border="1">'
    if startdate:
        retarg += "<h4>%s</h4>"% _("Course Activity")

    keys = notes_dict.keys()
    #keys.sort()

    for key in keys:
        date, op = key
        if startdate and date >= startdate:
            data = notes_dict[key]
            note = get_rec_summary(data)
            if note:
                retarg += '<tr><td>%s</td><td>%s</td></tr>'% (
                    localsettings.formatDate(date), note)

    retarg += '</table></body></html>'

    return retarg
    def __init__(self, candidates, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setupUi(self)
        self.tableWidget.clear()
        self.tableWidget.setSortingEnabled(False)
        #--good practice to disable this while loading
        self.tableWidget.setRowCount(len(candidates))
        headers = ('Serialno', 'Surname', 'Forename', 'dob', 'Address1',
                   'Address2', 'POSTCODE')

        widthFraction = (0, 20, 20, 15, 30, 30, 10)
        self.tableWidget.setColumnCount(len(headers))
        self.tableWidget.setHorizontalHeaderLabels(headers)
        self.tableWidget.verticalHeader().hide()
        self.tableWidget.horizontalHeader().setStretchLastSection(True)
        row = 0

        for col in range(len(headers)):
            self.tableWidget.setColumnWidth(col, widthFraction[col] *
                                           (self.width() - 100) / 130)

        for candidate in candidates:
            col = 0
            for attr in candidate:
                if isinstance(attr, datetime.date):
                    item = QtGui.QTableWidgetItem(
                        localsettings.formatDate(attr))
                else:
                    item = QtGui.QTableWidgetItem(str(attr))
                self.tableWidget.setItem(row, col, item)
                col += 1
            row += 1
        self.tableWidget.setCurrentCell(0, 1)

        self.tableWidget.itemDoubleClicked.connect(self.accept)
 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]))
                 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
Beispiel #20
0
    def extendBooks(self):
        print "extending books"

        message = "%s %s %s %s" % (_("Books Currently end on"),
                                   localsettings.formatDate(
                                       localsettings.bookEnd), "<br />",
                                   _("extend the books now?"))

        result = QtGui.QMessageBox.question(
            self.parent, _("Confirm"), message,
            QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
            QtGui.QMessageBox.Yes)

        if result == QtGui.QMessageBox.No:
            return
        else:
            months, result = QtGui.QInputDialog.getInteger(
                self.parent, _("Extend Books"), _("How many months?"))

        if result:

            newBookEnd = QtCore.QDate(
                localsettings.bookEnd).addMonths(months).toPyDate()

            if extend_books.extend(localsettings.apptix.values(),
                                   localsettings.bookEnd, newBookEnd):
                # now put this date into the settings database.

                db_format = "%s,%s,%s" % newBookEnd.timetuple()[:3]
                db_settings.insertData("bookend", db_format,
                                       localsettings.operator)
Beispiel #21
0
def rec_notes(notes_dict, startdate=None):
    '''
    returns an html string of notes, designed to fit into the
    reception notes panel (ie. vertical)
    '''

    retarg = HEADER + '<table border="1">'
    if startdate:
        retarg += "<h4>%s</h4>" % _("Course Activity")

    keys = notes_dict.keys()
    # keys.sort()

    for key in keys:
        date, op = key
        if startdate and date >= startdate:
            data = notes_dict[key]
            note = get_rec_summary(data)
            if note:
                retarg += '<tr><td>%s</td><td>%s</td></tr>' % (
                    localsettings.formatDate(date), note)

    retarg += '</table></body></html>'

    return retarg
    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()
Beispiel #23
0
def rec_notes(notes_dict, startdate=None):
    '''
    returns an html string of notes, designed to fit into the
    reception notes panel (ie. vertical)
    '''

    retarg = HEADER
    if startdate:
        retarg += "<h4>%s</h4>\n" % _("Course Activity")

    keys = list(notes_dict.keys())
    # keys.sort()

    for key in keys:
        date, op = key
        if startdate and date >= startdate:
            lines = notes_dict[key]
            note = get_rec_summary(op, lines)
            if note:
                retarg += '<p>\n  &nbsp;&nbsp;%s\n  <br />\n%s</p>\n' % (
                    localsettings.formatDate(date), note)

    retarg += '</body>\n</html>'

    return retarg
Beispiel #24
0
    def getFromDB(self):
        try:
            db = connect.connect()
            cursor = db.cursor()

            query = """SELECT %s,%s,%s,%s,%s,%s,%s,%s from plandata
            where serialno=%s""" % (
                planDBAtts[1:] + (self.serialno,)
            )
            cursor.execute(query)
            row = cursor.fetchone()
            cursor.close()
            i = 1
            if row:
                for val in row:
                    if val:
                        att = planDBAtts[i]
                        if att == "planjoin":
                            self.planjoin = localsettings.formatDate(val)
                        else:
                            self.__dict__[att] = val
                    i += 1
            self.retrieved = True
        except Exception as exc:
            LOGGER.exception("error loading from plandata")
    def __init__(self, candidates, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setupUi(self)
        self.tableWidget.clear()
        self.tableWidget.setSortingEnabled(False)
        #--good practice to disable this while loading
        self.tableWidget.setRowCount(len(candidates))
        headers = ('Serialno', 'Surname', 'Forename', 'dob', 'Address1',
                   'Address2', 'POSTCODE')

        widthFraction = (0, 20, 20, 15, 30, 30, 10)
        self.tableWidget.setColumnCount(len(headers))
        self.tableWidget.setHorizontalHeaderLabels(headers)
        self.tableWidget.verticalHeader().hide()
        self.tableWidget.horizontalHeader().setStretchLastSection(True)
        row = 0

        for col in range(len(headers)):
            self.tableWidget.setColumnWidth(
                col, widthFraction[col] * (self.width() - 100) / 130)

        for candidate in candidates:
            col = 0
            for attr in candidate:
                if isinstance(attr, datetime.date):
                    item = QtGui.QTableWidgetItem(
                        localsettings.formatDate(attr))
                else:
                    item = QtGui.QTableWidgetItem(str(attr))
                self.tableWidget.setItem(row, col, item)
                col += 1
            row += 1
        self.tableWidget.setCurrentCell(0, 1)

        self.tableWidget.itemDoubleClicked.connect(self.accept)
Beispiel #26
0
def getHtml(description, pt):
    '''
    get the HTML for a letter to
    referral_centre identified by description about this pt
    '''
    db = connect()
    cursor = db.cursor()
    cursor.execute(ADDRESS_QUERY, (description, ))
    row = cursor.fetchone()
    cursor.close()
    if not row:
        return HTML

    greeting, addr1, addr2, addr3, addr4, addr5, addr6, addr7 = row

    tel = _("Telephone") + " :- "
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val != "":
            tel += "%s %s " % ((_("home"), _("work "), _("mobile "))[i], val)

    return HTML % ("<br />".join([
        a for a in (addr1, addr2, addr3, addr4, addr5, addr6, addr7) if a != ""
    ]), localsettings.longDate(localsettings.currentDay()), greeting,
                   pt.title.title(), pt.fname.title(), pt.sname.title(),
                   _("D.O.B."), localsettings.formatDate(pt.dob), ",".join([
                       a for a in (pt.addr1, pt.addr2, pt.addr3, pt.town,
                                   pt.county, pt.pcde) if a != ""
                   ]), tel, _("Yours Sincerely"))
Beispiel #27
0
def toHtml(pt):
    '''
    returns an HTML table of the patients pt
    '''

    retarg='''<html><body><center>
    <h3>NHS DETAILS</h3>
    <table width ="100%" border="1">
    '''
    retarg+="<tr><td>EXEMPTION</td><td>%s</td></tr>"%pt.exemption
    retarg+="<tr><td>EXEMPTION TEXT</td><td>%s</td></tr>"%pt.exempttext
    retarg+="<tr><td>PREVIOUS SURNAME</td><td>%s</td></tr>"%pt.psn
    retarg+="<tr><td>NHS NUMBER</td><td>%s</td></tr>"%pt.nhsno

    retarg+="<tr><td>LAST CLAIM</td><td>%s</td></tr>"% localsettings.formatDate(pt.pd3)
    retarg+="<tr><td>INITIAL ACCEPTANCE</td><td>%s</td></tr>"% localsettings.formatDate(pt.pd12)
    retarg+="<tr><td>LAST REACCEPTANCE</td><td>%s</td></tr>"% localsettings.formatDate(pt.pd14)
    retarg+="<tr><td>EXPIRY</td><td>%s</td></tr>"% localsettings.formatDate(pt.expiry)
    retarg+="<tr><td>CSTATUS</td><td>%s</td></tr>"% localsettings.formatDate(pt.cstatus)
    retarg+="<tr><td>TRANSFER</td><td>%s</td></tr>"% localsettings.formatDate(pt.transfer)

    if pt.sex=="F":
        retarg+="<tr><td>CONFINEMENT DATE</td><td>%s</td></tr>"% localsettings.formatDate(pt.cnfd)

    retarg+='</table></body></html>'

    return retarg
Beispiel #28
0
def toHtml(pt):
    '''
    returns an HTML table of the patients pt
    '''

    retarg = '''<html><body><center>
    <h3>NHS DETAILS</h3>
    <table width ="100%" border="1">
    '''
    retarg += "<tr><td>EXEMPTION</td><td>%s</td></tr>" % pt.exemption
    retarg += "<tr><td>EXEMPTION TEXT</td><td>%s</td></tr>" % pt.exempttext
    retarg += "<tr><td>PREVIOUS SURNAME</td><td>%s</td></tr>" % pt.psn
    retarg += "<tr><td>NHS NUMBER</td><td>%s</td></tr>" % pt.nhsno

    retarg += "<tr><td>LAST CLAIM</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.pd3)
    retarg += "<tr><td>INITIAL ACCEPTANCE</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.pd12)
    retarg += "<tr><td>LAST REACCEPTANCE</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.pd14)
    retarg += "<tr><td>EXPIRY</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.expiry)
    retarg += "<tr><td>CSTATUS</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.cstatus)
    retarg += "<tr><td>TRANSFER</td><td>%s</td></tr>" % localsettings.formatDate(
        pt.transfer)

    if pt.sex == "F":
        retarg += "<tr><td>CONFINEMENT DATE</td><td>%s</td></tr>" % localsettings.formatDate(
            pt.cnfd)

    retarg += '</table></body></html>'

    return retarg
Beispiel #29
0
def getHtml(desc,pt):
    try:
        d=minidom.parse(localsettings.referralfile)
        descriptions=d.getElementsByTagName("description")
        desclist=[]
        found=False
        for description in descriptions:
            if description.firstChild.data==desc:
                found=True
                break
        if found:
            '''this means we have a node with the required address fields etc...'''
            refnode=description.parentNode
            surgeon_postal=refnode.getElementsByTagName("surgeon_postal")[0].firstChild.data
            addressNode=refnode.getElementsByTagName("address")
            lines=addressNode[0].getElementsByTagName("line")
            address=[]
            for line in lines:
                address.append(line.firstChild.data)
            greeting=refnode.getElementsByTagName("surgeon_greeting")[0].firstChild.data
            retarg="<html><body>"
            retarg+="<br />"*6
            retarg+="<b>%s<br />"%surgeon_postal
            for line in address:
                retarg+="%s<br />"%line
            retarg+="</b>"+"<br />"*2
            today=time.localtime()[:3]
            d=datetime.date(today[0],today[1],today[2])
            retarg+="%s, " %("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")[d.weekday()]
            retarg+="%s "%d.day
            retarg+="%s, "%("January","February","March","April","May","June","July","August","September","October","November","December")[d.month-1]
            retarg+= '%s <br /><br />'%d.year
            retarg+="Dear %s,<br />"%greeting
            retarg+='<div align="center"><b>Re. %s %s %s - '%(pt.title.title(),pt.fname.title(),pt.sname.title())
            retarg+='DOB %s</b><br />'% localsettings.formatDate(pt.dob)
            for val in (pt.addr1,pt.addr2,pt.addr3,pt.town,pt.county):
                if val!="":
                    retarg+=val+","
            if pt.pcde!="":
               retarg+=pt.pcde+"."
            retarg+="<br />Tel - "
            i=0
            for val in (pt.tel1,pt.tel2,pt.mobile):
                if val!="":
                    retarg+=("home ","work ","mobile ")[i]+ val+" "
                i+=1
            retarg+="</div>"
            retarg+="<br />"*(12)
            retarg+="Yours Sincerely,"+"<br />"*4
            retarg+="</body></html>"
            return retarg
        else:
            return ("<html><body>SORRY - we couldn't find letter data for % </body></html>"%desc)

    except Exception,e:
        print e
        return False
Beispiel #30
0
 def update_recall_date(self):
     if not self.pt.appt_prefs.recall_active:
         self.om_gui.advise(
             _("WARNING - Not updating recall due to patients recall settings"
               ), 1)
     else:
         date_ = localsettings.formatDate(self.pt.appt_prefs.new_recdent)
         self.om_gui.advise("updating recall date to %s" % date_, 1)
         self.pt.appt_prefs.update_recdent()
Beispiel #31
0
    def __repr__(self):
        '''
        a readable description of the object
        '''
        retarg = "%d Tables \n" % len(self.tables)
        for key in self.tables:
            table = self.tables[key]
            retarg += "===" * 20 + "\n"
            retarg += "   table %s - %s\n" % (key, table.briefName)
            retarg += "%s \n" % table.description
            retarg += "valid %s - %s\n" % (localsettings.formatDate(
                table.startDate), localsettings.formatDate(table.endDate))

            retarg += "       categories %s\n" % table.categories
            retarg += "    has pt column %s\n" % table.hasPtCols
            retarg += "    has %d fee items\n" % len(table.feesDict)
            retarg += "===" * 20 + "\n"
        return retarg
Beispiel #32
0
 def update_recall_date(self):
     if not self.pt.appt_prefs.recall_active:
         self.om_gui.advise(
         _("WARNING - Not updating recall due to patients recall settings")
         ,1)
     else:
         date_ = localsettings.formatDate(self.pt.appt_prefs.new_recdent)
         self.om_gui.advise("updating recall date to %s"% date_, 1)
         self.pt.appt_prefs.update_recdent()
Beispiel #33
0
    def __repr__(self):
        '''
        a readable description of the object
        '''
        retarg = "%d Tables \n" % len(self.tables)
        for key in self.tables:
            table = self.tables[key]
            retarg += "===" * 12 + "\n"
            retarg += "   table %s - %s\n" % (key, table.briefName)
            retarg += "%s \n" % table.description
            retarg += "valid %s - %s\n" % (localsettings.formatDate(
                table.startDate), localsettings.formatDate(table.endDate))

            retarg += "       categories %s\n" % table.categories
            retarg += "       fee cols %s\n" % str(table.feeColNames)
            retarg += "    pt_fee cols %s\n" % str(table.pt_feeColNames)
            retarg += "       query %s\n" % table.columnQuery
            retarg += "===" * 12 + "\n"
        return retarg
Beispiel #34
0
 def update_recall_date(self):
     if not self.pt.appt_prefs.recall_active:
         message = "%s<hr />%s" % (
             _("WARNING"),
             _("Not updating recall due to patient's recall settings"))
         self.om_gui.advise(message, 1)
     else:
         date_ = localsettings.formatDate(self.pt.appt_prefs.new_recdent)
         self.om_gui.advise("updating recall date to %s" % date_)
         self.pt.appt_prefs.update_recdent()
Beispiel #35
0
    def __repr__(self):
        '''
        a readable description of the object
        '''
        retarg = "%d Tables \n" % len(self.tables)
        for key in self.tables:
            table = self.tables[key]
            retarg += "===" * 20 + "\n"
            retarg += "   table %s - %s\n" % (key, table.briefName)
            retarg += "%s \n" % table.description
            retarg += "valid %s - %s\n" % (
                localsettings.formatDate(table.startDate),
                localsettings.formatDate(table.endDate))

            retarg += "       categories %s\n" % table.categories
            retarg += "    has pt column %s\n" % table.hasPtCols
            retarg += "    has %d fee items\n" % len(table.feesDict)
            retarg += "===" * 20 + "\n"
        return retarg
Beispiel #36
0
def html_history(sno):
    html = "<h1>%s</h1>" % _("Medical History Changelog")
    db = connect()
    cursor = db.cursor()
    cursor.execute(MH_QUERY, (sno, ))
    for row in cursor.fetchall():
        table, meds_html = "", ""
        values = row[:2] + ({}, ) + row[2:]
        mh = MedHist(*values)
        cursor.execute(MEDS_QUERY, (mh.ix, ))
        for med, details in cursor.fetchall():
            meds_html += med
            meds_html += " <em>%s</em>" % ("" if details in (None, "") else
                                           "(%s)" % details)
            meds_html += "<br />"
        if meds_html:
            table += "<tr><th>%s</th><td>%s<td></tr>" % (_("MEDICATIONS"),
                                                         meds_html[:-6])

        for key, value in ((_("Warning Card"),
                            mh.warning_card), (_("Medication Comments"),
                                               mh.medication_comments),
                           (_("Allergies"), mh.allergies), (_("Respiratory"),
                                                            mh.respiratory),
                           (_("Heart"), mh.heart), (_("Diabetes"),
                                                    mh.diabetes),
                           (_("Arthritis"), mh.arthritis), (_("Bleeding"),
                                                            mh.bleeding),
                           (_("Infectious disease"), mh.infectious_disease),
                           (_("Endorcarditis"), mh.endocarditis), (_("Liver"),
                                                                   mh.liver),
                           (_("Anaesthetic"),
                            mh.anaesthetic), (_("Join Replacement"),
                                              mh.joint_replacement),
                           (_("Heart Surgery"),
                            mh.heart_surgery), (_("Brain Surgery"),
                                                mh.brain_surgery),
                           (_("Hospitalised"),
                            mh.hospital), (_("CJD"), mh.cjd), (_("OTHER"),
                                                               mh.other),
                           (_("ALERT"), _("TRUE") if mh.alert else "")):
            if value:
                table += "<tr><th>%s</th><td>%s<td></tr>" % (key, value)
        if table:
            if mh.chkdate:
                date_ = localsettings.formatDate(mh.chkdate)
            else:
                date_ = _("Original values, no date")
            html += '''<h2>%s - %s</h2>
            <table width='100%%' border='1'>%s</table>
            <br />
            ''' % (date_, mh.modified_by, table)

    cursor.close()
    return html + _("End of History")
Beispiel #37
0
def html_history(sno):
    html = "<h1>%s</h1>" % _("Medical History Changelog")
    db = connect()
    cursor = db.cursor()
    cursor.execute(MH_QUERY, (sno,))
    for row in cursor.fetchall():
        table, meds_html = "", ""
        values = row[:2] + ({},) + row[2:]
        mh = MedHist(*values)
        cursor.execute(MEDS_QUERY, (mh.ix,))
        for med, details in cursor.fetchall():
            meds_html += med
            meds_html += " <em>%s</em>" % (
                "" if details in (None, "") else "(%s)" % details)
            meds_html += "<br />"
        if meds_html:
            table += "<tr><th>%s</th><td>%s<td></tr>" % (
                _("MEDICATIONS"), meds_html[:-6])

        for key, value in (
            (_("Warning Card"), mh.warning_card),
            (_("Medication Comments"), mh.medication_comments),
            (_("Allergies"), mh.allergies),
            (_("Respiratory"), mh.respiratory),
            (_("Heart"), mh.heart),
            (_("Diabetes"), mh.diabetes),
            (_("Arthritis"), mh.arthritis),
            (_("Bleeding"), mh.bleeding),
            (_("Infectious disease"), mh.infectious_disease),
            (_("Endorcarditis"), mh.endocarditis),
            (_("Liver"), mh.liver),
            (_("Anaesthetic"), mh.anaesthetic),
            (_("Join Replacement"), mh.joint_replacement),
            (_("Heart Surgery"), mh.heart_surgery),
            (_("Brain Surgery"), mh.brain_surgery),
            (_("Hospitalised"), mh.hospital),
            (_("CJD"), mh.cjd),
            (_("OTHER"), mh.other),
            (_("ALERT"), _("TRUE") if mh.alert else "")
        ):
            if value:
                table += "<tr><th>%s</th><td>%s<td></tr>" % (
                    key, value)
        if table:
            html += '''<h2>%s - %s</h2>
            <table width='100%%' border='1'>%s</table>
            <br />
            ''' % (
                localsettings.formatDate(mh.chkdate),
                localsettings.operator,
                table,
            )

    cursor.close()
    return html + _("End of History")
Beispiel #38
0
def summary_html(pt):
    key_values = []
    key_values.append((
        _("Contract Dentist"),
        localsettings.dentDict.get(pt.dnt1, UNKNOWN_DENT)[1]
        ))

    days = (localsettings.currentDay() - pt.first_note_date).days
    if days < 7:
        duration = _("this week")
    elif days < 365:
        duration = _("recently")
    elif days < 730:
        duration = _("last year")
    else:
        duration = "%s %s" % (days//365, _("years ago."))

    key_values.append((
        _("Joined the practice"),
        duration
        ))

    key_values.append((
        _("Last Treatment"),
        localsettings.formatDate(pt.last_treatment_date)
        ))

    key_values.append((
        _("Exam Due"),
        _("YES!") if pt.exam_due else _("No")
        ))

    key_values.append((
        _("Has seen hygienist on"),
        "%s %s" % (pt.n_hyg_visits, _("Occasions"))
        ))

    phone = False
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val:
            key = (_("Telephone (Home)"),
                   _("Telephone (Work)"),
                   _("Mobile"))[i]
            key_values.append((key, val))
            phone = True
    if not phone:
        key_values.append((_("Telephone"), _("Please get a phone number")))

    content = "<ul>"
    for key, value in key_values:
        content += "<li><b>%s</b> - %s</li>" % (key, value)
    content += "</ul>"
    html_ = HTML_TEMPLATE.replace("{{CONTENT}}", content)

    return html_
Beispiel #39
0
    def __repr__(self):
        '''
        a readable description of the object
        '''
        retarg = "%d Tables \n" % len(self.tables)
        for key in self.tables:
            table = self.tables[key]
            retarg += "===" * 12 + "\n"
            retarg += "   table %s - %s\n" % (key, table.briefName)
            retarg += "%s \n" % table.description
            retarg += "valid %s - %s\n" % (
                localsettings.formatDate(table.startDate),
                localsettings.formatDate(table.endDate))

            retarg += "       categories %s\n" % table.categories
            retarg += "       fee cols %s\n" % str(table.feeColNames)
            retarg += "    pt_fee cols %s\n" % str(table.pt_feeColNames)
            retarg += "       query %s\n" % table.columnQuery
            retarg += "===" * 12 + "\n"
        return retarg
    def messages(self):
        yield "%s %d %s" % (_("you have"), localsettings.PT_COUNT,
                            _("patients"))

        yield "%s %d %s" % (_("you have"), len(localsettings.activedents),
                            _("active dentists"))

        yield "%s %d %s" % (_("you have"), len(localsettings.activehygs),
                            _("active hygienists"))

        yield "%s %s" % (_("appointment search final date is"),
                         localsettings.formatDate(localsettings.BOOKEND))
    def messages(self):
        yield "%s %d %s" % (_("you have"), localsettings.PT_COUNT,
                            _("patients"))

        yield "%s %d %s" % (_("you have"), len(
            localsettings.activedents), _("active dentists"))

        yield "%s %d %s" % (_("you have"), len(
            localsettings.activehygs), _("active hygienists"))

        yield "%s %s" % (_("appointment search final date is"),
                         localsettings.formatDate(localsettings.BOOKEND))
Beispiel #42
0
def get_date_from_date(key):
    """
    converts to a readable date
    """
    try:
        k = key.split("_")
        d = datetime.date(int(k[0]), int(k[1]), int(k[2]))
        return localsettings.formatDate(d)
        # return k[2]+"/"+k[1]+"/"+k[0]
    except IndexError:
        return "IndexERROR converting date %s" % key
    except ValueError:
        return "TypeERROR converting date %s" % key
Beispiel #43
0
def get_date_from_date(key):
    '''
    converts to a readable date
    '''
    try:
        k = key.split('_')
        d = datetime.date(int(k[0]), int(k[1]), int(k[2]))
        return localsettings.formatDate(d)
        # return k[2]+"/"+k[1]+"/"+k[0]
    except IndexError:
        return "IndexERROR converting date %s" % key
    except ValueError:
        return "TypeERROR converting date %s" % key
Beispiel #44
0
def chooseFeescale(om_gui, i):
    '''
    receives signals from the choose feescale combobox
    acts on the fee table
    arg will be the chosen index
    '''
    if i == -1:
        return
    table = localsettings.FEETABLES.tables[i]
    if table.endDate is None:
        end = _("IN CURRENT USE")
    else:
        end = localsettings.formatDate(table.endDate)
    om_gui.ui.feeScale_label.setText(
        "<b>%s</b> %s - %s" %
        (table.description, localsettings.formatDate(table.startDate), end))
    om_gui.ui.feesearch_results_label.setText("")

    try:
        om_gui.ui.feeScales_treeView.setModel(om_gui.fee_models[i])
    except IndexError:
        print(i, len(om_gui.fee_models))
        om_gui.advise(_("fee table error"), 2)
 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 load_values(self):
     db = connect()
     cursor = db.cursor()
     values = (
         self.om_gui.pt.addr1,
         self.om_gui.pt.addr1[:10],
         self.om_gui.pt.addr2[:10],
         self.om_gui.pt.addr3[:10],
         self.om_gui.pt.town[:10],
         self.om_gui.pt.pcde,
         self.om_gui.pt.addr1[:10],
         self.om_gui.pt.addr2[:10],
         self.om_gui.pt.town[:10],
         self.om_gui.pt.pcde[:10],
         )
     
     cursor.execute(QUERY, (values))
     rows = cursor.fetchall()
     cursor.close()
     
     self.table_widget.clear()
     self.table_widget.setSortingEnabled(False)
     #--good practice to disable this while loading
     self.table_widget.setRowCount(len(rows))
     self.table_widget.setColumnCount(len(HEADERS))
     self.table_widget.setHorizontalHeaderLabels(HEADERS)
     self.table_widget.horizontalHeader().setStretchLastSection(True)
     #table.verticalHeader().hide()
     for row, result in enumerate(rows):
         for col, field in enumerate(result):
             if field is None:
                 continue
             if col == 5:
                 item = QtGui.QTableWidgetItem(
                     localsettings.formatDate(field))
             elif col == 0: #match
                 item = QtGui.QTableWidgetItem("%04d"% field)
             elif col == 1: #serialno
                 item = QtGui.QTableWidgetItem("%d"% field)
             else:
                 item = QtGui.QTableWidgetItem(field)
             self.table_widget.setItem(row, col, item)
         
     self.table_widget.resizeColumnsToContents()
     #hide match and serialno column
     self.table_widget.setColumnWidth(0, 0)
     self.table_widget.setColumnWidth(1, 0)
     self.table_widget.setSortingEnabled(True)
     self.table_widget.sortItems(0, QtCore.Qt.DescendingOrder)
 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")
     QtGui.QMessageBox.information(
         self, _("Success!"),
         "%s %s %s %s" % (_("Sucessfully saved "),
                          localsettings.formatDate(self.check_date),
                          _("for patient"), self.pt.serialno))
Beispiel #48
0
def bpe_dates(om_gui):
    """
    updates the date in the bpe date groupbox
    """
    # --bpe = "basic periodontal exam"
    om_gui.ui.bpeDateComboBox.clear()
    om_gui.ui.bpe_textBrowser.setPlainText("")
    if om_gui.pt.bpe == []:
        om_gui.ui.bpeDateComboBox.addItem(QtCore.QString("NO BPE"))
    else:
        l = copy.deepcopy(om_gui.pt.bpe)
        l.reverse()  # show newest first
        for sets in l:
            bpedate = localsettings.formatDate(sets[0])
            om_gui.ui.bpeDateComboBox.addItem(bpedate)
Beispiel #49
0
def chooseFeescale(om_gui, i):
    '''
    receives signals from the choose feescale combobox
    acts on the fee table
    arg will be the chosen index
    '''
    if i == -1:
        return
    table = localsettings.FEETABLES.tables[i]
    if table.endDate == None:
        end = _("IN CURRENT USE")
    else:
        end = localsettings.formatDate(table.endDate)
    om_gui.ui.feeScale_label.setText("<b>%s</b> %s - %s"% (
    table.description,
    localsettings.formatDate(table.startDate), end))

    om_gui.ui.feesearch_results_label.setText("")

    try:
        om_gui.ui.feeScales_treeView.setModel(om_gui.fee_models[i])
    except IndexError:
        print i, len(om_gui.fee_models)
        om_gui.advise(_("fee table error"),2)
Beispiel #50
0
def getHistory(pt, tooth):
    '''
    get daybook history for this tooth
    '''
    tooth = tooth.upper()
    hist = ""
    for tdate, apptix, items in pt.dayBookHistory:
        regex = "%s (.*)" % tooth
        for item in items.split("  "):
            for tx in re.findall(regex, item):
                hist += "<li>%s - %s - %s</li>" % (localsettings.formatDate(
                    tdate), localsettings.ops.get(int(apptix)), tx)
    if hist == "":
        hist = "None Found"
    else:
        hist = "<ul>%s</ul>" % hist
    return "History for %s<hr />%s" % (tooth, hist)
Beispiel #51
0
def getHistory(pt, tooth):
    '''
    get daybook history for this tooth
    '''
    tooth = tooth.upper()
    hist = ""
    for tdate, apptix, item in pt.dayBookHistory:
        regex = "%s (.*)\n?" % tooth
        m = re.search(regex, item.replace("  ", "\n"))
        if m:
            for group in m.groups():
                hist += "<li>%s - %s - %s</li>" % (localsettings.formatDate(
                    tdate), localsettings.ops.get(int(apptix)), group)
    if hist == "":
        hist = "None Found"
    else:
        hist = "<ul>%s</ul>" % hist
    return "History for %s<hr />%s" % (tooth, hist)
def getHistory(pt, tooth):
    '''
    get daybook history for this tooth
    '''
    tooth = tooth.upper()
    hist = ""
    for tdate, apptix, items in pt.dayBookHistory:
        regex = "%s (.*)" % tooth
        for item in items.split("  "):
            for tx in re.findall(regex, item):
                hist += "<li>%s - %s - %s</li>" % (
                    localsettings.formatDate(tdate),
                    localsettings.ops.get(int(apptix)),
                    tx)
    if hist == "":
        hist = "None Found"
    else:
        hist = "<ul>%s</ul>" % hist
    return "History for %s<hr />%s" % (tooth, hist)
Beispiel #53
0
def summary_html(pt):
    key_values = []
    key_values.append((_("Contract Dentist"),
                       localsettings.dentDict.get(pt.dnt1, UNKNOWN_DENT)[1]))

    days = (localsettings.currentDay() - pt.first_note_date).days
    if days < 7:
        duration = _("this week")
    elif days < 365:
        duration = _("recently")
    elif days < 730:
        duration = _("last year")
    else:
        duration = "%s %s" % (days // 365, _("years ago."))

    key_values.append((_("Joined the practice"), duration))

    key_values.append((_("Last Treatment"),
                       localsettings.formatDate(pt.last_treatment_date)))

    key_values.append((_("Exam Due"), _("YES!") if pt.exam_due else _("No")))

    key_values.append((_("Has seen hygienist on"),
                       "%s %s" % (pt.n_hyg_visits, _("Occasions"))))

    phone = False
    for i, val in enumerate((pt.tel1, pt.tel2, pt.mobile)):
        if val:
            key = (_("Telephone (Home)"), _("Telephone (Work)"),
                   _("Mobile"))[i]
            key_values.append((key, val))
            phone = True
    if not phone:
        key_values.append((_("Telephone"), _("Please get a phone number")))

    content = "<ul>"
    for key, value in key_values:
        content += "<li><b>%s</b> - %s</li>" % (key, value)
    content += "</ul>"
    html_ = HTML_TEMPLATE.replace("{{CONTENT}}", content)

    return html_
Beispiel #54
0
def getHistory(pt, tooth):
    '''
    get daybook history for this tooth
    '''
    tooth = tooth.upper()
    hist = ""
    for tdate, apptix, item in pt.dayBookHistory:
        regex = "%s (.*)\n?"% tooth
        m = re.search(regex, item.replace("  ","\n"))
        if m:
            for group in m.groups():
                hist += "<li>%s - %s - %s</li>"%(
                localsettings.formatDate(tdate),
                localsettings.ops.get(int(apptix)),
                group)
    if hist == "":
        hist = "None Found"
    else:
        hist = "<ul>%s</ul>"% hist
    return "History for %s<hr />%s"% (tooth, hist)
Beispiel #55
0
def header(pt):
    html = '''
    <html>
    <head><link rel="stylesheet" href="%s" type="text/css"></head>
    <body><div align = "center">
    <h4>Patient %d</h4>
    <h3>%s %s %s</h3>
    %s %s<hr />
        ''' % (localsettings.stylesheet, pt.serialno, pt.title.title(),
               pt.fname.title(), pt.sname.title(),
               localsettings.formatDate(pt.dob), getAge(pt))

    address = (pt.addr1, pt.addr2, pt.addr3, pt.town, pt.county, pt.pcde)
    html += "<br />".join([l for l in address if l != ""])
    if pt.pcde == "":
        html += "<b>%s</b>" % _("!UNKNOWN POSTCODE!")

    if pt.status not in ("Active", "", None):
        html += "<hr /><h1>%s</h1>" % pt.status

    return html
    def load_candidates(self):
        self.table_widget.clear()
        self.table_widget.setSortingEnabled(False)
        self.table_widget.setRowCount(len(self.candidates))
        self.table_widget.setColumnCount(len(self.headers))
        self.table_widget.setHorizontalHeaderLabels(self.headers)
        self.table_widget.verticalHeader().hide()
        self.table_widget.horizontalHeader().setStretchLastSection(True)

        for row, candidate in enumerate(self.candidates):
            for col, attr in enumerate(candidate):
                if isinstance(attr, datetime.date):
                    item = QtGui.QTableWidgetItem(
                        localsettings.formatDate(attr))
                else:
                    item = QtGui.QTableWidgetItem(str(attr))
                self.table_widget.setItem(row, col, item)

        self.table_widget.setSortingEnabled(True)
        self.table_widget.sortItems(4)
        self.table_widget.setCurrentCell(0, 1)
        self.set_more_but_text()
Beispiel #57
0
def header(pt):
    retarg = '''<html>
<head><link rel="stylesheet" href="%s" type="text/css"></head>
<body><div align = "center">
<h4>Patient %d</h4>
<h3>%s %s %s</h3>
        ''' % (localsettings.stylesheet, pt.serialno, pt.title.title(),
               pt.fname.title(), pt.sname.title())

    retarg += '%s %s' % (localsettings.formatDate(pt.dob), getAge(pt))
    for line in (pt.addr1, pt.addr2, pt.addr3, pt.town, pt.county):
        if str(line) != '':
            retarg += "%s <br />" % line
    if pt.pcde == "":
        retarg += "<b>!UNKNOWN POSTCODE!</b>"
    else:
        retarg += "%s" % pt.pcde

    if not pt.status in ("Active", "", None):
        retarg += "<hr /><h1>%s</h1>" % pt.status

    return retarg
Beispiel #58
0
def header(pt):
    html = '''
    <html>
    <head><link rel="stylesheet" href="%s" type="text/css"></head>
    <body><div align = "center">
    <h4>Patient %d</h4>
    <h3>%s %s %s</h3>
    %s %s<hr />
        ''' % (
        localsettings.stylesheet, pt.serialno, pt.title.title(),
        pt.fname.title(), pt.sname.title(),
        localsettings.formatDate(pt.dob), getAge(pt))

    address = (pt.addr1, pt.addr2, pt.addr3, pt.town, pt.county, pt.pcde)
    html += "<br />".join([l for l in address if l != ""])
    if pt.pcde == "":
        html += "<b>%s</b>" % _("!UNKNOWN POSTCODE!")

    if pt.status not in ("Active", "", None):
        html += "<hr /><h1>%s</h1>" % pt.status

    return html
Beispiel #59
0
    def getFromDB(self):
        try:
            db = connect.connect()
            cursor = db.cursor()

            query = '''SELECT %s,%s,%s,%s,%s,%s,%s,%s from plandata
            where serialno=%s''' % (planDBAtts[1:] + (self.serialno, ))
            cursor.execute(query)
            row = cursor.fetchone()
            cursor.close()
            i = 1
            if row:
                for val in row:
                    if val:
                        att = planDBAtts[i]
                        if att == "planjoin":
                            self.planjoin = localsettings.formatDate(val)
                        else:
                            self.__dict__[att] = val
                    i += 1
            self.retrieved = True
        except Exception:
            LOGGER.exception("error loading from plandata")