Exemplo n.º 1
0
 def _load(self):
     db = QtGui.qApp.db
     tableAction = db.table('Action')
     tableAT = db.table('ActionType')
     tableATG = db.table('ActionType').alias('ActionTypeGroup')
     queryTable = tableAction.join(
         tableAT, tableAction['actionType_id'].eq(tableAT['id']))
     queryTable = queryTable.join(tableATG,
                                  tableAT['group_id'].eq(tableATG['id']))
     fields = (tableAction['id'], tableAT['flatCode'], tableATG['flatCode'])
     cond = (tableAction['event_id'].eq(self.__event_id), )
     height = None
     weight = None
     regimen = None
     feed = None
     for actionRecord in db.getRecordIter(queryTable, fields, cond,
                                          'Action.createDatetime DESC'):
         actionId = forceRef(actionRecord.value(0))
         flatCode = forceString(actionRecord.value(1))
         groupCode = forceString(actionRecord.value(2))
         if flatCode in ('regimen',
                         'feed') or groupCode in ('primaryInspection', ):
             action = CAction.getById(actionId)
             if 'height' in action._propertiesByCode:
                 if not height and action['height', ]:
                     height = action['height', ]
             if 'weight' in action._propertiesByCode:
                 if not weight and action['weight', ]:
                     weight = action['weight', ]
             if 'regimen' in action._propertiesByCode:
                 if not regimen and action['regimen', ]:
                     regimen = action['regimen', ]
             if 'feed' in action._propertiesByCode:
                 if not feed and action['feed', ]:
                     feed = action['feed', ]
         if height and weight and regimen and weight:
             break
     self.__height = height or u'Неизвестно'
     self.__weight = weight or u'Неизвестно'
     self.__regimen = regimen or u'Неизвестно'
     self.__feed = feed or u'Неизвестно'
     self.__square = height * weight / 3600.0 if height and weight else u'Неизвестно'
Exemplo n.º 2
0
 def _load(self):
     # TODO: отвязаться от необходимости знать внутреннюю структуру actInfo
     if isinstance(self.__model, CPrescriptionSqlModel):
         cAction = self.__model.actInfo._cAction
     else:
         cAction = CAction.getById(self.__model.id)
     self._action = cAction.toInfo(self.context)
     self._eventInfo = self.context.getInstance(CEventInfo,
                                                cAction.event_id)
     self._clientInfo = self.context.getInstance(CClientInfo,
                                                 cAction.Event.client_id)
     self._prescIntervals = self.context.getInstance(
         CPrescDrugCellInfoList, self.__model, self.__interval, self.__step)
     self._execIntervals = self.context.getInstance(CExecDrugCellInfoList,
                                                    self.__model,
                                                    self.__interval,
                                                    self.__step)
     self._drugs = CDrugInfoList(self.context, self.__model.drugComponents)
     self._interval = CDateTimeIntervalInfo(self.context, self.__interval,
                                            self.__step)
     return True