|
@@ -344,16 +344,22 @@ class Application extends Base
|
|
|
$application_info['clin_diag'] = isset($param['clin_diag']) ? $param['clin_diag'] : '';
|
|
|
if(isset($param['is_urgent']) && $param['is_urgent'] == 'true' ){
|
|
|
$application_info['is_urgent'] = 1;
|
|
|
- $application_info['remote_doctor_id'] = '';
|
|
|
+ $remote_doctor_id = '';
|
|
|
$d_time = date('H:i',strtotime('+30 min'));
|
|
|
}else{
|
|
|
$application_info['is_urgent'] = 0;
|
|
|
- $application_info['remote_doctor_id'] = isset($param['remote_doctor_id']) ? $param['remote_doctor_id'] : '';
|
|
|
+ $remote_doctor_id = isset($param['remote_doctor_id']) ? $param['remote_doctor_id'] : '';
|
|
|
$d_time = date('H:i',strtotime('+1 hour'));
|
|
|
}
|
|
|
+ if($remote_doctor_id === '') {
|
|
|
+ $manager = DB::table('')->where('institution_id',$application_info['remote_institution_id'])->where('is_admin', '1')->field('id')->find();
|
|
|
+ if(!empty($manager)) {
|
|
|
+ $remote_doctor_id = $manager['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
$application_info['application_desc'] = isset($param['description']) ? $param['description'] : '';
|
|
|
$application_info['req_doctor_id'] = $doctor['id'];
|
|
|
- $application_info['remote_doctor_id'] = isset($param['remote_doctor_id']) ? $param['remote_doctor_id'] : '';
|
|
|
+ $application_info['remote_doctor_id'] = $remote_doctor_id;
|
|
|
$application_info['attachment'] = isset($param['attachment']) ? $param['attachment'] : '';
|
|
|
// $remote_application = DB::table('remote_application')->where('exam_id',$param['id'])->select();
|
|
|
// 申请远程
|
|
@@ -372,7 +378,7 @@ class Application extends Base
|
|
|
$app_id = $application_info['id'];
|
|
|
}
|
|
|
$aid = $app_id;
|
|
|
- $r_info = DB::table('report')->where('exam_id',$param['id'])->find();
|
|
|
+ $r_info = DB::table('report')->where('exam_id',$param['id'])->where('remote_application_id', $aid)->find();
|
|
|
if(empty($r_info)){
|
|
|
$report['id'] = UUIDs::uuid16();
|
|
|
$report['exam_id'] = $param['id'];
|
|
@@ -399,14 +405,15 @@ class Application extends Base
|
|
|
}
|
|
|
$remote_institution_id = $application['remote_institution_id'];
|
|
|
$remote_doctor_id = $application['remote_doctor_id'];
|
|
|
+ $is_urgent = $application['is_urgent'];
|
|
|
$local_institution_id = $application['local_institution_id'];
|
|
|
$req_doctor_id = $application['req_doctor_id'];
|
|
|
if(empty($remote_institution_id)) {
|
|
|
return json_encode(['status'=>'fail','code'=>'2012','msg'=> '远程机构id为空']);
|
|
|
}
|
|
|
- if(empty($remote_doctor_id)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2013','msg'=> '远程医生id为空']);
|
|
|
- }
|
|
|
+ // if(empty($remote_doctor_id)) {
|
|
|
+ // return json_encode(['status'=>'fail','code'=>'2013','msg'=> '远程医生id为空']);
|
|
|
+ // }
|
|
|
if(empty($local_institution_id)) {
|
|
|
return json_encode(['status'=>'fail','code'=>'2014','msg'=> '本地机构id为空']);
|
|
|
}
|
|
@@ -435,7 +442,7 @@ class Application extends Base
|
|
|
}
|
|
|
if($contact['pay_type'] === 0) { //医院挂账
|
|
|
// $hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money
|
|
|
- $res = $this->createHospitalOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money']);
|
|
|
+ $res = $this->createHospitalOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent);
|
|
|
if($res !== true) {
|
|
|
return $res;
|
|
|
}
|
|
@@ -445,7 +452,7 @@ class Application extends Base
|
|
|
// var_dump($wechatService);
|
|
|
// $push_res = WechatService::pushWechatOrder($param['id']);
|
|
|
$wechatService->pushWechatOrder($param['id']);
|
|
|
- $res = $this->createPatientsOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money']);
|
|
|
+ $res = $this->createPatientsOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent);
|
|
|
return json_encode(['status'=>'ok','code'=>'0000']);
|
|
|
}
|
|
|
}
|
|
@@ -458,6 +465,7 @@ class Application extends Base
|
|
|
'doctor_id' => $req_doctor_id,
|
|
|
'application_id' => $application['id'],
|
|
|
'super_doctor_id' => $remote_doctor_id,
|
|
|
+ 'is_urgent' => $is_urgent,
|
|
|
'order_money' => 0,
|
|
|
'pay_type' => self::PAY_TYPE['HOSPITAL'],
|
|
|
'pay_way' => self::PAY_WAY['HOSPITAL'],
|
|
@@ -494,7 +502,7 @@ class Application extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function createHospitalOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money) {
|
|
|
+ private function createHospitalOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0) {
|
|
|
DB::startTrans();
|
|
|
$pay_type = self::PAY_TYPE['HOSPITAL'];
|
|
|
$pay_way = self::PAY_TYPE['HOSPITAL'];
|
|
@@ -535,6 +543,7 @@ class Application extends Base
|
|
|
'super_hospital_id' => $super_hospital_id,
|
|
|
'exam_class' => $exam_class,
|
|
|
'doctor_id' => $doctor_id,
|
|
|
+ 'is_urgent' => $is_urgent,
|
|
|
'application_id' => $application_id,
|
|
|
'super_doctor_id' => $super_doctor_id,
|
|
|
'order_money' => $order_money,
|
|
@@ -560,7 +569,7 @@ class Application extends Base
|
|
|
}
|
|
|
return json_encode(['status'=>'fail','code'=>'2018','远程诊断发起失败']);
|
|
|
}
|
|
|
- private function createPatientsOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money) {
|
|
|
+ private function createPatientsOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0) {
|
|
|
$pay_type = self::PAY_TYPE['PATIENT'];
|
|
|
$pay_way = self::PAY_WAY['WECHAT'];
|
|
|
DB::startTrans();
|
|
@@ -586,6 +595,7 @@ class Application extends Base
|
|
|
'doctor_id' => $doctor_id,
|
|
|
'application_id' => $application_id,
|
|
|
'super_doctor_id' => $super_doctor_id,
|
|
|
+ 'is_urgent' => $is_urgent,
|
|
|
'order_money' => $order_money,
|
|
|
'pay_type' => $pay_type,
|
|
|
'pay_way' => $pay_way,
|