示例#1
0
 def getPatientDesc(record):
     desc = ''
     desc += u'ИБ №' + (forceString(record.value('externalId'))       +   '\n')
     desc += (forceString(record.value('lastName'))         +   '\n')
     desc += (forceString(record.value('firstName'))        +   '\n')
     desc += (forceString(record.value('patrName'))         +   '\n')
     desc += u'Пол: ' + (formatSex(record.value('sex'))                +   '\n')
     date = forceDate(record.value('birthDate'))
     desc += u'Дата рождения: ' + (date.toString('dd.MM.yyyy') + u'(' + repr(calcAgeInYears(date, QtCore.QDate.currentDate())) + u' лет)\n')
     return desc
示例#2
0
def sendTestASTM(widget, clientInfo, jobTicketId, laboratory, testCodes,
                 properties):
    from Exchange.Lab.AstmE1381.FileInterface import CFileInterface
    from Exchange.Lab.AstmE1394.Message import CMessage
    import json

    opts = json.loads(laboratory.address)

    now = QtCore.QDateTime.currentDateTime()
    message = CMessage()
    patient = message.newPatient()
    patient.patientId = clientInfo['id']
    patient.laboratoryPatientId = clientInfo['id']
    patient.lastName = clientInfo['lastName']
    patient.firstName = clientInfo['firstName']
    patient.patrName = clientInfo['patrName']
    patient.birthDate = clientInfo['birthDate']
    patient.sex = ['U', 'M', 'F'][clientInfo['sexCode']]
    patient.age = calcAgeInYears(clientInfo['birthDate'], now.date())

    for property in properties:
        testId = property.type().testId
        if testId in testCodes:
            book, code, name = testCodes[testId]
            propertyRecordId = forceRef(property.getRecord().value('id'))
            order = patient.newOrder()
            order.specimenId = jobTicketId
            order.assayCode = code
            order.assayName = name
            order.requestDateTime = now
            order.specimenCollectionDateTime = now
            order.propertyRecordId
            order.priority = 'R'
            order.actionCode = 'A'
            #order.specimenDescriptor =  'S'
            order.userField1 = jobTicketId
            order.userField2 = propertyRecordId
            order.reportTypes = 'O'
            #order.specimenInstitution='LAB2'
        else:
            pass  # 'testId' not found

    records = message.getRecords(encoding=opts.get('encoding', 'utf-8'))
    interface = CFileInterface(opts)
    interface.send(records)
    QtGui.QMessageBox.information(widget, u'Результат', u'Передача успешна',
                                  QtGui.QMessageBox.Close)
示例#3
0
def sendRequestOverASTM(widget, equipmentInterface, clientInfo, dateTime,
                        label, testList):
    from Exchange.Lab.AstmE1381.FileInterface import CFileInterface
    from Exchange.Lab.AstmE1394.Message import CMessage
    import json

    opts = json.loads(equipmentInterface.address)

    now = QtCore.QDateTime.currentDateTime()
    message = CMessage()
    patient = message.newPatient()
    patient.patientId = clientInfo['id']
    patient.laboratoryPatientId = label
    patient.lastName = clientInfo['lastName']
    patient.firstName = clientInfo['firstName']
    patient.patrName = clientInfo['patrName']
    patient.birthDate = clientInfo['birthDate']
    patient.sex = ['U', 'M', 'F'][clientInfo['sexCode']]
    patient.age = calcAgeInYears(clientInfo['birthDate'], dateTime.date())

    for test in testList:
        probeId, testCode, testName, specimenCode, specimenName, isUrgent = test
        order = patient.newOrder()
        order.specimenId = label
        order.instrumentSpecimenId = label
        order.assayCode = testCode
        order.assayName = testName
        order.requestDateTime = now
        order.specimenCollectionDateTime = dateTime
        order.priority = 'A' if isUrgent else 'R'
        order.actionCode = 'A'
        order.specimenDescr = specimenCode
        order.userField1 = probeId
        #            order.userField2      = probeId
        order.reportTypes = 'O'
        #order.specimenInstitution='LAB2'

    records = message.getRecords(encoding=opts.get('encoding', 'utf-8'))
    interface = CFileInterface(opts)
    interface.write(records)
