Esempio n. 1
0
def showCheckMesDescription(parent, mesId):
    if parent.eventEditor is not None:
        view = CReportViewDialog(parent)
        view.setWindowTitle(u'ПРОТОКОЛ')
        view.setText(getMesDescription(parent, mesId))
        view.showMaximized()
        view.exec_()
Esempio n. 2
0
 def __init__(self, parent, fname, fsize, md5, params):
     CReportViewDialog.__init__(self, parent)
     self.fname = fname
     self.fsize = fsize
     self.md5 = md5
     self.begDate = params.get('begDate', QtCore.QDate())
     self.endDate = params.get('endDate', QtCore.QDate())
     try:
         QtGui.qApp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
         object = self.build()
     finally:
         QtGui.qApp.restoreOverrideCursor()
     self.setWindowTitle(u'Акт приёма-передачи')
     self.setText(object)
Esempio n. 3
0
 def on_btnPrint_clicked(self):
     doc = QtGui.QTextDocument()
     cursor = QtGui.QTextCursor(doc)
     format = QtGui.QTextCharFormat()
     format.setProperty(QtGui.QTextFormat.FontSizeIncrement,
                        QtCore.QVariant(2))
     format.setFontWeight(QtGui.QFont.Bold)
     cursor.setCharFormat(format)
     if len(self.actionPropertyList) == 1:
         title = u'Журнал значения свойства "' + self.actionPropertyList[0][
             0].type().name + '"'
     else:
         names = [
             '"' + actionProperty[0].type().name + '"'
             for actionProperty in self.actionPropertyList
         ]
         title = u'Журнал значения свойств ' + ', '.join(
             names[:-1]) + u' и ' + names[-1]
     cursor.insertText(title)
     cursor.insertBlock()
     cursor.setCharFormat(QtGui.QTextCharFormat())
     cursor.insertText(u'пациент:')
     cursor.insertBlock()
     cursor.insertHtml(getClientBanner(self.clientId))
     self.tblValues.addContentToTextCursor(cursor)
     view = CReportViewDialog(self)
     view.setWindowTitle(u'Журнал значения свойства')
     view.setText(doc)
     view.exec_()
Esempio n. 4
0
 def on_btnPrint_clicked(self):
     widgetIndex = self.tabWidget.currentIndex()
     if widgetIndex == 1:
         model = self.modelTemperatureSheet
         doc = QtGui.QTextDocument()
         cursor = QtGui.QTextCursor(doc)
         cursor.setCharFormat(CReportBase.ReportTitle)
         cursor.insertText(u'Таблица температурного листа\n')
         cursor.insertBlock()
         cursor.setCharFormat(CReportBase.ReportBody)
         cursor.insertText(u'Пациент: %s' %
                           (getClientString(self.clientId)))
         cursor.insertText(u'\nОтчёт составлен: ' +
                           forceString(QtCore.QDateTime.currentDateTime()))
         cursor.insertBlock()
         colWidths = [
             self.tblTemperatureSheet.columnWidth(i)
             for i in xrange(model.columnCount() - 1)
         ]
         colWidths.insert(0, 10)
         totalWidth = sum(colWidths)
         tableColumns = []
         iColNumber = False
         for iCol, colWidth in enumerate(colWidths):
             widthInPercents = str(max(1, colWidth * 90 / totalWidth)) + '%'
             if iColNumber == False:
                 tableColumns.append(
                     (widthInPercents, [u'№'], CReportBase.AlignRight))
                 iColNumber = True
             headers = model.headers
             tableColumns.append(
                 (widthInPercents, [forceString(headers[iCol][1])],
                  CReportBase.AlignLeft))
         table = createTable(cursor, tableColumns)
         for iModelRow in xrange(model.rowCount()):
             iTableRow = table.addRow()
             table.setText(iTableRow, 0, iModelRow + 1)
             for iModelCol in xrange(model.columnCount()):
                 index = model.createIndex(iModelRow, iModelCol)
                 text = forceString(model.data(index))
                 table.setText(iTableRow, iModelCol + 1, text)
         html = doc.toHtml(QtCore.QByteArray('utf-8'))
         view = CReportViewDialog(self)
         view.setText(html)
         view.exec_()
     else:
         printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
         printer.setOrientation(QtGui.QPrinter.Landscape)
         dialog = QtGui.QPrintDialog(printer, self)
         if dialog.exec_():
             painter = QtGui.QPainter(printer)
             scale = min(
                 printer.pageRect().width() /
                 self.scrollArea.widget().width(),
                 printer.pageRect().height() /
                 self.scrollArea.widget().height())
             painter.scale(scale, scale)
             self.scrollArea.widget().render(painter)
             painter.end()
