|
|
@ -218,39 +218,67 @@ class mCase extends mBase { |
|
|
|
} |
|
|
|
|
|
|
|
public function getCaseList($uid, $name, $page_num, $page_size) { |
|
|
|
$case = $this->getCaseByName($uid, $name, $page_num, $page_size); |
|
|
|
if (empty($case)) { |
|
|
|
$case_data = $this->getCaseByName($uid, $name, $page_num, $page_size); |
|
|
|
if (empty($case_data)) { |
|
|
|
$this->setError('查询不到此药方'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
$case_ids = array(); |
|
|
|
foreach ($case as &$item) { |
|
|
|
$item['original'] = json_decode($item['original'], true); |
|
|
|
$case_ids[] = $item['id']; |
|
|
|
} |
|
|
|
|
|
|
|
$case_ids = array_column($case_data, 'id'); |
|
|
|
//药方药材信息 |
|
|
|
$case_herbs = $this->getCaseHerbByCaseIds($case_ids); |
|
|
|
if (empty($case_herbs)) { |
|
|
|
$this->setError('药方药材查询失败'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$herb_ids = array_column($case_herbs, 'herb_id'); |
|
|
|
|
|
|
|
//药材名称 |
|
|
|
$herb_ids = array_column($case_herbs, 'herb_id'); |
|
|
|
$herb = $this->getHerbByIds($herb_ids); |
|
|
|
if (empty($herb)) { |
|
|
|
$this->setError('药材名称查询失败'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$herb_list = array_column($herb, null, 'id'); |
|
|
|
|
|
|
|
$case_herb = array(); |
|
|
|
foreach ($case_herbs as $v) { |
|
|
|
$case_herb[$v['case_id']][] = $v; |
|
|
|
$case_list = array(); |
|
|
|
foreach ($case_data as $item) { |
|
|
|
$case = array( |
|
|
|
'id' => $item['id'], |
|
|
|
'name' => $item['name'], |
|
|
|
'source' => $item['source'], |
|
|
|
'method' => $item['method'], |
|
|
|
'use_num' => $item['use_num'], |
|
|
|
'sort' => $item['sort'], |
|
|
|
'case_herb' => array() |
|
|
|
); |
|
|
|
|
|
|
|
$original = json_decode($item['original'], true); |
|
|
|
foreach ($case_herbs as $value) { |
|
|
|
if ($item['id'] != $value['case_id']) continue; |
|
|
|
|
|
|
|
|
|
|
|
$temp = array( |
|
|
|
'name' => $herb_list[$value['herb_id']]['name'], |
|
|
|
'num' => $value['num'], |
|
|
|
'org_num' => '', |
|
|
|
'desc' => $value['desc'], |
|
|
|
'org_desc' => '', |
|
|
|
); |
|
|
|
|
|
|
|
foreach ($original as $v) { |
|
|
|
if ($temp['name'] == $v['name']) { |
|
|
|
$temp['org_num'] = $v['num']; |
|
|
|
$temp['org_desc'] = $v['desc']; |
|
|
|
} |
|
|
|
} |
|
|
|
$case['case_herb'][] = $temp; |
|
|
|
} |
|
|
|
|
|
|
|
return array('case' => $case, 'case_herb' => $case_herb, 'herb' => array_column($herb, null, 'id')); |
|
|
|
$case_list[] = $case; |
|
|
|
} |
|
|
|
|
|
|
|
return $case_list; |
|
|
|
} |
|
|
|
|
|
|
|
public function getCaseByNameTotal($name) { |
|
|
@ -270,24 +298,49 @@ class mCase extends mBase { |
|
|
|
$this->setError('查询不到此药方'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$case['original'] = json_decode($case['original'], true); |
|
|
|
|
|
|
|
//药方药材信息 |
|
|
|
$case_herb = $this->getCaseHerbByCaseId($case['id']); |
|
|
|
if (empty($case_herb)) { |
|
|
|
$case_herb_date = $this->getCaseHerbByCaseId($case['id']); |
|
|
|
if (empty($case_herb_date)) { |
|
|
|
$this->setError('药方药材查询失败'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//药材名称 |
|
|
|
$herb_ids = array_column($case_herb, 'herb_id'); |
|
|
|
$herb_ids = array_column($case_herb_date, 'herb_id'); |
|
|
|
$herb = $this->getHerbByIds($herb_ids); |
|
|
|
if (empty($herb)) { |
|
|
|
$this->setError('药材名称查询失败'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$herb_list = array_column($herb, null, 'id'); |
|
|
|
|
|
|
|
$original = json_decode($case['original'], true); |
|
|
|
unset($case['original']); |
|
|
|
|
|
|
|
$case_herb = array(); |
|
|
|
foreach ($case_herb_date as $item) { |
|
|
|
$temp = array( |
|
|
|
'name' => $herb_list[$item['herb_id']]['name'], |
|
|
|
'num' => $item['num'], |
|
|
|
'org_num' => '', |
|
|
|
'desc' => $item['desc'], |
|
|
|
'org_desc' => '', |
|
|
|
); |
|
|
|
|
|
|
|
foreach ($original as $v) { |
|
|
|
if ($temp['name'] == $v['name']) { |
|
|
|
$temp['org_num'] = $v['num']; |
|
|
|
$temp['org_desc'] = $v['desc']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$case_herb[] = $temp; |
|
|
|
} |
|
|
|
|
|
|
|
$case['case_herb'] = $case_herb; |
|
|
|
|
|
|
|
return array('case' => $case, 'case_herb' => $case_herb, 'herb' => array_column($herb, null, 'id')); |
|
|
|
return $case; |
|
|
|
} |
|
|
|
|
|
|
|
public function getCaseById($id) { |
|
|
|