示例#4
0
    def build(self, params):
        begDate = params.get('begDate', QtCore.QDate())
        endDate = params.get('endDate', QtCore.QDate())
        byPeriod = params.get('byPeriod', False)
        doctype = params.get('doctype', 0)
        tempInvalidReason = params.get('tempInvalidReason', None)
        onlyClosed = params.get('onlyClosed', True)
        orgStructureId = params.get('orgStructureId', None)
        personId = params.get('personId', None)
        insuranceOfficeMark = params.get('insuranceOfficeMark', 0)
        oldForm = params.get('oldForm', 0)
        tableRows = MainRows if oldForm else newMainRows

        mapMainRows = createMapCodeToRowIdx(
            [row[1] for row in tableRows if row[1]])

        db = QtGui.qApp.db

        rowSize = 12
        reportMainData = [[0] * rowSize for row in xrange(len(tableRows) * 2)]
        pregnancyRowIndex = len(tableRows) - 1
        totalRowIndex = pregnancyRowIndex - 1
        quarantineRowIndex = totalRowIndex - 1
        sanatoriumRowIndex = quarantineRowIndex - 1
        careRowIndex = sanatoriumRowIndex - 1

        query = selectData(begDate, endDate, byPeriod, doctype,
                           tempInvalidReason, onlyClosed, orgStructureId,
                           personId, insuranceOfficeMark)
        self.setQueryText(forceString(query.lastQuery()))
        while query.next():
            record = query.record()
            reasonGroup = forceInt(record.value('reasonGroup'))
            reasonCode = forceString(record.value('reasonCode'))
            duration = forceInt(record.value('duration'))
            if reasonGroup == 1:  ## уход
                #                sex = forceInt(record.value('sex'))
                #                age = calcAgeInYears(forceDate(record.value('birthDate')), forceDate(record.value('begDate')))
                sex = forceInt(record.value('tsex'))
                age = forceInt(record.value('tage'))
            else:
                sex = forceInt(record.value('sex'))
                age = calcAgeInYears(forceDate(record.value('birthDate')),
                                     forceDate(record.value('caseBegDate')))

            rows = []
            if reasonGroup == 0:  ## заболевание
                MKB = forceString(record.value('MKB'))
                if MKB[:2] == 'N7':
                    pass
                rows.extend(mapMainRows.get(normalizeMKB(MKB), []))
                if rows or MKB[:1] == 'Z':
                    rows.append(totalRowIndex)
            elif reasonGroup == 1:  ## уход
                if reasonCode in (u'09', u'12', u'13',
                                  u'15'):  # уход за больным
                    rows = [careRowIndex, totalRowIndex]
                elif reasonCode == u'03':  # карантин
                    rows = [quarantineRowIndex, totalRowIndex]
                elif reasonCode == u'14':  # поствакцинальное осложнение
                    rows = [quarantineRowIndex, totalRowIndex]
                elif reasonCode == u'08':  # санкурлечение
                    rows = [sanatoriumRowIndex, totalRowIndex]
            elif reasonGroup == 2:
                rows = [pregnancyRowIndex]
            # if age <15:
            #     continue
            if sex not in [1, 2]:
                continue
            ageCol = min(max(age, 15), 60) / 5 - 1
            for row in rows:
                reportLine = reportMainData[row * 2 + (1 if sex == 1 else 0)]
                reportLine[0] += duration
                reportLine[1] += 1
                reportLine[ageCol] += 1

        # now text
        doc = QtGui.QTextDocument()
        cursor = QtGui.QTextCursor(doc)

        cursor.setCharFormat(CReportBase.ReportTitle)
        cursor.insertText(self.name)
        cursor.insertBlock()
        self.dumpParams(cursor, params)
        cursor.insertBlock()

        tableColumns = [
            ('15%', [u'Причина нетрудоспособности', u'',
                     u'1'], CReportBase.AlignLeft),
            ('10%', [u'Код по МКБ X', u'', u'2'], CReportBase.AlignLeft),
            ('5%', [u'Пол', u'', u'3'], CReportBase.AlignCenter),
            ('5%', [u'№ строки', u'', u'4'], CReportBase.AlignRight),
            ('10%', [u'число дней', u'', u'5'], CReportBase.AlignRight),
            ('5%', [u'число случаев', u'', u'6'], CReportBase.AlignRight),
            ('5%', [u'в т.ч. по возрастам', u'15-19',
                    u'7'], CReportBase.AlignRight),
            ('5%', [u'', u'20-24', u'8'], CReportBase.AlignRight),
            ('5%', [u'', u'25-29', u'9'], CReportBase.AlignRight),
            ('5%', [u'', u'30-34', u'10'], CReportBase.AlignRight),
            ('5%', [u'', u'35-39', u'11'], CReportBase.AlignRight),
            ('5%', [u'', u'40-44', u'12'], CReportBase.AlignRight),
            ('5%', [u'', u'45-49', u'13'], CReportBase.AlignRight),
            ('5%', [u'', u'50-54', u'14'], CReportBase.AlignRight),
            ('5%', [u'', u'55-59', u'15'], CReportBase.AlignRight),
            ('5%', [u'', u'60 и старше', u'16'], CReportBase.AlignRight),
        ]
        table = createTable(cursor, tableColumns)
        table.mergeCells(0, 0, 2, 1)  # п.н.
        table.mergeCells(0, 1, 2, 1)  # мкб
        table.mergeCells(0, 2, 2, 1)  # пол
        table.mergeCells(0, 3, 2, 1)  # N
        table.mergeCells(0, 4, 2, 1)  # дней
        table.mergeCells(0, 5, 2, 1)  # случаев
        table.mergeCells(0, 6, 1, 10)  # по возрастам

        for row, rowDescr in enumerate(tableRows):
            i = table.addRow()
            table.setText(i, 0, rowDescr[0])
            table.setText(i, 1, rowDescr[1])
            rowSep = rowDescr[2]
            if rowSep[0] > 0 and rowSep[1] > 0:
                i1 = table.addRow()
                table.mergeCells(i, 0, 2, 1)  # п.н.
                table.mergeCells(i, 1, 2, 1)  # мкб
                mTableRow = i
                wTableRow = i1
            elif rowSep[0] > 0:
                mTableRow = -1
                wTableRow = i
            else:
                mTableRow = i
                wTableRow = -1
            if wTableRow >= 0:
                table.setText(wTableRow, 2, u'ж')
                table.setText(wTableRow, 3, rowSep[0])
                reportLine = reportMainData[row * 2]
                for col in xrange(rowSize):
                    table.setText(wTableRow, 4 + col, reportLine[col])
            if mTableRow >= 0:
                table.setText(mTableRow, 2, u'м')
                table.setText(mTableRow, 3, rowSep[1])
                reportLine = reportMainData[row * 2 + 1]
                for col in xrange(rowSize):
                    table.setText(mTableRow, 4 + col, reportLine[col])
        return doc
