|
@@ -16,37 +16,37 @@ use app\inter\service\WechatService;
|
|
|
class Application extends Base
|
|
|
{
|
|
|
/**
|
|
|
- * 发起远程申请
|
|
|
- *
|
|
|
- * @ApiTitle (发起远程申请)
|
|
|
- * @ApiSummary (发起远程申请)
|
|
|
- * @ApiSector (远程诊断)
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @ApiRoute (/inter/application/index)
|
|
|
- * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key")
|
|
|
- * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数")
|
|
|
- * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s")
|
|
|
- * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串")
|
|
|
- * @ApiParams (name="param", type="string", required=true, description="参数json字符串")
|
|
|
- * @ApiParams (name="is_remote", type="string", required=true, description="参数json字符串")
|
|
|
- * @ApiParams (name="param[id]", type="string", sample="", description="预约登记exams表id值<必填>")
|
|
|
- * @ApiParams (name="param[rid]", type="string", sample="", description="远程申请表id值<远程列表进入必填>")
|
|
|
- * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功"))
|
|
|
- * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码")
|
|
|
- * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息")
|
|
|
- * @ApiReturnParams (name="is_remote", type="object", sample="{}", description="是否为远程诊断进入")
|
|
|
- * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key")
|
|
|
- * @ApiReturn (data="
|
|
|
-{
|
|
|
-'status': ok,
|
|
|
-'code': '0000',
|
|
|
-'sessionid': 'a17z7a7a8f9g9rh9d89jio',
|
|
|
-'is_remote': 1,
|
|
|
-'info' : '',
|
|
|
-'rid' : ''
|
|
|
-}
|
|
|
- *")
|
|
|
- **/
|
|
|
+ * 发起远程申请
|
|
|
+ *
|
|
|
+ * @ApiTitle (发起远程申请)
|
|
|
+ * @ApiSummary (发起远程申请)
|
|
|
+ * @ApiSector (远程诊断)
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @ApiRoute (/inter/application/index)
|
|
|
+ * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key")
|
|
|
+ * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数")
|
|
|
+ * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s")
|
|
|
+ * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串")
|
|
|
+ * @ApiParams (name="param", type="string", required=true, description="参数json字符串")
|
|
|
+ * @ApiParams (name="is_remote", type="string", required=true, description="参数json字符串")
|
|
|
+ * @ApiParams (name="param[id]", type="string", sample="", description="预约登记exams表id值<必填>")
|
|
|
+ * @ApiParams (name="param[rid]", type="string", sample="", description="远程申请表id值<远程列表进入必填>")
|
|
|
+ * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功"))
|
|
|
+ * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码")
|
|
|
+ * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息")
|
|
|
+ * @ApiReturnParams (name="is_remote", type="object", sample="{}", description="是否为远程诊断进入")
|
|
|
+ * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key")
|
|
|
+ * @ApiReturn (data="
|
|
|
+ {
|
|
|
+ 'status': ok,
|
|
|
+ 'code': '0000',
|
|
|
+ 'sessionid': 'a17z7a7a8f9g9rh9d89jio',
|
|
|
+ 'is_remote': 1,
|
|
|
+ 'info' : '',
|
|
|
+ 'rid' : ''
|
|
|
+ }
|
|
|
+ *")
|
|
|
+ **/
|
|
|
public function index(){
|
|
|
try{
|
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
@@ -56,20 +56,15 @@ class Application extends Base
|
|
|
if(isset($_REQUEST['is_remote']) && $_REQUEST['is_remote']==1){
|
|
|
$is_remote = 1;
|
|
|
}
|
|
|
- $info = DB::table('exams')->where('id',$id)->field('id,urgent,study_id,patient_id,exam_class,exam_sub_class,exam_project,device_name as device,exam_datetime,exam_status')->find();
|
|
|
+ $info = DB::table('exams')->where('id',$id)->field('id,urgent,study_id,patient_id,register_datetime,exam_class,exam_sub_class,exam_project,device,exam_datetime,exam_status')->find();
|
|
|
$exam_class = DB::table('constant')->where('id',$info['exam_class'])->field('constant_value')->find();
|
|
|
- $exam_subclass = DB::table('exam_subclass')->where('id',$info['exam_sub_class'])->find();
|
|
|
- $exam_project = DB::table('exam_project')->where('id',$info['exam_project'])->find();
|
|
|
- $device = DB::table('device')->where('id',$info['device'])->find();
|
|
|
- if(empty($device)){
|
|
|
- $deviceName = $info['device'];
|
|
|
- }else{
|
|
|
- $deviceName = $device['name'];
|
|
|
- }
|
|
|
+ $exam_subclass = DB::table('exam_subclass')->where('id',$info['exam_sub_class'])->cache(300)->find();
|
|
|
+ $exam_project = DB::table('exam_project')->where('id',$info['exam_project'])->cache(300)->find();
|
|
|
+ $device = DB::table('device')->where('id',$info['device'])->cache(300)->find();
|
|
|
$info['exam_class_name'] = $exam_class['constant_value'];
|
|
|
$info['exam_subclass_name'] = $exam_subclass['name'];
|
|
|
$info['exam_project_name'] = $exam_project['name'];
|
|
|
- $info['device_name'] = $deviceName;
|
|
|
+ $info['device_name'] = $device['name'];
|
|
|
$patient_info = DB::table('patient_infos')->where('id',$info['patient_id'])->field(['temp_patient_id','id','name','sex','age','birthday', 'phone'])->find();
|
|
|
$info['pid'] = $patient_info['id'];
|
|
|
$info['temp_patient_id'] = $patient_info['temp_patient_id'];
|
|
@@ -88,16 +83,16 @@ class Application extends Base
|
|
|
|
|
|
// 特殊机构
|
|
|
$special_doctors = Db::table('special_contact')
|
|
|
- ->alias("sc")
|
|
|
- ->join('doctors d', 'sc.did = d.id')
|
|
|
- ->join('institution i', 'sc.hid = i.id')
|
|
|
- ->join('special_remote sr', 'sc.sid = sr.id')
|
|
|
- ->where('sr.status', 1)
|
|
|
- ->where('sc.status', 1)
|
|
|
- ->order('sr.sort asc')
|
|
|
- ->order('sc.sort asc')
|
|
|
- ->field('sc.hid, sc.did, sc.id, sc.cost, sc.describe, sr.id as sid, sr.name, sr.check, sr.color, d.realname as dname, i.name as hname')
|
|
|
- ->select();
|
|
|
+ ->alias("sc")
|
|
|
+ ->join('doctors d', 'sc.did = d.id')
|
|
|
+ ->join('institution i', 'sc.hid = i.id')
|
|
|
+ ->join('special_remote sr', 'sc.sid = sr.id')
|
|
|
+ ->where('sr.status', 1)
|
|
|
+ ->where('sc.status', 1)
|
|
|
+ ->order('sr.sort asc')
|
|
|
+ ->order('sc.sort asc')
|
|
|
+ ->field('sc.hid, sc.did, sc.id, sc.cost, sc.describe, sr.id as sid, sr.name, sr.check, sr.color, d.realname as dname, i.name as hname')
|
|
|
+ ->select();
|
|
|
$super_hospitals = array();
|
|
|
// 特殊机构
|
|
|
if(!empty($special_doctors)) {
|
|
@@ -143,13 +138,13 @@ class Application extends Base
|
|
|
if($is_pay === 1) {
|
|
|
$super_hospitals = array();
|
|
|
$super_doctors = DB::table("remote_contact")
|
|
|
- ->alias("rc1")
|
|
|
- ->join('remote_cost rc2', 'rc1.hospital_id = rc2.hospital_id and rc1.super_hospital_id = rc2.super_hospital_id')
|
|
|
- ->where('rc1.hospital_id', $institution_id)
|
|
|
- ->where('rc2.exam_class', $info['exam_class'])
|
|
|
- ->field('rc1.hospital_id, rc1.super_hospital_id, rc1.hospital_name, rc1.super_hospital_name, rc1.pay_type, rc2.super_doctor_id, rc2.super_doctor_name, rc2.exam_class, rc2.is_admin')
|
|
|
- // ->fetchSql()
|
|
|
- ->select();
|
|
|
+ ->alias("rc1")
|
|
|
+ ->join('remote_cost rc2', 'rc1.hospital_id = rc2.hospital_id and rc1.super_hospital_id = rc2.super_hospital_id')
|
|
|
+ ->where('rc1.hospital_id', $institution_id)
|
|
|
+ ->where('rc2.exam_class', $info['exam_class'])
|
|
|
+ ->field('rc1.hospital_id, rc1.super_hospital_id, rc1.hospital_name, rc1.super_hospital_name, rc1.pay_type, rc2.super_doctor_id, rc2.super_doctor_name, rc2.exam_class, rc2.is_admin')
|
|
|
+ // ->fetchSql()
|
|
|
+ ->select();
|
|
|
// var_dump($super_doctors);
|
|
|
foreach($super_doctors as $v) {
|
|
|
if(!isset($super_hospitals[$v['hospital_id']])){
|
|
@@ -178,7 +173,7 @@ class Application extends Base
|
|
|
} else {
|
|
|
$parent_hosp = explode(',',$hospital['parent_institution']);
|
|
|
foreach($parent_hosp as $v){
|
|
|
- $phname = DB::table("institution")->where('id',$v)->field(['id','name'])->find();
|
|
|
+ $phname = DB::table("institution")->where('id',$v)->cache(300)->field(['id','name'])->find();
|
|
|
log::record('上级医院----'.json_encode($phname));
|
|
|
if(!isset($phname['id']) || empty($phname['id'])){
|
|
|
$phname['id'] = $v;
|
|
@@ -197,19 +192,19 @@ class Application extends Base
|
|
|
//申请信息
|
|
|
if(isset($param['rid']) && !empty($param['rid'])){
|
|
|
$rid = $param['rid'];
|
|
|
- $application = DB::table('remote_application')->where('id',$rid)->field(['id,remote_institution_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();
|
|
|
+ $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(['id,remote_institution_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();
|
|
|
+ $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'];
|
|
|
}
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
- ->where('application_id', $application['id'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
- ->field('id, status, exam_class, super_hospital_id, super_doctor_id')
|
|
|
- ->find();
|
|
|
+ ->where('application_id', $application['id'])
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->field('id, status, exam_class, super_hospital_id, super_doctor_id')
|
|
|
+ ->find();
|
|
|
if($remote_order) {
|
|
|
$info['remote_order'] = $remote_order;
|
|
|
}
|
|
@@ -225,7 +220,7 @@ class Application extends Base
|
|
|
}
|
|
|
$info['department_name'] = $dep['department_name'];
|
|
|
if(empty($application)){
|
|
|
- $exam_application = DB::table('register')->where('exam_id',$id)->field(['illness_desc','phys_sign','clin_symp','clin_diag','anamnesis','family_ill'])->find();
|
|
|
+ $exam_application = DB::table('exams')->where('id',$id)->field(['illness_desc','phys_sign','clin_symp','remark','clin_diag','anamnesis','family_ill'])->find();
|
|
|
if(empty($exam_application['anamnesis'])){
|
|
|
$exam_application['anamnesis'] = '';
|
|
|
}else{
|
|
@@ -238,7 +233,7 @@ class Application extends Base
|
|
|
}
|
|
|
$exam_application['report_status'] = '';
|
|
|
$exam_application['remark'] = '';
|
|
|
- $exam_application['remote_institution'] = '';
|
|
|
+ $exam_application['remote_institution'] =
|
|
|
$info['application'] = $exam_application;
|
|
|
}else{
|
|
|
$remote_name = DB::table('doctors')->where('id',$application['remote_doctor_id'])->field('realname')->find();
|
|
@@ -466,7 +461,7 @@ class Application extends Base
|
|
|
// $r = DB::table('remote_application')->where('exam_id',$param['id'])->field('id')->find();
|
|
|
// $aid = $r['id'];
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
if(isset($param['apply']) && !empty($param['apply'])){
|
|
|
$institution_id = $doctor['institution_id'];
|
|
|
$lower_hospital = DB::table('institution')->where('id', $institution_id)->field('is_pay')->find();
|
|
@@ -498,23 +493,24 @@ class Application extends Base
|
|
|
if(!empty($sid) && empty($scid)) {
|
|
|
return json_encode(['status'=>'fail','code'=>'2016','msg'=> '请选择问诊医生']);
|
|
|
}
|
|
|
+
|
|
|
if($is_pay === 1 && empty($sid)) {
|
|
|
$cost = DB::table('remote_cost')
|
|
|
- ->where('hospital_id', $local_institution_id)
|
|
|
- ->where('super_hospital_id', $remote_institution_id)
|
|
|
- ->where('super_doctor_id', $remote_doctor_id)
|
|
|
- ->where('exam_class', $exam_info['exam_class'])
|
|
|
- ->field('money')
|
|
|
- ->find();
|
|
|
+ ->where('hospital_id', $local_institution_id)
|
|
|
+ ->where('super_hospital_id', $remote_institution_id)
|
|
|
+ ->where('super_doctor_id', $remote_doctor_id)
|
|
|
+ ->where('exam_class', $exam_info['exam_class'])
|
|
|
+ ->field('money')
|
|
|
+ ->find();
|
|
|
if(!$cost) {
|
|
|
return json_encode(['status'=>'ok','code'=>'2016','msg'=> '远程医生获取失败']);
|
|
|
}
|
|
|
if($cost['money'] !== 0) {
|
|
|
$contact = DB::table('remote_contact')
|
|
|
- ->where('hospital_id', $local_institution_id)
|
|
|
- ->where('super_hospital_id', $remote_institution_id)
|
|
|
- ->field('pay_type')
|
|
|
- ->find();
|
|
|
+ ->where('hospital_id', $local_institution_id)
|
|
|
+ ->where('super_hospital_id', $remote_institution_id)
|
|
|
+ ->field('pay_type')
|
|
|
+ ->find();
|
|
|
if(!$contact) {
|
|
|
return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
|
}
|
|
@@ -555,6 +551,7 @@ class Application extends Base
|
|
|
DB::table('remote_application')->where('exam_id',$param['id'])->update(['report_status'=>4]);
|
|
|
}
|
|
|
// 添加messages信息
|
|
|
+
|
|
|
// $wechatService->pushWechatOrder($param['id']);
|
|
|
$t = '收到一条远程诊断申请';
|
|
|
$ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
@@ -574,10 +571,10 @@ class Application extends Base
|
|
|
// if($dinfo['institution_id'] == '22100003' || $dinfo['send_sms'] == 1){ //魏庙
|
|
|
// $repsone = send_message::sendSms2Apply($d_phone,$d_time,$d_name);
|
|
|
// }
|
|
|
- // $tel = '18910184804';
|
|
|
- // $type = '发起申请';
|
|
|
- // $content = $aid;
|
|
|
- // $response = send_message::sendSms2Self($tel,$type,$content);
|
|
|
+ // $tel = '18910184804';
|
|
|
+ // $type = '发起申请';
|
|
|
+ // $content = $aid;
|
|
|
+ // $response = send_message::sendSms2Self($tel,$type,$content);
|
|
|
}
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid,'aid'=>$aid]);
|
|
|
}catch(\Exception $e){
|
|
@@ -617,11 +614,11 @@ class Application extends Base
|
|
|
$water_why = self::WATER_WHY['REMOTEPAY'];
|
|
|
try{
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
- ->where('application_id', $application_id)
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
- ->field('id')
|
|
|
- ->find();
|
|
|
+ ->where('application_id', $application_id)
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->field('id')
|
|
|
+ ->find();
|
|
|
DB::table('remote_application')->where('id',$application_id)->update(['report_status'=>4]);
|
|
|
if($remote_order) {
|
|
|
DB::commit();
|
|
@@ -630,9 +627,9 @@ class Application extends Base
|
|
|
return json_encode(['status'=>'fail','code'=>'2019','msg' => '已存在订单,请勿重复发起']);
|
|
|
}
|
|
|
$hospital = DB::table('institution')
|
|
|
- ->where('id', $hospital_id)
|
|
|
- ->field('min_money, current_money')
|
|
|
- ->find();
|
|
|
+ ->where('id', $hospital_id)
|
|
|
+ ->field('min_money, current_money')
|
|
|
+ ->find();
|
|
|
if(!$hospital) {
|
|
|
DB::rollback();
|
|
|
return json_encode(['status'=>'fail','code'=>'2017','msg' => '查找本地医院失败']);
|
|
@@ -645,7 +642,6 @@ class Application extends Base
|
|
|
}
|
|
|
DB::table('institution')->where('id',$hospital_id)->update(['current_money'=> $current_money - $order_money]);
|
|
|
$order_id = UUIDs::uuid16();
|
|
|
- var_dump(1);
|
|
|
DB::table('remote_order')->insert([
|
|
|
'id' => $order_id,
|
|
|
'hospital_id' => $hospital_id,
|
|
@@ -660,7 +656,6 @@ class Application extends Base
|
|
|
'pay_way' => $pay_way,
|
|
|
'timestamp' => time(),
|
|
|
]);
|
|
|
- var_dump(2);
|
|
|
DB::table('remote_water')->insert([
|
|
|
'id' => UUIDs::uuid16(),
|
|
|
'hospital_id' => $hospital_id,
|
|
@@ -686,11 +681,11 @@ class Application extends Base
|
|
|
DB::startTrans();
|
|
|
try{
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
- ->where('application_id', $application_id)
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
- ->field('id')
|
|
|
- ->find();
|
|
|
+ ->where('application_id', $application_id)
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
+ ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->field('id')
|
|
|
+ ->find();
|
|
|
DB::table('remote_application')->where('id',$application_id)->update(['report_status'=>4]);
|
|
|
if($remote_order) {
|
|
|
DB::commit();
|
|
@@ -731,9 +726,9 @@ class Application extends Base
|
|
|
try{
|
|
|
DB::table('remote_order')->where('id', $order_id)->update(["status" => self::ORDER_STATUS["REDUCE"]]);
|
|
|
$hospital = DB::table('institution')
|
|
|
- ->where('id', $hospital_id)
|
|
|
- ->field('current_money')
|
|
|
- ->find();
|
|
|
+ ->where('id', $hospital_id)
|
|
|
+ ->field('current_money')
|
|
|
+ ->find();
|
|
|
$current_money = $hospital['current_money'];
|
|
|
DB::table('institution')->where('id',$hospital_id)->update(['current_money'=> $current_money + $order_money]);
|
|
|
DB::table('remote_water')->insert([
|
|
@@ -796,7 +791,7 @@ class Application extends Base
|
|
|
"ALIPAY" => 12,
|
|
|
"BANK" => 13
|
|
|
];
|
|
|
-
|
|
|
+
|
|
|
/**支付类型 微信 医院 */
|
|
|
public const PAY_TYPE = [
|
|
|
"PATIENT" => 0,
|