|
@@ -10,6 +10,7 @@ use think\Log;
|
|
|
use app\common\library\Verify;
|
|
|
use think\File;
|
|
|
use app\common\library\send_message;
|
|
|
+use app\common\library\Message;
|
|
|
class Application extends Base
|
|
|
{
|
|
|
/**
|
|
@@ -86,16 +87,20 @@ class Application extends Base
|
|
|
//申请信息
|
|
|
if(isset($param['rid']) && !empty($param['rid'])){
|
|
|
$rid = $param['rid'];
|
|
|
- $application = DB::table('remote_application')->where('id',$rid)->field(['report_status,id,remote_doctor_id','application_desc','attachment','req_doctor_id','illness_desc','phys_sign','is_urgent','clin_symp','anamnesis','family_ill','remark','clin_diag'])->find();
|
|
|
+ $application = DB::table('remote_application')->where('id',$rid)->field(['id,report_status,id,remote_doctor_id','application_desc','attachment','req_doctor_id','illness_desc','phys_sign','is_urgent','clin_symp','anamnesis','family_ill','remark','clin_diag'])->find();
|
|
|
+ $aid = $application['id'];
|
|
|
}else{
|
|
|
$rid = '';
|
|
|
- $application = DB::table('remote_application')->where('exam_id',$id)->field(['report_status,id,remote_doctor_id','application_desc','attachment','req_doctor_id','illness_desc','phys_sign','clin_symp','is_urgent','anamnesis','family_ill','remark','clin_diag'])->find();
|
|
|
+ $application = DB::table('remote_application')->where('exam_id',$id)->field(['id,report_status,id,remote_doctor_id','application_desc','attachment','req_doctor_id','illness_desc','phys_sign','clin_symp','is_urgent','anamnesis','family_ill','remark','clin_diag'])->find();
|
|
|
+ $aid = $application['id'];
|
|
|
}
|
|
|
if($is_remote == 1){
|
|
|
+ Message::read($doctor['id'],$aid,1);
|
|
|
//远程申请点击进入
|
|
|
$dinfo = DB::table('doctors')->where('id',$application['req_doctor_id'])->field('department_id')->find();
|
|
|
$dep = DB::table('department')->where('id',$dinfo['department_id'])->field('department_name')->find();
|
|
|
}else{
|
|
|
+ Message::read($doctor['id'],$aid,2);
|
|
|
//本地远程申请中
|
|
|
$dep = DB::table('department')->where('id',$doctor['department_id'])->field('department_name')->find();
|
|
|
}
|
|
@@ -193,7 +198,7 @@ class Application extends Base
|
|
|
if(empty($application_info['remote_institution_id'])){
|
|
|
return json_encode(['status'=>'fail','code'=>'3029','msg'=>'没有选择远程机构']);
|
|
|
}
|
|
|
- $exam_info = DB::table('exams')->where('id',$param['id'])->field('exam_status,patient_id')->find();
|
|
|
+ $exam_info = DB::table('exams')->where('id',$param['id'])->field('exam_class,exam_status,patient_id')->find();
|
|
|
// 修改病人姓名
|
|
|
DB::table('patient_infos')->where('id',$exam_info['patient_id'])->update(['name'=>$param['name']]);
|
|
|
if($exam_info['exam_status'] != 3 && $exam_info['exam_status'] != 5 && $exam_info['exam_status'] != 8){
|
|
@@ -263,6 +268,7 @@ class Application extends Base
|
|
|
}else{
|
|
|
$application_info['id'] = UUIDs::uuid16();
|
|
|
$application_info['createdAt'] = date('Y-m-d H:i:s',time());
|
|
|
+ $application_info['type'] = 2;
|
|
|
DB::table('remote_application')->insert($application_info);
|
|
|
$app_id = $application_info['id'];
|
|
|
}
|
|
@@ -274,6 +280,9 @@ class Application extends Base
|
|
|
$report['exam_id'] = $param['id'];
|
|
|
$report['remote_application_id'] = $aid;
|
|
|
DB::table('report')->insert($report);
|
|
|
+ $r_id = $report['id'];
|
|
|
+ }else{
|
|
|
+ $r_id = $r_info['id'];
|
|
|
}
|
|
|
// }else{
|
|
|
// log::record('修改远程申请');
|
|
@@ -283,8 +292,15 @@ class Application extends Base
|
|
|
// }
|
|
|
if(isset($param['apply']) && !empty($param['apply'])){
|
|
|
DB::table('remote_application')->where('exam_id',$param['id'])->update(['report_status'=>4]);
|
|
|
+ // 添加messages信息
|
|
|
+ $t = '收到一条远程诊断申请';
|
|
|
+ $ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
+ $c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
|
|
|
+ $d = $application_info['remote_doctor_id'];
|
|
|
+ $t = '1';
|
|
|
+ $url = Message::url($sessionid,$param['id'],1,$exam_info['exam_class'],$r_id);
|
|
|
+ Message::insert($t,$c,$d,$t,$url,1,$aid);
|
|
|
//保存 申请
|
|
|
-// if(isset($param['remote_doctor_id']) && $param['remote_doctor_id'] == 'c44663d6d3c0b535'){
|
|
|
$dinfo = DB::table('doctors')->where('id',$application_info['remote_doctor_id'])->find();
|
|
|
$d_phone = $dinfo['phone'];
|
|
|
$d_name = $dinfo['realname'];
|
|
@@ -295,7 +311,6 @@ class Application extends Base
|
|
|
$type = '发起申请';
|
|
|
$content = $aid;
|
|
|
$response = send_message::sendSms2Self($tel,$type,$content);
|
|
|
-// }
|
|
|
}
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid,'aid'=>$aid]);
|
|
|
}catch(\Exception $e){
|
|
@@ -380,7 +395,7 @@ class Application extends Base
|
|
|
$doctor = Cache::get($sessionid);
|
|
|
$param = $_REQUEST['param'];
|
|
|
$id = $param['id'];
|
|
|
- $re = DB::table('remote_application')->where('id',$id)->field('report_status')->find();
|
|
|
+ $re = DB::table('remote_application')->where('id',$id)->field('exam_id,report_status')->find();
|
|
|
if($re['report_status'] != 4){
|
|
|
return json_encode(['status'=>'fail','code'=>'0321','msg'=>'只能驳回申请中的单子']);
|
|
|
}
|
|
@@ -410,9 +425,17 @@ class Application extends Base
|
|
|
// $message['doctor_id'] = $application['req_doctor_id'];
|
|
|
// $message['institution_id'] = $application['local_institution_id'];
|
|
|
DB::table('remote_application')->where('id',$id)->update(['report_status'=>5]);
|
|
|
- // 驳回发短信
|
|
|
-// if($application['req_doctor_id'] == 'c44663d6d3c0b535'){
|
|
|
$dinfo = DB::table('doctors')->where('id',$application['req_doctor_id'])->find();
|
|
|
+ $institution = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
+ // 驳回添加messages消息
|
|
|
+ $t = '您的远程诊断申请被驳回';
|
|
|
+ $c = '您的远程诊断申请,被'.$institution['name'].$doctor['realname'].'xx(下级机构)xx(医生)医师驳回。驳回理由:'.$param['description'];
|
|
|
+ $d = $application['req_doctor_id'];
|
|
|
+ $type = '2';
|
|
|
+ $exam_class = DB::table('exams')->where('id',$re['exam_id'])->field('exam_class')->find();
|
|
|
+ $url = Message::url($sessionid,$re['exam_id'],0,$exam_class['exam_class'],$report['id']);
|
|
|
+ Message::insert($t,$c,$d,$type,$url,1,$id);
|
|
|
+ // 驳回发短信
|
|
|
$d_phone = $dinfo['phone'];
|
|
|
if($dinfo['institution_id'] == '22100002' || $dinfo['send_sms'] == 1){ //魏庙下级
|
|
|
$des = mb_substr($param['description'],0,20,'utf-8');
|
|
@@ -424,7 +447,6 @@ class Application extends Base
|
|
|
send_message::sendSms2Self($tel,$type,$content);
|
|
|
$tel = '18366391911';
|
|
|
send_message::sendSms2Self($tel,$type,$content);
|
|
|
-// }
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid]);
|
|
|
}
|
|
|
|
|
@@ -457,18 +479,26 @@ class Application extends Base
|
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
|
$doctor = Cache::get($sessionid);
|
|
|
$id = $_REQUEST['id'];
|
|
|
- $re = DB::table('remote_application')->where('id',$id)->field('report_status')->find();
|
|
|
+ $re = DB::table('remote_application')->where('id',$id)->field('report_status,req_doctor_id,exam_id')->find();
|
|
|
if($re['report_status'] != 4){
|
|
|
return json_encode(['status'=>'fail','code'=>'0321','msg'=>'只能接收申请中的单子']);
|
|
|
}
|
|
|
DB::table('remote_application')->where('id',$id)->update(['report_status'=>6]);
|
|
|
$application = DB::table('remote_application')->where('exam_id',$id)->find();
|
|
|
- if($application['req_doctor_id'] == 'c44663d6d3c0b535'){
|
|
|
- $tel = '18910184804';
|
|
|
- $type = '接收申请';
|
|
|
- $content = $application['id'];
|
|
|
- send_message::sendSms2Self($tel,$type,$content);
|
|
|
- }
|
|
|
+ $tel = '18910184804';
|
|
|
+ $type = '接收申请';
|
|
|
+ $content = $application['id'];
|
|
|
+ send_message::sendSms2Self($tel,$type,$content);
|
|
|
+ // 添加messages消息
|
|
|
+ $t = '您的远程诊断申请被接收';
|
|
|
+ $institution = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
+ $c = '您的远程诊断申请,被'.$institution['name'].$doctor['realname'].'医师接收';
|
|
|
+ $d = $re['req_doctor_id'];
|
|
|
+ $type = '4';
|
|
|
+ $exam_class = DB::table('exams')->where('id',$re['exam_id'])->field('exam_class')->find();
|
|
|
+ $report = DB::table('report')->where('remote_application_id',$id)->field('id')->find();
|
|
|
+ $url = Message::url($sessionid,$re['exam_id'],0,$exam_class['exam_class'],$report['id']);
|
|
|
+ Message::insert($t,$c,$d,$type,$url,1,$id);
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid]);
|
|
|
}
|
|
|
|
|
@@ -482,18 +512,31 @@ class Application extends Base
|
|
|
$info = array();
|
|
|
$info['id'] = UUIDs::uuid16();
|
|
|
$info['initiator'] = $doctor['id'];
|
|
|
+ $is_remote = $_REQUEST['is_remote'];
|
|
|
+ $rinfo = DB::table('remote_application')->where('id',$param['appid'])->field('req_doctor_id,remote_doctor_id')->find();
|
|
|
+ if($is_remote == 1){
|
|
|
+ // 远程医生
|
|
|
+ $info['reply'] = $rinfo['req_doctor_id']; //申请医生
|
|
|
+ $remote = 0;
|
|
|
+ }else{
|
|
|
+ $info['reply'] = $rinfo['remote_doctor_id']; //申请的目标远程医生
|
|
|
+ $remote = 1;
|
|
|
+ }
|
|
|
// $info['reply'] = $param['reply']; // 回复人
|
|
|
$info['remote_application_id'] = $param['appid']; //申请单id
|
|
|
$info['content'] = $param['content'];
|
|
|
$info['attachment'] = $param['attachment'];
|
|
|
$info['createdAt'] = date('Y-m-d H:i:s',time());
|
|
|
DB::table('bbs')->insert($info);
|
|
|
+ // 添加message消息
|
|
|
+ Message::bbs_message($param['appid'],$doctor['id'],$param['content'],$info['reply'],$remote,$sessionid);
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid]);
|
|
|
}
|
|
|
public function getbbs(){
|
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
|
$doctor = Cache::get($sessionid);
|
|
|
$remote_id = $_REQUEST['application_id'];
|
|
|
+ Message::read($doctor['id'],$remote_id,5);
|
|
|
$info = DB::table('bbs')->where('remote_application_id',$remote_id)->order('createdAt desc')->select();
|
|
|
foreach ($info as $k => $v) {
|
|
|
$initiator = DB::table('doctors')->where('id',$v['initiator'])->field('realname')->find();
|
|
@@ -528,7 +571,7 @@ class Application extends Base
|
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
|
$doctor = Cache::get($sessionid);
|
|
|
$id = $_REQUEST['id'];
|
|
|
- $status = DB::table('remote_application')->where('exam_id',$id)->field('id,report_status')->find();
|
|
|
+ $status = DB::table('remote_application')->where('exam_id',$id)->field('id,report_status,remote_doctor_id')->find();
|
|
|
if($status['report_status'] == 4){
|
|
|
DB::table('remote_application')->where('exam_id',$id)->update(['report_status'=>12]);
|
|
|
}else{
|
|
@@ -542,6 +585,16 @@ class Application extends Base
|
|
|
$binfo['content'] = '已撤回了该申请';
|
|
|
$binfo['createdAt'] = date('Y-m-d H:i:s',time());
|
|
|
DB::table('bbs')->insert($binfo);
|
|
|
+ //
|
|
|
+ $t = '发起给您的远程诊断申请被撤回';
|
|
|
+ $institution = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
+ $c = '您的远程诊断申请'.$institution['name'].$doctor['realname'].'医师撤回';
|
|
|
+ $d = $status['remote_doctor_id'];
|
|
|
+ $type = '3';
|
|
|
+ $exam_class = DB::table('exams')->where('id',$id)->field('exam_class')->find();
|
|
|
+ $report = DB::table('report')->where('remote_application_id',$status['id'])->field('id')->find();
|
|
|
+ $url = Message::url($sessionid,$id,1,$exam_class['exam_class'],$report['id']);
|
|
|
+ Message::insert($t,$c,$d,$type,$url,1,$status['id']);
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','msg'=>'撤回成功']);
|
|
|
}
|
|
|
}
|