示例#5
0
    def getItemFromRecord(self, record):
        begDate = forceDateTime(record.value('begDate'))
        endDate = forceDateTime(record.value('endDate'))
        bedCodeName = forceString(record.value('bedCodeName')).split("  ")
        directionDate = forceDateTime(record.value('directionDate'))

        statusObservation = forceString(record.value('statusObservation')).split("  ")
        statusObservationCode = forceString(statusObservation[0]) if len(statusObservation)>=1 else ''
        statusObservationName = forceString(statusObservation[1]) if len(statusObservation)>=2 else ''
        statusObservationColor = forceString(statusObservation[2]) if len(statusObservation)>=3 else ''

        comfortable = forceString(record.value('comfortable'))
        comfortableList = []
        if comfortable:
            comfortableList = comfortable.split("  ")
        comfortableDate = forceDateTime(QtCore.QVariant(comfortableList[0])) if len(comfortableList)>=1 else ''
        comfortableStatus = forceInt(QtCore.QVariant(comfortableList[1])) if len(comfortableList)>=2 else 0
        if comfortableStatus:
            comfortablePayStatus = getRealPayed(comfortableStatus)
        else:
            comfortablePayStatus = False
        birthDate = forceDate(record.value('birthDate'))
        ageString = forceString(calcAge(birthDate, forceDate(endDate)))
        ageInYears = forceInt(calcAgeInYears(birthDate, forceDate(QtCore.QDate().currentDate())))
        sex = forceInt(record.value('sex'))
        item = {'statusObservationCode' : statusObservationCode,
                'nameFinance' : forceString(record.value('nameFinance')),
                'codeFinance' : forceString(record.value('codeFinance')),
                'feed' : forceBool(record.value('countEventFeedId')),
                'physicalActivityName' : forceString(record.value('physicalActivityName')),
                'clientId' : forceRef(record.value('client_id')),
                'contractInfo': '%s %s %s' % tuple(map(lambda f: forceStringEx(record.value(f)), ['contract_number', 'contract_date', 'contract_resolution'])),
                'externalId' : forceString(record.value('externalId')),
                'clientName' : forceString(record.value('lastName')) + u' ' + forceString(record.value('firstName')) + u' ' + forceString(record.value('patrName')),
                'sex' : self.sex[sex],
                'birthDateRaw' : birthDate,
                'birthDate' : forceString(birthDate),
                'age' : ageString,
                'employable': self.employableCheck(sex, ageInYears),
                'plannedEndDate' : forceDate(record.value('plannedEndDate')),
                'MKB' : forceString(record.value('MKB')),
                'quota':  forceString(record.value('quotaCode')),#quotaTypeClassItems[forceInt(record.value('class'))][0] if forceRef(record.value('class')) >= 0 else u'',
                'codeBed' : forceString(bedCodeName[0]) if len(bedCodeName)>=1 else '' + forceString(bedCodeName[2]) if len(bedCodeName)>=3 else '',
                'nameBed' : forceString(bedCodeName[1]) if len(bedCodeName)>=2 else '',
                'profileBed': forceString(record.value('bedProfile')),
                'nameOS' : forceString(record.value('nameOS')),
                'codeOS' : forceString(record.value('codeOS')),
                'idOS' : forceRef(record.value('idOS')),
                'namePerson' : forceString(record.value('namePerson')),
                'eventId' : forceRef(record.value('eventId')),
                'statusObservationName' : statusObservationName,
                'actionId' : forceRef(record.value('actionId')),
                'actionTypeId' : forceRef(record.value('actionType_id')),
                'statusObservationColor' : statusObservationColor,
                'begDate' : begDate,
                'endDate' : endDate,
                'begDateString' : begDate.toString('dd.MM.yyyy hh:mm'),
                'endDateString' : endDate.toString('dd.MM.yyyy hh:mm'),
                'begDateReceived' : forceDateTime(record.value('setDate')).toString('dd.MM.yyyy hh:mm'),
                'waitingDays': directionDate.daysTo(QtCore.QDateTime.currentDateTime()) if not directionDate.date().isNull() else u'',
                'isHasNotPayedActions' : forceBool(record.value('isExistsNotPayedActions')),     #Определение наличия в событии клиента действий, имеющих тип финансирования ПМУ и без состояния "Оплачено" (задача 482, atronah)
                'comfortableDate' : comfortableDate,
                'comfortablePayStatus' : comfortablePayStatus,
                'patronage': u'да' if forceBool(record.value('patronage')) else u'',
                'currentCommonOSName' : forceStringEx(record.value('currentCommonOSName')),
                'isUnconscious': forceInt(record.value('isUnconscious')),
                'isVIP': forceInt(record.value('isVIP')),
                'vipColor': forceInt(record.value('vipColor')),
                'snils': formatSNILS(forceString(record.value('SNILS'))),
                'directionDate': forceDate(record.value('directionDate'))
                }
        return item
