def on_btnPrint_printByTemplate(self, templateId): context = CInfoContext() data = { 'client': context.getInstance(CClientInfo, self.clientId), 'date': CDateInfo(self.eventDate), 'person': context.getInstance(CPersonInfo, self.personId), 'visits': [], 'actions': self.modelActions.getInfoList(context) } applyTemplate(self, templateId, data)
def on_printByTemplate(self, templateId): context = CInfoContext() if templateId in [printAction.id for printAction in self.btnPrint.additionalActions()]: self.additionalPrint(context, templateId) else: jobTicketId = self.itemId() makeDependentActionIdList([jobTicketId]) presetActions = tuple(self.modelJobTicketProbe.actionList()) jobTicketInfo = context.getInstance(CJobTicketWithActionsInfo, jobTicketId, presetActions=presetActions) data = {'jobTicket': jobTicketInfo} applyTemplate(self, templateId, data)
def on_btnPrintEvent_printByTemplate(self, templateId): context = CInfoContext() eventId = self.getCurrentEventId() eventInfo = context.getInstance(CEventInfo, eventId) tempInvalidInfo = None # self.getTempInvalidInfo(context) data = { 'event': eventInfo, 'client': eventInfo.client, 'tempInvalid': tempInvalidInfo } applyTemplate(self, templateId, data)
def printCurrentAccount(self, templateId): context = CInfoContext() accountInfo = context.getInstance(CAccountInfo, self.currentAccountId) accountInfo.selectedItemIdList = self.modelAccountItems.idList() eventInfo = context.getInstance(CEventInfo, self.eventId) clientInfo = eventInfo.client tempInvalidInfo = context.getInstance(CTempInvalidInfo, None) data = { 'account' : accountInfo, 'event': eventInfo, 'client': clientInfo, 'tempInvalid': tempInvalidInfo } applyTemplate(self, templateId, data)
def printCashOrder(widget, templateId, eventId, date, cashOperationId, sum, cashBox): context = CInfoContext() eventInfo = context.getInstance(CEventInfo, eventId) data = { 'event': eventInfo, 'client': eventInfo.client, 'date': CDateInfo(date), 'cashOperation': context.getInstance(CCashOperationInfo, cashOperationId), 'sum': sum, 'cashBox': cashBox } applyTemplate(widget, templateId, data)
def on_btnPrint_printByTemplate(self, templateId): from Registry.RegistryWindow import getEventInfoByDiagnosis context = CInfoContext() tempInvalidInfo = self.getTempInvalidInfo(context) eventInfo = getEventInfoByDiagnosis(context, self.diagnosisId) data = { 'event': eventInfo, 'client': context.getInstance(CClientInfo, self.clientId, QtCore.QDate.currentDate()), 'tempInvalid': tempInvalidInfo, } applyTemplate(self, templateId, data)
def getDispensaryOneRecommendations(self, eventId): recommendations = self.emk.factory.create('ns8:ArrayOfRecommendation') recommendations.Recommendation = [] for rec in getDispensaryOneRecommendationRecords(self.db, eventId): actionId = forceRef(rec.value('id')) personId = forceRef(rec.value('person_id')) templateId = forceRef(rec.value('templateId')) endDate = forceDate(rec.value('endDate')) try: tname, template, tt = getTemplate(templateId) data = {'action': CActionInfo(CInfoContext(), actionId)} res = compileAndExecTemplate(template, data) html = res[0].encode('utf8') except Exception as e: self.logExceptionExtra(e, {'event_id': eventId}) html = '' recommendation = self.emk.factory.create('ns8:Recommendation') recommendation.Date = forceDateTuple(endDate) recommendation.Doctor = self.getMedicalStaff(personId=personId) recommendation.Text = html recommendations.Recommendation.append(recommendation) return recommendations
def getPrintInfo(self): context = CInfoContext() result = {'deviceInfo': CInfoProxy(context, self.getDeviceInfo(forceUpdate=True)), 'checkItems': [CInfoProxy(context, checkItem) for checkItem in self.model().items()], 'operations': [{'info': CInfoProxy(context, operationInfo), 'checkItems': [CInfoProxy(context, checkItem) for checkItem in itemList]} for operationInfo, itemList in self.operationInfoList()]} return result
def drugSelected(self, index): def isDosageZero(dosage): val = unicode(dosage).split(u' ')[0] if forceInt(val) == 0: return True return False def extractDosageFromName(name): vals = unicode(name).split(u', ') if len(vals) >= 4: val = vals[3].strip(u' ') vals = val.split(u' ') if len(vals) == 2: dosage = vals[0] elif len(vals) == 3: dosage = vals[1] else: dosage = '' return dosage return u'' #TODO: mdldml: переписать этот ужас drugId = forceInt(self.cmbDrug.value()) db = QtGui.qApp.db stmt = '''SELECT item.name, CONCAT_WS(' ', CAST(item.dosageQnt AS CHAR), dosage.name) AS dosage, item.qnt AS qnt FROM DloDrugFormulary_Item AS item LEFT JOIN dlo_rbDosage AS dosage ON dosage.id = item.dosage_id WHERE item.id = %d AND dosage.name IS NOT NULL AND item.isSprPC = 1 ''' % drugId query = db.query(stmt) if query.next(): dosage = forceString(query.record().value('dosage')) if isDosageZero(dosage): dosage = extractDosageFromName( forceString(query.record().value('name'))) qnt = forceInt(query.record().value('qnt')) self.edtDosage.setText(dosage) self.spbQnt.setValue(qnt) context = CInfoContext() formularyItem = context.getInstance(CDloDrugFormularyItemInfo, drugId) noMnn = formularyItem.mnn.code == u'1' if noMnn: self.rbtnPrintMNN.setChecked(not noMnn) self.rbtnPrintTradeName.setChecked(noMnn) self.rbtnPrintMNN.setEnabled(not noMnn)
def on_btnPrint_printByTemplate(self, templateId): context = CInfoContext() eventInfo = context.getInstance(CEventInfo, self.eventId) eventActions = eventInfo.actions eventActions._idList = [self.itemId()] eventActions._items = [CCookedActionInfo(context, self.getRecord(), self.action)] eventActions._loaded = True action = eventInfo.actions[0] action.setCurrentPropertyIndex(self.tblProps.currentIndex().row()) data = { 'event': eventInfo, 'action': action, 'client': eventInfo.client, 'actions': eventActions, 'currentActionIndex': 0, 'tempInvalid': None } applyTemplate(self, templateId, data)
def on_actAdd_triggered(self): db = QtGui.qApp.db clientInfo = getClientInfo(self.clientId) if len(clientInfo.SNILS) == 0: QtGui.QMessageBox.warning( self, u'Внимание', u'У пациента не заполнен СНИЛС.\n' u'Укажите СНИЛС пациента в рег. карте.', QtGui.QMessageBox.Close) return if len(clientInfo.socStatuses) == 0: QtGui.QMessageBox.warning(self, u'Внимание', u'У пациента отсутствуют льготы.', QMessageBox.Close) return federalCode = forceString( db.translate('Person', 'id', self.personId, 'federalCode')) if len(federalCode) == 0: QtGui.QMessageBox.warning( self, u'Внимание', u'У ответственного за событие врача не указан федеральный код.', QMessageBox.Close) return record = self.tblItems.model().getEmptyRecord() record.setValue('dateTime', toVariant(QDateTime().currentDateTime())) try: record.setValue('percentage', toVariant(100)) if self.mkb: record.setValue('mkb', toVariant(self.mkb)) record.setValue('term', toVariant(2)) record.setValue('printMnn', toVariant(1)) context = CInfoContext() client, setPerson = self.getEventInfo(context) if len(client.socStatuses) == 0: raise Exception(u'В регистрационной карте не указаны льготы!') dlg = CRecipeEditDialog(self, client.socStatuses, client.id, setPerson.personId) dlg.setRecord(record) if dlg.exec_() == QDialog.Accepted: dlg.getRecord(record) recipeNumber = self.getRecipeNumber(record) record.setValue('number', recipeNumber) self.tblItems.model().addRecord(record) self.tblItems.model().reset() self.tblItems.setCurrentRow(self.tblItems.model().rowCount() - 1) except Exception as ex: QtGui.QMessageBox.question(self, u'Внимание', ex.message, QMessageBox.Close)
def on_actEdit_triggered(self): row = self.tblItems.selectionModel().currentIndex().row() if 0 <= row < self.tblItems.model().rowCount() - 1: record = self.tblItems.model().items()[row] context = CInfoContext() client, setPerson = self.getEventInfo(context) dlg = CRecipeEditDialog(self, client.socStatuses, client.id, setPerson.personId) dlg.setRecord(record) if dlg.exec_() == QDialog.Accepted: dlg.getRecord(record) self.tblItems.model().reset()
def on_btnDestPrint_printByTemplate(self, templateId): context = CInfoContext() destinationInfo = self.getDestinationInfo(context) orgStructureId = forceInt( QtGui.qApp.db.translate('Person', 'id', self.personId, 'orgStructure_id')) data = { 'departmentNumber': forceString( QtGui.qApp.db.translate('OrgStructure', 'id', orgStructureId, 'code')), 'destinationInfo': destinationInfo } QtGui.qApp.call(self, applyTemplate, (self, templateId, data))
def execTemplate(code, data, pageFormat=None): # code is tuple (complied_code, source_code) if not pageFormat: pageFormat = CPageFormat(pageSize=CPageFormat.A4, orientation=CPageFormat.Portrait, leftMargin=5, topMargin=5, rightMargin=5, bottomMargin=5) try: infoContext = None for item in data.itervalues(): if isinstance(item, CInfo): infoContext = item.context if infoContext: break if not infoContext: infoContext = CInfoContext() stream = StringIO.StringIO() canvases = {} try: execContext = CTemplateContext(data, infoContext, stream, pageFormat) if QtGui.qApp.preferences.appPrefs.get('templateDebug', False): import pdb pdb.runeval(code[0], execContext, execContext.locals) sys.stdout = stream exec code[0] in execContext.locals, execContext canvases = execContext.getCanvases() finally: sys.stdout = sys.__stdout__ return stream.getvalue(), canvases except ExTemplateContext, ex: QtGui.QMessageBox.critical(None, u'Печатная форма', ex.getRusMessage(), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) QtGui.qApp.logCurrentException() raise
def fillMedDocument(self, eventId, event, documentCode, html=None): clientId = forceRef( self.db.translateEx(table=u'Event', keyCol=u'id', keyVal=eventId, valCol=u'client_id')) medRecord = self.db.getRecordEx(stmt=MED_DOCUMENT_STMT % eventId) tname = u'Эпикриз' if html is None: # Заполняем документ по шаблонам печати medDocumentPrintTemplateId = forceRef( self.db.getIdList(stmt=MED_DOCUMENT_PRINT_TEMPLATE_STMT % documentCode)) if not medDocumentPrintTemplateId: return False medDocumentPrintTemplateId = medDocumentPrintTemplateId[0] tname, template, tt = getTemplate(medDocumentPrintTemplateId) data = { 'client': CClientInfo(CInfoContext(), clientId), 'event': CEventInfo(CInfoContext(), eventId) } try: res = compileAndExecTemplate(template, data) html = res[0].encode('utf8') except Exception as e: self.logExceptionExtra(e, {'event_id': eventId}) html = '' data1 = base64.b64encode(html) data2 = base64.b64encode(SIGN_DATA % data1) medDocument = self.emk.factory.create('ns8:%s' % documentCode) medDocument.CreationDate = forceDateTuple( medRecord.value('CreationDate')) medDocument.IdDocumentMis = forceRef(medRecord.value('IdDocumentMis')) medDocument.Header = tname medDocument.Attachment.Data = data2 medDocument.Attachment.MimeType = MIME_TYPE medDocument.Author = self.getMedicalStaff(record=medRecord) if documentCode == 'SickList': tempInvRecord = getTempInvalidRecord(self.db, eventId) if tempInvRecord: medDocument.SickListInfo = self.emk.factory.create( 'ns8:SickListInfo') medDocument.SickListInfo.Number = forceStringEx( tempInvRecord.value('number')) medDocument.SickListInfo.DateStart = forceDateTuple( tempInvRecord.value('begDate')) medDocument.SickListInfo.DateEnd = forceDateTuple( tempInvRecord.value('endDate')) medDocument.SickListInfo.IsPatientTaker = True else: return False elif documentCode == 'DispensaryOne': dispensaryInfo = getDispensaryOneInfo(self.db, eventId) if dispensaryInfo: medDocument.IsGuested = dispensaryInfo['IsGuested'] medDocument.IsUnderObservation = dispensaryInfo[ 'IsUnderObservation'] medDocument.HasExpertCareRefferal = dispensaryInfo[ 'HasExtraResearchRefferal'] medDocument.HasHealthResortRefferal = dispensaryInfo[ 'HasHealthResortRefferal'] medDocument.HasSecondStageRefferal = dispensaryInfo[ 'HasSecondStageRefferal'] medDocument.HasPrescribeCure = dispensaryInfo[ 'HasPrescribeCure'] medDocument.HasExtraResearchRefferal = dispensaryInfo[ 'HasExtraResearchRefferal'] medDocument.HealthGroup = self.emk.factory.create( 'ns8:HealthGroup') medDocument.HealthGroup.Doctor = self.getMedicalStaff( record=medRecord) medDocument.HealthGroup.HealthGroupInfo = self.emk.factory.create( 'ns8:HealthGroupInfo') medDocument.HealthGroup.HealthGroupInfo.IdHealthGroup = dispensaryInfo[ 'IdHealthGroup'] medDocument.HealthGroup.HealthGroupInfo.Date = forceDateTuple( dispensaryInfo['Date']) medDocument.Recommendations = self.getDispensaryOneRecommendations( eventId) else: return False elif documentCode == 'Referral': referralRecord = getReferralRecord(self.db, eventId) if referralRecord: medDocument.IdSourceLpu = forceStringEx( referralRecord.value('IdSourceLpu')) medDocument.IdTargetLpu = forceStringEx( referralRecord.value('IdTargetLpu')) medDocument.DepartmentHead = self.getMedicalStaff( personId=forceRef(referralRecord.value('personId'))) medDocument.ReferralInfo = self.emk.factory.create( 'ns8:ReferralInfo') medDocument.ReferralInfo.Reason = forceStringEx( referralRecord.value('Reason')) medDocument.ReferralInfo.IdReferralMis = forceStringEx( referralRecord.value('IdReferralMis')) medDocument.ReferralInfo.IdReferralType = forceInt( referralRecord.value('IdReferralType')) medDocument.ReferralInfo.IssuedDateTime = forceDateTuple( referralRecord.value('IssuedDateTime')) medDocument.ReferralInfo.HospitalizationOrder = forceInt( referralRecord.value('HospitalizationOrder')) medDocument.ReferralInfo.MkbCode = forceStringEx( referralRecord.value('MkbCode')) else: return False elif documentCode == 'ConsultNote': if getEventTypeCode(self.db, eventId) in ('211', '261'): return False event.MedRecords.MedRecord.append(medDocument) return True
def build(self, params): begDate = params.get('begDate', QtCore.QDate()) endDate = params.get('endDate', QtCore.QDate()) orgStructureId = params.get('orgStructureId', None) personId = params.get('personId', None) rowGrouping = params.get('rowGrouping', 0) sex = params.get('sex', 0) socStatusClassId = params.get('socStatusClassId', None) socStatusTypeId = params.get('socStatusTypeId', None) group = params.get('group', False) address = params.get('address', False) regAddress = params.get('regAddress', False) query = select(begDate, endDate, orgStructureId, personId, rowGrouping, sex, socStatusClassId, socStatusTypeId, group) self.setQueryText(forceString(query.lastQuery())) if rowGrouping == 5: forceKeyVal = forceRef keyValToString = lambda clientId: forceString(QtGui.qApp.db.translate('vrbClientInfo', 'id', clientId, 'clientName')) keyName = u'Пациент' elif rowGrouping == 4: # by post_id forceKeyVal = forceRef keyValToString = lambda postId: forceString(QtGui.qApp.db.translate('rbPost', 'id', postId, 'name')) keyName = u'Должность' elif rowGrouping == 3: # by speciality_id forceKeyVal = forceRef keyValToString = lambda specialityId: forceString(QtGui.qApp.db.translate('rbSpeciality', 'id', specialityId, 'name')) keyName = u'Специальность' elif rowGrouping == 2: # by orgStructureId forceKeyVal = forceRef keyValToString = lambda orgStructureId: forceString(QtGui.qApp.db.translate('OrgStructure', 'id', orgStructureId, 'name')) keyName = u'Подразделение' elif rowGrouping == 1: # by personId forceKeyVal = forceRef keyValToString = lambda personId: forceString(QtGui.qApp.db.translate('vrbPersonWithSpeciality', 'id', personId, 'name')) keyName = u'Врач' else: forceKeyVal = lambda x: pyDate(forceDate(x)) keyValToString = lambda x: forceString(QtCore.QDate(x)) keyName = u'Дата' forceKey = forceRef keyToString = lambda orgStructureId: forceString(QtGui.qApp.db.translate('OrgStructure', 'id', orgStructureId, 'name')) doc = QtGui.QTextDocument() cursor = QtGui.QTextCursor(doc) cursor.setCharFormat(CReportBase.ReportTitle) cursor.insertText(self.title()) cursor.insertBlock() self.dumpParams(cursor, params) cursor.insertBlock() additional = 0 tableColumns = [('5%', u'№п/п', CReportBase.AlignLeft), ( '20%', [keyName], CReportBase.AlignLeft)] if regAddress: tableColumns.append(('10%', [u'Адрес регистрации'], CReportBase.AlignCenter)) additional += 1 if address: tableColumns.append(('10%', [u'Адрес проживания'], CReportBase.AlignCenter)) additional += 1 tableColumns.append(( '10%', [u'Всего'], CReportBase.AlignCenter)) tableColumns.append(( '10%', [u'Амбулаторно'], CReportBase.AlignCenter)) tableColumns.append(( '10%', [u'На дому'], CReportBase.AlignCenter)) table = createTable(cursor, tableColumns) total = [0, 0, 0] totalOrg = [0]*3 prevOrgGroup = None orderNumber = 0 while query.next(): record = query.record() orderNumber += 1 rowKey = forceKeyVal(record.value('rowKey')) cnt = forceInt(record.value('cnt')) atHome = forceInt(record.value('atHome')) orgGroup = keyToString(forceKey(record.value('orgGroup'))) clientInfo = CClientInfo(CInfoContext(), rowKey) regAddr = clientInfo.regAddress addr = clientInfo.locAddress if not orgGroup: orgGroup = '-' if group: if prevOrgGroup and prevOrgGroup != orgGroup: i = table.addRow() table.setText(i, 1, u'Всего', CReportBase.TableTotal) for j in xrange(3): table.setText(i, j+2, totalOrg[j], CReportBase.TableTotal) total[j] += totalOrg[j] totalOrg = [0]*3 if prevOrgGroup != orgGroup: i = table.addRow() table.setText(i, 1, orgGroup, CReportBase.TableTotal) table.mergeCells(i, 0, 1, 4) prevOrgGroup = orgGroup i = table.addRow() table.setText(i, 0, forceString(orderNumber)) table.setText(i, 1, keyValToString(rowKey)) if regAddress: table.setText(i, 2, regAddr) if address: table.setText(i, 1 + additional, addr) table.setText(i, 2 + additional, cnt) totalOrg[0] += cnt table.setText(i, 3 + additional, cnt-atHome) totalOrg[1] += cnt - atHome table.setText(i, 4 + additional, atHome) totalOrg[2] += atHome if group: i = table.addRow() table.setText(i, 1, u'Всего', CReportBase.TableTotal) for j in xrange(3): table.setText(i, j+2 + additional, totalOrg[j], CReportBase.TableTotal) total[j] += totalOrg[j] else: total = totalOrg i = table.addRow() table.setText(i, 0, u'Итого', CReportBase.TableTotal) for j in xrange(3): table.setText(i, j+2 + additional, total[j], CReportBase.TableTotal) return doc
def __init__(self, eventId, clientId, parent): self.infoContext = CInfoContext() self.mapEventIdToMKB = {} report = self.build(eventId, clientId) self.view = self.getView(report, parent)
def build(self, params): columns = params.get('columns', []) enterClientId = params.get('enterClientId', True) enterClientIdentification = params.get('enterClientIdentification', False) defColumns = [ u'Фамилия', u'Имя', u'Отчество', u'Пол', u'Дата рождения' ] query = selectData(params) doc = QtGui.QTextDocument() cursor = QtGui.QTextCursor(doc) cursor.setCharFormat(CReportBase.ReportTitle) cursor.insertText(self.title()) cursor.insertBlock() cursor.insertText( u'проверка производилась по: ' + ', '.join(index for index in set(columns) & set(defColumns)), QtGui.QTextCharFormat()) self.dumpParams(cursor, params) cursor.insertBlock() tableColumns = [('%20', [u'ФИО'], CReportBase.AlignLeft), ('%15', [u'Дата рождения'], CReportBase.AlignLeft), ('%15', [u'Адрес регистрации'], CReportBase.AlignLeft), ('%15', [u'Адрес проживания'], CReportBase.AlignLeft), ('%15', [u'Диагноз'], CReportBase.AlignLeft)] if enterClientId: tableColumns.insert(0, ('%2', [u'Код'], CReportBase.AlignRight)) if enterClientIdentification: tableColumns.insert( 1 if enterClientId else 0, ('%2', [u'№ истории \n болезни'], CReportBase.AlignRight)) table = createTable(cursor, tableColumns) boldChars = QtGui.QTextCharFormat() boldChars.setFontWeight(QtGui.QFont.Bold) boldItalicChars = QtGui.QTextCharFormat() boldItalicChars.setFontWeight(QtGui.QFont.Bold) boldItalicChars.setFontItalic(True) self.setQueryText(forceString(query.lastQuery())) while query.next(): record = query.record() identifier = forceString(record.value('identifier')) id = forceRef(record.value('id')) clientInfo = CClientInfo(CInfoContext(), id) name = clientInfo.fullName birthDate = clientInfo.birthDate addressReg = clientInfo.regAddress address = clientInfo.locAddress diagnosis = findLastDiagnosisRecord(id) diag = forceString(diagnosis.value('MKB')) if diagnosis else u'' if id: i = table.addRow() table.setText( i, 0, identifier if not enterClientId and enterClientIdentification else id) if enterClientIdentification: table.setText(i, 1, identifier) table.setText( i, 2 if enterClientIdentification and enterClientId else 1, name) table.setText( i, 3 if enterClientIdentification and enterClientId else 2, birthDate) table.setText( i, 4 if enterClientIdentification and enterClientId else 3, addressReg) table.setText( i, 5 if enterClientIdentification and enterClientId else 4, address) table.setText( i, 6 if enterClientIdentification and enterClientId else 5, diag) return doc
def on_actPrint_triggered(self): currentItem = self.tblItems.currentIndex() if not currentItem.isValid(): return context = CInfoContext() drugRecipeInfo = context.getInstance( CDrugRecipeInfo, None, record=self.tblItems.model().items()[currentItem.row()]) if not drugRecipeInfo.number or len(drugRecipeInfo.number) == 0: QtGui.QMessageBox.question(self, u'Внимание', u'Не был сформирован номер рецепта!') return if not drugRecipeInfo.finance.code in ['70', '71', '72', '73']: QtGui.QMessageBox.question( self, u'Внимание', u'Неверный код финансирования! Допустимы только коды 70, 71, 72 и 73.' ) return client, person = self.getEventInfo(context) policyStr = u'' if len(client.policy.serial) > 0: policyStr = client.policy.serial + u' ' policyStr += client.policy.number if drugRecipeInfo.printMnn and drugRecipeInfo.formularyItem.mnn.code != u'1': drugCode = drugRecipeInfo.formularyItem.mnn.code drugName = drugRecipeInfo.formularyItem.mnn.latinName else: drugCode = drugRecipeInfo.formularyItem.tradeName.code drugName = drugRecipeInfo.formularyItem.tradeName.latinName data = { 'orgCode': forceString(getBookkeeperCode(self.personId)).rjust(5, '0'), 'ogrn': person.organisation.OGRN.ljust(15, u' '), 'socCode': drugRecipeInfo.socCode.ljust(3, u' '), 'mkbCode': drugRecipeInfo.mkb.ljust(6, u' '), 'characterId': self.characterId, 'financeSel': { '70': 1, '71': 2, '72': 3, '73': 4 }[drugRecipeInfo.finance.code], 'percentSel': 1 if forceInt(drugRecipeInfo.percentage) == 50 else 0, 'termSel': drugRecipeInfo.term, 'recipeSeria': drugRecipeInfo.number.split('#')[0], 'recipeNumber': drugRecipeInfo.number.split('#')[1], 'recipeDate': drugRecipeInfo.dateTime.toString('dd.MM.yyyy'), 'clientLastName': client.lastName, 'clientFirstName': client.firstName, 'clientPatrName': client.patrName, 'clientSnils': unicode(client.SNILS), 'clientBirthDate': client.birthDate.toString('dd.MM.yyyy'), 'clientPolicyNumber': policyStr.ljust(25, u' '), 'clientId': drugRecipeInfo.pregCard if drugRecipeInfo.pregCard > 0 else client.id, 'clientRegAddress': client.regAddress, 'doctor': person, 'doctorName': person.longName, 'doctorCode': unicode(person.federalCode)[:6].ljust(6, u' '), 'mnn': drugName, 'mnnCode': drugCode, 'tradeName': drugRecipeInfo.formularyItem.tradeName, 'issueForm': drugRecipeInfo.formularyItem.issueForm.name, 'issueFormLat': drugRecipeInfo.formularyItem.issueForm.latinName, 'dosage': drugRecipeInfo.dosage, 'qnt': drugRecipeInfo.qnt, 'signa': drugRecipeInfo.signa, 'duration': drugRecipeInfo.duration, 'numPerDay': drugRecipeInfo.numPerDay } templateId = getFirstPrintTemplate('recipe_new')[1] QtGui.qApp.call(self, applyTemplate, (self, templateId, data))
def setRecord(self, record): annoyingWidgets = [ self.cmbDrug, self.edtDosage, self.spbQnt, self.spbNumPerDay, self.spbDuration, self.cmbSocCodes ] for widget in annoyingWidgets: widget.blockSignals(True) # self.disconnect(self.cmbDrug, QtCore.SIGNAL('currentIndexChanged(int)'), self.drugSelected) self.edtDate.setDate(forceDateTime(record.value('dateTime')).date()) socCode = forceString(record.value('socCode')) i = self.cmbSocCodes.findData(socCode) self.cmbSocCodes.setCurrentIndex(i) pregCard = forceInt(record.value('pregCard')) if pregCard > 0: self.edtPregCard.setText(QString.number(pregCard)) #mdldml: см. i2446 financeId = forceRef(record.value('finance_id')) self.cmbFinance.setValue(financeId) if financeId: db = QtGui.qApp.db counterRecord = db.getRecordEx( 'rbCounter', '`id`', "`code`='%s'" % getBookkeeperCode(self.personId)) if not counterRecord: self.cmbFinance.setEnabled(False) self.cmbMKB.setText(forceString(record.value('mkb'))) setLineEditValue(self.edtDosage, record, 'dosage') setSpinBoxValue(self.spbQnt, record, 'qnt') setLineEditValue(self.edtSigna, record, 'signa') setSpinBoxValue(self.spbDuration, record, 'duration') setSpinBoxValue(self.spbNumPerDay, record, 'numPerDay') formularyFilter = 'master_id = %d AND isSprPC = 1' % forceInt( self.drugMasterId) if forceInt(record.value('isVk')) == 1: self.rbtnVkYes.setChecked(True) else: self.rbtnVkNo.setChecked(True) formularyFilter += ' AND federalCode IS NOT NULL' if forceInt(record.value('printMnn')) == 1: self.rbtnPrintMNN.setChecked(True) else: self.rbtnPrintTradeName.setChecked(True) self.cmbDrug.setFilter(formularyFilter, order='`name` ASC') setRBComboBoxValue(self.cmbDrug, record, 'formularyItem_id') context = CInfoContext() formularyItem = context.getInstance( CDloDrugFormularyItemInfo, forceRef(record.value('formularyItem_id'))) self.rbtnPrintMNN.setEnabled(not formularyItem.mnn.code == u'1') if forceInt(record.value('percentage')) == 50: self.rbtn50proc.setChecked(True) else: self.rbtn100proc.setChecked(True) setComboBoxValue(self.cmbTerm, record, 'term') self.cmbStatus.setCurrentIndex( self.modelRecipeStatus.getIndex(forceInt(record.value('status')))) # self.connect(self.cmbDrug, QtCore.SIGNAL('currentIndexChanged(int)'), self.drugSelected) for widget in annoyingWidgets: widget.blockSignals(False)
def on_btnPrint_printByTemplate(self, templateId): context = CInfoContext() actionsInfo = context.getInstance(CActionTableRedactorInfoList, tuple(self._actionIdList)) data = {'actions': actionsInfo} applyTemplate(self, templateId, data)