Esempio n. 5
0
 def execReportInt():
     report = CReportR67DP(self)
     params = {
         'accountId': self.accountId,
         'accountItemIdList': self.idList
     }
     reportTxt = report.build(params)
     view = CReportViewDialog(self)
     view.setWindowTitle(report.title())
     view.setText(reportTxt)
     return view
Esempio n. 6
0
 def printContent(self, columnRoleList=None, titles=None, fontSize=8, additionalCol=None, additionalColTitle=None):
     if not additionalCol:
         additionalCol = {}
     if not additionalColTitle:
         additionalColTitle = []
     if additionalCol:
         html = self.contentToHTMLWithAnAdditionalColumn(columnRoleList, titles, fontSize, additionalCol, additionalColTitle)
     else:
         html = self.contentToHTML(columnRoleList, titles, fontSize)
     view = CReportViewDialog(self)
     view.setText(html)
     view.exec_()
Esempio n. 7
0
File: MKB.py Progetto: dio4/vista_1
    def on_btnPrintSelected_clicked(self):
        tbl = self.tblItems

        model = tbl.model()

        report = CReportBase()
        doc = QtGui.QTextDocument()
        cursor = QtGui.QTextCursor(doc)

        cursor.setCharFormat(CReportBase.ReportTitle)
        cursor.insertText(u'Коды МКБ X\n')
        cursor.insertBlock()
        cursor.setCharFormat(CReportBase.ReportBody)
        cursor.insertText(tbl.reportDescription())
        cursor.insertBlock()

        cols = model.cols()
        colWidths = [tbl.columnWidth(i) for i in xrange(len(cols))]
        colWidths.insert(0, 10)
        totalWidth = sum(colWidths)
        tableColumns = []
        for iCol, colWidth in enumerate(colWidths):
            widthInPercents = str(max(1, colWidth * 90 / totalWidth)) + '%'
            if iCol == 0:
                tableColumns.append(
                    (widthInPercents, [u'№'], CReportBase.AlignRight))
            else:
                col = cols[iCol - 1]
                colAlingment = QtCore.Qt.AlignHorizontal_Mask & forceInt(
                    col.alignment())
                format = QtGui.QTextBlockFormat()
                format.setAlignment(QtCore.Qt.AlignmentFlag(colAlingment))
                tableColumns.append(
                    (widthInPercents, [forceString(col.title())], format))

        table = createTable(cursor, tableColumns)
        for index in tbl.selectedIndexes():
            iModelRow = index.row()
            if index.column():
                continue
            iTableRow = table.addRow()
            table.setText(iTableRow, 0, iModelRow + 1)
            for iModelCol in xrange(len(cols)):
                index = model.createIndex(iModelRow, iModelCol)
                text = forceString(model.data(index))
                table.setText(iTableRow, iModelCol + 1, text)

        html = doc.toHtml(QtCore.QByteArray('utf-8'))

        view = CReportViewDialog(self)
        view.setText(html)
        view.exec_()
