public function workSheet($request, $response) { /*{{{*/ $auditor = $this->auditor; $response->auditor = $auditor; $followupAuditor = DAL::get()->find_by_auditorid('FollowupAuditor', $auditor->id); if ($followupAuditor->isNull()) { throw new BizException('你没有权限访问'); } $workSheetId = $request->worksheetid; $workSheet = DAL::get()->find('WorkSheet', $workSheetId); $response->workSheet = $workSheet; if ($workSheet->isNull()) { echo '没有找到该工作单!'; return parent::DIRECT_OUTPUT; } $user = DAL::get()->find('User', $workSheet->customer->userId); $response->user = $user; if (WorkSheet::SUBMIT_YES == $workSheet->submit) { $response->setRedirect($response->router->urlfor('followup/getworksheetcontent', array('worksheetId' => $workSheet->id))); } //找到患者基本信息 $owner = $user->getFollowupPatientSignin(); DBC::requireTrue(empty($patientsignin), '未找到指定signinId的患者'); $response->owner = $owner; // 新的血压、心率 $xueyaxinlvhealthRecordProblemCategory = HealthRecordClient::getInstance()->getProblemCategoryByName('血压心率组合'); $response->xueyaxinlvhealthRecordProblems = $xueyaxinlvhealthRecordProblemCategory->problems; //问诊,其他部分 $labelArr = WorkSheetClient::getInstance()->getLabels4WorkSheet($workSheet->id); $response->labelArr = $labelArr; $response->labelCategories = DAL::get()->find_all_by_isDeleted_and_type('LabelCategory', LabelCategory::DELETED_NO, LabelCategory::NFS_TEXTWENZHEN); $response->contactLabels = DAL::get()->find('Label', $workSheet->contactLabelIds); $wenzhenInquiry = WorkSheetClient::getInstance()->getInquiryByTypeAndWorkSheetId(WorkSheetInquiry::TYPE_STANDARD_TEXT, $workSheet->id); $qitaInquiry = WorkSheetClient::getInstance()->getInquiryByTypeAndWorkSheetId(WorkSheetInquiry::TYPE_OTHER, $workSheet->id); $response->wenzhenContent = $wenzhenInquiry->content; $response->qitaContent = $qitaInquiry->content; //标准化问诊 $this->getStandardInquiryQuestionSheet($request, $response); //用药部分 $medicineSchemeList = MedicineClient::getInstance()->getUserCurrentMedicineScheme($user->id); $response->medicineSchemeList = $medicineSchemeList; $medicineSchemeId = -1; if (false == empty($medicineSchemeList)) { $medicineSchemeId = key($medicineSchemeList); } $response->medicineSchemeId = $medicineSchemeId; //$response->followupAuditorList = FollowupOwner::getFollowupAuditors(); $auditorsRole = DAL::get()->find_by_name('followupauditorrole', FollowupAuditorRole::NAME_ASSISTANTDOCTOROPERATION); $response->followupAuditorList = FollowupAuditorClient::getInstance()->getAuditorListByRoleId($auditorsRole->id); $response->medicineEventLabelList = MedicineClient::getInstance()->getDefaultMedicineEventLabel(); //任务部分 $role = $followupAuditor->role; $response->auditorRole = $role; // 抽成方法 $params = array('auditorroleid' => $role->id, 'customerid' => $workSheet->customer->id, 'action' => 'tel', 'pending' => NfsTask::PENDING_NO, 'statusarr' => array(NfsTask::STATUS_UNFINISHED), 'deadline' => XDateTime::today()); $taskList = TaskClient::getInstance()->getOwnerTaskList($params); $resultArr = array(); foreach ($taskList['before'] as $task) { $resultArr[$task->taskModel->id][] = $task; } $response->taskList = $resultArr; $modelIds = array_keys($response->taskList); $response->modelList = DAL::get()->find('NfsTaskModel', $modelIds); $customerInfoRecordList = FollowupCustomerClient::getInstance()->getCustomerInfoRecordList4ByTaskIdArr(array_keys($taskList['before'])); $taskId_infoRecordList = array(); if ($customerInfoRecordList != null) { foreach ($customerInfoRecordList as $record) { $taskId_infoRecordList[$record->sourceid][] = $record; } $response->taskId_infoRecordList = $taskId_infoRecordList; } //健康日记部分 $response->diaryList = HealthDiaryClient::getInstance()->getLatestDiaries($user->id, XDateTime::today()->addDay(-14)->toShortString(), HealthDiary::AGENTAUDITORID_PATIENT); //提问部分 $response->checkupAnswerSheets = DAL::get()->find_all_by_userid_and_deleted('CheckupAnswerSheet', $owner->user->id); $response->questionLabelInfos = CheckupWenDaClient::getInstance()->formatCheckupAnswerSheet($response->checkupAnswerSheets); $response->labelList = DAL::get()->find('Label', array_keys($response->questionLabelInfos)); //下次联系内容部分 $lastCollectTimes = WorkSheetClient::getInstance()->getLastCollectTimes($user->id); foreach ($lastCollectTimes as $key => $time) { if (empty($time)) { $collectDayStr[$key] = "<span class='fb'>没有采集记录</span>"; } else { $time = XDateTime::valueOf($time); $collectDay = (strtotime(XDateTime::today()) - strtotime(XDateTime::valueOf($time->toShortString()))) / 3600 / 24; if ($collectDay < 14) { $collectDayStr[$key] = "<span>距离上次采集" . $collectDay . "天</span>"; } else { $collectDayStr[$key] = "<span class='fb'>距离上次采集" . $collectDay . "天</span>"; } } } $response->collectDayStr = $collectDayStr; $response->auditorId = $auditor->id; //找到患者现在体重 $nowWeightAnswerId = FollowupClient::getInstance()->getUserLastProblemByProblemId($owner->user->id, HealthRecordProblem::HEALTHDIARY_WEIGHT); if ($nowWeightAnswerId != '') { $response->nowWeightAnswer = DAL::get()->find('HealthRecordanswer', $nowWeightAnswerId); } //找到患者报到信息 if ($owner->getNfsDisease() != null) { $signinProblems = $owner->getNfsDisease()->getSigninHealthProblems(); $response->signinProblems = $signinProblems; } $heightProblem = DAL::get()->find_by_title_and_type('healthrecordproblem', HealthRecordProblem::HEIGHT, HealthRecordProblem::TYPE_SIGNIN); $heightAnswerList = HealthRecordClient::getInstance()->getLastHealthAnswerList($owner->user->id, array($heightProblem->id)); if (false == empty($heightAnswerList)) { $heightAnswer = array_shift($heightAnswerList); $height = $heightAnswer->value; } else { $height = ''; } $response->height = $height; $customerId = $workSheet->customer->id; $customer = DAL::get()->find('followupCustomer', $customerId); $response->customer = $customer; $customerWorkSheets = DAL::get()->find_all_by_customerid('worksheet', $customerId); XString::sortArray($customerWorkSheets, 'ctime'); $response->workSheetContents = array(); $response->workSheetContentMaxCount = 3; if (false == empty($customerWorkSheets)) { $workSheetContents = array(); foreach ($customerWorkSheets as $lastWorkSheet) { $lastInfo = WorkSheetClient::getInstance()->getWorkSheetContactByWorkSheetId($lastWorkSheet->id, $owner->patient); if (false == empty($lastInfo)) { $workSheetContents[] = $lastInfo; } } $response->workSheetContents = $workSheetContents; $response->isShow = false; } //得到患者的userid $userId = $owner->user->id; $flowList = FlowClient::getInstance()->get2WeeksFlowList($owner->patient->id, $customer->space->id); $response->flowList = $flowList; //PCI手术信息 $category = DAL::get()->find_by_name('HealthRecordProblemCategory', '二、PCI手术信息'); $healthProblems = $category->problems; $problemIds = array_keys($healthProblems); $answerList = HealthRecordClient::getInstance()->getHealthAnswerList4Initial($userId, $problemIds); $myAnswerList = array(); foreach ($answerList as $answer) { if ($answer->isNull() == false) { $myAnswerList[$answer->ref->problem->id] = $answer; } } $response->healthProblems = $healthProblems; $response->myAnswerList = $myAnswerList; $response->contacthealthitemnames = $workSheet->contactHealthItemNames; $response->sportProblems = HealthRecordClient::getInstance()->getSportProblem4WorkSheet(); $historyArr = HealthDiaryClient::getInstance()->getDiaryAnswerHistory4WorkSheet($userId, $num = 10); // 老的血压、心率历史记录,即将废掉 $response->bloodPressureHistory = $historyArr['bloodpressure']; $response->heartRateHistory = $historyArr['heartrate']; // 新的血压、心率历史记录 $response->xueyaxinlvHistory = $historyArr['xueyaxinlv']; $response->bloodGlucoseHistory = $historyArr['bloodglucose']; $response->weightHistory = $historyArr['weight']; $response->sportHistory = $historyArr['sport']; //出院诊断部分 $resultList = array(); $diagnosisList = DAL::get()->find_all_by_customerid('LeaveHospitalDiagnosis', $customerId); foreach ($diagnosisList as $diagnosis) { $resultList[$diagnosis->leavehospitaltime] = DiagnosisClient::getInstance()->findAllDiagnosisResultByDiagnosisId($diagnosis->id); } $response->resultList = $resultList; $response->BMIInfo = $user->getFollowupCustomer()->getBIMInfo(); $weightAnswer = DAL::get()->find_LastestWeightAnswer('HealthRecordAnswer', $owner->getFollowupCustomer()->userId); $lastWeight = $weightAnswer instanceof HealthRecordAnswer ? $weightAnswer->value : 0; //$lastWeight = DAL::get()->find_LastestWeightAnswer('HealthRecordAnswer', $owner->getFollowupCustomer()->userId)->value; $response->bmr = Patient::getBMR($owner->patient->getAgeNum(true), $lastWeight, $owner->patient->sex); //饮食部分 $tmpArr = array(dietFoodInfoNodeDefine::DIET_CACULATOR_WORKSHEETID => $workSheetId); $response->dietFoodsNodeObjs = DAL::get()->find_all_by_nodename_and_keyname_and_value_and_source('nodeobj', NodeObj::NODE_DEFINE_DIET_CACULATOR, $tmpArr, NodeObj::SOURCE_NFS); //疾病管理 $response->workMemos = DAL::get()->find_all_by_customerid('workmemo', $customerId); //新体重管理 $healthItemProjects = DAL::get()->find_all_by_followupcustomerid('HealthItemProject', $workSheet->customer->id); $response->healthItemProjects = $healthItemProjects; //症状事件 $incidents = DAL::get()->find_all_by_followupcustomerid('Incident', $workSheet->customer->id); $arr = array(); $res = array(); foreach ($incidents as $incident) { /*{{{*/ $incidentStates = DAL::get()->find_all_by_incidentid('IncidentState', $incident->id); if (false == empty($incidentStates)) { $arr[$incident->id] = end($incidentStates); } } /*}}}*/ if (false == empty($arr)) { /*{{{*/ foreach ($arr as $incidentId => $incidentState) { $ids[] = $incidentId; $emerg[] = $incidentState->emergencyLevel; $f[] = $incidentState->careLevel + $incidentState->impactLevel; } array_multisort($emerg, $f, SORT_DESC, SORT_NUMERIC, $ids); $res = array(); if (false == empty($ids)) { foreach ($ids as $id) { $res[$id] = DAL::get()->find('Incident', $id); } } } else { $res = $incidents; } $response->incidents = $res; //复查异常 $nfsSubTasks = DAL::get()->find_all_by_followupcustomerid_and_status('NfsSubTask', $workSheet->customer->id, ProjectConst::CustomerStatus_Start); //展示时先展示用药任务,然后是复查任务。 $_FuChaTasks[] = array(); $_YongYaoTasks[] = array(); foreach ($nfsSubTasks as $nfsSubTask) { /*{{{*/ if ($nfsSubTask->type == NfsSubTask::Type_FuCha) { $_FuChaTasks[$nfsSubTask->id] = $nfsSubTask; } else { if ($nfsSubTask->type == NfsSubTask::Type_YongYao) { $_YongYaoTasks[$nfsSubTask->id] = $nfsSubTask; } } } /*}}}*/ $nfsSubTasks = $_YongYaoTasks + $_FuChaTasks; $response->nfsSubTasks = $nfsSubTasks; //血糖管理 $bloodSugarSteps = DAL::get()->find_all_by_followupcustomerid('bloodSugarStep', $workSheet->customer->id); $response->bloodSugarSteps = $bloodSugarSteps; }
public function patientPostAgent($request, $response) { /*{{{*/ $signinId = $request->signinId; $response->patientSignin = DAL::get()->find('FollowupOwner', $signinId); if ($response->patientSignin->isNull()) { throw new BizException('随访患者报到信息不存在'); } $response->checkupAnswerSheets = DAL::get()->find_all_by_userid_and_deleted('CheckupAnswerSheet', $response->patientSignin->user->id); $response->questionLabelInfos = CheckupWenDaClient::getInstance()->formatCheckupAnswerSheet($response->checkupAnswerSheets); $response->labelList = DAL::get()->find('Label', array_keys($response->questionLabelInfos)); $response->patientAttachments = $response->patientSignin->patient->attachments; }
public function ajaxShowSelectCheckup($request, $response) { /*{{{*/ $customerId = $request->customerid; $response->modelName = $request->modelname; $customer = DAL::get()->find("FollowupCustomer", $customerId); DBC::requireFalse($customer->isNull(), "customer{$customerId}不存在"); $response->checkupAnswerSheets = DAL::get()->find_all_by_userid_and_deleted('CheckupAnswerSheet', $customer->userId); $response->questionLabelInfos = CheckupWenDaClient::getInstance()->formatCheckupAnswerSheet($response->checkupAnswerSheets); $response->labelList = DAL::get()->find('Label', array_keys($response->questionLabelInfos)); }
public function saveCheckupAnswer($request, $response) {/*{{{*/ $sheets = $request->sheets; CheckupWenDaClient::getInstance()->modifyStructedCheckupAnswerSheet($this->user, $sheets, $this->user); $response->setRedirect($response->router->urlfor('myhealth/checkuphistory', array('ticketId' => $request->ticketid, 'userid' => $this->user->id))); }/*}}}*/
public function modifyQuestionValueRanges($request, $response) { /*{{{*/ $newRangeList = $request->getRequest('new', array()); $deletedRangeList = $request->getRequest('deleted', array()); $modifiedRangeList = $request->getRequest('ranges', array()); CheckupWenDaClient::getInstance()->auditQuestionValueRanges($request->questionid, $modifiedRangeList, $newRangeList, $deletedRangeList); $response->setRedirect('/checkup/showquestionofvaluerange?questionid=' . $request->questionid); }