public function updateDiagnosisDiseaseResultAndOptionRef($request, $response) { /*{{{*/ $optionNames = ""; $diagnosisResultId = $request->resultId; DiagnosisClient::getInstance()->delDiagnosisResultOptionRefByDiagnosisResultId($diagnosisResultId); $diagnosisResult = DAL::get()->find('DiagnosisResult', $diagnosisResultId); $vars = $request->var; if (isset($vars['option'])) { DiagnosisClient::getInstance()->addDiagnosisResultOptionRefs($diagnosisResultId, $vars['option']); } foreach ($vars['other'] as $categoryId => $otherContent) { if ("" == trim($otherContent)) { continue; } else { $optionId = DiagnosisClient::getInstance()->addDiagnosisDiseaseOption($categoryId, $otherContent); DiagnosisClient::getInstance()->addDiagnosisResultOptionRef($diagnosisResultId, $optionId); } } $response->setRedirect($response->router->urlfor('followup/leavehospitaldiagnosis', array('leaveHospitalDiagnosisId' => $request->leaveHospitalDiagnosisId))); }
public function showTaskTicketDangerFactors($request, $response) { /*{{{*/ $ticketId = $request->ticketId; if (false == isset($ticketId)) { $response->msg = '审核结束!'; return; } $ticket = DAL::get()->find('NfsTaskTicket', $ticketId); if ($ticket->isNull()) { $response->msg = '审核结束!'; return; } DBC::requireFalse($ticket->isNull(), '工单不存在!'); $response->ticket = $ticket; $user = DAL::get()->find('user', $ticket->owner->id); $response->user = $user; $response->auditor = $this->auditor; $hostEntity = $ticket->hostEntity; //DBC::requireTrue($hostEntity instanceof HealthDiary, '当前患者没有任何健康日记!'); $diaryIds = array(); if ($hostEntity instanceof HealthDiary) { $diaryIds = DAL::get()->find_id_by_condition('HealthDiary', 'id<=? and userid=? and status=?', array($hostEntity->id, $ticket->owner->id, HealthDiary::STATUS_UNAUDITED)); } $diaryList = DAL::get()->find('HealthDiary', $diaryIds); $response->diaryList = $diaryList; if ($hostEntity instanceof HealthDiary) { $latestDotimeDiary = DAL::get()->find_by_LatestDoTimeDiary('HealthDiary', $ticket->owner->id, HealthDiary::TYPE_NORMAL, array('lasthostid' => $hostEntity->id, 'status' => HealthDiary::STATUS_UNAUDITED)); $response->latestDotimeDiary = $latestDotimeDiary; } $noValueProblems = array(); $highRiskArr = array(); $middleLowRiskArr = array(); $noRiskArr = array(); foreach ($diaryList as $diary) { $answerGroupInfo = $diary->getAnswerGroupsGroupByRiskLevel(); $highRiskArr[$diary->id] = $answerGroupInfo['highRisk']; $middleLowRiskArr[$diary->id] = array_merge($answerGroupInfo['middleRisk'], $answerGroupInfo['lowRisk']); $noRiskArr[$diary->id] = $answerGroupInfo['noRisk']; $noValueProblems[$diary->id] = $diary->getProblemsWithoutValue(); } $answerGroupInfos = array('highRisk' => $highRiskArr, 'middleLowRisk' => $middleLowRiskArr, 'noRisk' => $noRiskArr); $response->answerGroupInfos = $answerGroupInfos; $response->noValueProblems = $noValueProblems; //上次批注 $annotation = null; $annotationIds = DAL::get()->queryLatestIds_byUserId_hosttype('NfsAnnotation', $ticket->owner->id, 'HealthDiary', array('limit' => 1)); if (isset($annotationIds[0])) { $annotation = DAL::get()->find('NfsAnnotation', $annotationIds[0]); } $response->annotation = $annotation; // 患者信息 $customer = $ticket->owner->getFollowupCustomer(); $response->customer = $customer; //出院诊断展示部分 $resultList = array(); $diagnosisList = DAL::get()->find_all_by_customerid('LeaveHospitalDiagnosis', $customer->id); foreach ($diagnosisList as $diagnosis) { $resultList[$diagnosis->leavehospitaltime] = DiagnosisClient::getInstance()->findAllDiagnosisResultByDiagnosisId($diagnosis->id); } $response->resultList = $resultList; // 需要批注 $annotationMsg = ""; if (false == empty($diaryIds)) { $annotation = DAL::get()->find_by_condition('nfsannotation', 'userid=:userid and hosttype=:hosttype and hostid in (:hostid)', array(':userid' => $ticket->owner->id, ':hosttype' => 'HealthDiary', ':hostid' => $diaryIds)); if ($hostEntity instanceof HealthDiary && $annotation->isNull()) { /*{{{*/ $annIdIn3Days = DAL::get()->queryLatestIds_byUserId_hosttype('nfsannotation', $ticket->owner->id, 'HealthDiary', array('startTime' => XDateTime::today()->addDay(-3), 'limit' => 1)); $annIdIn5Days = DAL::get()->queryLatestIds_byUserId_hosttype('nfsannotation', $ticket->owner->id, 'HealthDiary', array('startTime' => XDateTime::today()->addDay(-5), 'limit' => 1)); $diary = DAL::get()->find_by_condition('HealthDiary', 'id<=? and userid=? and status=?', array($hostEntity->id, $ticket->owner->id, HealthDiary::STATUS_AUDITED)); $diaryInOneMonth = DAL::get()->find_by_condition('HealthDiary', 'id<=? and userid=? and ctime > ?', array($hostEntity->id, $ticket->owner->id, $hostEntity->ctime->addDay(-30))); $diaryWithContent = DAL::get()->find_by_condition('HealthDiary', 'id<=? and userid=? and status=? and content is not null and content !=?', array($hostEntity->id, $ticket->owner->id, HealthDiary::STATUS_UNAUDITED, '')); if ($diary->isNull()) { $annotationMsg = "第一次填写健康日记,需要批注!"; } else { if ($diaryInOneMonth->isNull()) { $annotationMsg = "长时间不记录后的第一次主动记录, 需要批注!"; } else { if ($customer->isSeriousIll()) { if (0 == count($annIdIn3Days)) { $annotationMsg = "患者病情较重,上次批注在3天前,需要批注!"; } } else { if ($customer->isFollowed()) { if (0 == count($annIdIn3Days)) { $annotationMsg = "患者有问题在跟进中,上次批注在3天前,需要批注!"; } } else { if (0 == count($annIdIn5Days)) { $annotationMsg = "上次批注在5天前,需要批注!"; } else { if (false == $diaryWithContent->isNull()) { $annotationMsg = "患者有主观陈述,需要批注!"; } else { if (HealthDangerFactorCalcBase::LEVEL_RISK_HIGH == $ticket->rank) { $annotationMsg = "患者有高危因素,需要批注!"; } } } } } } } } /*}}}*/ } $response->annotationMsg = $annotationMsg; $this->importExceptionCheckupSheet($request, $response, $user); }