ReportDao.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <?php
  2. namespace app\api\dao\report;
  3. use app\api\actions\ZskkCache;
  4. use app\api\dao\ZskkDefaultDao;
  5. use app\api\model\analysis\AnalysisModel;
  6. use app\api\model\exam\ExamModel;
  7. use app\api\model\institution\InstitutionModel;
  8. use app\api\model\keyword\KeywordreportModel;
  9. use app\api\model\keyword\KeywordvisitModel;
  10. use app\api\model\report\ReportModel;
  11. use app\api\model\smslog\SmslogModel;
  12. use app\api\model\visit\VisitModel;
  13. use think\facade\Log;
  14. use think\facade\Cache;
  15. /**
  16. * 后台控制器基类
  17. * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
  18. */
  19. class ReportDao extends ZskkDefaultDao {
  20. protected $flag = true;
  21. protected $logName = "ExamDao";
  22. protected $report = null;
  23. protected $institution = null;
  24. protected $exam = null;
  25. protected $reportKeyword = null;
  26. protected $visitKeyword = null;
  27. protected $visitModel = null;
  28. protected $smsLogModel = null;
  29. protected $analysisModel = null;
  30. public function __construct(ReportModel $reportModel,InstitutionModel $institutionModel,ExamModel $examModel,KeywordreportModel $keywordreportModel,KeywordvisitModel $keywordvisitModel,VisitModel $visitModel,SmslogModel $smsLogModel,AnalysisModel $analysisModel)
  31. {
  32. parent::__construct();
  33. $this->report = $reportModel;
  34. $this->institution = $institutionModel;
  35. $this->exam = $examModel;
  36. $this->reportKeyword = $keywordreportModel;
  37. $this->visitKeyword = $keywordvisitModel;
  38. $this->visitModel = $visitModel;
  39. $this->smsLogModel = $smsLogModel;
  40. $this->analysisModel = $analysisModel;
  41. }
  42. public function getAllExamCount($where, $whereTime)
  43. {
  44. $all = $this->exam->where($where)->where($whereTime)->count();
  45. return $all;
  46. }
  47. public function getAllNum($dateWhere,$where,$anotherWhere=[])
  48. {
  49. return $this->exam->where($dateWhere)->where($where)->where($anotherWhere)->count();
  50. }
  51. public function getExamGroupByIns($dateWhere,$where = [],$anotherWhere=[])
  52. {
  53. return $this->exam->where($dateWhere)->where($where)->where($anotherWhere)->field('institution_id, count(*) as num')->group('institution_id')->select();
  54. }
  55. public function getSmsNum($dateWhere,$where)
  56. {
  57. return $this->smsLogModel->where($dateWhere)->where($where)->count();
  58. }
  59. public function getSmsNumGroupByIns($dateWhere,$where = [],$anotherWhere=[])
  60. {
  61. return $this->smsLogModel->where($dateWhere)->where($where)->where($anotherWhere)->field('institution_id, count(*) as num')->group('institution_id')->select();
  62. }
  63. public function saveAnalysis($arr)
  64. {
  65. $this->analysisModel->saveAll($arr);
  66. }
  67. public function getPvWechatVisit($where, $whereTime)
  68. {
  69. $all = $this->visitModel->where($where)->where($whereTime)->count();
  70. return $all;
  71. }
  72. public function getUvWechatVisit($where, $whereTime)
  73. {
  74. $all = $this->visitModel
  75. ->where($where)
  76. ->where($whereTime)
  77. ->count('DISTINCT exam_id');
  78. return $all;
  79. }
  80. function getPvUvWechatVisitGroupByIns($dateWhere, $where = [],$anotherWhere=[])
  81. {
  82. $all = $this->visitModel
  83. ->where($dateWhere)
  84. ->where($where)
  85. ->where($anotherWhere)
  86. ->field('institution_id, count(*) as pv, count(DISTINCT exam_id) as uv')
  87. ->group('institution_id')
  88. ->select();
  89. return $all;
  90. }
  91. public function getReportInfo($examId)
  92. {
  93. $info = $this->report->getReportInfo($examId);
  94. return $info;
  95. }
  96. public function getRemoteReportInfo($ra_id)
  97. {
  98. $info = $this->report->getRemoteReportInfo($ra_id);
  99. return $info;
  100. }
  101. public function getInstitutionData($where, $field)
  102. {
  103. $info = $this->report->getInstitutionData($where, $field);
  104. return $info;
  105. }
  106. public function getReportStatus($id)
  107. {
  108. $status = $this->report->getStatus($id);
  109. return $status;
  110. }
  111. public function getDoctorsName($id)
  112. {
  113. $doctorNames = $this->report->getDoctorName($id);
  114. if(empty($doctorNames)){
  115. return null;
  116. }
  117. return $doctorNames;
  118. }
  119. public function getInstitution($dcotorId)
  120. {
  121. $info = $this->report->getInstitutionInfo($dcotorId);
  122. return $info;
  123. }
  124. public function getUser($token)
  125. {
  126. $user = $this->getCache($token);
  127. if(!$user){
  128. $this->throwError('登陆信息失效,请重新进行登陆','0099');
  129. }
  130. return $user;
  131. }
  132. public function saveBbs($info)
  133. {
  134. $info = $this->report->saveBbs($info);
  135. return $info;
  136. }
  137. public function getUserId($token)
  138. {
  139. $user = $this->getCache($token);
  140. if(!$user){
  141. $this->throwError('登陆信息失效,请重新进行登陆','0099');
  142. }
  143. return $user['id'];
  144. }
  145. public function getTrace($reportId)
  146. {
  147. $trace = $this->report->getTrace($reportId);
  148. return $trace;
  149. }
  150. public function remoteStage($token)
  151. {
  152. $trace = $this->getCache($token);
  153. if($trace){
  154. Cache::rm($token);
  155. }
  156. }
  157. public function getOrderMoney($id)
  158. {
  159. $money = $this->report->getOrderMoney($id);
  160. return $money;
  161. }
  162. public function getStage($cacheToken)
  163. {
  164. $trace = $this->getCache($cacheToken);
  165. return $trace;
  166. }
  167. public function updateInstititonMoney($id,$money)
  168. {
  169. $info = $this->report->updateInstititonMoney($id,$money);
  170. return $info;
  171. }
  172. public function getCurrentMoney($id)
  173. {
  174. $money = $this->report->getCurrentMoney($id);
  175. return $money;
  176. }
  177. public function updateOrder($id,$status)
  178. {
  179. $info = $this->report->updateOrder($id,$status);
  180. return $info;
  181. }
  182. public function getExam($id)
  183. {
  184. $info = $this->report->getExam($id);
  185. return $info;
  186. }
  187. public function getOrderId($id)
  188. {
  189. $info = $this->report->getOrderId($id);
  190. return $info;
  191. }
  192. public function insertReport($data)
  193. {
  194. $info = $this->report->insertReport($data);
  195. return $info;
  196. }
  197. public function getMiddle($where)
  198. {
  199. $info = $this->report->getMiddle($where);
  200. return $info;
  201. }
  202. public function saveRmiddle($middle,$middleWhere = [])
  203. {
  204. $info = $this->report->saveRmiddle($middle,$middleWhere);
  205. return $info;
  206. }
  207. public function delStage($key)
  208. {
  209. $info = $this->delCache($key);
  210. return $info;
  211. }
  212. public function insertShare($data)
  213. {
  214. $info = $this->report->insertShare($data);
  215. return $info;
  216. }
  217. public function insertSMSLog($data)
  218. {
  219. $info = $this->smsLogModel->insert($data);
  220. return $info;
  221. }
  222. public function updateExamMsg($examId, $patientId, $examUp)
  223. {
  224. $info = $this->report->updateExam($examId, $patientId, $examUp);
  225. return $info;
  226. }
  227. public function updateRemote($id,$update)
  228. {
  229. $info = $this->report->updateRemote($id,$update);
  230. return $info;
  231. }
  232. public function getReportId($examId,$reportType)
  233. {
  234. $id = $this->report->getReportId($examId,$reportType);
  235. return $id;
  236. }
  237. public function getRemoteReportId($id)
  238. {
  239. $id = $this->report-> getRemoteReportId($id);
  240. return $id;
  241. }
  242. public function getInstitutionSms($id)
  243. {
  244. $sms = $this->report->getInstitutionSms($id);
  245. return $sms;
  246. }
  247. public function getInstitutionName($id)
  248. {
  249. $name = $this->report->getInstitutionName($id);
  250. return $name;
  251. }
  252. public function getApplicationId($examId)
  253. {
  254. $id = $this->report->getApplicationId($examId);
  255. return $id;
  256. }
  257. public function saveCache($key,$value,$time)
  258. {
  259. $this->setCache($key,$value,$time);
  260. }
  261. public function getDoctorInfo($id,$field)
  262. {
  263. $info = $this->report->getDoctorInfo($id,$field);
  264. return $info;
  265. }
  266. public function getPrintInfo($reportId,$is_remote)
  267. {
  268. $info = $this->report->getPrintInfo($reportId,$is_remote);
  269. return $info;
  270. }
  271. public function updateReport($examId,$type,$update)
  272. {
  273. $info = $this->report->updateReport($examId,$type,$update);
  274. return $info;
  275. }
  276. public function readMessage($id)
  277. {
  278. $info = $this->report->readMessage($id);
  279. return $info;
  280. }
  281. public function updateRemoteReport($id,$update)
  282. {
  283. $info = $this->report->updateRemoteReport($id,$update);
  284. return $info;
  285. }
  286. public function updateExamStatus($examId,$status)
  287. {
  288. $info = $this->report->updateExamStauts($examId,$status);
  289. return $info;
  290. }
  291. public function updateExamInfo($id,$update)
  292. {
  293. $info = $this->report->updateExamInfo($update,$id);
  294. return $info;
  295. }
  296. public function insertMessage($data)
  297. {
  298. $info = $this->report->insertMessage($data);
  299. return $info;
  300. }
  301. public function updateRemoteStauts($examId,$status)
  302. {
  303. $info = $this->report->updateRemoteStauts($examId,$status);
  304. return $info;
  305. }
  306. public function updateremoteExamStatus($examId,$status)
  307. {
  308. $info = $this->report->updateremoteExamStatus($examId,$status);
  309. return $info;
  310. }
  311. public function insertReportRecord($info)
  312. {
  313. $info = $this->report->insertRecord($info);
  314. return $info;
  315. }
  316. public function getDoctorClass($userId)
  317. {
  318. $info = $this->report->getDoctorClass($userId);
  319. return $info;
  320. }
  321. public function getReportById($id,$field)
  322. {
  323. $info = $this->report->getReportById($id,$field);
  324. return $info;
  325. }
  326. public function getReport($examId,$type,$ra_id=null)
  327. {
  328. $info = $this->report->getReport($examId,$type,$ra_id);
  329. return $info;
  330. }
  331. public function deleteAiReport($examId,$type)
  332. {
  333. $info = $this->report->deleteAiReport($examId,$type);
  334. return $info;
  335. }
  336. public function getXzData($id)
  337. {
  338. $info = $this->report->getXzData($id);
  339. return $info;
  340. }
  341. public function getDoctorName($id)
  342. {
  343. $info = $this->report->getDoctorRealName($id);
  344. return $info;
  345. }
  346. public function getUid($id)
  347. {
  348. $uid = $this->report->getUid($id);
  349. return $uid;
  350. }
  351. public function getAccession($id)
  352. {
  353. $info = $this->report->getAccession($id);
  354. return $info;
  355. }
  356. public function savePregressLog($log)
  357. {
  358. $this->report->savePregressLog($log);
  359. }
  360. public function saveVideo($data,$where)
  361. {
  362. $info = $this->report->saveVideo($data,$where);
  363. return $info;
  364. }
  365. public function cancel_video($id)
  366. {
  367. $info = $this->report->cancel_video($id);
  368. return $info;
  369. }
  370. public function getVideo($id)
  371. {
  372. $info = $this->report->getVideo($id);
  373. return $info;
  374. }
  375. public function insertDcmPath($data)
  376. {
  377. $info = $this->report->insertDcmPath($data);
  378. return $info;
  379. }
  380. public function updateDcmPath($where,$update)
  381. {
  382. $info = $this->report->updateDcmPath($where,$update);
  383. return $info;
  384. }
  385. public function getDcmPath($where,$study)
  386. {
  387. $info = $this->report->getDcmPath($where,$study);
  388. return $info;
  389. }
  390. public function getDcmPathData($where,$study)
  391. {
  392. $info = $this->report->getDcmPathData($where,$study);
  393. return $info;
  394. }
  395. public function insertReject($data)
  396. {
  397. $info = $this->report->insertReject($data);
  398. return $info;
  399. }
  400. public function checkLock($id)
  401. {
  402. $info = $this->report->checkLock($id);
  403. return $info;
  404. }
  405. public function updateEmailStatus($study, $email)
  406. {
  407. $info = $this->report->updateEmailStatus($study, $email);
  408. return $info;
  409. }
  410. public function getPatientName($study)
  411. {
  412. $name = $this->report->getPatientName($study);
  413. return $name;
  414. }
  415. public function insertNote($data)
  416. {
  417. $id = $this->report->insertNote($data);
  418. return $id;
  419. }
  420. public function saveDcmReportData($data,$exam,$type,$tsTime)
  421. {
  422. $info = $this->report->saveDcmReportData($data,$exam,$type,$tsTime);
  423. return $info;
  424. }
  425. public function getExamByStudy($study)
  426. {
  427. $info = $this->report->getExamByStudy($study);
  428. return $info;
  429. }
  430. public function getDmReport($date1, $date2)
  431. {
  432. $info = $this->report->getDmReport($date1, $date2);
  433. return $info;
  434. }
  435. public function getInsReport($date1, $date2,$ins,$remote,$page,$num)
  436. {
  437. $info = $this->report->getInsReport($date1, $date2,$ins,$remote,$page,$num);
  438. return $info;
  439. }
  440. public function insertDcmCompress($data)
  441. {
  442. $info = $this->report->insertDcmCompress($data);
  443. return $info;
  444. }
  445. public function updateDcmCompress($where,$data)
  446. {
  447. $info = $this->report->updateDcmCompress($where,$data);
  448. return $info;
  449. }
  450. public function getWechatData($openid)
  451. {
  452. $info = $this->report->getWechatData($openid);
  453. return $info;
  454. }
  455. public function getInsKeywordIds()
  456. {
  457. return $this->institution->where('keyword_switch',1)->column('id');
  458. }
  459. public function getExamCount($where,$insWhere)
  460. {
  461. return $this->exam->where($where)->where($insWhere)->count();
  462. }
  463. public function getAllPush($where)
  464. {
  465. return $this->reportKeyword->where($where)->select();
  466. }
  467. public function getAllVisit($where,$where2 = [])
  468. {
  469. return $this->visitKeyword->where($where)->where($where2)->select();
  470. }
  471. public function getLwSyncExam($institution, $num,$field)
  472. {
  473. $data = $this->exam->where('institution_id', $institution)->field($field)->limit(0, $num)->select();
  474. return $data;
  475. }
  476. public function changeLwSyncStatus($id)
  477. {
  478. return $this->exam->where('id',$id)->update(['lw_sync_status'=>2]);
  479. }
  480. public function changeLwSyncReportStatus($id)
  481. {
  482. return $this->exam->where('id',$id)->update(['lw_report_sync_status'=>2]);
  483. }
  484. public function getAllIns()
  485. {
  486. return $this->institution->column('id,name');
  487. }
  488. public function getExamList($where)
  489. {
  490. $exam = $this->exam->where($where)->field('id,name,card_num,patient_num,accession_num,exam_class,exam_datetime,sex,age,birthday,body_part_text')->select();
  491. return $exam;
  492. }
  493. public function getExamReport($where)
  494. {
  495. $data = $this->exam->alias('e')
  496. ->join(['report'=>'r'],'r.exam_id = e.id and r.type=1','left')
  497. ->where($where)
  498. ->field('e.study_id,e.name,e.sex,e.age,e.exam_datetime,e.exam_class,e.body_part,e.body_part_text,r.impression,r.description,r.report_doctor_name,r.review_doctor_name,r.confirm_doctor_name,r.review_datetime,r.report_datetime,r.confirm_datetime,r.report_result')
  499. ->find();
  500. return $data;
  501. }
  502. }