Reciveremote.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <?php
  2. namespace app\inter\controller;
  3. use app\common\library\UUIDs;
  4. use think\Cache;
  5. use think\Controller;
  6. use think\Db;
  7. use think\Log;
  8. // select count(*) from remote_application ra left join remote_order ro on ro.id = (select id from remote_order rot where rot.application_id = ra.id order by timestamp desc limit 1) where ra.remote_institution_id='09b4765b26ba8b7c' and (report_status = '4' or report_status = '6' or report_status = '7' or report_status = '8' or report_status = '9') and (ra.remote_doctor_id='b5bed8f973852c22' or ra.remote_doctor_id = '') and (ro.status is null or ro.status = 2 or ro.status = 3)
  9. // select is_urgent, report_status, req_date_time from remote_application ra left join remote_order ro on ro.id = (select id from remote_order rot where rot.application_id = ra.id order by timestamp desc limit 1) where ra.remote_institution_id='09b4765b26ba8b7c' and (report_status = '4' or report_status = '6' or report_status = '7' or report_status = '8' or report_status = '9') and (ra.remote_doctor_id='b5bed8f973852c22' or ra.remote_doctor_id = '') and (ro.status is null or ro.status = 2 or ro.status = 3) order by (ra.is_urgent = '1' and ra.report_status = '4') desc, (ra.is_urgent = '1' and ra.report_status = '6') desc, (ra.is_urgent = '1' and ra.report_status = '7'), ra.req_date_time desc limit 20
  10. class Reciveremote extends Base
  11. {
  12. /**
  13. * 远程申请列表
  14. *
  15. * @ApiTitle (远程申请列表)
  16. * @ApiSummary (远程申请列表)
  17. * @ApiSector (远程诊断)
  18. * @ApiMethod (POST)
  19. * @ApiRoute (/inter/reciveremote/index)
  20. * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key")
  21. * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数")
  22. * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s")
  23. * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串")
  24. * @ApiParams (name="param", type="string", required=true, description="参数json字符串")
  25. * @ApiParams (name="page", type="string", required=true, description="当前页")
  26. * @ApiParams (name="num", type="string", required=true, description="每页显示条数")
  27. * @ApiParams (name="param[patient_num]", type="string", sample="", description="预约登记exams表id值<选填>")
  28. * @ApiParams (name="param[exam_class]", type="string", sample="", description="检查类<选填>")
  29. * @ApiParams (name="param[name]", type="string", sample="", description="患者姓名<选填>")
  30. * @ApiParams (name="param[applicationtime]", type="string", sample="", description="申请时间<选填>")
  31. * @ApiParams (name="param[is_urgent]", type="string", sample="", description="是否急诊<选填>")
  32. * @ApiParams (name="param[report_result]", type="string", sample="", description="检查结果<选填>")
  33. * @ApiParams (name="param[exam_status]", type="string", sample="", description="检查状态<选填>")
  34. * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功"))
  35. * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码")
  36. * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息")
  37. * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key")
  38. * @ApiReturnParams (name="count", type="object", sample="{}", description="总条数")
  39. * @ApiReturn (data="
  40. {
  41. 'status': ok,
  42. 'code': '0000',
  43. 'sessionid': 'a17z7a7a8f9g9rh9d89jio',
  44. 'info' : ''
  45. 'count' : '110'
  46. }
  47. *")
  48. **/
  49. // public function index()
  50. // {
  51. // try{
  52. // log::record('---------工作列表--------');
  53. // log::record($_REQUEST);
  54. // $sessionid = $_REQUEST['sessionid'];
  55. // $doctor = Cache::get($sessionid);
  56. // log::record($doctor);
  57. // $app_info = DB::table('remote_application')->where('remote_institution_id', $doctor['institution_id'])->select();
  58. // foreach ($app_info as $k => $v) {
  59. // $exam_id = $v['exam_id'];
  60. // $report = DB::table('report')->where('exam_id', $exam_id)->where('remote_application_id',$v['id'])->find();
  61. // if (!$report) {
  62. // $data = array();
  63. // $data['id'] = UUIDs::uuid16();
  64. // $data['exam_id'] = $exam_id;
  65. // $data['remote_application_id'] = $v['id'];
  66. // $data['type'] = 2;
  67. // $data['createdAt'] = date('Y-m-d H:i:s',time());
  68. // DB::table('report')->insert($data);
  69. // }
  70. // }
  71. // $where = '';
  72. // if(isset($_REQUEST['param'])){
  73. // $param = $_REQUEST['param'];
  74. // foreach ($param as $k => $v) {
  75. // switch ($k) {
  76. // case 'patient_num':
  77. // $where .= " and e." . $k . "='" . $v . "' ";
  78. // break;
  79. // case 'exam_class' :
  80. // if(empty($v)){
  81. // break;
  82. // }
  83. // $ex = implode('\',\'',$v);
  84. // $where .= " and e.exam_class in ('".$ex."')";
  85. // break;
  86. // case 'name':
  87. // $where .= " and p.name like '".$v."%' ";
  88. // break;
  89. // case 'applicationtime':
  90. // if(empty($v)){
  91. // break;
  92. // }
  93. // $where .= " and ra.req_date_time between '$v[0]' and '$v[1]'";
  94. // break;
  95. // case 'is_urgent':
  96. // if($v == 0){
  97. // break;
  98. // }
  99. // $where .= " and ra.is_urgent=".$v;
  100. // break;
  101. // case 'report_result':
  102. // if($v == 2){
  103. // $where .= " and r.report_result=2";
  104. // }elseif($v == 1){
  105. // $where .= " and r.report_result=1";
  106. // }{
  107. // break;
  108. // }
  109. // break;
  110. // case 'exam_status':
  111. // if($v != 10){
  112. // $where .= " and ra.report_status=".$v;
  113. // }
  114. // break;
  115. // }
  116. // }
  117. // }
  118. // $doc_class = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->value('doctor_class');
  119. // if(strpos('8',$doc_class) !== false){
  120. // $dwhere = ' or ra.report_status=7 ';
  121. // }else{
  122. // $dwhere = '';
  123. // }
  124. // log::record($where);
  125. // $page = $_REQUEST['page'];
  126. // $num = $_REQUEST['num'];
  127. // $fnum = ($page-1)*$num;
  128. // $limit = " limit ".$fnum.",".$num;
  129. // /*if(empty($where)){
  130. // $dclass = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->cache(300)->field('doctor_class')->find();
  131. // if(empty($dclass['doctor_class'])){
  132. // $dclass['doctor_class'] = 0;
  133. // }
  134. // log::record($dclass);
  135. // $sql1 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "' and ra.is_urgent=1 and e.exam_status in (".$dclass['doctor_class'].")";
  136. // $sql2 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "' and ra.is_urgent=0 and e.exam_status in (".$dclass['doctor_class'].")";
  137. // $sql3 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "'and e.exam_status not in (".$dclass['doctor_class'].")";
  138. // $sql = '('.$sql1.') union ('.$sql2.') union ('.$sql3.')'.$limit; //ra.report_status,6,7,8,4,9,5,12
  139. // }else{*/
  140. // $sql = "SELECT e.id,e.severe,e.exam_status,e.exam_class,e.exam_sub_class,e.body_part,e.device,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.id as ra_id,ra.*,r.id as report_id,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where (ra.remote_doctor_id='".$doctor['id']."' or ra.remote_doctor_id=''".$dwhere.") and ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and r.remote_application_id=ra.id and ra.report_status !='' and ra.remote_institution_id='" . $doctor['institution_id']."'".$where." order by req_date_time desc,ra.is_urgent desc,ra.req_date_time desc".$limit;
  141. // // }
  142. // log::record($sql);
  143. // $list = DB::query($sql);
  144. // $csql = "SELECT count(1) from exams as e,remote_application as ra,patient_infos as p,report as r where (ra.remote_doctor_id='".$doctor['id']."' or ra.remote_doctor_id=''".$dwhere.") and r.remote_application_id=ra.id and ra.exam_id=e.id and ra.report_status !='' and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id']."'".$where;
  145. // $count = DB::query($csql);
  146. // foreach ($list as $k => $v) {
  147. // $cache_key = $doctor['id'].'_'.$v['id'];
  148. // if(Cache::get($cache_key)){
  149. // $list[$k]['status'] = 1;
  150. // }else{
  151. // $list[$k]['status'] = 0;
  152. // }
  153. // //申请医院
  154. // $local_institution = DB::table('institution')->where('id',$v['local_institution_id'])->cache(300)->field('name')->find();
  155. // $list[$k]['local_institution_name'] = $local_institution['name'];
  156. // //检查类型
  157. // $check_class = DB::table('constant')->where('id',$v['exam_class'])->cache(300)->field('constant_value as name')->find();
  158. // $list[$k]['class_name'] = $check_class['name'];
  159. // //检查子类
  160. // $subclass_name = DB::table('exam_subclass')->where('id',$v['exam_sub_class'])->cache(300)->field('name')->find();
  161. // $list[$k]['subclass_name'] = $subclass_name['name'];
  162. // //检查部位
  163. // $body_part = DB::table('bodypart')->where('id',$v['body_part'])->cache(300)->field('name')->find();
  164. // $list[$k]['body_name'] = $body_part['name'];
  165. // //检查设备
  166. // $device = DB::table('device')->where('id',$v['device'])->cache(300)->field('name')->find();
  167. // $list[$k]['device_name'] = $device['name'];
  168. // //报告医生
  169. // $report_doctor = DB::table('doctors')->where('id',$v['report_doctor_id'])->field('realname')->find();
  170. // $list[$k]['report_doctor_id'] = $report_doctor['realname'];
  171. // $list[$k]['datetime'] = $v['req_date_time'];
  172. // $list[$k]['rdatetime'] = $v['report_datetime'];
  173. // }
  174. // return json_encode(['status'=>'ok','code'=>'0000','count'=>$count[0]['count(1)'],'info'=>$list,'sessionid'=>$sessionid]);
  175. // }catch(\Exception $e){
  176. // return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
  177. // }
  178. // $remote_institution_id = '09b4765b26ba8b7c';
  179. // $remote_doctor_id = 'b5bed8f973852c22';
  180. // $filed = 'ra.id as ra_id, ra.anamnesis, ra.application_desc, ra.attachment, ra.clin_diag, ra.clin_symp, ra.createdAt, ra.exam_id, ra.family_ill, ra.illness_desc, ra.is_urgent, ra.local_institution_id, ra.marrital, ra.phys_sign, ra.remark, ra.remote_doctor_id, ra.remote_institution_id, ra.report_status, ra.req_date_time, ra.req_doctor_id, ra.status, e.body_part, e.exam_class, e.device, e.exam_datetime, e.id as exam_id, e.exam_status, e.exam_sub_class, e.id, e.severe, e.patient_id, r.report_datetime as rdatetime, r.report_datetime, r.report_doctor_id, r.id as report_id, r.report_result, pi.age, pi.name, pi.sex, i.name as local_institution_name';
  181. // $table = 'remote_application ra left join remote_order ro on ro.id = (select id from remote_order rot where rot.application_id = ra.id order by timestamp desc limit 1) left join exams e on ra.exam_id = e.id left join report r on ra.id = r.remote_application_id left join patient_infos pi on e.patient_id = pi.id left join institution i on ra.local_institution_id = i.id';
  182. // $where1 = "ra.remote_institution_id=:remote_institution_id";
  183. // $where2 = "(ra.report_status = '4' or report_status = '6' or report_status = '7' or report_status = '8' or report_status = '9')";
  184. // $where3 = "(ra.remote_doctor_id= :remote_doctor_id or ra.remote_doctor_id = '')";
  185. // $where4 = "(ro.status is null or ro.status = 2 or ro.status = 3)";
  186. // $order = "(ra.is_urgent = '1' and ra.report_status = '4') desc, (ra.is_urgent = '1' and ra.report_status = '6') desc, (ra.is_urgent = '1' and ra.report_status = '7'), ra.req_date_time desc";
  187. // $limit = ":start :number";
  188. // $where = $where1.$where2.$where3.$where4;
  189. // $sql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
  190. // $options = [
  191. // "remote_institution_id" => $remote_institution_id,
  192. // "remote_doctor_id" => $remote_doctor_id,
  193. // "start" => 0,
  194. // "number" => 20
  195. // ];
  196. // DB::execute($sql, $options);
  197. // // $db->execute(SQLServerHelp::SET_LIS_DEPARTEMT_SQL,$departemt);
  198. // }
  199. // }
  200. public function index()
  201. {
  202. try{
  203. log::record('---------工作列表--------');
  204. log::record($_REQUEST);
  205. $sessionid = $_REQUEST['sessionid'];
  206. $doctor = Cache::get($sessionid);
  207. log::record($doctor);
  208. $remote_institution_id = $doctor['institution_id'];
  209. $remote_doctor_id = $doctor['id'];
  210. $page = $_REQUEST['page'];
  211. $num = $_REQUEST['num'];
  212. $doc_class = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->value('doctor_class');
  213. if(strpos('8', $doc_class) !== false){
  214. $where2 = "((`ra`.`report_status` = '7' or `ra`.`report_status` = '8' or `ra`.`report_status` = '9') or ((`ra`.`report_status` = '4' or `ra`.`report_status` = '6') and (`ra`.`remote_doctor_id`= ? or `ra`.`remote_doctor_id` = '')))";
  215. } else {
  216. $where2 = "(`ra`.`report_status` = '4' or `ra`.`report_status` = '6' or `ra`.`report_status` = '7' or `ra`.`report_status` = '8' or `ra`.`report_status` = '9') and (`ra`.`remote_doctor_id`= ? or `ra`.`remote_doctor_id` = '')";
  217. }
  218. $filed = "`d`.`realname` as `report_doctor_id`, `ra`.`id` as `ra_id`, `ra`.`anamnesis`, `ra`.`application_desc`, `ra`.`attachment`, `ra`.`clin_diag`, `ra`.`clin_symp`, `ra`.`createdAt`, `ra`.`exam_id`, `ra`.`family_ill`, `ra`.`illness_desc`, `ra`.`is_urgent`, `ra`.`local_institution_id`, `ra`.`marrital`, `ra`.`phys_sign`, `ra`.`remark`, `ra`.`remote_doctor_id`, `ra`.`remote_institution_id`, `ra`.`report_status`, `ra`.`req_date_time`, `ra`.`req_doctor_id`, `ra`.`status`, `e`.`body_part`, `e`.`exam_class`, `e`.`exam_class` as `class_name`, `e`.`device`, `e`.`exam_datetime`, `e`.`id` as `exam_id`, `e`.`exam_status`, `e`.`exam_sub_class`, `e`.`id`, `e`.`severe`, `e`.`patient_id`, `r`.`report_datetime` as `rdatetime`, `r`.`report_datetime`, `r`.`report_doctor_id` as `r_report_doctor_id`, `r`.`id` as `report_id`, `r`.`report_result`, `pi`.`age`, `pi`.`name`, `pi`.`sex`, `pi`.`temp_patient_id`, `i`.`name` as `local_institution_name`";
  219. $table = "`remote_application` `ra` left join `remote_order` `ro` on `ro`.`id` = (select `id` from `remote_order` `rot` where `rot`.`application_id` = `ra`.`id` order by `timestamp` desc limit 1) left join `exams` `e` on `ra`.`exam_id` = `e`.`id` left join `report` `r` on `ra`.`id` = `r`.`remote_application_id` left join `patient_infos` `pi` on `e`.`patient_id` = `pi`.`id` left join `institution` `i` on `ra`.`local_institution_id` = `i`.`id` left join `doctors` `d` on `r`.`report_doctor_id` = `d`.`id`";
  220. $where1 = "`ra`.`remote_institution_id` = ?";
  221. $where3 = "(`ro`.`status` is null or `ro`.`status` = 2 or `ro`.`status` = 3)";
  222. $order = "(`ra`.`is_urgent` = '1' and `ra`.`report_status` = '4') desc, (`ra`.`is_urgent` = '1' and `ra`.`report_status` = '6') desc, (`ra`.`is_urgent` = '1' and `ra`.`report_status` = '7'), `ra`.`req_date_time` desc";
  223. $limit = "?, ?";
  224. $options = [
  225. $remote_institution_id,$remote_doctor_id
  226. ];
  227. $queryWhere = "";
  228. if(isset($_REQUEST['param'])){
  229. $param = $_REQUEST['param'];
  230. foreach ($param as $k => $v) {
  231. switch ($k) {
  232. case 'patient_num':
  233. $queryWhere.= " and `e`.`patient_num` like ?";
  234. $options[] = '%'.$v.'%';
  235. break;
  236. case 'exam_class' :
  237. if(empty($v)){
  238. break;
  239. }
  240. $length = sizeof($v);
  241. if($length === 1) {
  242. $queryWhere.= " and `e`.`exam_class` = ?";
  243. $options[] = $v[0];
  244. break;
  245. }
  246. $index = 1;
  247. $queryWhere.= " and (`e`.`exam_class` = ?";
  248. $options[] = $v[0];
  249. while($index < $length) {
  250. $queryWhere.= " or `e`.`exam_class` = ?";
  251. $options[] = $v[$index];
  252. $index++;
  253. }
  254. $queryWhere.= ')';
  255. // $queryWhere.= " and `e`.`exam_class` in ?";
  256. // $ex = implode("or `e`.`exam_class` = ", $v);
  257. // $val = "('".$ex."')";
  258. // // $where .= " and e.exam_class in ('".$ex."')";
  259. // $options[] = $val;
  260. // var_dump($val);
  261. break;
  262. case 'name':
  263. $queryWhere.= " and `pi`.`name` like ?";
  264. $options[] = '%'.$v.'%';
  265. break;
  266. case 'applicationtime':
  267. if(empty($v)){
  268. break;
  269. }
  270. $queryWhere.= " and `ra`.`req_date_time` between ? and ?";
  271. $options[] = $v[0];
  272. $options[] = $v[1];
  273. break;
  274. case 'is_urgent':
  275. if($v == 0){
  276. break;
  277. }
  278. $queryWhere.= " and `ra`.`is_urgent` = ?";
  279. $options[] = $v[0];
  280. break;
  281. case 'report_result':
  282. if($v == 1 || $v == 2) {
  283. $queryWhere.= " and `r`.`report_result` = ?";
  284. $options[] = $v[0];
  285. }
  286. break;
  287. case 'exam_status':
  288. if($v != 10){
  289. $queryWhere.= " and `ra`.`report_status` = ?";
  290. $options[] = $v[0];
  291. }
  292. break;
  293. }
  294. }
  295. }
  296. $where = $where1." and ".$where2." and ".$where3.$queryWhere;
  297. $listSql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
  298. $countSql = "select count(*) as count from ".$table." where ".$where;
  299. log::record("----countSql----");
  300. log::record($countSql);
  301. log::record("----countSql----");
  302. log::record("---countSql-options----");
  303. log::record($options);
  304. log::record("---countSql-options----");
  305. $count = DB::query($countSql, $options);
  306. // var_dump($count);
  307. $options[] = ($page - 1) * $num;
  308. $options[] = $num;
  309. log::record("----sql----");
  310. log::record($listSql);
  311. log::record("----sql----");
  312. log::record("----options----");
  313. log::record($options);
  314. log::record("----options----");
  315. $list = DB::query($listSql, $options);
  316. foreach($list as $v) {
  317. if(empty($v['report_id'])) {
  318. $data = array();
  319. $data['id'] = UUIDs::uuid16();
  320. $data['exam_id'] = $v['exam_id'];
  321. $data['remote_application_id'] = $v['ra_id'];
  322. $data['type'] = 2;
  323. $data['createdAt'] = date('Y-m-d H:i:s',time());
  324. DB::table('report')->insert($data);
  325. $v['report_id'] = $data['id'];
  326. }
  327. }
  328. // var_dump($res);
  329. return json_encode(['status'=>'ok','code'=>'0000','count'=>$count[0]['count'],'info'=>$list,'sessionid'=>$sessionid]);
  330. } catch(\Exception $e) {
  331. return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
  332. }
  333. }
  334. // select
  335. // ra.id as ra_id, ra.anamnesis, ra.application_desc, ra.attachment, ra.clin_diag, ra.clin_symp, ra.createdAt, ra.exam_id, ra.family_ill, ra.illness_desc, ra.is_urgent, ra.local_institution_id, ra.marrital, ra.phys_sign, ra.remark, ra.remote_doctor_id, ra.remote_institution_id, ra.report_status, ra.req_date_time, ra.req_doctor_id, ra.status,
  336. // e.body_part, e.exam_class, e.device, e.exam_datetime, e.id as exam_id, e.exam_status, e.exam_sub_class, e.id, e.severe, e.patient_id,
  337. // r.report_datetime as rdatetime, r.report_datetime, r.report_doctor_id, r.id as report_id, r.report_result,
  338. // pi.age, pi.name, pi.sex,
  339. // i.name as local_institution_name
  340. // from
  341. // remote_application ra
  342. // left join
  343. // remote_order ro
  344. // on
  345. // ro.id = (
  346. // select
  347. // id
  348. // from
  349. // remote_order rot
  350. // where
  351. // rot.application_id = ra.id
  352. // order by timestamp desc limit 1
  353. // )
  354. // left join
  355. // exams e
  356. // on
  357. // ra.exam_id = e.id
  358. // left join
  359. // report r
  360. // on
  361. // ra.id = r.remote_application_id
  362. // left join
  363. // patient_infos pi
  364. // on
  365. // e.patient_id = pi.id
  366. // left join
  367. // institution i
  368. // on
  369. // ra.local_institution_id = i.id
  370. // where
  371. // ra.remote_institution_id='09b4765b26ba8b7c'
  372. // and
  373. // (report_status = '4' or report_status = '6' or report_status = '7' or report_status = '8' or report_status = '9')
  374. // and
  375. // (ra.remote_doctor_id='b5bed8f973852c22' or ra.remote_doctor_id = '')
  376. // and
  377. // (ro.status is null or ro.status = 2 or ro.status = 3)
  378. // order by
  379. // (ra.is_urgent = '1' and ra.report_status = '4') desc,
  380. // (ra.is_urgent = '1' and ra.report_status = '6') desc,
  381. // (ra.is_urgent = '1' and ra.report_status = '7'),
  382. // ra.req_date_time desc
  383. // -- 4、申请 5、驳回 6、接收、7、初步报告 8、审核报告 9、确认、
  384. //接受 3
  385. /*public function accept(){
  386. $sessionid = $_REQUEST['sessionid'];
  387. $doctor = Cache::get($sessionid);
  388. $id = $_REQUEST['id'];
  389. DB::table('exams')->where('id',$id)->update(['exam_status'=>6]);
  390. DB::table('report')->where('exam_id',$id)->update(['report_doctor_id',$doctor['id']]);
  391. return json_encode(['status'=>'ok','code'=>'0000','msg'=>'已接受']);
  392. }
  393. //驳回 7
  394. public function reject(){
  395. // $sessionid = $_REQUEST['sessionid'];
  396. // $doctor = Cache::get($sessionid);
  397. $id = $_REQUEST['id'];
  398. DB::table('exams')->where('id',$id)->update(['exam_status'=>5]);
  399. return json_encode(['status'=>'ok','code'=>'0000','msg'=>'已驳回']);
  400. }
  401. //确认 5
  402. public function confirm(){
  403. $sessionid = $_REQUEST['sessionid'];
  404. $doctor = Cache::get($sessionid);
  405. $id = $_REQUEST['id'];
  406. DB::table('exams')->where('id',$id)->update(['exam_status'=>9]);
  407. DB::table('report')->where('exam_id',$id)->update(['confirm_doctor_id'=>$doctor['id'],'confirm_datetime'=>date('Y-m-d H:i:s')]);
  408. return json_encode(['status'=>'ok','code'=>'0000','msg'=>'已确认']);
  409. }
  410. // 审核
  411. public function examine(){
  412. $id = $_REQUEST['id'];
  413. DB::table('exams')->where('id',$id)->update(['exam_status'=>8]);
  414. return json_encode(['status'=>'ok','code'=>'0000','msg'=>'已审核']);
  415. }*/
  416. }