def updateFilter(self): self._filter.clear() self._filter['orgStructureId'] = self.cmbPWLOrgStructure.value() equipmentId = self.cmbPWLEquipment.value() self.btnPWLTripod.setEnabled(bool(equipmentId)) self._filter['equipmentId'] = equipmentId if equipmentId: sTripodNumber = forceStringEx(self.edtPWLTripodNumber.text()) self._filter['tripodNumber'] = int(sTripodNumber) if sTripodNumber else None self._filter['testGroupId'] = self.cmbPWLTestGroup.value() self._filter['testId'] = self.cmbPWLTest.value() self._filter['status'] = self.cmbPWLStatus.currentIndex() self._filter['dateFrom'] = self.edtPWLDateFrom.date() self._filter['dateTo'] = self.edtPWLDateTo.date() self._filter['tissueTypeId'] = self.cmbPWLTissueType.value() self._filter['chkPWLRelegateOrg'] = self.chkPWLRelegateOrg.isChecked() self._filter['PWLRelegateOrgId'] = self.cmbPWLRelegateOrg.value() self._filter['ibm'] = forceStringEx(self.edtPWLIbm.text()) self._filter['probeIdentifier'] = forceStringEx(self.edtPWLProbeIdentifier.text()) self._filter['isUrgent'] = self.chkPWLIsUrgent.isChecked() self._filter['containerTypeId'] = self.cmbPWLContainerType.value() self._filter['personId'] = self.cmbPWLPerson.value() self._filter['clientFilter'] = self.grpClient.isChecked() if self._filter['clientFilter']: self._filter['chkClientId'] = self.chkPWLId.isChecked() self._filter['accountingSystemId'] = self.cmbPWLAccountingSystem.value() self._filter['clientId'] = forceStringEx(self.edtPWLId.text()) self._filter['chkPWLLastName'] = self.chkPWLLastName.isChecked() self._filter['lastName'] = nameCase(forceStringEx(self.edtPWLLastName.text())) self._filter['chkPWLFirstName'] = self.chkPWLFirstName.isChecked() self._filter['firstName'] = nameCase(forceStringEx(self.edtPWLFirstName.text())) self._filter['chkPWLPatrName'] = self.chkPWLPatrName. isChecked() self._filter['patrName'] = nameCase(forceStringEx(self.edtPWLPatrName.text())) self._filter['chkPWLBirthDay'] = self.chkPWLBirthDay.isChecked() self._filter['birthDay'] = self.edtPWLBirthDay.date()
def getClientInfo(node): doc = DocumentInfo(forceUnicode(node._a21_ps), forceUnicode(node._a22_pn), forceInt(node._a23_dt)) policy = PolicyInfo(forceUnicode(node._a11_dcs), forceUnicode(node._a12_dcn), forceInt(node._a10_dct)) return AttachedClientInfo(nameCase(forceUnicode(node._a15_pfio)), nameCase(forceUnicode(node._a16_pnm)), nameCase(forceUnicode(node._a17_pln)), forceDate(fromDateTimeTuple(node._a19_pbd)), doc=doc, policy=policy)
def getAttachedClientInfo(node): doc = DocumentInfo(forceUnicode(node._a28), forceUnicode(node._a29), forceInt(node._a30)) policy = PolicyInfo(forceUnicode(node._a05), forceUnicode(node._a06), forceInt(node._a07), enp=forceUnicode(node._a08), insurerCode=forceUnicode(node._a32)) attaches = [ AttachInfo(begDate=fromDateTimeTuple(a._i1), doctorSNILS=forceUnicode(a._i2), sectionCode=forceUnicode(a._i3), orgCode=forceUnicode(a._i4), attachType=forceInt(a._i5)) for a in node._a09 ] regAddress = AddressInfo(forceUnicode(node._a12_r), forceUnicode(node._a13_c), forceUnicode(node._a14_n), forceUnicode(node._a15_u), forceUnicode(node._a16_d), forceUnicode(node._a17_k), forceUnicode(node._a18_k)) locAddress = AddressInfo(forceUnicode(node._a19_pr), forceUnicode(node._a20_pc), forceUnicode(node._a21_pn), forceUnicode(node._a22_pu), forceUnicode(node._a23_pd), forceUnicode(node._a24_pk), forceUnicode(node._a25_pk)) return [ AttachedClientInfo(nameCase(forceUnicode(node._a01)), nameCase(forceUnicode(node._a02)), nameCase(forceUnicode(node._a03)), birthDate=forceDate(fromDateTimeTuple( node._a04)), sex=forceUnicode(node._a10), SNILS=forceUnicode(node._a31), doc=doc, policy=policy, attach=attach, regAddress=regAddress, locAddress=locAddress) for attach in attaches ]
def getPersonInfo(id): result = {} if id: db = QtGui.qApp.db tablePerson = db.table('Person') record = db.getRecord(tablePerson, '*', id) if record: result['id'] = id result['code'] = forceString(record.value('code')) lastName = nameCase(forceString(record.value('lastName'))) firstName = nameCase(forceString(record.value('firstName'))) patrName = nameCase(forceString(record.value('patrName'))) result['lastName'] = lastName result['firstName'] = firstName result['patrName'] = patrName result['fullName'] = formatNameInt(lastName, firstName, patrName) result['shortName'] = formatShortNameInt(lastName, firstName, patrName) result['orgStructure_id'] = forceRef( record.value('orgStructure_id')) result['post_id'] = forceRef(record.value('post_id')) result['postName'] = forceString( db.translate('rbPost', 'id', result['post_id'], 'name')) result['speciality_id'] = forceRef(record.value('speciality_id')) result['specialityName'] = forceString( db.translate('rbSpeciality', 'id', result['speciality_id'], 'name')) result['maritalStatus'] = forceInt(record.value('maritalStatus')) result['contactNumber'] = forceString( record.value('contactNumber')) result['regType'] = forceInt(record.value('regType')) result['regBegDate'] = forceDate(record.value('regBegDate')) result['regEndDate'] = forceDate(record.value('regEndDate')) result['isReservist'] = forceInt(record.value('isReservist')) result['employmentType'] = forceInt(record.value('employmentType')) result['occupationType'] = forceInt(record.value('occupationType')) result['citizenship_id'] = forceInt(record.value('citizenship_id')) return result
def getDeAttachedClientInfo(node): p = node._p11_pr doc = DocumentInfo(forceUnicode(p._a21_ps), forceUnicode(p._a22_pn), forceInt(p._a23_dt)) policy = PolicyInfo(forceUnicode(p._a11_dcs), forceUnicode(p._a12_dcn), forceInt(p._a10_dct), insurerCode=forceUnicode(p._a13_smcd), insuranceArea=forceUnicode(p._a14_trcd)) attach = AttachInfo(orgCode=forceUnicode(node._p15_mo), sectionCode=forceUnicode(node._p12_sect), endDate=forceDate(fromDateTimeTuple( node._p13_add)), deattachReason=forceInt(node._p14_adr), id=forceRef(node._p10_nzap)) return AttachedClientInfo(nameCase(forceUnicode(p._a15_pfio)), nameCase(forceUnicode(p._a16_pnm)), nameCase(forceUnicode(p._a17_pln)), forceDate(fromDateTimeTuple(p._a19_pbd)), forceInt(p._a18_ps), doc=doc, policy=policy, attach=attach)
def process(self, dbfP, record, codeLPU): db = QtGui.qApp.db birthDate = forceDate(record.value('clientBirthDate')) # Номер стат.талона clientId = forceRef(record.value('clientId')) eventId = forceRef(record.value('eventId')) insurerArea = forceString(record.value('insurerArea')) isAlien = insurerArea[:2] != QtGui.qApp.defaultKLADR()[:2] if not ((clientId, eventId) in self.exportedClients): dbfRecord = dbfP.newRecord() # номер реестра счетов (п. 1 примечаний) обязательное # dbfRecord['NS'] = 123 #self.edtRegistryNumber.value() # тип реестра счетов (п. 2;4 примечаний) обязательное SPR21 # dbfRecord['VS'] = accType # дата формирования реестра счетов (п. 3 примечаний) обязательное dbfRecord['DATS'] = pyDate(QtCore.QDate()) # номер персонального счета обязательное dbfRecord[ 'SN'] = eventId # В импорте ФЛК в этом поле ожидается Event.id # дата формирования персонального счета обязательное dbfRecord['DATPS'] = pyDate(QtCore.QDate()) # код медицинской организации в системе ОМС, # предоставившей медицинскую помощь обязательное SPR01 dbfRecord['CODE_MO'] = codeLPU # ОГРН плательщика dbfRecord['PL_OGRN'] = forceString( record.value('insurerOGRN')) or (self.TF_OGRN if isAlien else '') # фамилия (п. 5 примечаний) обязательное dbfRecord['FIO'] = nameCase( forceString(record.value('clientLastName'))) # имя (п. 5 примечаний) обязательное dbfRecord['IMA'] = nameCase( forceString(record.value('clientFirstName'))) # отчество (п. 5 примечаний) patrName = forceString(record.value('clientPatrName')) dbfRecord['OTCH'] = nameCase(patrName) # пол (М/Ж) (п. 6 примечаний) обязательное dbfRecord['POL'] = formatSex(record.value('clientSex')).upper() # дата рождения (п. 7 примечаний) обязательное dbfRecord['DATR'] = pyDate(birthDate) # СНИЛС dbfRecord['SNILS'] = formatSNILS( forceString(record.value('clientSNILS'))) # статус пациента обязательное SPR40 age = calcAgeInYears(birthDate, QtCore.QDate.currentDate()) # код ОКАТО территории страхования по ОМС обязательное для инокраевых SPR39 dbfRecord['OKATO_OMS'] = forceStringEx( record.value('insurerOKATO')) if not dbfRecord['OKATO_OMS']: insurerName = forceString(record.value('insurerName')) self.log(u'<b><font color=orange>Внимание</font></b>:' \ u' ОКАТО для ОМС "%s" не задан, пытаюсь определить по области страхования!' % insurerName) dbfRecord['OKATO_OMS'] = forceString( db.translate('kladr.KLADR', 'CODE', insurerArea, 'OCATD', idFieldName='CODE')) if not dbfRecord['OKATO_OMS']: self.log(u'<b><font color=red>Внимание</font></b>:' \ u' ОКАТО для ОМС "%s" не задан!' % forceString(record.value('insurerName'))) policyInsuranceArea = forceString( record.value('policyInsuranceArea')) if policyInsuranceArea: dbfRecord['OKATO_OMS'] = forceString( db.translate('kladr.KLADR', 'CODE', policyInsuranceArea, 'OCATD', idFieldName='CODE')) # серия полиса ОМС обязательное dbfRecord['SPS'] = forceString(record.value('policySerial')) # номер полиса ОМС обязательное dbfRecord['SPN'] = forceString(record.value('policyNumber')) # дата начала действия полиса ОМС (п. 8 примечаний) обязательное для инокраевых # серия документа, удостоверяющего личность пациента (представителя) (п. 10 примечаний) documentSerial = forceString(record.value('documentSerial')) if documentSerial: dbfRecord['S_DOC'] = documentSerial # номер документа, удостоверяющего личность пациента (представителя) (п. 10 примечаний) documentNumber = forceString(record.value('documentNumber')) if documentNumber: dbfRecord['N_DOC'] = documentNumber # Признак новорожденого isLittleStrangerAge = calcAgeInDays( birthDate, forceDate(record.value('eventSetDate'))) < 90 exportAsLittleStranger = isLittleStrangerAge and ( dbfRecord['S_DOC'] == '' and dbfRecord['N_DOC'] == '') # (dbfRecord['SPS'] == '' and dbfRecord['SPN'] == '') and \ # признак "Особый случай" при регистрации обращения # за медицинской помощью (п. 9 примечаний) SPR42 flags = '' if dbfRecord['SPS'] == '' and dbfRecord['SPN'] == '' and forceDate( record.value('eventExecDate')) <= QtCore.QDate( 2016, 9, 30): # нет данных по полису: flags += ' 1' if exportAsLittleStranger: # новорождённый: flags += ' 2' if patrName == '': flags += ' 4' flags += ' ' + self.getSocStatusFederalCode(clientId) dbfRecord['Q_G'] = trim(flags) representativeInfo = self.getClientRepresentativeInfo(clientId) if exportAsLittleStranger and representativeInfo: # статус представителя пациента обязательное для инокраевых SPR41 # dbfRecord['STAT_P'] = representativeInfo.get('relationTypeCode', '0')[:1] # 'C', 1), # фамилия родителя (представителя) пациента (п. 5 примечаний) обязательное для инокраевых dbfRecord['FAMP'] = representativeInfo.get('lastName', '') # имя родителя (представителя) пациента (п. 5 примечаний) обязательное для инокраевых dbfRecord['IMP'] = representativeInfo.get('firstName', '') # отчество родителя (представителя) пациента (п. 5 примечаний) dbfRecord['OTP'] = representativeInfo.get('patrName', '') s = representativeInfo.get('serial', '') n = representativeInfo.get('number', '') # код типа документа, удостоверяющего личность пациента (представителя) (п. 10 примечаний) SPR43 dbfRecord['C_DOC'] = representativeInfo.get( 'documentTypeRegionalCode', 18 if s or n else 0) % 100 # серия документа, удостоверяющего личность пациента (представителя) (п. 10 примечаний) dbfRecord['S_DOC'] = s # номер документа, удостоверяющего личность пациента (представителя) (п. 10 примечаний) dbfRecord['N_DOC'] = n sexp = representativeInfo.get('sex', 0) dbfRecord[ 'POLP'] = u'М' if sexp == 1 else u'Ж' if sexp == 2 else u'0' dbfRecord['DATRP'] = pyDate( representativeInfo.get('birthDate', None)) dbfRecord['FIO'] = dbfRecord['FAMP'] dbfRecord['IMA'] = dbfRecord['IMP'] dbfRecord['OTCH'] = dbfRecord['OTP'] dbfRecord['POL'] = dbfRecord['POLP'] dbfRecord['DATR'] = dbfRecord['DATRP'] dbfRecord['SNILS'] = formatSNILS( representativeInfo.get('SNILS', '')) dbfRecord['SPS'] = representativeInfo.get('policySerial', '') dbfRecord['SPN'] = representativeInfo.get('policyNumber', '') # код типа документа, удостоверяющего личность пациента (представителя) # (п. 10 примечаний) SPR43 documentRegionalCode = forceInt( record.value('documentTypeRegionalCode')) % 100 if documentRegionalCode and (documentSerial or documentNumber): dbfRecord['C_DOC'] = documentRegionalCode dbfRecord['SPV'] = forceInt(record.value('policyKindCode')) % 10 setDate = forceDate(record.value('eventSetDate')).toPyDate() execDate = forceDate(record.value('eventExecDate')).toPyDate() dbfRecord['DATN'] = setDate dbfRecord['DATO'] = execDate dbfRecord.store() self.exportedClients.add((clientId, eventId))
def toXMLValue(value): return nameCase(forceString(value))
def getPersonItem(self, clientId): u""" :param clientId: Client.id :rtype: PersonItem """ db = self.db tableClient = db.table('Client') tableDocument = db.table('ClientDocument') tableDocumentType = db.table('rbDocumentType') tablePolicy = db.table('ClientPolicy') tablePolicyKind = db.table('rbPolicyKind') tableInsurer = db.table('Organisation').alias('Ins') tableInsurerHead = db.table('Organisation').alias('InsHead') table = tableClient table = table.leftJoin( tableDocument, tableDocument['id'].eq( db.func.getClientDocumentId(tableClient['id']))) table = table.leftJoin( tableDocumentType, tableDocumentType['id'].eq(tableDocument['documentType_id'])) table = table.leftJoin( tablePolicy, tablePolicy['id'].eq( db.func.getClientPolicyId(tableClient['id'], 1))) table = table.leftJoin( tablePolicyKind, tablePolicyKind['id'].eq(tablePolicy['policyKind_id'])) table = table.leftJoin( tableInsurer, tableInsurer['id'].eq(tablePolicy['insurer_id'])) table = table.leftJoin( tableInsurerHead, tableInsurerHead['id'].eq(tableInsurer['head_id'])) cols = [ tableClient['lastName'], tableClient['firstName'], tableClient['patrName'], tableClient['sex'], tableClient['birthDate'], tableClient['SNILS'], tableDocument['serial'].alias('docSerial'), tableDocument['number'].alias('docNumber'), tableDocumentType['code'].alias('docType'), tablePolicy['serial'].alias('policySerial'), tablePolicy['number'].alias('policyNumber'), tablePolicyKind['regionalCode'].alias('policyType'), db.ifnull(tableInsurerHead['miacCode'], tableInsurer['miacCode']).alias('insurerCode'), db.ifnull(tableInsurerHead['OKATO'], tableInsurer['OKATO']).alias('insurerOKATO') ] rec = self.db.getRecordEx(table, cols, tableClient['id'].eq(clientId)) if rec: policyNumber = forceString(rec.value('policyNumber')) policyType = forceInt(rec.value('policyType')) return PersonItem( lastName=nameCase(forceString(rec.value('lastName'))), firstName=nameCase(forceString(rec.value('firstName'))), patrName=nameCase(forceString(rec.value('patrName'))), sex=forceInt(rec.value('sex')), birthDate=forceDate(rec.value('birthDate')), SNILS=formatSNILS(forceString(rec.value('SNILS'))), docSerial=forceString(rec.value('docSerial')), docNumber=forceString(rec.value('docNumber')), docType=forceInt(rec.value('docType')), policySerial=forceString(rec.value('policySerial')), policyNumber=policyNumber, policyType=policyType, insurerCode=forceString(rec.value('insurerCode')), insuranceArea=forceString(rec.value('insurerOKATO')), ) return PersonItem()
def formatAddr(a): if not a: return u'' l = a.split() if len(l) > 1: return u' '.join(map(nameCase, l[:-1]) + [l[-1].lower()]) return nameCase(a)
def toPlanItemList(self, idList): u""" Персонализированный список лиц, подлежажих проф. мероприятиям :param idList: [list of ClientExaminationPlan.id] :rtype: list of PlanItem """ db = self.db tableAttach = db.table('ClientAttach') tableLastAttach = tableAttach.alias('LastAttach') tableClientExamPlan = db.table('ClientExaminationPlan') tableClient = db.table('Client') tableDocument = db.table('ClientDocument') tableDocumentType = db.table('rbDocumentType') tableEvent = db.table('Event') tableEventType = db.table('EventType') tableEventProfile = db.table('rbEventProfile') tableEventResult = db.table('rbResult') tablePolicy = db.table('ClientPolicy') tablePolicyKind = db.table('rbPolicyKind') tableInsurer = db.table('Organisation').alias('Ins') tableInsurerHead = db.table('Organisation').alias('InsHead') table = tableClientExamPlan table = table.innerJoin( tableClient, tableClient['id'].eq(tableClientExamPlan['client_id'])) table = table.leftJoin( tableDocument, tableDocument['id'].eq( db.func.getClientDocumentId(tableClient['id']))) table = table.leftJoin( tableDocumentType, tableDocumentType['id'].eq(tableDocument['documentType_id'])) table = table.leftJoin( tablePolicy, tablePolicy['id'].eq( db.func.getClientPolicyId(tableClient['id'], 1))) table = table.leftJoin( tablePolicyKind, tablePolicyKind['id'].eq(tablePolicy['policyKind_id'])) table = table.leftJoin( tableInsurer, tableInsurer['id'].eq(tablePolicy['insurer_id'])) table = table.leftJoin( tableInsurerHead, tableInsurerHead['id'].eq(tableInsurer['head_id'])) table = table.leftJoin( tableLastAttach, tableLastAttach['id'].eqStmt( db.selectMax(tableAttach, tableAttach['id'], [ tableAttach['client_id'].eq(tableClient['id']), tableAttach['attachType_id'].inlist( self.attachedAttachTypes), tableAttach['endDate'].isNull(), tableAttach['deleted'].eq(0) ]))) table = table.leftJoin( tableEvent, tableEvent['id'].eq(tableClientExamPlan['event_id'])) table = table.leftJoin( tableEventType, tableEventType['id'].eq(tableEvent['eventType_id'])) table = table.leftJoin( tableEventProfile, tableEventProfile['id'].eq(tableEventType['eventProfile_id'])) table = table.leftJoin( tableEventResult, tableEventResult['id'].eq(tableEvent['result_id'])) cols = [ tableClient['lastName'], tableClient['firstName'], tableClient['patrName'], tableClient['sex'], tableClient['birthDate'], tableClient['SNILS'], tableDocument['serial'].alias('docSerial'), tableDocument['number'].alias('docNumber'), tableDocumentType['code'].alias('docType'), tablePolicy['serial'].alias('policySerial'), tablePolicy['number'].alias('policyNumber'), tablePolicyKind['regionalCode'].alias('policyType'), db.ifnull(tableInsurerHead['miacCode'], tableInsurer['miacCode']).alias('insurerCode'), db.ifnull(tableInsurerHead['OKATO'], tableInsurer['OKATO']).alias('insurerOKATO'), tableClientExamPlan['id'], tableClientExamPlan['year'], tableClientExamPlan['month'], tableClientExamPlan['kind'], tableClientExamPlan['category'], tableLastAttach['orgStructure_id'].alias('attachOrgStructureId'), tableEvent['execDate'], tableEventProfile['regionalCode'].alias('eventProfileCode') ] cond = [tableClientExamPlan['id'].inlist(idList)] planItems = [] for rec in db.iterRecordList(table, cols, cond): attachOrgCode, attachSectionCode = CBookkeeperCode.getOrgCode( forceRef(rec.value('attachOrgStructureId'))) person = PersonItem( lastName=nameCase(forceString(rec.value('lastName'))), firstName=nameCase(forceString(rec.value('firstName'))), patrName=nameCase(forceString(rec.value('patrName'))), sex=forceInt(rec.value('sex')), birthDate=forceDate(rec.value('birthDate')), SNILS=formatSNILS(forceString(rec.value('SNILS'))), docSerial=forceString(rec.value('docSerial')), docNumber=forceString(rec.value('docNumber')), docType=forceInt(rec.value('docType')), policySerial=forceString(rec.value('policySerial')), policyNumber=forceString(rec.value('policyNumber')), policyType=forceInt(rec.value('policyType')), insurerCode=forceString(rec.value('insurerCode')), insuranceArea=forceString(rec.value('insurerOKATO')), ) planItem = PlanItem(rid=forceRef(rec.value('id')), kind=forceInt(rec.value('kind')), year=forceInt(rec.value('year')), month=forceInt(rec.value('month')), category=forceInt(rec.value('category')), orgCode=attachOrgCode, sectionCode=attachSectionCode, person=person) planItems.append(planItem) return planItems
def toFactExecList(self, idList): u""" Список проведенных проф. мероприятий :param idList: [list of ClientExaminationPlan.id] :rtype: list of FactExec """ db = self.db tableClient = db.table('Client') tableClientExamPlan = db.table('ClientExaminationPlan') tableDocument = db.table('ClientDocument') tableDocumentType = db.table('rbDocumentType') tableEvent = db.table('Event') tableOrganisation = db.table('Organisation') tableInsurer = db.table('Organisation').alias('Ins') tableInsurerHead = db.table('Organisation').alias('InsHead') tablePolicy = db.table('ClientPolicy') tablePolicyKind = db.table('rbPolicyKind') table = tableClientExamPlan table = table.innerJoin( tableClient, tableClient['id'].eq(tableClientExamPlan['client_id'])) table = table.leftJoin( tableDocument, tableDocument['id'].eq( db.func.getClientDocumentId(tableClient['id']))) table = table.leftJoin( tableDocumentType, tableDocumentType['id'].eq(tableDocument['documentType_id'])) table = table.leftJoin( tablePolicy, tablePolicy['id'].eq( db.func.getClientPolicyId(tableClient['id'], 1))) table = table.leftJoin( tablePolicyKind, tablePolicyKind['id'].eq(tablePolicy['policyKind_id'])) table = table.leftJoin( tableInsurer, tableInsurer['id'].eq(tablePolicy['insurer_id'])) table = table.leftJoin( tableInsurerHead, tableInsurerHead['id'].eq(tableInsurer['head_id'])) table = table.leftJoin( tableEvent, tableEvent['id'].eq(tableClientExamPlan['event_id'])) table = table.leftJoin( tableOrganisation, tableOrganisation['id'].eq(tableEvent['org_id'])) cols = [ tableClientExamPlan['id'], tableClientExamPlan['year'], tableClientExamPlan['month'], tableClientExamPlan['kind'], tableClientExamPlan['category'], tableClientExamPlan['step'], tableClientExamPlan['date'], tableClient['lastName'], tableClient['firstName'], tableClient['patrName'], tableClient['sex'], tableClient['birthDate'], tableClient['SNILS'], tableDocument['serial'].alias('docSerial'), tableDocument['number'].alias('docNumber'), tableDocumentType['code'].alias('docType'), tablePolicy['serial'].alias('policySerial'), tablePolicy['number'].alias('policyNumber'), tablePolicyKind['regionalCode'].alias('policyType'), db.ifnull(tableInsurerHead['miacCode'], tableInsurer['miacCode']).alias('insurerCode'), db.ifnull(tableInsurerHead['OKATO'], tableInsurer['OKATO']).alias('insurerOKATO'), tableOrganisation['infisCode'].alias('orgCode') ] cond = [tableClientExamPlan['id'].inlist(idList)] factExecs = [] for rec in db.iterRecordList(table, cols, cond): person = PersonItem( lastName=nameCase(forceString(rec.value('lastName'))), firstName=nameCase(forceString(rec.value('firstName'))), patrName=nameCase(forceString(rec.value('patrName'))), sex=forceInt(rec.value('sex')), birthDate=forceDate(rec.value('birthDate')), SNILS=formatSNILS(forceString(rec.value('SNILS'))), docSerial=forceString(rec.value('docSerial')), docNumber=forceString(rec.value('docNumber')), docType=forceInt(rec.value('docType')), policySerial=forceString(rec.value('policySerial')), policyNumber=forceString(rec.value('policyNumber')), policyType=forceInt(rec.value('policyType')), insurerCode=forceString(rec.value('insurerCode')), insuranceArea=forceString(rec.value('insurerOKATO')), ) factExec = FactExec(rid=forceRef(rec.value('id')), orgCode=forceString(rec.value('orgCode')) or self.orgCode, date=forceDate(rec.value('date')), step=forceInt(rec.value('step')), person=person) factExecs.append(factExec) return factExecs