예제 #1
0
 def on_cmbEventType_currentIndexChanged(self, idx):
     eventTypeId = self.cmbEventType.value()
     if eventTypeId and (hasEventAssistant(eventTypeId)
                         or hasEventCurator(eventTypeId)):
         db = QtGui.qApp.db
         tableEventType = db.table('EventType')
         record = db.getRecordEx(tableEventType, [tableEventType['form']], [
             tableEventType['deleted'].eq(0),
             tableEventType['id'].eq(eventTypeId)
         ])
         form = forceString(record.value('form')) if record else ''
         if form == '027' or form == '025':
             tableEvent = db.table('Event')
             record = db.getRecordEx(
                 tableEvent,
                 [tableEvent['curator_id'], tableEvent['assistant_id']], [
                     tableEvent['eventType_id'].eq(eventTypeId),
                     tableEvent['deleted'].eq(0)
                 ], 'Event.id DESC')
             if record:
                 CPreCreateEventDialog._assistantId = forceRef(
                     record.value('assistant_id'))
                 CPreCreateEventDialog._curatorId = forceRef(
                     record.value('curator_id'))
                 self.cmbAssistantId.setValue(
                     CPreCreateEventDialog._assistantId)
                 self.cmbCuratorId.setValue(
                     CPreCreateEventDialog._curatorId)
     self.setupDatesAndTimes()
     self.setupAssistant()
     self.setupCurator()
     self.setupExternal()
     self.setupTissue()
     self.setupSelectPreviousActions()
