Example #1
0
 def _setIdList(self, idList):
     db = QtGui.qApp.db
     self._idList = idList[:]
     self._items = [
         self.getInstance(CActionTypeInfo, CActionTypeCache.getById(id))
         for id in self._idList
     ]
Example #2
0
 def getPropertyTypeCellsSettings(self, actionTypeId, row):
     cellSettings = {}
     actionType = CActionTypeCache.getById(actionTypeId)
     for propertyType in actionType.getPropertiesById().values():
         if propertyType.inActionsSelectionTable:
             column = self._propertyColsIndexes[
                 propertyType.inActionsSelectionTable - 1]
             result = self._mapPropertyTypeCellsActivity.get((row, column),
                                                             None)
             if result is None:
                 self._cols[column].setValueType(
                     propertyType.valueType.variantType)
                 self._mapPropertyTypeCellsActivity[(row, column)] = True
                 cellName = self._propertyColsNames[
                     propertyType.inActionsSelectionTable - 1]
                 cellSettings[cellName] = True
                 values = self._mapActionTypeIdToPropertyValues.get(
                     actionTypeId, None)
                 if values is None:
                     values = {
                         cellName: {
                             'propertyType': propertyType,
                             'value': QtCore.QVariant()
                         }
                     }
                     self._mapActionTypeIdToPropertyValues[
                         actionTypeId] = values
                 else:
                     values[cellName] = {
                         'propertyType': propertyType,
                         'value': QtCore.QVariant()
                     }
     return cellSettings
Example #3
0
 def format(self, values):
     val = values[0]
     actionTypeId = self.getActionTypeId(forceRef(val))
     if actionTypeId:
         actionType = CActionTypeCache.getById(actionTypeId)
         if actionType:
             return QtCore.QVariant(actionType.code + ' | ' +
                                    actionType.name)
     return QtCore.QVariant()
Example #4
0
 def __init__(self, parent=None):
     QtGui.QDialog.__init__(self, parent)
     self.setupUi(self)
     self.setBusynessEnabled(False)
     self.setMKBFilterEnabled(False)
     try:
         actionType = CActionTypeCache.getByFlatCode('deathCurcumstance')
     except:
         actionType = None
     self.preparePropertyComboBox(self.cmbPlace, actionType, u'Смерть последовала')
     self.preparePropertyComboBox(self.cmbCause, actionType, u'Смерть произошла')
     self.preparePropertyComboBox(self.cmbFoundBy,    actionType, u'Причина установлена')
     self.preparePropertyComboBox(self.cmbFoundation, actionType, u'Основание')
     self.cmbSocStatusType.setTable('vrbSocStatusType', True)
     self.cmbSocStatusType.setShowFields(CRBComboBox.showNameAndCode)
Example #5
0
    def data(self, index, role=QtCore.Qt.DisplayRole):
        row, column = index.row(), index.column()
        if 0 <= row < len(self._items):
            item = self.getItemByRow(row)
            record, action = item

            if role == QtCore.Qt.EditRole:
                return record.value('actionType_id')

            elif role == QtCore.Qt.DisplayRole:
                if column == 0:
                    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
                        if not self.isMainActionType(actionTypeId):
                            outName = ' ' * 10 + outName
                    return QtCore.QVariant(outName)

                elif column == 1:
                    if action in self.getMainActions():
                        return toVariant(
                            forceDate(record.value('directionDate')))
                    elif self.orderByDirectionDate:
                        return toVariant(
                            forceString(record.value('importDate')))

            elif role in (QtCore.Qt.StatusTipRole, QtCore.Qt.ToolTipRole):
                if action:
                    actionType = action.getType()
                    return QtCore.QVariant(u'{0}: {1}'.format(
                        actionType.code, actionType.name))

            elif role == QtCore.Qt.ForegroundRole:
                if action and action.getType(
                ).isRequiredCoordination and record.isNull('coordDate'):
                    return QtCore.QVariant(QtGui.QColor(255, 0, 0))

            elif role == QtCore.Qt.FontRole:
                if self.isMainActionType(
                        forceRef(record.value('actionType_id'))):
                    boldFont = QtGui.QFont()
                    boldFont.setWeight(QtGui.QFont.Bold)
                    return QtCore.QVariant(boldFont)

        return QtCore.QVariant()
