ApiModel.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\api\model\api;
  3. use app\api\model\application\ApplicationModel;
  4. use app\api\model\doctor\DoctorModel;
  5. use app\api\model\message\MessageModel;
  6. use app\api\model\ZskkDefaultModel;
  7. use think\facade\Log;
  8. class ApiModel extends ZskkDefaultModel {
  9. protected $table= 'apis';
  10. protected $logName = "ApiModel";
  11. public function getRemoteExamList($institutionId, $fuzzyWhere, $moreWhere,$class_where, $params,$doctor_where)
  12. {
  13. try{
  14. $field = [
  15. 'a.name', 'a.sex', 'a.age',
  16. 'a.exam_id', 'a.patient_num', 'a.exam_class', 'a.exam_datetime', 'a.study_id', 'a.accession_num', 'a.exam_project','a.remote_institution_name',
  17. 'r.report_result', 'r.report_datetime','r.id AS rid',
  18. 'r.report_doctor_name',
  19. 'r.review_doctor_name',
  20. 'a.report_status',
  21. 'r.remote_application_id',
  22. 'a.id AS ra_id',
  23. 'ro.status','ro.id AS order_id'
  24. ];
  25. $list = ApplicationModel::alias('a')
  26. ->join(['remote_order'=>'ro'],'a.id=ro.application_id','left')
  27. ->join(['report'=>'r'],'r.remote_application_id=a.id','LEFT')
  28. ->where($fuzzyWhere)
  29. ->where($moreWhere)
  30. ->where($class_where)
  31. ->where($doctor_where)
  32. ->where('a.status',0)
  33. ->where('a.local_institution_id', $institutionId)
  34. ->field($field)
  35. ->page($params['page'],$params['num'])
  36. ->order('a.req_date_time desc')
  37. ->select();
  38. $total = ApplicationModel::alias('a')
  39. ->join(['report'=>'r'],'r.remote_application_id=a.id','LEFT')
  40. ->where($fuzzyWhere)
  41. ->where($moreWhere)
  42. ->where($class_where)
  43. ->where($doctor_where)
  44. ->where('a.status',0)
  45. ->where('a.local_institution_id', $institutionId)
  46. ->count();
  47. return ['total'=>$total, 'list'=>$list];
  48. } catch (Exception $exception){
  49. $this->throwError($exception->getMessage(),0001);
  50. }
  51. }
  52. public function updateAutograph($url,$id)
  53. {
  54. $info = DoctorModel::where('id',$id)->update(['autograph'=>$url,'autograph_type'=>2]);
  55. return $info;
  56. }
  57. public function autograph_switch($switch,$id)
  58. {
  59. $info = DoctorModel::where('id',$id)->update(['is_use_autograph'=>$switch]);
  60. return $info;
  61. }
  62. public function insertMessage($data)
  63. {
  64. $info = MessageModel::insert($data);
  65. return $info;
  66. }
  67. public function getAutograph($id)
  68. {
  69. $data = DoctorModel::where('id',$id)->field('is_use_autograph,autograph,autograph_type')->find();
  70. return $data;
  71. }
  72. }