Esempio n. 8
0
    def on_btnPrint_clicked(self):

        def processCallBack(label, step):
            QtGui.qApp.stepProgressBar()
            QtGui.qApp.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)

        errorsMax = 0
        errors = self._getErrors()
        if self.rbGroupByData.isChecked():
            # data = {label1: {keyValue1: [errorCodes1]}, label2: {keyValue2: [errorCodes2]}, ...}
            data = errors
            for keyValues in data.itervalues():
                errorsMax += len(keyValues)
        else:
            # data = {label1: {errorCode1: [keyValues]}, label2: {errorCode2: [keyValues2]}, ...}
            allErrorCodes = set()
            map(lambda errorCodes: allErrorCodes.update(errorCodes),
                [errorCodes for keyValues in errors.itervalues() for errorCodes in keyValues.itervalues()])
            data = {}
            for errorCode in allErrorCodes:
                for label, keyValues in errors.iteritems():
                    for keyValue, errorCodes in keyValues.iteritems():
                        if errorCode in errorCodes:
                            data.setdefault(label, {}).setdefault(errorCode, []).append(keyValue)
            for errorCodes in data.itervalues():
                for keyValues in errorCodes.itervalues():
                    errorsMax += len(keyValues)
        QtGui.qApp.startProgressBar(errorsMax)
        QtGui.qApp.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
        try:
            doc = QtGui.QTextDocument()
            doc.setIndentWidth(doc.indentWidth()/4.0)
            cursor = QtGui.QTextCursor(doc)
            for label in self._orderedLabels:
                if label in data:
                    self._toHtml(label, data[label], cursor, processCallBack=processCallBack)
                elif label == 'U':
                    for label in sorted([label for label in data.iterkeys() if isinstance(label, tuple) and
                                                                               label[0] == 'U'],
                                        key=lambda label: label[1]):
                        doctorInfo = self._getAdditionalInfo('D', 'DOC_TABN', label[1], self._doctorsInfo)
                        self._toHtml(label[0], data[label], cursor, additionalTitle=u'%s: %s %s %s' % (label[1],
                                                                                                       doctorInfo[0],
                                                                                                       doctorInfo[1],
                                                                                                       doctorInfo[2]),
                                     processCallBack=processCallBack)
            view = CReportViewDialog()
            view.setText(doc.toHtml())
            view.exec_()
        finally:
            QtGui.qApp.stopProgressBar()
Esempio n. 9
0
 def on_btnFeedPrint_clicked(self):
     model = self.modelFeed
     doc = QtGui.QTextDocument()
     cursor = QtGui.QTextCursor(doc)
     cursor.setCharFormat(CReportBase.ReportTitle)
     cursor.insertText(u'Питание\n')
     cursor.insertBlock()
     cursor.setCharFormat(CReportBase.ReportBody)
     cursor.insertHtml(u'Пациент: %s' % (getClientString(self.clientId)))
     cursor.setCharFormat(CReportBase.ReportBody)
     cursor.insertBlock()
     cursor.insertText(u'Отчёт составлен: ' +
                       forceString(QtCore.QDateTime.currentDateTime()))
     cursor.insertBlock()
     colWidths = [
         self.tblFeed.columnWidth(i)
         for i in xrange(model.columnCount() - 1)
     ]
     colWidths.insert(0, 10)
     totalWidth = sum(colWidths)
     tableColumns = []
     iColNumber = False
     for iCol, colWidth in enumerate(colWidths):
         widthInPercents = str(max(1, colWidth * 90 / totalWidth)) + '%'
         if not iColNumber:
             tableColumns.append(
                 (widthInPercents, [u'№'], CReportBase.AlignRight))
             iColNumber = True
         headers = model.headers
         tableColumns.append(
             (widthInPercents, [forceString(headers[iCol][1])],
              CReportBase.AlignLeft))
     table = createTable(cursor, tableColumns)
     for iModelRow in xrange(model.rowCount() - 1):
         iTableRow = table.addRow()
         table.setText(iTableRow, 0, iModelRow + 1)
         for iModelCol in xrange(model.columnCount()):
             index = model.createIndex(iModelRow, iModelCol)
             text = forceString(model.data(index))
             table.setText(iTableRow, iModelCol + 1, text)
     html = doc.toHtml(QtCore.QByteArray('utf-8'))
     view = CReportViewDialog(self)
     view.setText(html)
     view.exec_()
