|
@ -104,22 +104,20 @@ class mUserCase extends mBase { |
|
|
return $id; |
|
|
return $id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCaseInfo($id, $uid){ |
|
|
public function getUserCaseInfo($uid, $token, $id){ |
|
|
|
|
|
$m_user = new mUser(); |
|
|
|
|
|
$is_login = $m_user->validateToken($uid,$token); |
|
|
|
|
|
if(!$is_login){$this->setError('请登录后操作');return false;} |
|
|
|
|
|
|
|
|
$user_case = $this->obj->select($this->tbl, array('sql'=>'`id`=? and `uid`=?', 'vals'=>array($id, $uid))); |
|
|
$user_case = $this->obj->select($this->tbl, array('sql'=>'`id`=? and `uid`=?', 'vals'=>array($id, $uid))); |
|
|
if(empty($user_case)){ |
|
|
if(empty($user_case)){$this->setError('找不到相关医案');return false;} |
|
|
$this->setError('找不到相关医案'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$prescribe_herb = json_decode($user_case['prescribe_herb'],true); |
|
|
$prescribe_herb = json_decode($user_case['prescribe_herb'],true); |
|
|
$user_case['prescribe_herb'] = $prescribe_herb; |
|
|
$user_case['prescribe_herb'] = $prescribe_herb; |
|
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
$mCase = new mCase(); |
|
|
$case = $mCase->getCaseById($user_case['case_id']); |
|
|
$case = $mCase->getCaseById($user_case['case_id']); |
|
|
if(empty($case)){ |
|
|
if(empty($case)){$this->setError('找不到相关药方');return false;} |
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$herb_ids = $user_herb_ids = array(); |
|
|
$herb_ids = $user_herb_ids = array(); |
|
|
foreach ($prescribe_herb as $item){ |
|
|
foreach ($prescribe_herb as $item){ |
|
@ -129,50 +127,41 @@ class mUserCase extends mBase { |
|
|
} |
|
|
} |
|
|
$herb_ids[] =$item['herb_id']; |
|
|
$herb_ids[] =$item['herb_id']; |
|
|
} |
|
|
} |
|
|
|
|
|
if(empty($herb_ids) && empty($user_herb_ids)){$this->setError('医案开药详情不正确');return false;} |
|
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
$mCase = new mCase(); |
|
|
$herb = $mCase->getHerbByIds($herb_ids); |
|
|
$herb = $mCase->getHerbByIds($herb_ids); |
|
|
$user_herb = $this->getUserHerbByIds($user_herb_ids); |
|
|
$user_herb = $this->getUserHerbByIds($user_herb_ids); |
|
|
if(empty($herb) && empty($user_herb)){ |
|
|
if(empty($herb) && empty($user_herb)){$this->setError('找不到相关药材');return false;} |
|
|
$this->setError('找不到相关药材'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data = array( |
|
|
return array( |
|
|
'user_case' => $user_case, |
|
|
'user_case' => $user_case, |
|
|
'case' => $case, |
|
|
'case' => $case, |
|
|
'herb' => array_column($herb,null,'id'), |
|
|
'herb' => array_column($herb,null,'id'), |
|
|
'user_herb' => array_column($user_herb,null,'id'), |
|
|
'user_herb' => array_column($user_herb,null,'id'), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCaseList($uid, $start, $pagesize, $get_case_herb = false){ |
|
|
public function getUserCaseList($uid, $token, $page_num, $page_size, $get_case_herb = false){ |
|
|
$user_case = $this->obj->selectAll($this->tbl, array('sql'=>'`uid`=?', 'vals'=>array($uid)), 'case_time desc ', array($start, $pagesize)); |
|
|
$m_user = new mUser(); |
|
|
if(empty($user_case)){ |
|
|
$is_login = $m_user->validateToken($uid,$token); |
|
|
$this->setError('找不到相关医案'); |
|
|
if(!$is_login){$this->setError('请登录后操作');return false;} |
|
|
return false; |
|
|
|
|
|
} |
|
|
$offset = ($page_num - 1) * $page_size; |
|
|
|
|
|
$user_case = $this->obj->selectAll($this->tbl, array('sql'=>'`uid`=?', 'vals'=>array($uid)), 'case_time desc ', array($offset, $page_size)); |
|
|
|
|
|
if(empty($user_case)){$this->setError('找不到相关医案');return false;} |
|
|
|
|
|
|
|
|
$case_ids = array_column($user_case,'case_id'); |
|
|
$case_ids = array_column($user_case,'case_id'); |
|
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
$m_case = new mCase(); |
|
|
$case = $mCase->getCaseByIds($case_ids); |
|
|
$case = $m_case->getCaseByIds($case_ids); |
|
|
if(empty($case)){ |
|
|
if(empty($case)){$this->setError('找不到相关药方');return false;} |
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
$case = array_column($case,null,'id'); |
|
|
|
|
|
|
|
|
|
|
|
if(!$get_case_herb){ |
|
|
$case = array_column($case,null,'id'); |
|
|
$data = array( |
|
|
|
|
|
'user_case_list' => $user_case, |
|
|
|
|
|
'case_list' => $case, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
if(!$get_case_herb)return array('user_case_list' => $user_case, 'case_list' => $case); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取医案开药详情 |
|
|
$herb_ids = $user_herb_ids = array(); |
|
|
$herb_ids = $user_herb_ids = array(); |
|
|
foreach ($user_case as &$item){ |
|
|
foreach ($user_case as &$item){ |
|
|
$prescribe_herb = json_decode($item['prescribe_herb'],true); |
|
|
$prescribe_herb = json_decode($item['prescribe_herb'],true); |
|
@ -186,23 +175,18 @@ class mUserCase extends mBase { |
|
|
$herb_ids[] = $herb_item['herb_id']; |
|
|
$herb_ids[] = $herb_item['herb_id']; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if(empty($herb_ids) && empty($user_herb_ids)){$this->setError('医案开药详情不正确');return false;} |
|
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
$herb = $m_case->getHerbByIds($herb_ids); |
|
|
$herb = $mCase->getHerbByIds($herb_ids); |
|
|
|
|
|
$user_herb = $this->getUserHerbByIds($user_herb_ids); |
|
|
$user_herb = $this->getUserHerbByIds($user_herb_ids); |
|
|
if(empty($herb) && empty($user_herb)){ |
|
|
if(empty($herb) && empty($user_herb)){$this->setError('找不到相关药材');return false;} |
|
|
$this->setError('找不到相关药材'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data = array( |
|
|
return array( |
|
|
'user_case_list' => $user_case, |
|
|
'user_case_list' => $user_case, |
|
|
'case_list' => $case, |
|
|
'case_list' => $case, |
|
|
'herb' => array_column($herb,null,'id'), |
|
|
'herb' => array_column($herb,null,'id'), |
|
|
'user_herb' => array_column($user_herb,null,'id'), |
|
|
'user_herb' => array_column($user_herb,null,'id'), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserHerbByIds($ids){ |
|
|
public function getUserHerbByIds($ids){ |
|
|