示例#1
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(
         CRBInDocTableCol(u'Подразделение',
                          'orgStructure_id',
                          50,
                          'OrgStructure',
                          showFields=CRBComboBox.showCode))
     self.addCol(
         CNomenclatureInDocTableCol(u'ЛСиИМН',
                                    'nomenclature_id',
                                    50,
                                    showFields=CRBComboBox.showName))
     self.addCol(CInDocTableCol(u'Партия', 'batch', 16))
     self.addCol(
         CDateInDocTableCol(u'Годен до', 'shelfTime', 12, canBeEmpty=True))
     self.addCol(
         CRBInDocTableCol(u'Тип финансирования', 'finance_id', 15,
                          'rbFinance'))
     self.addCol(CFloatInDocTableCol(u'Кол-во', 'qnt', 12))
     self.addCol(CFloatInDocTableCol(u'Сумма', 'sum', 12))
     self.addCol(
         CFloatInDocTableCol(u'Гантированный запас', 'constrainedQnt', 12))
     self.addCol(CFloatInDocTableCol(u'Точка заказа', 'orderQnt', 12))
     self._cachedRow = None
     self._cachedRowColor = None
示例#2
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CRBInDocTableCol(u'Отделение', 'orgStructure_id', 300, 'OrgStructure'))
     self.addCol(CEnumInDocTableCol(u'Тип', 'type', 80, [u'формуляр отделения', u'формуляр расходных материалов', u'формуляр дезсредств', u'формуляр реактивов']))
     self.addCol(CInDocTableCol(u'Дата начала', 'begDate', 70))
     self.addCol(CInDocTableCol(u'Дата окончания', 'endDate', 70))
     self.addCol(CBoolInDocTableCol(u'Активен', 'isActive', 20))
