DictModel.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. namespace app\api\model\dict;
  3. use app\api\model\constant\ConstantModel;
  4. use app\api\model\department\DepartmentModel;
  5. use app\api\model\device\DeviceModel;
  6. use app\api\model\dicticd\DicticdModel;
  7. use app\api\model\doctor\DoctorModel;
  8. use app\api\model\exam\ExamModel;
  9. use app\api\model\newpart\NewpartModel;
  10. use app\api\model\project\ProjectModel;
  11. use app\api\model\qc\QcModel;
  12. use app\api\model\qcause\QcauseModel;
  13. use app\api\model\qf\QfModel;
  14. use app\api\model\report\ReportModel;
  15. use app\api\model\subclass\SubclassModel;
  16. use app\api\model\ZskkDefaultModel;
  17. use think\facade\Log;
  18. class DictModel extends ZskkDefaultModel {
  19. protected $table= 'dict';
  20. protected $logName = "DictModel";
  21. public function getDevice($id)
  22. {
  23. // $device = DeviceModel::where('id','in',$id)->field('id, name, exam_class_id')->select();
  24. $device = DeviceModel::field('id, name, exam_class_id')->select();
  25. return $device;
  26. }
  27. public function getSubclass()
  28. {
  29. $info = SubclassModel::select();
  30. return $info;
  31. }
  32. public function getClass($id)
  33. {
  34. $info = SubclassModel::where('exam_class_id',$id)->select();
  35. return $info;
  36. }
  37. public function Project($id)
  38. {
  39. $info = ProjectModel::where('exam_class_id',$id)->select();
  40. return $info;
  41. }
  42. public function getProject()
  43. {
  44. $info = ProjectModel::field('status',true)
  45. ->select();
  46. return $info;
  47. }
  48. public function getIllness()
  49. {
  50. $data = ConstantModel::where('parent_id','illness')
  51. ->cache('illness',43200)
  52. ->field('constant_value AS name')
  53. ->select();
  54. return $data;
  55. }
  56. public function getFamilyIll()
  57. {
  58. $data = ConstantModel::where('parent_id','family_ill')
  59. ->cache('family_ill',43200)
  60. ->field('constant_value AS name')
  61. ->select();
  62. return $data;
  63. }
  64. public function getIcd()
  65. {
  66. $data = DicticdModel::where('pid',0)
  67. ->cache(true)
  68. ->select();
  69. return $data;
  70. }
  71. public function getIcdList($class_where, $name_where, $last_id)
  72. {
  73. $id_where = $last_id ? [
  74. ['id','>', $last_id]
  75. ] : false;
  76. $data = DicticdModel::whereOr($name_where)
  77. ->where($class_where)
  78. ->where($id_where)
  79. ->where('valid',1)
  80. ->field('id,code,name,pname')
  81. ->limit(1,50)
  82. ->select();
  83. return $data ? $data->toArray() : $data;
  84. }
  85. public function getDictChild($id)
  86. {
  87. $data = DicticdModel::whereIn('pid', $id)
  88. ->cache(true)
  89. ->select();
  90. return $data;
  91. }
  92. public function getExamClass()
  93. {
  94. $data = ConstantModel::where('parent_id','exam_class')
  95. ->cache('exam_class',43200)
  96. ->field('constant_value AS name')
  97. ->select();
  98. return $data;
  99. }
  100. public function getDepartment($institution)
  101. {
  102. $data = DepartmentModel::where('institution_id',$institution)->field('department_name')->select();
  103. return $data;
  104. }
  105. public function getDoctors($institution)
  106. {
  107. $data = DoctorModel::where('institution_id',$institution)->field('id,realname')->select();
  108. return $data;
  109. }
  110. public function saveQuality($data)
  111. {
  112. $info = QcModel::insert($data);
  113. return $info;
  114. }
  115. public function delpic($id,$type)
  116. {
  117. $data = QcauseModel::where('control_id',$id)->where('type',$type)->delete();
  118. return $data;
  119. }
  120. public function updateQuality($id,$data)
  121. {
  122. $info = QcModel::where('id',$id)->update($data);
  123. return $info;
  124. }
  125. public function savePic($data)
  126. {
  127. $info = QcauseModel::insert($data);
  128. return $info;
  129. }
  130. public function getQuality($id,$user)
  131. {
  132. $info = QcModel::where('report_id',$id)->where('comment_user_id',$user['id'])->field('id,report_id,pic_quality,pic_evaluate,report_quality,report_evaluate')->find();
  133. return $info;
  134. }
  135. public function getQualityById($id)
  136. {
  137. $info = QcModel::where('id',$id)->find();
  138. return $info;
  139. }
  140. public function getReportDoctor($id)
  141. {
  142. $doctor = ReportModel::where('id',$id)->value('report_doctor_id');
  143. return $doctor;
  144. }
  145. public function getqualityFactorPic()
  146. {
  147. $info = QfModel::where('type','1')->field('id,description')->select();
  148. return $info;
  149. }
  150. public function getqualityFactorReport()
  151. {
  152. $info = QfModel::where('type','2')->field('id,description')->select();
  153. return $info;
  154. }
  155. public function getApplicationDepartment($id)
  156. {
  157. $data = ExamModel::where('institution_id',$id)
  158. ->where("application_department is not null and application_department != ''")
  159. ->field("count(*) AS c,application_department")
  160. ->cache($id.'_depart',43200)
  161. ->group('application_department')
  162. ->having('count(*)>1')
  163. ->order('count(*) desc')
  164. ->select();
  165. return $data;
  166. }
  167. public function getNewPart()
  168. {
  169. $data = NewpartModel::select();
  170. return $data;
  171. }
  172. }