Esempio n. 10
0
    def on_btnRadiationDosePrint_clicked(self):
        def formatClientInfo(clientInfo):
            return u'\n'.join([
                u'ФИО: %s' % clientInfo.fullName,
                u'Дата рождения: %s' % clientInfo.birthDate,
                u'Пол: %s' % clientInfo.sex,
                u'Код: %d' % clientInfo.id
            ])

        def formatRadiationDoseSumInfo(radiationDoseSumInfo):
            return '\n'.join([
                '%s: %s' % (key, item)
                for key, item in radiationDoseSumInfo.items() if key != 'total'
            ] + [u'Всего: %s' % radiationDoseSumInfo['total']])

        doc = QtGui.QTextDocument()
        cursor = QtGui.QTextCursor(doc)

        cursor.setCharFormat(CReportBase.ReportTitle)
        cursor.insertText(
            u'Сигнальный лист учета дозы рентгеновского облучения')
        cursor.setCharFormat(CReportBase.TableBody)
        cursor.insertBlock()
        clientInfo = getClientInfoEx(self.clientId)
        cursor.insertText(formatClientInfo(clientInfo))
        cursor.insertBlock()

        tableColumns = [
            ('2%', [u'№'], CReportBase.AlignLeft),
            ('20%', [u'Дата'], CReportBase.AlignLeft),
            ('20%', [u'Вид рентгенологического исследования'],
             CReportBase.AlignLeft),
            ('10%', [u'Количество снимков'], CReportBase.AlignRight),
            ('25%', [u'Суммарная доза облучения'], CReportBase.AlignRight),
        ]
        table = createTable(cursor, tableColumns)

        for idRow, id in enumerate(self.modelRadiationDose.idList()):
            values = [
                idRow + 1,
                forceString(
                    self.modelRadiationDose.data(
                        self.modelRadiationDose.index(
                            idRow,
                            self.modelRadiationDose.columnIndex(
                                u'Дата выполнения')))),
                forceString(
                    self.modelRadiationDose.data(
                        self.modelRadiationDose.index(
                            idRow,
                            self.modelRadiationDose.columnIndex(
                                u'Тип действия')))),
                forceDouble(
                    self.modelRadiationDose.data(
                        self.modelRadiationDose.index(
                            idRow,
                            self.modelRadiationDose.columnIndex(
                                u'Количество')))),
                forceDouble(
                    self.modelRadiationDose.data(
                        self.modelRadiationDose.index(
                            idRow,
                            self.modelRadiationDose.columnIndex(u'Доза'))))
            ]

            i = table.addRow()
            for column, value in enumerate(values):
                table.setText(i, column, value)

        i = table.addRow()
        table.setText(i, 0, u'Итого')
        table.setText(i, 3, self.modelRadiationDose.actionsSum())
        table.setText(
            i, 4,
            formatRadiationDoseSumInfo(
                self.modelRadiationDose.radiationDoseSum()))

        cursor.movePosition(QtGui.QTextCursor.End)

        result = '          '.join([
            '\n\n\n' + forceString(QtCore.QDate.currentDate()),
            u'ФИО: %s' % clientInfo.fullName
        ])
        cursor.insertText(result)
        cursor.insertBlock()

        view = CReportViewDialog(self)
        view.setText(doc)
        view.exec_()
Esempio n. 11
0
 def on_btnPrint_clicked(self):
     html = self.contentToHTML()
     view = CReportViewDialog(self)
     view.setText(html)
     view.exec_()
Esempio n. 12
0
 def getView(self, report, parent):
     view = CReportViewDialog(parent)
     view.setWindowTitle(u'Справка о стоимости лечения')
     view.setText(report)
     return view
Esempio n. 13
0
def showMesDescription(widget, mesId):
    view = CReportViewDialog(widget)
    view.setWindowTitle(u'МЭС')
    view.setText(getMesDescription(mesId))
    view.showMaximized()
    view.exec_()
Esempio n. 14
0
def buildReport():
    dialog = CAccount()
    dialog.setTitle(u'Сводный реестр услуг')
    if dialog.exec_():
        report = CAccountRegistry(None, True)
        params = dialog.params()
        financeDict = params.get('finance', None)
        financeList = financeDict.keys()
        reportTxt = report.build(
            u'типы финансирования: ' +
            ', '.join([forceString(financeDict[key]) for key in financeList]),
            params)
        view = CReportViewDialog()
        view.setWindowTitle(report.title())
        view.setText(reportTxt)
        view.setQueryText(report.queryText)
        view.setRepeatButtonVisible(True, buildReport)
        view.exec_()
