Beispiel #1
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_()
Beispiel #2
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_()