Esempio n. 1
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
Esempio n. 2
0
 def getDefaultPlannedEndDate(self, actionTypeId):
     return CActionTypeCache.getById(actionTypeId).defaultPlannedEndDate
Esempio n. 3
0
    def prepareActions(self, eventTypeId, specialityId, showFlags,
                       flagHospitalization, addActionTypeId,
                       recommendationList):
        includedGroups = set()
        db = QtGui.qApp.db
        table = db.table('EventType_Action')
        tableActionType = db.table('ActionType')
        self.disabledActionTypeIdList = []
        self.notDeletedActionTypes = {}
        join = table.leftJoin(tableActionType,
                              tableActionType['id'].eq(table['actionType_id']))
        cond = [
            table['eventType_id'].eq(eventTypeId),
            tableActionType['deleted'].eq(0)
        ]
        if specialityId:
            cond.append(
                db.joinOr([
                    table['speciality_id'].eq(specialityId),
                    table['speciality_id'].isNull()
                ]))
        records = QtGui.qApp.db.getRecordList(
            join,
            'EventType_Action.*, CONCAT_WS(\'|\', ActionType.code, ActionType.name) AS actionTypeName',
            cond, 'ActionType.class, idx, id')
        complexActionType = {}
        for record in records:
            actionTypeId = forceRef(record.value('actionType_id'))
            actionType = CActionTypeCache.getById(actionTypeId)
            if self.wholeEventForCash:
                payable = 2
            elif not self.showPrice:
                payable = 0
            else:
                payable = forceInt(record.value('payable'))

            if actionType and self.recordAcceptable(record):
                tissueTypeId = forceRef(record.value('tissueType_id'))
                if tissueTypeId and self.tissueTypeId:
                    if self.tissueTypeId != tissueTypeId:
                        continue
                selectionGroup = forceInt(record.value('selectionGroup'))
                if forceBool(record.value('isCompulsory')):
                    self.notDeletedActionTypes[actionTypeId] = forceString(
                        record.value('actionTypeName'))
                if selectionGroup == -99:
                    self.disabledActionTypeIdList.append(actionTypeId)
                elif selectionGroup == 1 and not payable:
                    el = {
                        'actionType_id': actionTypeId,
                        'defaultOrg_id':
                        forceRef(record.value('defaultOrg_id'))
                    }
                    self.unconditional_actionTypes_list.append(el)
                else:
                    if selectionGroup > 1 or showFlags[
                            actionType.class_] or payable:
                        item = self.modelActions.getEmptyRecord()
                        item.setValue('actionType_id', toVariant(actionTypeId))
                        item.setValue('actuality', record.value('actuality'))
                        item.setValue('selectionGroup',
                                      record.value('selectionGroup'))
                        if selectionGroup <= 0 or selectionGroup in includedGroups:
                            item.setValue('include', QtCore.QVariant(0))
                            if not complexActionType.has_key(selectionGroup):
                                complexActionType[selectionGroup] = [
                                    actionTypeId
                                ]
                            else:
                                complexActionType[selectionGroup].append(
                                    actionTypeId)
                        else:
                            item.setValue('include', QtCore.QVariant(1))
                            if selectionGroup != 1:
                                includedGroups.add(selectionGroup)
                        item.setValue(
                            'cash',
                            QtCore.QVariant(self.wholeEventForCash
                                            or payable == 2))
                        item.setValue('price', QtCore.QVariant(0.0))
                        item.setValue('payable', QtCore.QVariant(payable))
                        if forceRef(record.value('defaultOrg_id')):
                            item.setValue('defaultOrg_id',
                                          record.value('defaultOrg_id'))
                        else:
                            item.setValue('defaultOrg_id',
                                          toVariant(actionType.defaultOrgId))
                        item.setValue('id', record.value('id'))
                        self.modelActions.items().append(item)
        if flagHospitalization and addActionTypeId:
            actionTypeId = addActionTypeId
            actionType = CActionTypeCache.getById(actionTypeId)
            if actionType:
                if not self.isInside_unconditional_actionTypes_list(
                        actionTypeId):
                    el = {'actionType_id': actionTypeId}
                    self.unconditional_actionTypes_list.append(el)

        actionTypeIdRecMap = {}
        for rec in recommendationList:
            actionTypeIdRecMap[forceInt(rec.value('actionType_id'))] = rec
        records = db.getRecordList(
            tableActionType,
            where=tableActionType['id'].inlist(actionTypeIdRecMap))
        for record in records:
            actionTypeId = forceInt(record.value('id'))
            el = {
                'actionType_id':
                actionTypeId,
                'org_id':
                forceInt(record.value('defaultOrg_id')),
                'amount':
                forceInt(actionTypeIdRecMap[actionTypeId].value('amount'))
            }
            self.unconditional_actionTypes_list.append(el)

        self.modelActions.setComplexActionType(complexActionType)
        self.modelActions.reset()