Esempio n. 15
0
    def printHistory(self):
        def isLastInBlock(valueIdx, valueRowIdx, valuesCount, valueRowsCount):
            return (valueIdx == (valuesCount -
                                 1)) and (valueRowIdx == (valueRowsCount - 1))

        self.printRowShift = 1
        title = u'Стоматологическая история пациента'
        model = self.model()
        items = list(model.items())
        items.reverse()
        if not items:
            return
        lastDentitionTeeth = self.getLastDentitionTeeth(items)
        teethAdditional = [('4.8%', [u''], CReportBase.AlignLeft)
                           for col in lastDentitionTeeth[0:16]]
        tableColumns = [('3%', [u'№'], CReportBase.AlignLeft),
                        ('10%', [u'Дата'], CReportBase.AlignLeft),
                        ('10%', [u'Тип свойства'], CReportBase.AlignLeft)
                        ] + teethAdditional

        doc = QtGui.QTextDocument()
        cursor = QtGui.QTextCursor(doc)
        cursor.setCharFormat(CReportBase.ReportTitle)
        cursor.insertText(title)
        cursor.insertBlock()
        cursor.setCharFormat(CReportBase.ReportSubTitle)
        cursor.insertText(self.getSubTitle())
        cursor.insertBlock()
        table = createTable(cursor, tableColumns)

        lenItems = len(items)
        for iRow, dentition in enumerate(items):
            record, action, actionId, eventId, isChecked = dentition
            if isChecked:
                if action.getType().flatCode == u'dentitionInspection':
                    teethNumber, teethStatusTop, teethStatusLower, teethStateTop, teethStateLower, teethMobilityTop, teethMobilityLower = self.getTeethValues(
                        action)
                    valueRowList = ((teethStatusTop, u'Статус'),
                                    (teethMobilityTop, u'Подвижность'),
                                    (teethStateTop, u'Состояние'),
                                    (teethNumber, u'Номер'), (teethStateLower,
                                                              u'Состояние'),
                                    (teethMobilityLower, u'Подвижность'),
                                    (teethStatusLower, u'Статус'))
                elif action.getType().flatCode == u'parodentInsp':
                    teethNumber, cunealDefectTop, cunealDefectLower, recessionTop, recessionLower, mobilityTop, mobilityLower, pocketDepthTop, pocketDepthLower = self.getParodentTeethValues(
                        action)
                    valueRowList = ((cunealDefectTop, u'Клиновидный дефект'),
                                    (recessionTop, u'Рецессия'),
                                    (mobilityTop, u'Подвижность'),
                                    (pocketDepthTop,
                                     u'Глубина кармана'), (teethNumber,
                                                           u'Номер'),
                                    (pocketDepthLower,
                                     u'Глубина кармана'), (mobilityLower,
                                                           u'Подвижность'),
                                    (recessionLower,
                                     u'Рецессия'), (cunealDefectLower,
                                                    u'Клиновидный дефект'))
                values = [(record, 'begDate', u'Осмотр', dentition,
                           valueRowList)]
                i = table.addRow()
                begMergeRow = i
                for valueIdx, (record, dateField, dentitionTypeName,
                               dentitionItem, valueRows) in enumerate(values):
                    i, lastDentitionTeeth = self.checkDentitionEquals(
                        lastDentitionTeeth, dentitionItem, table, i)
                    table.setText(i, 0, iRow + 1)
                    if record:
                        date = forceDate(record.value(dateField))
                        dateText = (
                            forceString(date) + '\n' +
                            dentitionTypeName) if date.isValid() else u''
                        table.setText(i, 1, dateText)
                    for valueRowIdx, (valueRow,
                                      rowName) in enumerate(valueRows):
                        self.addRowValues(rowName, table, valueRow, i,
                                          len(values), valueRowIdx)
                        if not isLastInBlock(valueIdx, valueRowIdx,
                                             len(values), len(valueRows)):
                            i = table.addRow()
                table.mergeCells(begMergeRow, 0, len(valueRowList), 1)
                table.mergeCells(begMergeRow, 1, len(valueRowList), 1)
                if iRow + 1 != lenItems:
                    i = table.addRow()
                    table.mergeCells(i, 0, 1, len(tableColumns))

        cursor.movePosition(QtGui.QTextCursor.End)
        cursor.insertText(self.getResult())
        cursor.insertBlock()

        viewDialog = CReportViewDialog(self)
        viewDialog.setWindowTitle(title)
        viewDialog.setRepeatButtonVisible()
        viewDialog.setText(doc)
        viewDialog.buttonBox.removeButton(
            viewDialog.buttonBox.button(QtGui.QDialogButtonBox.Retry))
        viewDialog.setWindowState(QtCore.Qt.WindowMaximized)
        viewDialog.exec_()
Esempio n. 16
0
def showHtml(widget, name, content, canvases, pageFormat):
    reportView = CReportViewDialog(widget)
    reportView.setWindowTitle(name)
    reportView.setText(content)
    reportView.setCanvases(canvases)
    reportView.setPageFormat(pageFormat)
    reportView.exec_()