示例#6
0
    def build(self, params):
        begDate = getVal(params, 'begDate', QtCore.QDate())
        endDate = getVal(params, 'endDate', QtCore.QDate())
        eventTypeId = getVal(params, 'eventTypeId', None)
        onlyPermanentAttach = getVal(params, 'onlyPermanentAttach', False)
        onlyPayedEvents = getVal(params, 'onlyPayedEvents', False)
        begPayDate = getVal(params, 'begPayDate', QtCore.QDate())
        endPayDate = getVal(params, 'endPayDate', QtCore.QDate())

        reportRowSize = 4
        reportData = [[0] * reportRowSize for row in ageSexRows]
        query = selectData(begDate, endDate, eventTypeId, onlyPermanentAttach,
                           onlyPayedEvents, begPayDate, endPayDate)

        while query.next():
            record = query.record()
            age = calcAgeInYears(forceDate(record.value('birthDate')),
                                 forceDate(record.value('date')))
            sex = forceInt(record.value('sex'))
            cnt = forceInt(record.value('cnt'))
            if cnt >= 3:
                column = 3
            else:
                column = cnt
            for row in dispatchAgeSex(age, sex):
                reportData[row][column] += 1

        # now text
        doc = QtGui.QTextDocument()
        cursor = QtGui.QTextCursor(doc)

        cursor.setCharFormat(CReportBase.ReportTitle)
        cursor.insertText(u'Итоги дополнительной диспансеризации граждан')
        cursor.insertBlock()
        self.dumpParams(cursor, params)
        cursor.insertText(u'(4000)')
        cursor.insertBlock()

        tableColumns = [
            ('30%', [
                u'Возрастной диапазон работающих граждан, прошедших диспансеризацию',
                u'', u'1'
            ], CReportBase.AlignLeft),
            ('10%', [u'№ строки', u'', u'2'], CReportBase.AlignCenter),
            ('10%', [
                u'Распределение прошедших дополнительную диспансеризацию граждан по количеству заболеваний',
                u'нет заболеваний', u'3'
            ], CReportBase.AlignRight),
            ('10%', [u'', u'1 заболевание', u'4'], CReportBase.AlignRight),
            ('10%', [u'', u'2 заболевания', u'5'], CReportBase.AlignRight),
            ('10%', [u'', u'3 и более заболеваний',
                     u'6'], CReportBase.AlignRight),
        ]
        table = createTable(cursor, tableColumns)
        table.mergeCells(0, 0, 2, 1)
        table.mergeCells(0, 1, 2, 1)
        table.mergeCells(0, 2, 1, 4)

        for iRow, row in enumerate(ageSexRows):
            i = table.addRow()
            for j in xrange(2):
                table.setText(i, j, row[j])
            for j in xrange(4):
                table.setText(i, 2 + j, reportData[iRow][j])
        return doc
示例#7
0
    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))