示例#3
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CRBInDocTableCol(u'Событие',            'eventType_id',  30, 'EventType')).setSortable(True)
     self.addCol(CEnumInDocTableCol(u'Тарифицируется',   'tariffType',     5, CTariffModel.tariffTypeNames)).setSortable(True)
     self.addCol(CRBInDocTableCol(u'Услуга',             'service_id',    30, 'rbService')).setSortable(True)
     self.addCol(CRBInDocTableCol(u'Специальность', 'speciality_id',   30,  'rbSpeciality')).setSortable(True)
     self.addCol(CRBInDocTableCol(u'Тарифная категория', 'tariffCategory_id',    30, 'rbTariffCategory')).setSortable(True)
     self.addCol(CInDocTableCol(u'Код по МКБ',           'MKB',           8)).setSortable(True)
     self.addCol(CDateInDocTableCol(u'Дата начала',      'begDate',      10, canBeEmpty=True)).setSortable(True)
     self.addCol(CDateInDocTableCol(u'Дата окончания',   'endDate',      10, canBeEmpty=True)).setSortable(True)
     self.addCol(CEnumInDocTableCol(u'Пол',              'sex',           3, [u'', u'М', u'Ж']))
     self.addCol(CInDocTableCol(u'Возраст',              'age',           8))
     self.addCol(CRBInDocTableCol(u'Тип',                'attachType_id', 30, 'rbAttachType'))
     self.addCol(CPolyclinicInDocTableCol(u'ЛПУ',        'attachLPU_id',       15))
     self.addCol(CRBInDocTableCol(u'Ед.Уч.',             'unit_id',       8, 'rbMedicalAidUnit'))
     self.addCol(CFloatInDocTableCol(u'Кол-во',          'amount',        8))
     self.addCol(CFloatInDocTableCol(u'УЕТ',             'uet',           4, precision=2))
     self.addCol(CFloatInDocTableCol(u'Цена',            'price',         8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Второй тариф с',  'frag1Start', 8, precision=0))
     self.addCol(CFloatInDocTableCol(u'Сумма второго тарифа', 'frag1Sum',   8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Цена второго тарифа',  'frag1Price',  8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Третий тариф с',  'frag2Start', 8, precision=0))
     self.addCol(CFloatInDocTableCol(u'Сумма третьего тарифа', 'frag2Sum',   8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Цена третьего тарифа',  'frag2Price',  8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Фед.цена',        'federalPrice',        8, precision=2))
     self.addCol(CFloatInDocTableCol(u'Фед.предел',      'federalLimitation',   8))
     self.addCol(CEnumInDocTableCol(u'НДС',              'vat',  8, CTariffModel.vat, precision=2))
     self.parent = parent
     self.table = QtGui.qApp.db.table('Contract_Tariff')
示例#4
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addExtCol(
         CNomenclatureInDocTableCol(u'ЛСиИМН',
                                    'id',
                                    50,
                                    showFields=CRBComboBox.showName),
         QtCore.QVariant.Int)
     self.masterId = None  # в rbNomenclature
     self.analogId = None  # в rbNomenclature_analog
示例#5
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CBoolInDocTableCol(u'Отметка', 'status', 6))
     self.addCol(
         CDateTimeInDocTableCol(u'Дата и время приема', 'directionDate',
                                20)).setReadOnly()
     self.addCol(CInDocTableCol(u'Каб', 'office', 6)).setReadOnly()
     self.addCol(
         CRBInDocTableCol(u'Специалист', 'person_id', 20,
                          'vrbPersonWithSpeciality')).setReadOnly()
     self.addCol(
         CRBInDocTableCol(u'Записал', 'setPerson_id', 20,
                          'vrbPersonWithSpeciality')).setReadOnly()
     self.addCol(CInDocTableCol(u'Примечания', 'note', 6)).setReadOnly()
示例#6
0
 def setData(self, index, value, role=QtCore.Qt.EditRole):
     if role == QtCore.Qt.EditRole:
         column = index.column()
         if column == self.getColIndex('id'):
             id  = forceRef(value)
             row = index.row()
             record = self._mapProbeId2Record[id]
             if id:
                 record.setValue('placeInTripod', QtCore.QVariant(row+1))
                 record.setValue('tripodNumber',  QtCore.QVariant(self._tripodNumber+1))
             self._items[row] = record
             self._mapTripodNumberToItems[self._tripodNumber][row] = record
             self.emitCellChanged(row, column)
             return True
     CRecordListModel.setData(self, index, value, role)
示例#7
0
 def setEditorData(self, index, editor, value, record):
     column = index.column()
     if column in self._propertyColsIndexes:
         return self.setPropertyEditorData(index, editor, value, record)
     else:
         return CRecordListModel.setEditorData(self, column, editor, value,
                                               record)
示例#8
0
    def setData(self, index, value, role=QtCore.Qt.EditRole):
        column = index.column()
        row = index.row()
        if role == QtCore.Qt.CheckStateRole and column == self.getColIndex(
                'checked'):
            record = self._items[row]
            actionTypeId = forceRef(record.value('actionType_id'))
            self.parentWidget.setSelected(actionTypeId,
                                          forceInt(value) == QtCore.Qt.Checked,
                                          resetMainModel=True)
            return False
        result = CRecordListModel.setData(self, index, value, role)

        col = self.cols()[column]
        fieldName = col.fieldName()

        if fieldName == 'finance_id':
            self.initContract(row)
            self.updatePricesAndSums(row, row)
        elif fieldName == 'contract_id':
            self.updatePricesAndSums(row, row)
        elif fieldName == 'amount':
            self.updatePricesAndSums(row, row)
            if self.isRowDpedBegDatePlusAmount(row):
                self.updatePlannedEndDate(row)
        elif fieldName == 'duration':
            self.updatePlannedEndDate(row)
        elif fieldName == 'begDate' and not self.isRowPlanEndDateEdited(row):
            self.updatePlannedEndDate(row)

        return result
示例#9
0
    def __init__(self, parent, equipmentId, tripodCount):
        CRecordListModel.__init__(self, parent)
        self.addCol(CLoadingProbeModel.CLocInDocProbeCol(self))

        self._parent = parent
        self._equipmentId = equipmentId
        self._tripodCapacity = forceInt(QtGui.qApp.db.translate('rbEquipment', 'id', equipmentId, 'tripodCapacity'))
        self._tripodCount = tripodCount
        self._tripodNumber = 0

        self._probeIdList = []
        self._existsProbeIdList = []
        self._mapProbeId2Record = {None: QtSql.QSqlRecord()}
        self._mapCurrentProbeId2Record = {None: QtSql.QSqlRecord()}
        self._mapTripodNumberToItems = {}

        self.buildItemsCache()
示例#10
0
    def __init__(self, parent, existsActionTypeIdList=None):
        if not existsActionTypeIdList:
            existsActionTypeIdList = []
        CRecordListModel.__init__(self, parent)
        self.addCol(CBoolInDocTableCol(u'Включить', 'checked', 10))
        self.addCol(
            CRBInDocTableCol(u'Тип действия',
                             'actionType_id',
                             14,
                             'ActionType',
                             showFields=2).setReadOnly())
        self.addCol(
            CFloatInDocTableCol(u'Количество', 'amount', 12, precision=2))
        #        self.addCol(CIntInDocTableCol(  u'Группа выбора', 'selectionGroup', 12).setReadOnly())

        self._existsActionTypeIdList = existsActionTypeIdList

        self._cacheItemsByGroup = {}
示例#11
0
 def setData(self, index, value, role=QtCore.Qt.EditRole):
     if role == QtCore.Qt.CheckStateRole and forceBool(value):
         row = index.row()
         item = self._items[row]
         selectionGroup = forceInt(item.value('selectionGroup'))
         if selectionGroup > 1:
             groupItemList = self._cacheItemsByGroup.get(selectionGroup, [])
             for item in groupItemList:
                 item.setValue('checked', QtCore.QVariant(False))
             self.emitColumnChanged(self.getColIndex('checked'))
     return CRecordListModel.setData(self, index, value, role)
示例#12
0
 def __init__(self, parent):
     CRecordListModel.__init__(
         self,
         parent,
         cols=[
             CInDocTableCol(u'client_id',
                            'client_id',
                            10,
                            valueType=QtCore.QVariant.Int,
                            readOnly=True),
             CInDocTableCol(u'event_id',
                            'event_id',
                            10,
                            valueType=QtCore.QVariant.Int,
                            readOnly=True),
             CInDocTableCol(u'Текст ошибки',
                            'error_stmt',
                            20,
                            valueType=QtCore.QVariant.String,
                            readOnly=True)
         ])
示例#13
0
 def flags(self, index):
     flags = CRecordListModel.flags(self, index)
     column = index.column()
     if column in [
             self.getColIndex('packPurchasePrice'),
             self.getColIndex('doseRatePrice')
     ]:
         row = index.row()
         record = self._items[row]
         if forceRef(record.value(
                 'actionType_id')) not in self._parent.medicamentList:
             flags = flags & (~QtCore.Qt.ItemIsEditable)
     return flags
示例#14
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addHiddenCol('localId')
     self.addCol(CFormularyInDocTableCol(u'Препарат', 'drugItem_id',
                                         50))  # 0
     self.addCol(CInDocTableCol(u'Доза', 'drugDose', 15))  # 1
     self.addCol(
         CRBInDocTableCol(u'Ед. изм.', 'drugMeasureUnit_id', 14,
                          'rbUnit'))  # 2
     self.addCol(
         CRBInDocTableCol(u'Путь\nвведения', 'drugRouteId', 20,
                          'rbRoute'))  # 3
     self.addCol(
         CTakeDosesInDocTableCol(u'Время\nприёма', 'receivingTime', 100,
                                 parent))  # 4!
     self.addCol(
         CEnumInDocTableCol(
             u'Интервал', 'interval', 40,
             [u'ежедневно', u'через день', u'раз в два дня']))  #5!
     self.addCol(CDateInDocTableCol(u'Дата\nначала', 'takeDateBegin',
                                    40))  # 6
     self.addCol(CDateInDocTableCol(u'Дата\nокончания', 'takeDateEnd',
                                    40))  # 7
     self.addCol(CInDocTableCol(u'Коментарий', 'drugComment', 20))  # 8
     self.addCol(
         CEnumInDocTableCol(u'Статус', 'drugStatus', 20, [
             u'новый', u'создано', u'назначено', u'сделан запрос',
             u'к выполнению', u'выполнено', u'не выполнено', u'отменено'
         ]).setReadOnly(True))  # 9
     self.addHiddenCol('takeDose')
     self.addHiddenCol('takeDate')
     self.addHiddenCol('takeTime')
     self.addHiddenCol('takeComment')
     self.addHiddenCol('actionParentId')
     self.addHiddenCol('rlsCode')
     self.setDirty(False)
     self.eventEditor = parent
     self._cachedRowColor = None
示例#15
0
 def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
     if orientation == QtCore.Qt.Horizontal:
         if role == QtCore.Qt.ToolTipRole:
             if section == self.getColIndex('duration'):
                 return QtCore.QVariant(
                     u'Длительность курса лечения в днях.')
             elif section == self.getColIndex('periodicity'):
                 result = '\n'.join([
                     u'0 - каждый день,', u'1 - через 1 день,',
                     u'2 - через 2 дня,', u'3 - через 3 дня,', u'и т.д.'
                 ])
                 return QtCore.QVariant(result)
             elif section == self.getColIndex('aliquoticity'):
                 return QtCore.QVariant(u'Сколько раз в сутки.')
     return CRecordListModel.headerData(self, section, orientation, role)
示例#16
0
 def data(self, index, role=QtCore.Qt.DisplayRole):
     row = index.row()
     column = index.column()
     if role == QtCore.Qt.DisplayRole and column == 8:
         comment = forceString(self._items[row].value('drugComment'))
         if comment:
             comment = u'Для аптеки: ' + comment
         rlsCode = forceInt(self._items[row].value('rlsCode'))
         if rlsCode > 0:
             rlsCodeRecord = QtGui.qApp.db.getRecordEx(
                 'rbRLS', 'name', 'code=%s' % rlsCode)
             if rlsCodeRecord:
                 rlsCode = forceString(rlsCodeRecord.value('name'))
                 if rlsCode:
                     if comment:
                         comment += '; '
                     comment += u'Рекомендованный препарат: ' + rlsCode
         return toVariant(comment)
     elif role == QtCore.Qt.BackgroundRole:
         return toVariant(self.getRowColor(row))
     elif role == QtCore.Qt.ToolTipRole:
         return CRecordListModel.data(self, index, Qt.DisplayRole)
     else:
         return CRecordListModel.data(self, index, role)
示例#17
0
 def setData(self, index, value, role=QtCore.Qt.EditRole):
     if role == QtCore.Qt.EditRole:
         id = forceRef(value)
         if not id:  # не добавляем пустую строку
             return False
         idlist = self.getIdList()
         if id in idlist:  # не добавляем повторы
             return False
         result = CRecordListModel.setData(self, index, value, role)
         if not result:
             return False
         # добавляем аналоги только что указанного
         idlist.append(id)
         db = QtGui.qApp.db
         table = db.table('rbNomenclature')
         newAnalogId = db.translate(table, 'id', value, 'analog_id')
         if newAnalogId:
             row = index.row() + 1
             for record in self.getAnalogies(idlist, newAnalogId):
                 self.insertRecord(row, record)
                 row += 1
         return True
     else:
         return CRecordListModel.setData(self, index, value, role)
示例#18
0
    def data(self, index, role=QtCore.Qt.DisplayRole):
        column = index.column()
        row = index.row()
        if role == QtCore.Qt.DisplayRole:
            if column == 0:
                return QtCore.QVariant(row + 1)

            elif column == self.getColIndex('actionType_id'):
                record = self._items[row]
                outName = forceString(record.value('specifiedName'))
                actionTypeId = forceRef(record.value('actionType_id'))
                if actionTypeId:
                    actionType = CActionTypeCache.getById(actionTypeId)
                    if actionType:
                        outName = actionType.name + ' ' + outName if outName else actionType.name
                    return QtCore.QVariant(outName)

            elif column in self._propertyColsIndexes:
                record = self._items[row]
                actionTypeId = forceRef(record.value('actionType_id'))
                values = self._mapActionTypeIdToPropertyValues.get(
                    actionTypeId, None)
                if values:
                    fieldName = self._cols[column].fieldName()
                    cellValues = values.get(fieldName, None)
                    if cellValues:
                        action = self._idToAction[actionTypeId]
                        propertyType = cellValues['propertyType']
                        prop = action.getPropertyById(propertyType.id)
                        return toVariant(prop.getText())

        elif role == QtCore.Qt.FontRole:
            record = self._items[row]
            actionTypeId = forceRef(record.value('actionType_id'))
            if self._existsActionsModel.hasActionTypeId(
                    actionTypeId
            ) or actionTypeId in self._mainActionTypesAnalyses:
                return self._qBoldFont

        return CRecordListModel.data(self, index, role)
示例#19
0
    def data(self, index, role=QtCore.Qt.DisplayRole):
        if index.column() == 0 and role == QtCore.Qt.CheckStateRole:
            row = index.row()
            item = self.items()[row]
            status = forceInt(item.value('status'))
            return toVariant(QtCore.Qt.Checked if status ==
                             0 else QtCore.Qt.Unchecked)
        elif role == QtCore.Qt.ToolTipRole:
            row = index.row()
            item = self.items()[row]
            reason = forceString(item.value('reason'))
            if reason:
                return toVariant(reason)
        elif role == QtCore.Qt.FontRole:
            row = index.row()
            item = self.items()[row]
            reason = forceString(item.value('reason'))
            if reason:
                font = QtGui.QFont()
                font.setBold(True)
                return toVariant(font)

        else:
            return CRecordListModel.data(self, index, role)
示例#20
0
 def data(self, index, role=QtCore.Qt.DisplayRole):
     if role == QtCore.Qt.ForegroundRole:
         row = index.row()
         return toVariant(self.getRowColor(row))
     else:
         return CRecordListModel.data(self, index, role)
示例#21
0
    def __init__(self, parent, existsActionsModel):
        CRecordListModel.__init__(self, parent)
        currentDateDict = {'currentDate': True}
        self.addExtCol(CInDocTableCol(u'№', '__serialNumber', 5),
                       QtCore.QVariant.Int)
        self.addExtCol(CCheckedActionsModel.CLocEnableCol(parent),
                       QtCore.QVariant.Bool)
        self.addExtCol(
            CRBInDocTableCol(u'Действие',
                             'actionType_id',
                             15,
                             'ActionType',
                             showFields=2).setReadOnly(), QtCore.QVariant.Int)
        self.addExtCol(
            CCheckedActionsModel.CLocDateTimeInDocTableCol(
                u'Назначить', 'directionDate', 10), QtCore.QVariant.DateTime)
        self.addExtCol(
            CCheckedActionsModel.CLocDateTimeInDocTableCol(
                u'Начать', 'begDate', 10), QtCore.QVariant.DateTime)
        self.addExtCol(
            CCheckedActionsModel.CLocDateTimeInDocTableCol(
                u'Выполнено', 'endDate', 10, **currentDateDict),
            QtCore.QVariant.DateTime)
        self.addExtCol(
            CPersonFindInDocTableCol(u'Врач',
                                     'person_id',
                                     10,
                                     'vrbPersonWithSpeciality',
                                     parent=parent), QtCore.QVariant.Int)
        self.addExtCol(
            CFloatInDocTableCol(u'Количество', 'amount', 10, precision=2),
            QtCore.QVariant.Double)
        self.addExtCol(
            CFloatInDocTableCol(u'ЧП', 'necessity', 10, precision=2),
            QtCore.QVariant.Double)
        self.addExtCol(CIntInDocTableCol(u'Длительность', 'duration', 10),
                       QtCore.QVariant.Int)
        self.addExtCol(CIntInDocTableCol(u'Интервал', 'periodicity', 10),
                       QtCore.QVariant.Int)
        self.addExtCol(CIntInDocTableCol(u'Кратность', 'aliquoticity', 10),
                       QtCore.QVariant.Int)
        self.addExtCol(CDateInDocTableCol(u'План', 'plannedEndDate', 10),
                       QtCore.QVariant.Date)
        self.addExtCol(
            CRBInDocTableCol(u'Тип финансирования',
                             'finance_id',
                             10,
                             'rbFinance',
                             showFields=2), QtCore.QVariant.Int)
        self.addExtCol(CCheckedActionsModel.CContractInDocTableCol(self),
                       QtCore.QVariant.Int)
        self.addExtCol(CFloatInDocTableCol(u'Сумма', 'price', 10, precision=2),
                       QtCore.QVariant.Double)
        self.addExtCol(
            CFloatInDocTableCol(u'Закупочная стоимость упаковки',
                                'packPurchasePrice',
                                10,
                                precision=2), QtCore.QVariant.Double)
        self.addExtCol(
            CFloatInDocTableCol(u'Стоимость курсовой дозы',
                                'doseRatePrice',
                                10,
                                precision=2), QtCore.QVariant.Double)
        self.addHiddenCol('parent_id')

        self._existsActionsModel = existsActionsModel
        self.clientId = None
        self.defaultFinanceId = None
        self.defaultContractFilterPart = None
        self._idToRow = {}
        self.parentWidget = parent
        self._table = QtGui.qApp.db.table('Action')
        self._dbFieldNamesList = [
            field.fieldName.replace('`', '') for field in self._table.fields
        ]
        self.prices = []
        self._mapPropertyTypeCellsActivity = {}
        self._propertyColsNames = ['recipe', 'doses', 'signa']
        self._propertyColsIndexes = [
            self.getColIndex(name) for name in self._propertyColsNames
        ]
        self._mapActionTypeIdToPropertyValues = {}
        self._idToAction = {}
        self._parent = parent
        self._mainActionTypesAnalyses = set(getMainActionTypesAnalyses())

        boldFont = QtGui.QFont()
        boldFont.setWeight(QtGui.QFont.Bold)
        self._qBoldFont = QtCore.QVariant(boldFont)
示例#22
0
    def setData(self, index, value, role=Qt.EditRole):
        column = index.column()
        row = index.row()
        if role == Qt.EditRole:
            if row == len(self._items):
                if value.isNull():
                    return False

            if column == self.getColIndex('actionType_id'):
                db = QtGui.qApp.db
                actionTypeId = forceRef(value)

                for r in range(self.rowCount() - 1):
                    record = self._items[r]
                    otherActionTypeId = forceRef(record.value('actionType_id'))
                    otherActionExpireDate = forceDate(
                        record.value('expireDate'))
                    otherActionAmountLeft = forceDouble(
                        record.value('amount_left'))
                    otherPerson2Id = forceRef(record.value('person2_id'))
                    currentDate = QtCore.QDate.currentDate()
                    if actionTypeId == otherActionTypeId and currentDate <= otherActionExpireDate and otherActionAmountLeft > 0.0 and not otherPerson2Id:
                        person = forceString(
                            db.translate('vrbPerson', 'id',
                                         record.value('person_id'), 'name'))
                        date = forceString(record.value('setDate'))
                        currentActionTypeId = self._items[row].value(
                            'actionType_id')
                        actionCode = forceString(
                            db.translate('ActionType', 'id', actionTypeId,
                                         'code'))
                        actionName = forceString(
                            db.translate('ActionType', 'id', actionTypeId,
                                         'name'))
                        if currentActionTypeId != actionTypeId:
                            QtGui.QMessageBox.warning(
                                None,  #TODO: mdldml: неплохо бы получить виджет-предок, amirite?
                                u'Внимание!',
                                u'Услуга ' + actionCode + u'|' + actionName +
                                u' была рекомендована врачом ' + person +
                                u' и ' + date,
                                QtGui.QMessageBox.Close)
                        return False

                stmt = u'''
                    SELECT
                        Recommendation.setDate AS date,
                        vrbPerson.name AS person
                    FROM
                        Recommendation
                        INNER JOIN vrbPerson ON Recommendation.person_id = vrbPerson.id
                        INNER JOIN Event ON Recommendation.setEvent_id = Event.id
                        INNER JOIN ActionType ON Recommendation.actionType_id = ActionType.id
                    WHERE
                        Event.client_id = %s
                        AND Recommendation.deleted = 0
                        AND Recommendation.actionType_id = %s
                        AND Recommendation.amount_left > 0.0
                        AND Recommendation.person2_id IS NULL
                        AND DATE(NOW()) <= Recommendation.expireDate
                    LIMIT 1
                '''
                query = db.query(stmt % (self.clientId, forceString(value)))
                if query.next():
                    record = query.record()
                    person = forceString(record.value('person'))
                    date = forceString(record.value('date'))
                    currentActionTypeId = self._items[row].value(
                        'actionType_id') if row < len(self._items) else None
                    if currentActionTypeId != actionTypeId:
                        actionCode = forceString(
                            db.translate('ActionType', 'id', actionTypeId,
                                         'code'))
                        actionName = forceString(
                            db.translate('ActionType', 'id', actionTypeId,
                                         'name'))
                        QtGui.QMessageBox.warning(
                            None, u'Внимание!',
                            u'Услуга ' + actionCode + u'|' + actionName +
                            u' была рекомендована врачом ' + person + u' и ' +
                            date, QtGui.QMessageBox.Close)
                    return False

                if row == len(self._items):
                    self._items.append(self.getEmptyRecord(actionTypeId))
                    count = len(self._items)
                    rootIndex = QModelIndex()
                    self.beginInsertRows(rootIndex, count, count)
                    self.insertRows(count, 1, rootIndex)
                    self.endInsertRows()
                record = self._items[
                    row]  #todo: заменить на getEmptyRecord или проставить все изменившиеся поля, потому что amount и expirePeriod зависят от actionType_id
                col = self._cols[column]
                record.setValue(col.fieldName(), value)
                self.emitCellChanged(row, column)
                return True

            elif column == self.getColIndex('amount'):
                result = CRecordListModel.setData(self, index, value, role)
                if result:
                    record = self._items[row]
                    record.setValue('amount_left', record.value('amount'))
                return result

        return CRecordListModel.setData(self, index, value, role)
示例#23
0
 def createEditor(self, index, parent):
     column = index.column()
     if column in self._propertyColsIndexes:
         return self.createPropertyEditor(index, parent)
     else:
         return CRecordListModel.createEditor(self, column, parent)
示例#24
0
文件: ICDTree.py 项目: dio4/vista_1
 def __init__(self, parent=None):
     CRecordListModel.__init__(self, parent)
     self.addExtCol(CInDocTableCol(u'Код', 'DiagID', 40).setReadOnly(), QtCore.QVariant.String)
     self.addExtCol(CInDocTableCol(u'Наименование', 'DiagName', 40).setReadOnly(), QtCore.QVariant.String)
     self.table = QtGui.qApp.db.table('MKB_Tree')
示例#25
0
 def getEditorData(self, index, editor):
     column = index.column()
     if column in self._propertyColsIndexes:
         return self.getPropertyEditorData(index, editor)
     else:
         return CRecordListModel.getEditorData(self, column, editor)
示例#26
0
 def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
     if orientation == QtCore.Qt.Vertical:
         if role == QtCore.Qt.DisplayRole:
             return QtCore.QVariant(section+1)
     return CRecordListModel.headerData(self, section, orientation, role)
示例#27
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CInDocTableCol(u'МНН', 'mnn', 70))
示例#28
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CInDocTableCol(u'Форма выпуска', 'issueForm', 70))
示例#29
0
 def getEmptyRecord(self):
     record = CRecordListModel.getEmptyRecord(self)
     record.append(QtSql.QSqlField('id', QtCore.QVariant.Int))
     return record
示例#30
0
 def __init__(self, parent):
     CRecordListModel.__init__(self, parent)
     self.addCol(CFormularyItemInDocTableCol(u'Наименование', 'drug_id', 400, order='name ASC')).setValueType(QVariant.Int)
     self.addCol(CInDocTableCol(u'Запас', 'limit', 100)).setValueType(QVariant.Double)