예제 #2
0
    def getNotes(self, record, eventTypeId):
        db = QtGui.qApp.db
        tbl = db.table('Referral')
        record.setValue('relegateOrg_id',
                        toVariant(self.cmbRelegateOrg.value()))
        getTextEditValue(self.edtEventNote, record, 'note')
        if getEventIsExternal(eventTypeId):
            getLineEditValue(self.edtEventExternalIdValue, record,
                             'externalId')
        if hasEventAssistant(eventTypeId):
            getRBComboBoxValue(self.cmbEventAssistant, record, 'assistant_id')
        if hasEventCurator(eventTypeId):
            getRBComboBoxValue(self.cmbEventCurator, record, 'curator_id')
        getRBComboBoxValue(self.cmbPatientModel, record, 'patientModel_id')
        getRBComboBoxValue(self.cmbCureType, record, 'cureType_id')
        getRBComboBoxValue(self.cmbCureMethod, record, 'cureMethod_id')
        getRBComboBoxValue(self.cmbClientPolicy, record, 'clientPolicy_id')
        if QtGui.qApp.isEventLockEnabled():
            getCheckBoxValue(self.chkLock, record, 'locked')
        refId = db.translate('Event', 'id', forceInt(record.value('id')),
                             'referral_id')
        if not refId:
            refId = db.translate('Referral', 'event_id',
                                 forceInt(record.value('id')), 'id')
        if QtGui.qApp.isReferralRequired() and not self.dontSaveReferral:
            if self.chkLPUReferral.isChecked() and not forceInt(refId):
                if not forceString(self.edtNumber.text()):
                    QtGui.QMessageBox.warning(self, u'Ошибка',
                                              u'Заполните номер направления')
                    return
                ref_record = db.getRecordEx(tbl, '*', [
                    tbl['type'].eq(forceInt(self.cmbReferralType.value())),
                    tbl['number'].eq(forceString(self.edtNumber.text())),
                    tbl['client_id'].eq(
                        forceInt(self._clientId if self._clientId else QtGui.
                                 qApp.currentClientId())), tbl['date'].eq(
                                     self.edtDate.date()),
                    tbl['isCancelled'].eq(0), tbl['deleted'].eq(0)
                ])
                if not ref_record:
                    ref_record = tbl.newRecord()
                ref_record.setValue('number',
                                    QtCore.QVariant(self.edtNumber.text()))
                ref_record.setValue(
                    'event_id',
                    QtCore.QVariant(
                        forceInt(record.value('id')
                                 ) if forceInt(record.value('id')) else self.
                        lblEventIdValue.text()))
                ref_record.setValue(
                    'relegateOrg_id',
                    QtCore.QVariant(self.cmbRelegateOrg.value()))
                ref_record.setValue(
                    'client_id',
                    QtCore.QVariant(self._clientId if self._clientId else QtGui
                                    .qApp.currentClientId()))
                ref_record.setValue('MKB', QtCore.QVariant(self.cmbMKB.text()))
                ref_record.setValue(
                    'speciality_id',
                    QtCore.QVariant(self.cmbSpeciality.value()))
                ref_record.setValue(
                    'type', QtCore.QVariant(self.cmbReferralType.value()))
                getDateEditValue(self.edtDate, ref_record, 'date')
                getDateEditValue(self.edtPlannedDate, ref_record, 'hospDate')
                getLineEditValue(self.edtPerson, ref_record, 'person')
                if self.chkFreeInput.isChecked():
                    getLineEditValue(self.edtFreeInput, ref_record,
                                     'freeInput')
                referralId = db.insertOrUpdate(db.table('Referral'),
                                               ref_record)
                record.setValue('referral_id', toVariant(referralId))
            elif forceInt(refId):
                if not forceString(self.edtNumber.text()):
                    QtGui.QMessageBox.warning(self, u'Ошибка',
                                              u'Заполните номер направления')
                    return
                record.setValue('referral_id', toVariant(refId))
                ref_record = db.getRecordEx(
                    tbl, '*', [tbl['id'].eq(refId), tbl['isSend'].eq(0)])
                if ref_record and not forceInt(ref_record.value('isSend')):
                    if self.chkLPUReferral.isChecked():
                        if ref_record:
                            ref_record.setValue(
                                'number',
                                QtCore.QVariant(self.edtNumber.text()))
                            ref_record.setValue(
                                'event_id',
                                QtCore.QVariant(
                                    forceInt(record.value('id')) if forceInt(
                                        record.value('id')) else self.
                                    lblEventIdValue.text()))
                            ref_record.setValue(
                                'relegateOrg_id',
                                QtCore.QVariant(self.cmbRelegateOrg.value()))
                            ref_record.setValue(
                                'client_id',
                                QtCore.QVariant(self._clientId if self.
                                                _clientId else QtGui.qApp.
                                                currentClientId()))
                            ref_record.setValue(
                                'MKB', QtCore.QVariant(self.cmbMKB.text()))
                            ref_record.setValue(
                                'speciality_id',
                                QtCore.QVariant(self.cmbSpeciality.value()))
                            ref_record.setValue(
                                'type',
                                QtCore.QVariant(self.cmbReferralType.value()))
                            ref_record.setValue(
                                'date', QtCore.QVariant(self.edtDate.date()))
                            ref_record.setValue(
                                'hospDate',
                                QtCore.QVariant(self.edtPlannedDate.date()))
                            ref_record.setValue(
                                'person',
                                QtCore.QVariant(self.edtPerson.text()))
                            db.updateRecord(tbl, ref_record)
                    else:
                        record.setValue('referral_id', QtCore.QVariant())
            else:
                record.setValue('referral_id', QtCore.QVariant())

            if self.chkArmyReferral.isChecked():
                armyCond = [
                    tbl['number'].eq(self.cmbArmyNumber.text()),
                    tbl['id'].eq(self.cmbArmyNumber.value())
                ]
                army_ref_record = db.getRecordEx(tbl, '*', where=armyCond)
                if not army_ref_record:
                    army_ref_record = tbl.newRecord()
                    new = True
                else:
                    new = False
                army_ref_record.setValue(
                    'number',
                    QtCore.QVariant(self.cmbArmyNumber.lineEdit().text()))
                army_ref_record.setValue(
                    'client_id',
                    QtCore.QVariant(self._clientId if self._clientId else QtGui
                                    .qApp.currentClientId()))
                army_ref_record.setValue('type', QtCore.QVariant(1))
                army_ref_record.setValue(
                    'relegateOrg_id', QtCore.QVariant(self.cmbArmyOrg.value()))
                getDateEditValue(self.edtArmyDate, army_ref_record, 'date')
                if self.chkArmyFreeInput.isChecked():
                    getLineEditValue(self.edtArmyFreeInput, army_ref_record,
                                     'freeInput')
                if new:
                    referralId = db.insertRecord(db.table('Referral'),
                                                 army_ref_record)
                else:
                    referralId = db.updateRecord(db.table('Referral'),
                                                 army_ref_record)
                record.setValue('armyReferral_id', toVariant(referralId))
                self.cmbArmyNumber.forceUpdate()
            else:
                record.setValue('armyReferral_id', QtCore.QVariant())