Example #6
0
def addCondForDeathCurcumstance(cond, tableEvent, place, cause, foundBy, foundation):
    db = QtGui.qApp.db
    try:
        actionType = CActionTypeCache.getByFlatCode('deathCurcumstance')
    except:
        actionType = None
    tableAction = db.table('Action')
    table = tableAction
    condActionProperties = []
    table, condActionProperties = addCondActionProperties(tableAction, table, condActionProperties, actionType, u'Смерть последовала', place)
    table, condActionProperties = addCondActionProperties(tableAction, table, condActionProperties, actionType, u'Смерть произошла', cause)
    table, condActionProperties = addCondActionProperties(tableAction, table, condActionProperties, actionType, u'Причина установлена', foundBy)
    table, condActionProperties = addCondActionProperties(tableAction, table, condActionProperties, actionType, u'Основание', foundation)
    if condActionProperties:
        condActionProperties.append(tableAction['event_id'].eq(tableEvent['id']))
        cond.append(db.existsStmt(table, condActionProperties))
Example #7
0
 def getInfoList(self, context):
     result = []
     for item in self.items():
         include = forceBool(item.value('include'))
         cash = forceBool(item.value('cash'))
         if include:
             actionTypeId = forceRef(item.value('actionType_id'))
             actionType = CActionTypeCache.getById(actionTypeId)
             actionTypeInfo = CActionTypeInfo(context, actionType)
             price = forceDouble(item.value('price'))
             actionTypeInfo.price = price
             amount = forceDouble(item.value('amount'))
             actionTypeInfo.amount = amount
             sum = forceDouble(item.value('sum'))
             actionTypeInfo.sum = sum
             actionTypeInfo.cash = cash
             result.append(actionTypeInfo)
     return result
Example #8
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)
Example #9
0
    def onCurrentActionChanged(self):
        model = self.modelAccActions
        items = model.items()
        row = self.tblAccActions.currentIndex().row()
        editWidgets = [
            self.edtAPCoordDate, self.edtAPCoordTime, self.edtAPCoordAgent,
            self.edtAPCoordInspector, self.edtAPCoordText
        ]

        if 0 <= row < len(items):
            record = items[row]
            canEdit = True
            for widget in editWidgets:
                widget.setEnabled(canEdit)
            try:
                for widget in editWidgets:
                    widget.blockSignals(True)
                actionTypeId = forceRef(
                    record.value('actionType_id')) if record else None
                actionType = CActionTypeCache.getById(
                    actionTypeId) if actionTypeId else None
                showTime = actionType.showTime if actionType else False
                self.edtAPDirectionTime.setVisible(showTime)
                self.edtAPPlannedEndTime.setVisible(showTime)
                self.edtAPCoordTime.setVisible(showTime)
                self.edtAPBegTime.setVisible(showTime)
                self.edtAPEndTime.setVisible(showTime)
                setDatetimeEditValue(self.edtAPDirectionDate,
                                     self.edtAPDirectionTime, record,
                                     'directionDate')
                setDatetimeEditValue(self.edtAPPlannedEndDate,
                                     self.edtAPPlannedEndTime, record,
                                     'plannedEndDate')
                setDatetimeEditValue(self.edtAPCoordDate, self.edtAPCoordTime,
                                     record, 'coordDate')
                self.edtAPCoordAgent.setText(
                    forceString(record.value('coordAgent')))
                self.edtAPCoordInspector.setText(
                    forceString(record.value('coordInspector')))
                self.edtAPCoordText.setText(
                    forceString(record.value('coordText')))
                setDatetimeEditValue(self.edtAPBegDate, self.edtAPBegTime,
                                     record, 'begDate')
                setDatetimeEditValue(self.edtAPEndDate, self.edtAPEndTime,
                                     record, 'endDate')
                self.cmbAPSetPerson.setValue(
                    forceRef(record.value('setPerson_id')))
                self.cmbAPStatus.setCurrentIndex(
                    forceInt(record.value('status')))
                self.edtAPOffice.setText(forceString(record.value('office')))
                self.cmbAPPerson.setValue(forceRef(record.value('person_id')))
                self.edtAPNote.setText(forceString(record.value('note')))
            finally:
                for widget in editWidgets:
                    widget.blockSignals(False)
        else:
            for widget in editWidgets:
                widget.setEnabled(False)
            self.edtAPDirectionTime.setVisible(False)
            self.edtAPPlannedEndTime.setVisible(False)
            self.edtAPCoordTime.setVisible(False)
            self.edtAPBegTime.setVisible(False)
            self.edtAPEndTime.setVisible(False)
