|
|
@ -75,73 +75,42 @@ class index extends publicBase { |
|
|
|
public function ajax_save_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, '请登录后操作'); |
|
|
|
$case_id = $this->post('case_id')+0; |
|
|
|
if(empty($uid) || empty($token) || empty($case_id))$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'], |
|
|
|
'name' => trim($this->post('name')), |
|
|
|
'patient_name' => trim($this->post('patient_name')), |
|
|
|
'patient_age' => $this->post('patient_age')+0, |
|
|
|
'patient_sex' => $this->post('patient_sex')+0, |
|
|
|
'patient_say' => trim($this->post('patient_say')), |
|
|
|
'first_diagnosis' => trim($this->post('first_diagnosis')), |
|
|
|
'diagnosis' => trim($this->post('diagnosis')), |
|
|
|
'prescribe_num' => $this->post('prescribe_num')+0, |
|
|
|
'prescribe_herb' => $this->post('prescribe_herb'), |
|
|
|
); |
|
|
|
|
|
|
|
$res = $mUserCase->updateUserCase($id,$data); |
|
|
|
if(!$res)$this->ajax_json(false, $mUserCase->getError()); |
|
|
|
$m_user_case = new mUserCase(); |
|
|
|
$id = $m_user_case->createUserCase($uid, $token, $case_id, $data); |
|
|
|
if(!$id)$this->ajax_json(false, $m_user_case->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功'); |
|
|
|
$this->ajax_json(true, '保存成功',array('id' => $id)); |
|
|
|
} |
|
|
|
|
|
|
|
$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()); |
|
|
|
public function ajax_update_user_case() { |
|
|
|
$uid = $this->post('uid'); |
|
|
|
$token = $this->post('token'); |
|
|
|
$id = $this->post('id')+0; |
|
|
|
if(empty($uid) || empty($token) || empty($id))$this->ajax_json(false, '非法请求'); |
|
|
|
|
|
|
|
$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, |
|
|
|
'name' => trim($this->post('name')), |
|
|
|
'feedback' => trim($this->post('feedback')), |
|
|
|
); |
|
|
|
|
|
|
|
$id = $mUserCase->createUserCase($data); |
|
|
|
if(!$id)$this->ajax_json(false, '保存失败'); |
|
|
|
|
|
|
|
//更新药方使用次数 这个后期会增加定时脚本去修正 |
|
|
|
$mCase = new mCase(); |
|
|
|
$mCase->updateCaseSearchNum($id); |
|
|
|
$m_user_case = new mUserCase(); |
|
|
|
$res = $m_user_case->updateUserCase($uid, $token, $id, $data); |
|
|
|
if(!$res)$this->ajax_json(false, $m_user_case->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功',array('id' => $id)); |
|
|
|
} |
|
|
|