예제 #3
0
 def enableEditors(self, eventTypeId):
     self.edtEventExternalIdValue.setEnabled(
         bool(getEventIsExternal(eventTypeId)))
     self.cmbEventAssistant.setEnabled(hasEventAssistant(eventTypeId))
     self.cmbEventCurator.setEnabled(hasEventCurator(eventTypeId))
예제 #4
0
 def setupCurator(self):
     self.cmbCuratorId.setEnabled(hasEventCurator(
         self.cmbEventType.value()))
예제 #5
0
    def __init__(self,
                 parent,
                 eventTypeFilterHospitalization=None,
                 dateTime=None,
                 personId=None,
                 orgStructureId=None,
                 externalId='',
                 clientId=None,
                 begDate=None,
                 endDate=None,
                 referralId=None):
        CDialogBase.__init__(self, parent)
        self.dateTime = dateTime
        self._clientId = clientId
        self.setupUi(self)

        self.edtPlannedDate.setDate(QtCore.QDate())
        self.edtDate.setDate(QtCore.QDate())
        if not CPreCreateEventDialog._orgId:
            self.loadDefaults()
        db = QtGui.qApp.db

        cond = [
            getWorkEventTypeFilter(),
            getOrgStructureEventTypeFilter(
                orgStructureId if orgStructureId else QtGui.qApp.
                currentOrgStructureId()), eventTypeFilterHospitalization
            if eventTypeFilterHospitalization else '1', 'deleted = 0',
            'EventType.filterPosts = 0 OR '
            '   EXISTS(SELECT etp.id '
            '          FROM EventType_Post etp '
            '          WHERE etp.post_id = %s AND '
            '                etp.eventType_id = EventType.id)' %
            (QtGui.qApp.userPostId or '-1'),
            'EventType.filterSpecialities = 0 OR '
            '   EXISTS(SELECT etp.id '
            '          FROM EventType_Speciality etp '
            '          WHERE etp.speciality_id = %s AND '
            '                etp.eventType_id = EventType.id)' %
            (QtGui.qApp.userSpecialityId or '-1')
        ]
        if db.getRecordEx(
                'Client_PaymentScheme c INNER JOIN PaymentScheme p ON p.id = c.paymentScheme_id',
                'c.id', 'c.client_id = %s AND p.type = 0 AND c.deleted = 0' %
                self._clientId) is not None:
            CPreCreateEventDialog._eventTypeId = getEventType(
                'protocol').eventTypeId
        else:
            cond.append('code != \'protocol\'')
        self.cmbEventType.setTable('EventType',
                                   False,
                                   db.joinAnd(cond),
                                   group='id')
        self.cmbTissueType.setTable('rbTissueType')

        self.cmbOrg.setValue(CPreCreateEventDialog._orgId)
        self.cmbRelegateOrg.setValue(CPreCreateEventDialog._relegateOrgId)
        if CPreCreateEventDialog._eventTypeId is None:
            self.cmbEventType.setCurrentIndex(0)
            CPreCreateEventDialog._eventTypeId = self.cmbEventType.value()
        else:
            self.cmbEventType.setValue(CPreCreateEventDialog._eventTypeId)
        if QtGui.qApp.currentOrgStructureId():
            self.cmbPerson.setOrgStructureId(
                QtGui.qApp.currentOrgStructureId())
        if orgStructureId:
            self.cmbPerson.setOrgStructureId(orgStructureId)
        self.cmbOrgStructure.setOrgId(CPreCreateEventDialog._orgId)
        self.cmbPerson.setValue(
            personId if personId else CPreCreateEventDialog._personId)
        eventType = self.cmbEventType.value()
        if hasEventAssistant(eventType):
            self.cmbAssistantId.setValue(CPreCreateEventDialog._assistantId)
        if hasEventCurator(eventType):
            self.cmbCuratorId.setValue(CPreCreateEventDialog._curatorId)
        self.chkAddVisits.setChecked(CPreCreateEventDialog._addVisits)
        self.chkIncludeRedDays.setChecked(
            CPreCreateEventDialog._includeRedDays)
        self.cmbTissueType.setValue(CPreCreateEventDialog._tissueTypeId)
        self.chkSelectPreviousActions.setChecked(
            CPreCreateEventDialog._selectPreviousActions)
        self.cmbReferralType.setTable('rbReferralType')
        if forceInt(CPreCreateEventDialog._referralType):
            self.cmbReferralType.setValue(CPreCreateEventDialog._referralType)

        self.prefix = ''
        self.on_cmbEventType_currentIndexChanged(0)

        self.edtExternalId.setText(externalId if externalId else '')
        self.edtPlannedDate.setMinimumDate(QtCore.QDate.currentDate())
        self.edtDate.setMinimumDate(QtCore.QDate.currentDate().addMonths(-6))
        self.edtDate.setMaximumDate(QtCore.QDate.currentDate())

        self.setupReferral()

        self.useArmyRef = False

        self.btnAppointment.setVisible(
            forceBool(getVal(QtGui.qApp.preferences.appPrefs, 'EGISZ', False)))

        if not CPreCreateEventDialog._connected:
            QtGui.qApp.connect(QtGui.qApp,
                               QtCore.SIGNAL('dbConnectionChanged(bool)'),
                               CPreCreateEventDialog.onConnectionChanged)
            CPreCreateEventDialog._connected = True

        self._isNosologyInit = False

        if not QtGui.qApp.isSupportCreateNosologyEvent():
            self.tabWidget.setTabEnabled(1, False)

        if begDate:
            self.edtEventSetDate.setDate(begDate.date())
            self.edtEventSetTime.setTime(begDate.time())
            #FIXME:skkachaev: Предпологается, что у эвента, который мы пересоздаём, setDate есть всегда
            self.isRecreated = True
        if endDate:
            self.edtEventDate.setDate(endDate.date())
            self.edtEventTime.setTime(endDate.time())

        self.edtPlannedDate.setDate(QtCore.QDate.currentDate())

        self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setDefault(True)
        if QtGui.qApp.changeFocusInPreCreateEvent():
            self.cmbEventType.setFocus(QtCore.Qt.OtherFocusReason)

        self._invisibleObjectsNameList = self.reduceNames(QtGui.qApp.userInfo.hiddenObjectsNameList([self.moduleName()])) \
                                         if QtGui.qApp.userInfo else []
        self.updateVisibleState(self, self._invisibleObjectsNameList)
        if referralId:
            # showDefaultHint(u'Найдено направление', u'Данные заполнены автоматически')
            tblReferral = db.table('Referral')
            recReferral = db.getRecordEx(tblReferral, '*',
                                         tblReferral['id'].eq(referralId))
            # self.grpReferral.setChecked(True)
            self.cmbReferralType.setValue(forceInt(recReferral.value('type')))
            self.edtNumber.setText(forceString(recReferral.value('number')))
            self.cmbRelegateOrg.setValue(
                forceInt(recReferral.value('relegateOrg_id')))
            self.edtDate.setDate(forceDate(recReferral.value('date')))
            self.edtPlannedDate.setDate(
                forceDate(recReferral.value('hospDate')))
            self.cmbSpeciality.setValue(
                forceInt(recReferral.value('medProfile_id')))
            self.cmbMKB.setText(forceString(recReferral.value('MKB')))
            self.edtPerson.setText(forceString(recReferral.value('person')))