def __init__(self, eventId=0, clientId=0, personId=0, parent=None): QtGui.QWidget.__init__(self, parent) self.curComplexNumber = -1 self.eventId = eventId self.clientId = clientId self.personId = personId self.localIndex = -1 self.destFilter = smartDict()
def processRecord(self, record): externalId = forceString(record.value('externalId')) lastName = forceString(record.value('lastName')) firstName = forceString(record.value('firstName')) patrName = forceString(record.value('patrName')) eventSetDate = forceDate(record.value('eventSetDate')) clientBirthDate = forceDate(record.value('clientBirthDate')) age = calcAge(clientBirthDate, eventSetDate) eventTypeId = forceInt(record.value('eventType_id')) eventEntry = self.data.setdefault( externalId, smartDict(externalId=externalId, name=formatName(lastName, firstName, patrName), age=age)) actionId = forceRef(record.value('actionId')) actionBegDate = forceDate(record.value('actionBegDate')) actionBegTime = forceTime(record.value('actionBegDate')) actionEndDate = forceDate(record.value('actionEndDate')) actionEndTime = forceTime(record.value('actionEndDate')) fromId = forceRef(record.value('FromId')) toId = forceRef(record.value('ToId')) currId = forceRef(record.value('CurrId')) fromName = forceString(record.value('FromName')) toName = forceString(record.value('ToName')) currName = forceString(record.value('CurrName')) actionTypeId = forceRef(record.value('actionTypeId')) isMoving = self.actionTypesMap[actionTypeId] == u'moving' HBProfile = forceString(record.value('HBProfileName')) patronage = forceString(record.value('patronage')) actionsEntry = eventEntry.setdefault('actions', {}) actionsEntry[(actionId, isMoving)] = smartDict(fromName=fromName, toName=toName, currName=currName, fromId=fromId, toId=toId, currId=currId, HBProfile=HBProfile, patronage=patronage, begDate=actionBegDate, begTime=actionBegTime, endDate=actionEndDate, endTime=actionEndTime, eventTypeId=eventTypeId)
def __init__(self, parent): QtCore.QAbstractTableModel.__init__(self, parent) self.items = [] self.headerSortingCol = {} self._cols = [] self.mapColFieldNameToColIndex = {} self.tables = smartDict() self.initTables() self._columnNamesList = []
def getEquipmentInterface(equipmentId): db = QtGui.qApp.db record = db.getRecord('rbEquipment', '*', equipmentId) if record: return smartDict(protocol=forceInt(record.value('protocol')), address=forceString(record.value('address')), ownName=forceString(record.value('ownName')), labName=forceString(record.value('labName'))) else: return None
def getLaboratory(laboratoryId): db = QtGui.qApp.db record = db.getRecord('rbLaboratory', '*', laboratoryId) if record: return smartDict(code=forceString(record.value('code')), name=forceString(record.value('name')), protocol=forceInt(record.value('protocol')), address=forceString(record.value('address')), ownName=forceString(record.value('ownName')), labName=forceString(record.value('labName'))) else: return None
def getItem(self): ok = self.exec_() result = smartDict() result.clientIdType = self.cmbIdentifierTypes.currentText() result.needAmountAndUnit = self.chkNeedAmountAndUnit.isChecked() result.chkNeedStatus = self.chkNeedStatus.isChecked() result.chkNeedDatetime = self.chkNeedDatetime.isChecked() result.chkNeedPerson = self.chkNeedPerson.isChecked() result.chkNeedMKB = self.chkNeedMKB.isChecked() result.orderBy = self.orderBy() return result, ok
def getAddressRecord(record, type=0): if type == 0: prefix = 'reg' else: prefix = 'loc' address = smartDict() address.KLADRCode = forceString(record.value(prefix + 'KLADRCode')) address.KLADRStreetCode = forceString( record.value(prefix + 'KLADRStreetCode')) address.number = forceString(record.value(prefix + 'Number')) address.corpus = forceString(record.value(prefix + 'Corpus')) address.flat = forceString(record.value(prefix + 'Flat')) address.freeInput = forceString(record.value(prefix + 'FreeInput')) return address
def structInfo(self, query, params): self.resetHelpers() condBegDate = params.get('begDate', None) condEndDate = params.get('endDate', None) while query.next(): record = query.record() begDate = forceDate(record.value('begDate')) endDate = forceDate(record.value('endDate')) modifyDatetime = forceDate(record.value('modifyDatetime')) clientId = forceRef(record.value('clientId')) insurerId = forceRef(record.value('insurerId')) organisationName = forceString(record.value( 'organisationName')) if insurerId else u'Не определено' infisCode = forceString(record.value('infisCode')) info, infoHelper = self._mapInsurer2Info.setdefault( insurerId, ([infisCode, organisationName] + [0] * 9, smartDict(clientListInRange=[]))) if begDate < condBegDate or not begDate.isValid(): info[2] += 1 info[9] -= 1 if condBegDate <= begDate and begDate <= condEndDate: info[3] += 1 if clientId in infoHelper.clientListInRange: info[5] += 1 else: info[4] += 1 infoHelper.clientListInRange.append(clientId) if endDate.isValid( ) and condBegDate <= endDate and endDate <= condEndDate: info[6] += 1 if modifyDatetime == begDate: info[7] += 1 else: info[8] += 1 if not endDate.isValid() or endDate > condEndDate: info[10] += 1 info[9] += 1
def getJobTypeAttributes(jobTicketId): db = QtGui.qApp.db tableJobTicket = db.table('Job_Ticket') tableJob = db.table('Job') tableJobType = db.table('rbJobType') queryTable = tableJobTicket.leftJoin( tableJob, tableJob['id'].eq(tableJobTicket['master_id'])) queryTable = queryTable.leftJoin( tableJobType, tableJobType['id'].eq(tableJob['jobType_id'])) record = db.getRecordEx( queryTable, [tableJobType['isInstant'], tableJobType['laboratory_id']], tableJobTicket['id'].eq(jobTicketId)) if record: return smartDict(isInstant=forceBool(record.value('isInstant')), laboratoryId=forceBool(record.value('laboratory_id'))) else: return None
def saveSetData(self): if self._needToSave: itemToSave = smartDict() itemToSave.items = self.copyItems(self._items) itemToSave.additionalItems = self.copyItems(self._additionalItems) itemToSave.mapAdditionalKeyToGroup = dict( self._mapAdditionalKeyToGroup) itemToSave.mapKeyToRow = dict(self._mapKeyToRow) itemToSave.mapGroupToRows = dict(self._mapGroupToRows) itemToSave.mapNameToRow = dict(self._mapNameToRow) itemToSave.mapRowToGroup = dict(self._mapRowToGroup) itemToSave.mapRowToButtonKey = dict(self._mapRowToButtonKey) itemToSave.mapPropertyTypeIdToCoords = dict( self._mapPropertyTypeIdToCoords) self._history.append(itemToSave) self._historyPointer += 1 self._onHistoryPointer = True self._needToSave = False
def __init__(self, config_name='reg_iemc'): self.settings = CRegIemcSettings(config_name) self.prepareDatabase() self.tableClient = self.db.table('Client') self.tableClientAddress = self.db.table('ClientAddress') self.tableClientPolicy = self.db.table('ClientPolicy') self.tableClientDocument = self.db.table('ClientDocument') self.tableEvent = self.db.table('Event') self.tableAction = self.db.table('Action') self.tableDiagnostic = self.db.table('Diagnostic') self.tableDiagnosis = self.db.table('Diagnosis') self.tableVisit = self.db.table('Visit') self._updateRegData = False self.nProcessed = 0 self.nUpdated = 0 self.nAdded = 0 self._depth = 0 # Глубина: 0 - ничего, 1 - IEMC, 2 - ORG/PERS_LIST, 3 - ZGLV/Client, 4 - Event, 5 - Action. # Остальное не может иметь ветвей и не считается self.exporterOrgCode = '' self._cache = smartDict() # Кэш справочников self._mapOrgCodeToId = {} self._mapPersonCodeToId = {} self._mapEventTypeCodeToId = {} self._mapEventTypeCodeToPurposeId = {} self._mapMesCodeToId = {} self._mapServiceCodeToId = {} self._mapPersonIdToSpecialityId = {} self.logs = { CErrorLevel.fatal: [], CErrorLevel.error: [], CErrorLevel.warning: [], CErrorLevel.debug: [], CErrorLevel.info: [] } self.inFile = None self.processedEvents = []
def __init__(self, parent=None): QtCore.QAbstractTableModel.__init__(self, parent) self._parent = parent self.clear() self.resetAdditional(False) self._inputData = None self._maxGroupValue = 100 self._rounding = 0 self._locale = QtCore.QLocale() self._historyPointer = 0 self._history = [] self._needToSave = False self._onHistoryPointer = True self._emptyItem = smartDict(items=[], mapKeyToRow={}, mapGroupToRows={}, mapNameToRow={}, mapRowToGroup={}, mapRowToButtonKey={}, mapPropertyTypeIdToCoords={}) self._history.append(self._emptyItem)
def __init__(self, parent): CDialogBase.__init__(self, parent) self.addModels('Motions', CMyMotionsModel(self)) self.mnuMotions = QtGui.QMenu(self) self.mnuMotions.setObjectName('mnuMotions') self.actAddInvoice = QtGui.QAction(u'Создать накладную', self) self.actAddInvoice.setObjectName('actAddInvoice') self.actAddInventory = QtGui.QAction(u'Создать инвентаризацию', self) self.actAddInventory.setObjectName('actAddInventory') self.actAddFinTransfer = QtGui.QAction(u'Создать фин.перенос', self) self.actAddFinTransfer.setObjectName('actAddFinTransfer') self.actAddProduction = QtGui.QAction(u'Создать производство', self) self.actAddProduction.setObjectName('actAddProduction') self.actEditMotion = QtGui.QAction(u'Редактировать движение', self) self.actEditMotion.setObjectName('actEditMotion') self.mnuMotions.addAction(self.actAddInvoice) self.mnuMotions.addAction(self.actAddInventory) self.mnuMotions.addAction(self.actAddFinTransfer) self.mnuMotions.addAction(self.actAddProduction) self.mnuMotions.addSeparator() self.mnuMotions.addAction(self.actEditMotion) self.addModels('Remainings', CRemainingsModel(self)) self.addModels('MRs', CMyRequisitionsModel(self)) self.mnuMRs = QtGui.QMenu(self) self.mnuMRs.setObjectName('mnuMRs') self.actAddRequisition = QtGui.QAction(u'Создать требование', self) self.actAddRequisition.setObjectName('actAddRequisition') self.actEditRequisition = QtGui.QAction(u'Редактировать требование', self) self.actEditRequisition.setObjectName('actEditRequisition') self.actRevokeRequisition = QtGui.QAction(u'Отменить требование', self) self.actRevokeRequisition.setObjectName('actRevokeRequisition') self.mnuMRs.addAction(self.actAddRequisition) self.mnuMRs.addAction(self.actEditRequisition) self.mnuMRs.addAction(self.actRevokeRequisition) self.addModels('MRContent', CRequisitionContentModel(self)) self.addModels('RTMs', CRequisitionsToMeModel(self)) self.mnuRTMs = QtGui.QMenu(self) self.mnuRTMs.setObjectName('mnuRTMs') # self.addObject('actOpenClient', QtGui.QAction(u'Открыть регистрационную карточку', self)) self.actCreateMotionByRequisition = QtGui.QAction( u'Создать движение по требованию', self) self.actCreateMotionByRequisition.setObjectName( 'actCreateMotionByRequisition') # self.addObject('actRejectRequisition', QtGui.QAction(u'Отказать в требование', self)) self.mnuRTMs.addAction(self.actCreateMotionByRequisition) # self.mnuRTMs.addAction(self.actRejectRequisition) self.addModels('RTMContent', CRequisitionContentModel(self)) self.btnPrint = QtGui.QPushButton(u'Печать', self) self.btnPrint.setObjectName('btnPrint') self.btnPrint.setShortcut('F6') self.setupUi(self) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) if QtGui.qApp.currentOrgStructureId(): self.setWindowTitle( u'Склад ЛСиИМН: %s' % getOrgStructureFullName(QtGui.qApp.currentOrgStructureId())) self.bbxMotionsFilter.button( QtGui.QDialogButtonBox.Apply).setDefault(True) self.bbxRemainingsFilter.button( QtGui.QDialogButtonBox.Apply).setDefault(True) self.bbxMRsFilter.button(QtGui.QDialogButtonBox.Apply).setDefault(True) self.bbxRTMsFilter.button( QtGui.QDialogButtonBox.Apply).setDefault(True) self.cmbMotionsFilterNomenclature.setTable('rbNomenclature', order='name') self.cmbMotionsFilterFinance.setTable('rbFinance', True) self.cmbRemainingsFilterNomenclature.setTable('rbNomenclature', order='name') self.cmbRemainingsFilterFinance.setTable('rbFinance', True) self.cmbMRsFilterNomenclature.setTable('rbNomenclature', order='name') self.cmbRTMsFilterNomenclature.setTable('rbNomenclature', order='name') self.tblMotions.setModel(self.modelMotions) self.tblMotions.setSelectionModel(self.selectionModelMotions) self.tblMotions.setPopupMenu(self.mnuMotions) self.tblRemainings.setModel(self.modelRemainings) self.tblRemainings.setSelectionModel(self.selectionModelRemainings) self.tblMRs.setModel(self.modelMRs) self.tblMRs.setSelectionModel(self.selectionModelMRs) self.tblMRs.setPopupMenu(self.mnuMRs) self.tblMRContent.setModel(self.modelMRContent) self.tblMRContent.setSelectionModel(self.selectionModelMRContent) self.tblRTMs.setModel(self.modelRTMs) self.tblRTMs.setSelectionModel(self.selectionModelRTMs) self.tblRTMs.setPopupMenu(self.mnuRTMs) self.tblRTMContent.setModel(self.modelRTMContent) self.tblRTMContent.setSelectionModel(self.selectionModelRTMContent) self.buttonBox.addButton(self.btnPrint, QtGui.QDialogButtonBox.ActionRole) self.motionsFilter = smartDict() self.remainingsFilter = smartDict() self.MRsFilter = smartDict() self.RTMsFilter = smartDict() self.controlSplitter = None # self.visitedMotions = False self.visitedMRs = False self.visitedRTMs = False
def makeStructAction(self, query, params): # chkAllOrgStructure:: если True - при структурировании по подразделениям к которым относится действие, # действие может относится ко многим подразделениям, а если False мы учитываем только первое. chkAllOrgStructure = params.get('chkAllOrgStructure', False) chkPatientInfo = params.get('chkPatientInfo', False) chkOrgStructure = params.get('chkOrgStructure', False) chkPerson = params.get('chkPerson', False) detailServiceTypes = params.get('detailServiceTypes', False) strongOrgStructureId = params.get('orgStructureId', None) enterPost = params.get('enterPost', False) existsOrgStructureActions = [] while query.next(): record = query.record() modifyDatetime = forceDate(record.value('modifyDatetime')) endDate = forceDate(record.value('endDate')) actionId = forceRef(record.value('id')) actionTypeCode = forceString(record.value('code')) actionTypeName = forceString(record.value('name')) amount = forceInt(record.value('amount')) orgStructureId = forceRef(record.value('orgStructureId')) # orgStructureName = forceString(record.value('orgStructureName')) price = forceDouble(record.value('price')) if chkAllOrgStructure: if (orgStructureId, actionId) in existsOrgStructureActions: continue existsOrgStructureActions.append((orgStructureId, actionId)) else: if actionId in existsOrgStructureActions: continue existsOrgStructureActions.append(actionId) result, orgStructureId = self.orgStructureFilterByParams( chkOrgStructure, strongOrgStructureId, orgStructureId) if not result: continue fullOrgStructureName = self._mapOrgStructureIdToFullName.get( orgStructureId, None) if not fullOrgStructureName: if not orgStructureId: if chkOrgStructure: fullOrgStructureName = u'Головное подразделение' else: fullOrgStructureName = u'Подразделение не определено' else: fullOrgStructureName = getOrgStructureFullName( orgStructureId) self._mapOrgStructureIdToFullName[ orgStructureId] = fullOrgStructureName actionValues = smartDict() actionValues.actionId = actionId actionValues.orgStructureId = orgStructureId actionValues.number = 0 values = [actionTypeCode, actionTypeName, amount, price * amount] if chkPatientInfo: clientName = formatName(record.value('lastName'), record.value('firstName'), record.value('patrName')) clientId = forceRef(record.value('clientId')) actionMKB = forceString(record.value('actionMKB')) endDate = endDate if endDate.isValid() else modifyDatetime values.insert(2, actionMKB) values.insert(2, clientName) values.insert(0, forceString(endDate)) if chkPerson: personName = forceString(record.value('personName')) personId = forceString(record.value('personId')) self._mapPersonIdToName[personId] = personName if enterPost: personPost = forceString(record.value('personPost')) self._mapPersonIdToName[personId] = {} self._mapPersonIdToName[personId]['name'] = personName self._mapPersonIdToName[personId]['post'] = personPost if detailServiceTypes: serviceType = forceInt(record.value('serviceType')) actionValues.values = values orgStructureDict = self._mapRowValues.setdefault( orgStructureId, {}) personDict = orgStructureDict.setdefault( personId if chkPerson else None, {}) serviceTypeDict = personDict.setdefault( serviceType if detailServiceTypes else None, {}) clientDict = serviceTypeDict.setdefault( clientId if chkPatientInfo else None, {}) existActionValues = clientDict.setdefault( (actionTypeCode, actionTypeName), actionValues) if existActionValues != actionValues: existActionValues.values[-2] += actionValues.values[-2] existActionValues.values[-1] += actionValues.values[-1] # set numbers within each orgStructure unit self.fillOrgStructureRows()
# -*- coding: utf-8 -*- ############################################################################# ## ## Copyright (C) 2006-2012 Chuk&Gek and Vista Software. All rights reserved. ## ############################################################################# from decimal import Decimal, Context from PyQt4 import QtCore, QtGui, QtSql from library.PreferencesMixin import CPreferencesMixin from library.Utils import forceDouble, forceInt, forceString, forceStringEx, smartDict FiledType = smartDict() FiledType.PercentType = '%' FiledType.GlobalType = 'A' groupList = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D' ] class CLaboratoryCalculatorTableModel(QtCore.QAbstractTableModel): horizontalHeaders = [ u'Имя свойства(А)', u'А', u'Сумма', u'%', u'Имя свойства(%)', u'Группа' ] fields = [('name(A)', QtCore.QVariant.String), ('A', QtCore.QVariant.Int), ('Sum', QtCore.QVariant.Int), ('%', QtCore.QVariant.Double), ('name(%)', QtCore.QVariant.String),