|
@ -8,25 +8,24 @@ include_once(SERVER_ROOT . "/vendor/mpdf/mpdf/mpdf.php"); |
|
|
class mUserCase extends mBase { |
|
|
class mUserCase extends mBase { |
|
|
private $obj; |
|
|
private $obj; |
|
|
private $tbl; |
|
|
private $tbl; |
|
|
private $user_herb_tbl; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct() { |
|
|
public function __construct() { |
|
|
$this->obj = new dUserCase(); |
|
|
$this->obj = new dUserCase(); |
|
|
$this->tbl = 'tcm_user_case'; |
|
|
$this->tbl = 'tcm_user_case'; |
|
|
$this->user_herb_tbl = 'tcm_user_herb'; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function updateUserCase($uid, $id, $data) { |
|
|
public function insertUserCase($info) { |
|
|
if (empty($data['name'])) { |
|
|
$id = $this->obj->insert($this->tbl, $info); |
|
|
$this->setError('药方名称不能为空'); |
|
|
if (empty($id)) { |
|
|
return false; |
|
|
$this->setError('添加医案失败'); |
|
|
} |
|
|
|
|
|
if (empty($data['feedback'])) { |
|
|
|
|
|
$this->setError('用药反馈不能为空'); |
|
|
|
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$res = $this->obj->update($this->tbl, $data, array('sql' => '`id`=? and `uid`=?', 'vals' => array($id, $uid))); |
|
|
return $id; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function updateUserCase($id, $info) { |
|
|
|
|
|
$res = $this->obj->update($this->tbl, $info, array('sql' => '`id`=?', 'vals' => array($id))); |
|
|
if (!$res) { |
|
|
if (!$res) { |
|
|
$this->setError('更新失败'); |
|
|
$this->setError('更新失败'); |
|
|
return false; |
|
|
return false; |
|
@ -35,57 +34,36 @@ class mUserCase extends mBase { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function formatUserCaseHerbs($uid, $prescribe_herb) { |
|
|
public function getUserCaseById($uid, $id) { |
|
|
$mCase = new mCase(); |
|
|
return $this->obj->select($this->tbl, array('sql' => '`id`=? and `uid`=?', 'vals' => array($id, $uid))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$prescribe_herb = json_decode($prescribe_herb, true); |
|
|
public function saveUserCase($uid, $id, $data) { |
|
|
if (empty($prescribe_herb)) { |
|
|
if (empty($data['name'])) { |
|
|
$this->setError('开药详情为空'); |
|
|
$this->setError('药方名称不能为空'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if (empty($data['feedback'])) { |
|
|
|
|
|
$this->setError('用药反馈不能为空'); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$data = array(); |
|
|
$user_case = $this->getUserCaseById($uid, $id); |
|
|
foreach ($prescribe_herb as $item) { |
|
|
if (empty($user_case)) { |
|
|
$temp = array(); |
|
|
$this->setError('找不到相关医案'); |
|
|
$temp['num'] = $item['num']; |
|
|
return false; |
|
|
if (isset($item['herb_id'])) { |
|
|
} |
|
|
$temp['herb_id'] = $item['herb_id']; |
|
|
|
|
|
$data[] = $temp; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$herb = $mCase->getHerbByName($item['name']); |
|
|
|
|
|
if ($herb) { |
|
|
|
|
|
$temp['herb_id'] = $herb['id']; |
|
|
|
|
|
$data[] = $temp; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$userherb = $this->obj->select($this->user_herb_tbl, array('sql' => '`name`=?', 'vals' => array($item['name']))); |
|
|
|
|
|
if ($userherb) { |
|
|
|
|
|
$temp['herb_id'] = 'u_' . $userherb['id']; |
|
|
|
|
|
$data[] = $temp; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$user_herb_id = $this->obj->insert($this->user_herb_tbl, array('uid' => $uid, 'name' => $item['name'])); |
|
|
|
|
|
if (!$user_herb_id) { |
|
|
|
|
|
$this->setError('添加自定义药材失败'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$temp['herb_id'] = 'u_' . $user_herb_id; |
|
|
$res = $this->updateUserCase($id, $data); |
|
|
$data[] = $temp; |
|
|
if (!$res) { |
|
|
|
|
|
$this->writeLog('user_case', 'update_error_log', '更新医案失败|' . $uid . '|' . json_encode($data, JSON_UNESCAPED_UNICODE)); |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return json_encode($data); |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function createUserCase($uid, $case_id, $data) { |
|
|
public function createUserCase($uid, $formula_id, $data) { |
|
|
if ($case_id <= 0) { |
|
|
|
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if (empty($data['patient_name'])) { |
|
|
if (empty($data['patient_name'])) { |
|
|
$this->setError('患者姓名不能为空'); |
|
|
$this->setError('患者姓名不能为空'); |
|
|
return false; |
|
|
return false; |
|
@ -119,189 +97,263 @@ class mUserCase extends mBase { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$m_case = new mCase(); |
|
|
//录医案 医案名称默认为药方名称 |
|
|
$case = $m_case->getCaseById($case_id); |
|
|
if ($formula_id > 0) { |
|
|
if (!$case) { |
|
|
$mformula = new mFormula(); |
|
|
$this->setError('找不到相关药方'); |
|
|
$formula = $mformula->getFormulaById($formula_id); |
|
|
return false; |
|
|
if (!$formula) { |
|
|
|
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($formula['uid'] > 0 && $uid != $formula['uid']) { |
|
|
|
|
|
$this->setError('这不是你的药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data['name'] = $formula['name']; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//手工录医案 生成随机医案名称 |
|
|
|
|
|
if ($formula_id == 0) { |
|
|
|
|
|
$data['name'] = "手工录入医案" . date("mdHi"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//格式化医案开药详情 |
|
|
//格式化医案开药详情 |
|
|
$prescribe_herb = $this->formatUserCaseHerbs($uid, $data['prescribe_herb']); |
|
|
$mformula = new mFormula(); |
|
|
|
|
|
$prescribe_herb = array(); |
|
|
|
|
|
|
|
|
|
|
|
$prescribe_herb_data = json_decode($data['prescribe_herb'], true); |
|
|
|
|
|
foreach ($prescribe_herb_data as $item) { |
|
|
|
|
|
$temp = array( |
|
|
|
|
|
'num' => $item['num'], |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (isset($item['herb_id'])) { |
|
|
|
|
|
$herb = $mformula->getHerbById($item['herb_id']); |
|
|
|
|
|
if (!$herb) { |
|
|
|
|
|
$this->setError('药材不存在|' . $item['herb_id']); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$temp['herb_id'] = $herb['id']; |
|
|
|
|
|
$prescribe_herb[] = $temp; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($item['name'])) { |
|
|
|
|
|
$herb = $mformula->getHerb($uid, $item['name'], ''); |
|
|
|
|
|
if ($herb) { |
|
|
|
|
|
$temp['herb_id'] = $herb['id']; |
|
|
|
|
|
$prescribe_herb[] = $temp; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$herb_id = $mformula->insertHerb(array('uid' => $uid, 'name' => $item['name'])); |
|
|
|
|
|
if (!$herb_id) { |
|
|
|
|
|
$this->writeLog('formula', 'insert_error_log', '添加药材失败|' . $uid . '|' . $item['name']); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$temp['herb_id'] = $herb_id; |
|
|
|
|
|
$prescribe_herb[] = $temp; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!$prescribe_herb) { |
|
|
if (!$prescribe_herb) { |
|
|
$this->setError('医案开药详情不正确'); |
|
|
$this->setError('医案开药详情不正确'); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$data['prescribe_herb'] = $prescribe_herb; |
|
|
$data['prescribe_herb'] = json_encode($prescribe_herb); |
|
|
$data['case_id'] = $case['id']; |
|
|
$data['formula_id'] = $formula_id; |
|
|
$data['uid'] = $uid; |
|
|
$data['uid'] = $uid; |
|
|
|
|
|
|
|
|
$id = $this->obj->insert($this->tbl, $data); |
|
|
$id = $this->insertUserCase($data); |
|
|
if (!$id) { |
|
|
if (!$id) { |
|
|
$this->setError('医案保存失败'); |
|
|
$this->writeLog('user_case', 'insert_error_log', '添加医案失败|' . $uid . '|' . json_encode($data, JSON_UNESCAPED_UNICODE)); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//更新用户药方使用次数 |
|
|
if ($formula_id > 0) { |
|
|
$m_case->updateCaseUseLog($uid, $case_id); |
|
|
//更新用户药方使用次数 |
|
|
|
|
|
$res = $mformula->updateFormulaUseLog($uid, $formula_id); |
|
|
|
|
|
if (!$res) { |
|
|
|
|
|
$this->writeLog('formula', 'update_error_log', '药方使用次数更新失败|' . $uid . '|' . $formula_id); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $id; |
|
|
return $id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCaseInfo($uid, $id) { |
|
|
public function getUserCaseInfo($uid, $id) { |
|
|
$user_case = $this->obj->select($this->tbl, array('sql' => '`id`=? and `uid`=?', 'vals' => array($id, $uid))); |
|
|
$user_case = $this->getUserCaseById($uid, $id); |
|
|
if (empty($user_case)) { |
|
|
if (empty($user_case)) { |
|
|
$this->setError('找不到相关医案'); |
|
|
$this->setError('找不到相关医案'); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
$mformula = new mFormula(); |
|
|
$case = $mCase->getCaseInfo($user_case['case_id']); |
|
|
|
|
|
if (empty($case)) { |
|
|
if ($user_case['formula_id'] > 0) { |
|
|
$this->setError('找不到相关药方'); |
|
|
$formula = $mformula->getFormulaInfo($user_case['formula_id'], $uid); |
|
|
return false; |
|
|
if (empty($formula)) { |
|
|
|
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$user_case['formula'] = $formula; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//格式化医案开药详情 |
|
|
//格式化医案开药详情 |
|
|
$prescribe_herb = $this->getUserCaseHerb(array($user_case['id'] => json_decode($user_case['prescribe_herb'], true))); |
|
|
$prescribe_herb_data = json_decode($user_case['prescribe_herb'], true); |
|
|
$user_case['prescribe_herb'] = $prescribe_herb[$user_case['id']]; |
|
|
|
|
|
|
|
|
$herbids = array_column($prescribe_herb_data, 'herb_id'); |
|
|
|
|
|
$herbs = $mformula->getHerbs($herbids); |
|
|
|
|
|
$herb_arr = array_column($herbs, null, 'id'); |
|
|
|
|
|
|
|
|
|
|
|
$prescribe_herb = array(); |
|
|
|
|
|
foreach ($prescribe_herb_data as &$item) { |
|
|
|
|
|
$temp = array( |
|
|
|
|
|
'id' => $item['id'], |
|
|
|
|
|
'name' => $herb_arr[$item['herb_id']]['name'], |
|
|
|
|
|
'num' => $item['num'], |
|
|
|
|
|
'desc' => $herb_arr[$item['herb_id']]['desc'], |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$prescribe_herb[] = $temp; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return array( |
|
|
$user_case['prescribe_herb'] = $prescribe_herb; |
|
|
'user_case' => $user_case, |
|
|
|
|
|
'case_data' => $case, |
|
|
|
|
|
); |
|
|
return $user_case; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCaseList($uid, $page_num, $page_size) { |
|
|
public function getUserCaseList($uid, $page_num, $page_size, $start_date = '', $end_date = '') { |
|
|
$offset = ($page_num - 1) * $page_size; |
|
|
$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'); |
|
|
$where = 'uid = ?'; |
|
|
|
|
|
$vals = array($uid); |
|
|
|
|
|
if ($start_date) { |
|
|
|
|
|
$where .= ' and case_time > ?'; |
|
|
|
|
|
array_push($vals, $start_date); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$m_case = new mCase(); |
|
|
if ($end_date) { |
|
|
$case = $m_case->getCaseByIds($case_ids); |
|
|
$where .= ' and case_time < ?'; |
|
|
if (empty($case)) { |
|
|
array_push($vals, $end_date); |
|
|
$this->setError('找不到相关药方'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return array( |
|
|
return $this->obj->selectAll($this->tbl, array('sql' => $where, 'vals' => $vals), 'case_time desc ', array($offset, $page_size)); |
|
|
'user_case' => $user_case, |
|
|
|
|
|
'case_data' => array_column($case, null, 'id') |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCaseHerb($prescribe_herb_arr) { |
|
|
public function getUserCaseListCount($uid) { |
|
|
$herb_ids = $user_herb_ids = array(); |
|
|
return $this->obj->count($this->tbl, array('sql' => '`uid`=?', 'vals' => array($uid))); |
|
|
foreach ($prescribe_herb_arr as $prescribe_herb) { |
|
|
} |
|
|
foreach ($prescribe_herb as $herb_item) { |
|
|
|
|
|
if (strpos($herb_item['herb_id'], 'u_') !== false) { |
|
|
|
|
|
$user_herb_ids[] = str_replace('u_', '', $herb_item['herb_id']); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
$herb_ids[] = $herb_item['herb_id']; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($herb_ids) && empty($user_herb_ids)) { |
|
|
public function getUserCaseListPdfInfo($uid, $page_num, $page_size, $start_date, $end_date) { |
|
|
$this->setError('医案开药详情不正确'); |
|
|
$data = $this->getUserCaseList($uid, $page_num, $page_size, $start_date, $end_date); |
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$m_case = new mCase(); |
|
|
$formula_ids = array(); |
|
|
$herb = $m_case->getHerbByIds($herb_ids); |
|
|
$herb_ids = array(); |
|
|
if (!empty($user_herb_ids)) { |
|
|
foreach ($data as &$value) { |
|
|
$user_herb = $this->getUserHerbByIds($user_herb_ids); |
|
|
$value['prescribe_herb'] = json_decode($value['prescribe_herb'], true); |
|
|
if (empty($user_herb)) { |
|
|
|
|
|
$this->setError('找不到相关自定义药材'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($user_herb as &$item) { |
|
|
$herb_ids = array_merge($herb_ids, array_column($value['prescribe_herb'], 'herb_id')); |
|
|
$item['id'] = "u_" . $item['id']; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$herb = array_merge($herb, $user_herb); |
|
|
$formula_ids[] = $value['formula_id']; |
|
|
} |
|
|
} |
|
|
$herb_list = array_column($herb, null, 'id'); |
|
|
|
|
|
|
|
|
$mformula = new mFormula(); |
|
|
$return = array(); |
|
|
|
|
|
foreach ($prescribe_herb_arr as $user_case_id => $prescribe_herb) { |
|
|
//查询药方索引 |
|
|
foreach ($prescribe_herb as $herb_item) { |
|
|
if (!empty($formula_ids)) { |
|
|
$temp = array( |
|
|
$formula_data = $mformula->getFormulaByIds($formula_ids); |
|
|
'id' => $herb_item['herb_id'], |
|
|
$formula_arr = array_column($formula_data, null, 'id'); |
|
|
'name' => $herb_list[$herb_item['herb_id']]['name'], |
|
|
|
|
|
'num' => $herb_item['num'], |
|
|
|
|
|
'desc' => $herb_list[$herb_item['herb_id']]['desc'] |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$return[$user_case_id][] = $temp; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $return; |
|
|
$herbs = $mformula->getHerbs($herb_ids); |
|
|
} |
|
|
$herb_arr = array_column($herbs, null, 'id'); |
|
|
|
|
|
|
|
|
public function getUserCaseListCount($uid) { |
|
|
//格式化pdf数据 |
|
|
return $this->obj->count($this->tbl, array('sql' => '`uid`=?', 'vals' => array($uid))); |
|
|
foreach ($data as &$value) { |
|
|
} |
|
|
$value['patient_sex'] = $value['patient_sex'] == 0 ? '男' : '女'; |
|
|
|
|
|
$value['case_time'] = date('Y年m月d日', strtotime($value['case_time'])); |
|
|
|
|
|
|
|
|
public function getUserHerbByIds($ids) { |
|
|
//格式化开药详情 |
|
|
return $this->obj->selectIn($this->user_herb_tbl, array('id' => $ids)); |
|
|
$herb_str_arr = array(); |
|
|
} |
|
|
foreach ($value['prescribe_herb'] as $va) { |
|
|
|
|
|
$herb_name = $herb_arr[$va['herb_id']]['name']; |
|
|
|
|
|
$herb_num = $va['num']; |
|
|
|
|
|
$herb_desc = $herb_arr[$va['herb_id']]['desc']; |
|
|
|
|
|
|
|
|
public function getUserCaseListPdfInfo($uid, $page_num, $page_size) { |
|
|
$herb_str_arr[] = $herb_name . $herb_desc . $herb_num . "克"; |
|
|
$data = $this->getUserCaseList($uid, $page_num, $page_size); |
|
|
} |
|
|
|
|
|
$value['prescribe_herb_info'] = implode('、', $herb_str_arr); |
|
|
|
|
|
|
|
|
$prescribe_herb_arr = array(); |
|
|
$value['formula_info'] = ''; |
|
|
foreach ($data['user_case'] as $value) { |
|
|
if (isset($formula_arr[$value['formula_id']])) { |
|
|
$prescribe_herb_arr[$value['id']] = json_decode($value['prescribe_herb'], true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//格式化医案开药详情 |
|
|
$formula_info = $formula_arr[$value['formula_id']]; |
|
|
$prescribe_herb = $this->getUserCaseHerb($prescribe_herb_arr); |
|
|
|
|
|
|
|
|
$value['formula_info'] .= "选 "; |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($formula_info['source'])) { |
|
|
|
|
|
$value['formula_info'] .= $formula_info['source'] . " "; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($formula_info['name'])) { |
|
|
|
|
|
$value['formula_info'] .= $formula_info['name'] . ":"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
foreach ($data['user_case'] as &$value) { |
|
|
unset($value['id']); |
|
|
$value['prescribe_herb'] = $prescribe_herb[$value['id']]; |
|
|
unset($value['uid']); |
|
|
|
|
|
unset($value['formula_id']); |
|
|
|
|
|
unset($value['prescribe_herb']); |
|
|
|
|
|
unset($value['create_time']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->formatUserCaseData($data); |
|
|
return $data; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getUserCasePdfInfo($uid, $id) { |
|
|
public function getUserCasePdfInfo($uid, $id) { |
|
|
$data = $this->getUserCaseInfo($uid, $id); |
|
|
$data = $this->getUserCaseInfo($uid, $id); |
|
|
|
|
|
|
|
|
return $this->formatUserCaseData($data); |
|
|
$data['patient_sex'] = $data['patient_sex'] == 0 ? '男' : '女'; |
|
|
} |
|
|
$data['case_time'] = date('Y年m月d日', strtotime($data['case_time'])); |
|
|
|
|
|
|
|
|
public function formatUserCaseData($data) { |
|
|
//格式化pdf数据 |
|
|
//兼容单个医案导出pdf |
|
|
$herb_arr = array(); |
|
|
if (isset($data['user_case']['id'])) { |
|
|
foreach ($data['prescribe_herb'] as $herb) { |
|
|
$data['user_case'] = array($data['user_case']); |
|
|
$herb_arr[] = $herb['name'] . $herb['num'] . "克"; |
|
|
$data['case_data'] = array($data['case_data']['id'] => $data['case_data']); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
$herb_str = implode('、', $herb_arr); |
|
|
|
|
|
$data['prescribe_herb_info'] = $herb_str; |
|
|
|
|
|
|
|
|
foreach ($data['user_case'] as &$item) { |
|
|
//查询药方索引 |
|
|
$item['patient_sex'] = $item['patient_sex'] == 0 ? '男' : '女'; |
|
|
$data['formula_info'] = ''; |
|
|
$item['case_time'] = date('Y年m月d日', strtotime($item['case_time'])); |
|
|
if (!empty($data['formula'])) { |
|
|
|
|
|
$data['formula_info'] .= "选 "; |
|
|
|
|
|
|
|
|
$case = $data['case_data'][$item['case_id']]; |
|
|
if (!empty($data['formula']['source'])) { |
|
|
$item['case_info'] = "选 " . $case['source'] . " " . $case['name'] . ":"; |
|
|
$data['formula_info'] .= $data['formula']['source'] . " "; |
|
|
|
|
|
|
|
|
$herb_arr = array(); |
|
|
|
|
|
foreach ($item['prescribe_herb'] as $herb) { |
|
|
|
|
|
$herb_arr[] = $herb['name'] . $herb['num'] . "克"; |
|
|
|
|
|
} |
|
|
} |
|
|
$herb_str = implode('、', $herb_arr); |
|
|
|
|
|
|
|
|
|
|
|
$item['case_herb_info'] = $herb_str; |
|
|
if (!empty($data['formula']['name'])) { |
|
|
|
|
|
$data['formula_info'] .= $data['formula']['name'] . ":"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unset($data['id']); |
|
|
|
|
|
unset($data['uid']); |
|
|
|
|
|
unset($data['index_id']); |
|
|
|
|
|
unset($data['prescribe_herb']); |
|
|
|
|
|
unset($data['create_time']); |
|
|
|
|
|
unset($data['formula']); |
|
|
|
|
|
|
|
|
return $data; |
|
|
return $data; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|