Example #10
0
 def _getGroup(self):
     groupId = self._actionType.groupId if self._actionType else None
     actionType = CActionTypeCache.getById(groupId) if groupId else None
     return self.getInstance(CActionTypeInfo, actionType)
Example #11
0
def selectData(params):
    db = QtGui.qApp.db
    tablePerson = db.table('vrbPersonWithSpeciality').alias('ExecPerson')
    tableAction = db.table('Action')

    begDate = params.get('begDate', None)
    endDate = params.get('endDate', None)
    begDateRecord = params.get('begDateBeforeRecord', None)
    endDateRecord = params.get('endDateBeforeRecord', None)
    personId = params.get('personId', None)
    userId = params.get('beforeRecordUserId', None)
    orgStructureId = params.get('orgStructureId', None)
    specialityId = params.get('specialityId', None)
    chkOrgStructure = params.get('chkOrgStructure', None)
    queueType = params.get('queueType', 0)
    chkPeriodRecord = params.get('chkPeriodRecord', None)
    chkPeriodBeforeRecord = params.get('chkPeriodBeforeRecord', None)
    userProfileId = params.get('userProfileId', None)
    showWithoutOverTime = params.get('showWithoutOverTime', None)
    ignoreRehabilitation = params.get('ignoreRehabilitation', None)
    detailExternalIS = params.get('detailExternalIS', None)

    cond = [tableAction['deleted'].eq(0)]
    if chkPeriodRecord:
        if begDate:
            cond.append(tableAction['createDatetime'].dateGe(begDate))
        if endDate:
            cond.append(tableAction['createDatetime'].dateLe(endDate))
    if chkPeriodBeforeRecord:
        if begDateRecord:
            cond.append(tableAction['directionDate'].dateGe(begDateRecord))
        if endDateRecord:
            cond.append(tableAction['directionDate'].dateLe(endDateRecord))

    if queueType == 0:
        ambActionType = CActionTypeCache.getByCode('amb')
        codeAT = 'AT.id = %d' % ambActionType.id
    elif queueType == 1:
        homeActionType = CActionTypeCache.getByCode('home')
        codeAT = 'AT.id = %d' % homeActionType.id
    else:
        ambActionType = CActionTypeCache.getByCode('amb')
        homeActionType = CActionTypeCache.getByCode('home')
        codeAT = '(AT.id = %d OR AT.id = %d)' % (ambActionType.id,
                                                 homeActionType.id)
    if chkOrgStructure:
        if personId:
            cond.append(tableAction['person_id'].eq(personId))
        if orgStructureId:
            cond.append(tablePerson['orgStructure_id'].inlist(
                getOrgStructureDescendants(orgStructureId)))
        else:
            if not personId:
                cond.append(tablePerson['org_id'].eq(
                    QtGui.qApp.currentOrgId()))
        if specialityId:
            cond.append(tablePerson['speciality_id'].eq(specialityId))
    if userId:
        cond.append(tableAction['createPerson_id'].eq(userId))
    if userProfileId:
        cond.append('EXISTS(SELECT PUP.id '
                    '       FROM Person_UserProfile AS PUP '
                    '       WHERE PUP.person_id = PersonUserProfile.id '
                    '               AND PUP.userProfile_id = %s)' %
                    userProfileId)
    if showWithoutOverTime:
        cond.append('APTime.value IS NOT NULL')
    if ignoreRehabilitation:
        cond.append(tablePerson['orgStructure_id'].notInlist(
            db.getIdList('OrgStructure', where=u'name LIKE "%реабилитац%"')))

    queueActionType = CActionTypeCache.getByCode('queue')
    cond.append(tableAction['actionType_id'].eq(queueActionType.id))

    mainCond = []
    if detailExternalIS:
        mainCond.append(u'''Locate('Call-центр', A2.note)
        or Locate('CALLCENTER', A2.note)
        or Locate('оператор колл-центра', setPerson.lastName)
        or Locate('call-центр', setPerson.lastName)
        or Locate('менеджер колл-центра', rbPost.name)
        or Locate('инфомат', A2.note)
        or Locate('E-mail', A2.note)
        or Locate('iVista Web Medical Service', A2.note)
        or Locate('ЗАПИСЬ ОСУЩЕСТВЛЕНА ЧЕРЕЗ СИСТЕМУ "НЕТРИКА"', A2.note)
        or Locate('FROM RIR', A2.note)
        or not (setPerson.lastName
            or setPerson.firstName
            or setPerson.patrName
            or setPerson.post_id
            or setPerson.speciality_id)''')
        mainCond = u'AND ' + db.joinAnd(mainCond)

    if not mainCond:
        mainCond = u''
    stmt = u'''
            SELECT DISTINCTROW
				A2.createPerson_id,
                A2.person_id,
                Client.id,
                Client.lastName,
                Client.firstName,
                Client.patrName,
                Client.birthDate,
                getClientContacts(Client.id) AS clientPhones,
                getClientRegAddress(Client.id) AS clientAddress,
                rbPolicyType.name AS policyType,
                ClientPolicy.serial,
                ClientPolicy.number,
                Insurer.shortName AS insurerName,
                AT.code AS codeAT, A2.note AS actionNote,
                A2.directionDate,
                A2.createDatetime,
                ExecPerson.speciality_id AS personSpecialyty,               
                PersonUser.name AS userName,
                ExecPerson.name AS personName,
                setPerson.lastName  AS setPersonLastName,
                setPerson.firstName  AS setPersonFirstName,
                setPerson.patrName  AS setPersonPatrName,
                setPerson.post_id  AS setPersonPost,
                setPerson.speciality_id AS setPersonSpeciality,
                rbPost.name As postName
            FROM ActionProperty_Action
            INNER JOIN ActionProperty ON ActionProperty.id = ActionProperty_Action.id
            
            INNER JOIN Action AS A ON A.id = ActionProperty.action_id
            INNER JOIN ActionType AS AT ON AT.id = A.actionType_id

            INNER JOIN Action AS A2 ON A2.id = ActionProperty_Action.value
            INNER JOIN Event ON Event.id = A2.event_id
            INNER JOIN Person AS setPerson ON setPerson.id = A2.setPerson_id
            
            INNER JOIN Client ON Client.id = Event.client_id
            INNER JOIN ClientPolicy ON ClientPolicy.client_id = Client.id
            INNER JOIN Organisation AS Insurer ON Insurer.id = ClientPolicy.insurer_id
            INNER JOIN rbPolicyType ON rbPolicyType.id = ClientPolicy.policyType_id
            
			LEFT JOIN rbPost ON rbPost.id = setPerson.post_id
            LEFT JOIN vrbPersonWithSpeciality AS ExecPerson ON ExecPerson.id = A2.person_id
            LEFT JOIN vrbPersonWithSpeciality AS PersonUser ON PersonUser.id = A2.createPerson_id
            WHERE %s
                AND Client.deleted = 0 AND Event.deleted = 0 AND A.deleted = 0 AND A2.deleted = 0   
				AND ClientPolicy.id = (SELECT MAX(CP.id) FROM ClientPolicy AS CP WHERE  CP.client_id = Client.id AND CP.deleted = 0)
                AND ActionProperty_Action.value IN (SELECT DISTINCT Action.id FROM Action WHERE %s)
                %s
            ORDER BY A2.directionDate
    ''' % (codeAT, db.joinAnd(cond), mainCond)
    return db.query(stmt)