|
|
@ -21,57 +21,33 @@ class index extends publicBase { |
|
|
|
$id = $this->post('id'); |
|
|
|
$name = $this->post('name'); |
|
|
|
$source = $this->post('source'); |
|
|
|
$original = $this->post('original'); |
|
|
|
$method = $this->post('method'); |
|
|
|
$herbs = $this->post('herbs'); |
|
|
|
if(empty($name)||empty($source)||empty($method)||empty($herbs))$this->ajax_json(false, '参数错误'); |
|
|
|
if(empty($name))$this->ajax_json(false, '姓名不能为空'); |
|
|
|
if(empty($source))$this->ajax_json(false, '药方来源不能为空'); |
|
|
|
if(empty($herbs))$this->ajax_json(false, '药方药材不能为空'); |
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
|
|
|
|
|
$case_data = array( |
|
|
|
'name'=>$name, |
|
|
|
'source'=>$source, |
|
|
|
'original'=>$original, |
|
|
|
'method'=>$method, |
|
|
|
); |
|
|
|
|
|
|
|
if($id){ |
|
|
|
$case_id = $id; |
|
|
|
$res = $mCase->updateCase($id, $case_data); |
|
|
|
if(empty($res))$this->ajax_json(false, '保存失败'); |
|
|
|
}else{ |
|
|
|
$case_id = $mCase->createCase($case_data); |
|
|
|
if(empty($case_id))$this->ajax_json(false, '添加失败'); |
|
|
|
} |
|
|
|
|
|
|
|
$case_herb = array(); |
|
|
|
foreach ($herbs as $key=>$item) { |
|
|
|
$temp = array(); |
|
|
|
$temp['case_id']=$case_id; |
|
|
|
$temp['num']=$item['num']; |
|
|
|
$temp['sort']=$key; |
|
|
|
|
|
|
|
$herb = $mCase->getHerbByName($item['name']); |
|
|
|
if($herb){ |
|
|
|
$temp['herb_id']=$herb['id']; |
|
|
|
}else{ |
|
|
|
$temp['herb_id'] = $mCase->createHerb(array('name'=>$item['name'])); |
|
|
|
} |
|
|
|
|
|
|
|
if(empty($temp['herb_id'])){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
$case_herb[] = $temp; |
|
|
|
} |
|
|
|
|
|
|
|
if($id){ |
|
|
|
$odata = $mCase->getCaseHerbByCaseId($id); |
|
|
|
$mCase->compareCaseHerb($odata,$case_herb); |
|
|
|
//更新药方 |
|
|
|
$res = $mCase->updateCase($id, $case_data, $herbs); |
|
|
|
if (!$res) $this->ajax_json(false, $mCase->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功'); |
|
|
|
} |
|
|
|
|
|
|
|
$res = $mCase->createCaseHerb($case_herb); |
|
|
|
if(empty($res))$this->ajax_json(false, '添加失败'); |
|
|
|
//新增药方 |
|
|
|
$id = $mCase->createCase($case_data, $herbs); |
|
|
|
if (!$id) $this->ajax_json(false, $mCase->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '添加成功'); |
|
|
|
} |
|
|
@ -81,7 +57,7 @@ class index extends publicBase { |
|
|
|
if(empty($content))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$start = $this->post('start') ? $this->post('start') : 0; |
|
|
|
$pagesize = $this->post('pagesize') ? $this->post('pagesize') : 200; |
|
|
|
$pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; |
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
|
$data = $mCase->getCaseByName($content,$start,$pagesize); |
|
|
@ -91,18 +67,11 @@ class index extends publicBase { |
|
|
|
|
|
|
|
public function ajax_case_detail() { |
|
|
|
$id = $this->get('id'); |
|
|
|
$is_search = $this->get('is_search'); |
|
|
|
if(empty($id))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$mCase = new mCase(); |
|
|
|
|
|
|
|
if($is_search){ |
|
|
|
//先更新搜索次数 |
|
|
|
$mCase->updateCaseSearchNum($id); |
|
|
|
} |
|
|
|
|
|
|
|
//查询药方信息 |
|
|
|
$data = $mCase->getCaseInfo($id); |
|
|
|
if (empty($data)) $this->ajax_json(false, $mCase->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功', $data); |
|
|
|
} |
|
|
@ -112,142 +81,108 @@ class index extends publicBase { |
|
|
|
$token = $this->post('token'); |
|
|
|
if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功'); |
|
|
|
$mUser = new mUser(); |
|
|
|
$is_login = $mUser->validateToken($uid,$token); |
|
|
|
if(!$is_login)$this->ajax_json(false, '请登录后操作'); |
|
|
|
|
|
|
|
$mUserCase = new mUserCase(); |
|
|
|
|
|
|
|
$name = $this->post('name'); |
|
|
|
if(empty($name)) $this->ajax_json(false, '药方名称不能为空'); |
|
|
|
|
|
|
|
$id = $this->post('id'); |
|
|
|
if($id){ |
|
|
|
$data = array( |
|
|
|
'uid' => $uid, |
|
|
|
'name' => $_POST['name'], |
|
|
|
'feedback' => $_POST['feedback'], |
|
|
|
); |
|
|
|
|
|
|
|
$res = $mUserCase->updateUserCase($id,$data); |
|
|
|
if(!$res)$this->ajax_json(false, $mUserCase->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功'); |
|
|
|
} |
|
|
|
|
|
|
|
$case_id = $this->post('case_id'); |
|
|
|
$patient_name = $this->post('patient_name'); |
|
|
|
$patient_age = $this->post('patient_age')+0; |
|
|
|
$patient_sex = $this->post('patient_sex')+0; |
|
|
|
$prescribe_num = $this->post('prescribe_num')+0; |
|
|
|
$prescribe_herb = $this->post('prescribe_herb'); |
|
|
|
$patient_say = $this->post('patient_say'); |
|
|
|
$first_diagnosis = $this->post('first_diagnosis'); |
|
|
|
$diagnosis = $this->post('diagnosis'); |
|
|
|
|
|
|
|
if(empty($case_id)) $this->ajax_json(false, '找不到相关药方'); |
|
|
|
if(empty($patient_name)) $this->ajax_json(false, '患者姓名不能为空'); |
|
|
|
if(empty($patient_age)) $this->ajax_json(false, '患者年龄不能为空'); |
|
|
|
if(empty($prescribe_num)) $this->ajax_json(false, '开药数量不能为空'); |
|
|
|
if(empty($prescribe_herb)) $this->ajax_json(false, '开药详情不能为空'); |
|
|
|
if(empty($patient_say)) $this->ajax_json(false, '主诉不能为空'); |
|
|
|
if(empty($first_diagnosis)) $this->ajax_json(false, '舌诊脉诊不能为空'); |
|
|
|
if(empty($diagnosis)) $this->ajax_json(false, '诊断不能为空'); |
|
|
|
|
|
|
|
$prescribe_herb = $mUserCase->formatUserCaseHerbs($uid, $prescribe_herb); |
|
|
|
if(!$prescribe_herb)$this->ajax_json(false, $mUserCase->getError()); |
|
|
|
|
|
|
|
$data = array( |
|
|
|
'name' => $name, |
|
|
|
'patient_name' => $patient_name, |
|
|
|
'patient_age' => $patient_age, |
|
|
|
'patient_sex' => $patient_sex, |
|
|
|
'patient_say' => $patient_say, |
|
|
|
'first_diagnosis' => $first_diagnosis, |
|
|
|
'diagnosis' => $diagnosis, |
|
|
|
'prescribe_num' => $prescribe_num, |
|
|
|
'prescribe_herb' => $prescribe_herb, |
|
|
|
'case_id' => $case_id, |
|
|
|
'uid' => $uid, |
|
|
|
); |
|
|
|
|
|
|
|
$id = $mUserCase->createUserCase($data); |
|
|
|
if(!$id)$this->ajax_json(false, '保存失败'); |
|
|
|
|
|
|
|
//更新药方使用次数 这个后期会增加定时脚本去修正 |
|
|
|
$mCase = new mCase(); |
|
|
|
$mCase->updateCaseSearchNum($id); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功',array('id' => $id)); |
|
|
|
} |
|
|
|
|
|
|
|
public function ajax_user_case_list() { |
|
|
|
public function ajax_user_case() { |
|
|
|
$uid = $this->post('uid'); |
|
|
|
$token = $this->post('token'); |
|
|
|
if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$mUser = new mUser(); |
|
|
|
$is_login = $mUser->validateToken($uid,$token); |
|
|
|
if(!$is_login)$this->ajax_json(false, '请登录后操作'); |
|
|
|
|
|
|
|
$start = $this->post('start') ? $this->post('start') : 0; |
|
|
|
$pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; |
|
|
|
|
|
|
|
$mUserCase = new mUserCase(); |
|
|
|
|
|
|
|
$id = $this->post('id'); |
|
|
|
if($id){ |
|
|
|
$data = array( |
|
|
|
'user_case' =>array( |
|
|
|
"id"=>"1", |
|
|
|
"uid"=>"8112779578", |
|
|
|
"case_id"=> "1", |
|
|
|
"name"=> "11", |
|
|
|
"patient_name"=> "11", |
|
|
|
"patient_age"=> "1", |
|
|
|
"patient_sex"=> "1", |
|
|
|
"patient_say"=> "1", |
|
|
|
"first_diagnosis"=> "1", |
|
|
|
"diagnosis"=> "1", |
|
|
|
"prescribe_num"=> "1", |
|
|
|
"prescribe_herb"=> array( |
|
|
|
array( |
|
|
|
"herb_id"=> 1, |
|
|
|
"num"=> 5 |
|
|
|
), |
|
|
|
array( |
|
|
|
"herb_id"=> 'u_1', |
|
|
|
"num"=> 5 |
|
|
|
) |
|
|
|
), |
|
|
|
"feedback"=> "111", |
|
|
|
"case_time"=> "2024-08-28 11:49:46", |
|
|
|
"create_time"=> "2024-08-28 11:49:46" |
|
|
|
), |
|
|
|
'case'=> array( |
|
|
|
'id'=>1, |
|
|
|
'name'=>"大陷胸丸方", |
|
|
|
'source'=>"仲景伤寒论卷第四", |
|
|
|
'search_num'=>100, |
|
|
|
'sort'=>1, |
|
|
|
), |
|
|
|
'herb'=>array( |
|
|
|
'1'=>array( |
|
|
|
"id"=> "1", |
|
|
|
"name"=> "知母", |
|
|
|
"desc"=> "", |
|
|
|
), |
|
|
|
), |
|
|
|
'user_herb'=>array( |
|
|
|
'1'=>array( |
|
|
|
"id"=> "1", |
|
|
|
"uid"=> "12", |
|
|
|
"name"=> "当归", |
|
|
|
"desc"=> "", |
|
|
|
), |
|
|
|
) |
|
|
|
); |
|
|
|
}else{ |
|
|
|
$data = array( |
|
|
|
'user_case'=>array( |
|
|
|
array( |
|
|
|
"id"=>"1", |
|
|
|
"uid"=>"8112779578", |
|
|
|
"case_id"=> "1", |
|
|
|
"name"=> "11", |
|
|
|
"patient_name"=> "11", |
|
|
|
"patient_age"=> "1", |
|
|
|
"patient_sex"=> "1", |
|
|
|
"patient_say"=> "1", |
|
|
|
"first_diagnosis"=> "1", |
|
|
|
"diagnosis"=> "1", |
|
|
|
"prescribe_num"=> "1", |
|
|
|
"prescribe_herb"=> "[{\"herb_id\":1,\"num\":5},{\"num\":5,\"herb_id\":\"u_1\"}]", |
|
|
|
"feedback"=> "111", |
|
|
|
"case_time"=> "2024-08-28 11:49:46", |
|
|
|
"create_time"=> "2024-08-28 11:49:46" |
|
|
|
), |
|
|
|
array( |
|
|
|
"id"=>"2", |
|
|
|
"uid"=>"8112779578", |
|
|
|
"case_id"=> "1", |
|
|
|
"name"=> "11", |
|
|
|
"patient_name"=> "11", |
|
|
|
"patient_age"=> "1", |
|
|
|
"patient_sex"=> "1", |
|
|
|
"patient_say"=> "1", |
|
|
|
"first_diagnosis"=> "1", |
|
|
|
"diagnosis"=> "1", |
|
|
|
"prescribe_num"=> "1", |
|
|
|
"prescribe_herb"=> "[{\"herb_id\":1,\"num\":5},{\"num\":5,\"herb_id\":\"u_1\"}]", |
|
|
|
"feedback"=> "111", |
|
|
|
"case_time"=> "2024-08-28 11:49:46", |
|
|
|
"create_time"=> "2024-08-28 11:49:46" |
|
|
|
) |
|
|
|
), |
|
|
|
'case'=>array( |
|
|
|
array( |
|
|
|
'id'=>1, |
|
|
|
'name'=>"大陷胸丸方", |
|
|
|
'source'=>"仲景伤寒论卷第四", |
|
|
|
'search_num'=>100, |
|
|
|
'sort'=>1, |
|
|
|
), |
|
|
|
array( |
|
|
|
'id'=>2, |
|
|
|
'name'=>"大陷胸汤方", |
|
|
|
'source'=>"仲景伤寒论卷第四", |
|
|
|
'search_num'=>88, |
|
|
|
'sort'=>1, |
|
|
|
) |
|
|
|
), |
|
|
|
); |
|
|
|
$data = $mUserCase->getUserCaseInfo($id, $uid); |
|
|
|
if(!$data)$this->ajax_json(false, $mUserCase->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功', $data); |
|
|
|
} |
|
|
|
|
|
|
|
$data = $mUserCase->getUserCaseList($uid, $start, $pagesize); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功', $data); |
|
|
|
} |
|
|
|
|
|
|
|
public function ajax_collect_log() { |
|
|
|
$start = $this->get('start') ? $this->get('start') : 0; |
|
|
|
$pagesize = $this->get('pagesize') ? $this->get('pagesize') : 200; |
|
|
|
$pagesize = $this->get('pagesize') ? $this->get('pagesize') : 500; |
|
|
|
|
|
|
|
$data = array( |
|
|
|
array( |
|
|
|
'id'=>1, |
|
|
|
'collect_msg'=>"大陷胸丸方", |
|
|
|
'collect_time'=>"2024-08-28 11:13:39", |
|
|
|
), |
|
|
|
array( |
|
|
|
'id'=>2, |
|
|
|
'collect_msg'=>"大陷胸丸方", |
|
|
|
'collect_time'=>"2024-08-28 11:13:35", |
|
|
|
) |
|
|
|
); |
|
|
|
$mCase = new mCase(); |
|
|
|
$data = $mCase->getCollectLog($start,$pagesize); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功', $data); |
|
|
|
} |
|
|
@ -256,9 +191,31 @@ class index extends publicBase { |
|
|
|
$code = $this->get('code'); |
|
|
|
if(!$code)$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$mUser = new mUser(); |
|
|
|
|
|
|
|
$openid = $mUser->getOpenid($code); |
|
|
|
if(!$openid)$this->ajax_json(false, $mUser->getError()); |
|
|
|
|
|
|
|
$user = $mUser->getUserByOpenid($openid); |
|
|
|
if($user){ |
|
|
|
$data = array( |
|
|
|
'uid' => $user['uid'], |
|
|
|
'token'=> $mUser->getToken($user['uid']), |
|
|
|
); |
|
|
|
$this->ajax_json(true, '登录成功', $data); |
|
|
|
} |
|
|
|
|
|
|
|
//获取唯一uid串 |
|
|
|
$uid = $mUser->createUniqueUid($openid); |
|
|
|
$user = $mUser->getUserByUid($uid); |
|
|
|
if($user)$this->ajax_json(false, 'uid生成失败'); |
|
|
|
|
|
|
|
$id = $mUser->createUser(array('uid'=>$uid,'openid'=>$openid)); |
|
|
|
if(!$id)$this->ajax_json(false, '用户创建失败'); |
|
|
|
|
|
|
|
$data = array( |
|
|
|
'uid'=>'12312321', |
|
|
|
'token'=>'asdasdasdsa' |
|
|
|
'uid' => $uid, |
|
|
|
'token'=> $mUser->getToken($uid), |
|
|
|
); |
|
|
|
|
|
|
|
$this->ajax_json(true, '登录成功', $data); |
|
|
@ -273,7 +230,32 @@ class index extends publicBase { |
|
|
|
$token = $this->post('token'); |
|
|
|
if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功',array('pdf_url'=>'')); |
|
|
|
$mUser = new mUser(); |
|
|
|
$is_login = $mUser->validateToken($uid,$token); |
|
|
|
if(!$is_login)$this->ajax_json(false, '请登录后操作'); |
|
|
|
|
|
|
|
$mUserCase = new mUserCase(); |
|
|
|
|
|
|
|
$id = $this->post('id'); |
|
|
|
if($id){ |
|
|
|
$data = $mUserCase->getUserCaseInfo($id, $uid); |
|
|
|
if (!$data) $this->ajax_json(false, $mUserCase->getError()); |
|
|
|
|
|
|
|
$pdf_url = $mUserCase->createUserCasePdf($uid, $data); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功',array('pdf_url'=> $pdf_url)); |
|
|
|
} |
|
|
|
|
|
|
|
//如果id不存在默认保存前500个医案 |
|
|
|
$start = $this->post('start') ? $this->post('start') : 0; |
|
|
|
$pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; |
|
|
|
|
|
|
|
$data = $mUserCase->getUserCaseList($uid, $start, $pagesize, true); |
|
|
|
if (!$data) $this->ajax_json(false, $mUserCase->getError()); |
|
|
|
|
|
|
|
$pdf_url = $mUserCase->createUserCasePdf($uid, $data); |
|
|
|
|
|
|
|
$this->ajax_json(true, '获取成功',array('pdf_url'=> $pdf_url)); |
|
|
|
} |
|
|
|
|
|
|
|
public function ajax_mail(){ |
|
|
@ -281,6 +263,25 @@ class index extends publicBase { |
|
|
|
$token = $this->post('token'); |
|
|
|
if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$mUser = new mUser(); |
|
|
|
$is_login = $mUser->validateToken($uid,$token); |
|
|
|
if(!$is_login)$this->ajax_json(false, '请登录后操作'); |
|
|
|
|
|
|
|
$email = $this->post('email'); |
|
|
|
if(empty($email))$this->ajax_json(false, '邮箱地址不能为空'); |
|
|
|
if(!filter_var($email, FILTER_VALIDATE_EMAIL))$this->ajax_json(false, '邮箱地址无效'); |
|
|
|
|
|
|
|
$pdf_url = $this->post('pdf_url'); |
|
|
|
if(empty($pdf_url))$this->ajax_json(false, 'pdf地址不能为空'); |
|
|
|
if(!filter_var($pdf_url, FILTER_VALIDATE_URL))$this->ajax_json(false, 'pdf地址无效'); |
|
|
|
|
|
|
|
$directory_name = basename(dirname($pdf_url)); |
|
|
|
if($directory_name != $uid)$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$mUserCase = new mUserCase(); |
|
|
|
$res = $mUserCase->sendMail(array($email),date('Y年m月d日',time()).'-医案导出','',sprintf(USER_CASE_PDF_PATH, $uid) . basename($pdf_url)); |
|
|
|
if(!$res)$this->ajax_json(true, '发送失败'); |
|
|
|
|
|
|
|
$this->ajax_json(true, '发送成功'); |
|
|
|
} |
|
|
|
} |
|
|
|