123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <?php
- namespace app\api\servies\dict;
- use app\api\response\ZskkErrorResponse;
- use app\api\servies\ZskkDefaultService;
- use app\api\dao\dict\DictDao;
- use app\api\servies\common\CommonService;
- use app\api\utils\UUIDUtils;
- use think\Db;
- use think\facade\Log;
- use think\Exception;
- /**
- * 后台控制器基类
- * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
- */
- class DictService extends ZskkDefaultService {
- protected $logName = "DictService";
- private $dict = null;
- // protected function zskkInit(TestDao $testDao) {
- // $this->testDao;
- // }
- public function __construct(DictDao $dictDao) {
- parent::__construct();
- $this->dict = $dictDao;
- }
- public function getDevice($token)
- {
- try{
- $user = $this->dict->getUser($token);
- $device_ids = $user['device_ids'] ?? [];
- if(!empty($device_ids)){
- $device_ids = explode(',', $device_ids);
- }else{
- // return '';
- }
- // 获取设备名称
- $devices = $this->dict->getDevice($device_ids);
- if(empty($devices)){
- $devices = $this->dict->getDevice(0);
- }
- $data = [];
- foreach ($devices as $k=>$v){
- $subClass = $this->dict->getClass($v['exam_class_id']);
- $data[$k]['device'] = $v;
- $data[$k]['class'] = $subClass;
- }
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function getDepartment($token)
- {
- $user = $this->dict->getUser($token);
- $data = $this->dict->getDepartment($user['institution_id']);
- return $data;
- }
- public function getDoctors($token)
- {
- $user = $this->dict->getUser($token);
- $data = $this->dict->getDoctors($user['institution_id']);
- return $data;
- }
- public function getExamSubclass()
- {
- try{
- $data = $this->dict->getExamSub();
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function getExamProject()
- {
- try{
- $data = $this->dict->getProject();
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function getExamClass()
- {
- try{
- $data = $this->dict->getExamClass();
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function getIllness()
- {
- try{
- $data = $this->dict->getIllness();
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function getFamilyIll()
- {
- try{
- $data = $this->dict->getFamilyIll();
- // 返回
- return $data;
- } catch (Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function icdClass()
- {
- try {
- $data = $this->dict->getIcd();
- foreach ($data as &$v){
- $v['children'] = $this->dict->getDictChild($v['id']);
- }
- return $data;
- }catch ( Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function icdList($params)
- {
- try {
- // 1. 拼装搜索条件
- $class_id = $params['class_id'] ?? false;
- $class_where = false;
- if($class_id){
- $class_where = ['pid' => $class_id];
- }
- $name_where = false;
- $name = $params['name'] ?? false;
- if($name){
- $name_where = "`name` LIKE '%$name%' OR `pinyin` LIKE '%$name%' OR `initial` LIKE '%$name%'";
- }
- $last_id = $params['last_id'] ?? false;
- // 2. 查询
- return $this->dict->getIcdList($class_where, $name_where, $last_id);
- }catch ( Exception $exception){
- $this->throwError($exception->getMessage(),0001);
- }
- }
- public function saveQuality($params,$token)
- {
- $user = $this->dict->getUser($token);
- $id = $params['id'] ?? '';
- $qcinfo = $this->dict->getQualityById($id);
- $report_doctor = $this->dict->getReportDoctor($params['report_id']);
- $data = [
- 'institution_id'=>$user['institution_id'],
- 'report_id'=>$params['report_id'],
- 'pic_quality'=>$params['pic_quality'] ?? '',
- 'report_quality'=>$params['report_quality'] ?? '',
- 'comment_user_id'=>$user['id'],
- 'comment_user_name'=>$user['realname'],
- 'report_doctor'=>$report_doctor,
- ];
- $p = implode(',',$params['pic_evaluate'] ?? []);
- // if(isset($params['pic_evaluate']) && !empty($params['pic_evaluate'])){
- // $p = implode(',',$params['pic_evaluate']);
- // }
- $r = implode(',',$params['report_evaluate'] ?? []);
- // if(isset($params['report_evaluate']) && !empty($params['report_evaluate'])){
- // $r = implode(',',$params['report_evaluate']);
- // }
- $data['pic_evaluate'] = $p;
- $data['report_evaluate'] = $r;
- if($id){
- $qc = $this->dict->updateQuality($id,$data);
- if($qcinfo['pic_evaluate']!=$p){
- //删除影像评价因子
- $this->dict->delPic($id,1);
- $this->savePic($params['pic_evaluate'],$id,1);
- }
- if($qcinfo['report_evaluate']!=$r){
- //删除报告评价因子
- $this->dict->delPic($id,2);
- $this->savePic($params['report_evaluate'],$id,2);
- }
- }else{
- $data['id'] = UUIDUtils::uuid();
- $qc = $this->dict->saveQuality($data);
- $this->savePic($params['pic_evaluate'],$data['id'],1);
- $this->savePic($params['report_evaluate'],$data['id'],2);
- }
- return $qc;
- }
- public function savePic($evaluate,$id,$type)
- {
- foreach ($evaluate as $v){
- $report_evaluate = [
- 'control_id'=>$id,
- 'factor_id'=>$v,
- 'type'=>$type,
- ];
- $this->dict->savePic($report_evaluate);
- }
- }
- public function getQuality($id,$token)
- {
- $user = $this->dict->getUser($token);
- $info = $this->dict->getQuality($id,$user);
- $info = json_decode(json_encode($info,true),true);
- if(empty($info)){
- $info = ['report_id'=>$id];
- return $info;
- }
- foreach ($info as $k=>$v){
- if($k == 'pic_evaluate'){
- if(empty($v)){
- $info[$k] = [];
- }else{
- $p = explode(',',$v);
- $pe = [];
- foreach ($p as $value){
- $pe[] = (int)$value;
- }
- $info[$k] = $pe;
- }
- }
- if($k == 'report_evaluate'){
- if(empty($v)){
- $info[$k] = [];
- }else{
- $r = explode(',',$v);
- $re = [];
- foreach ($r as $value){
- $re[] = (int)$value;
- }
- $info[$k] = $re;
- }
- }
- }
- return $info;
- }
- public function qualityFactorPic()
- {
- $info = $this->dict->getqualityFactorPic();
- return $info;
- }
- public function qualityFactorReport()
- {
- $info = $this->dict->getqualityFactorReport();
- return $info;
- }
- public function getApplicationDepartment($token)
- {
- $doctor = $this->getCache($token);
- $institution = $doctor['institution_id'];
- $info = $this->dict->getApplicationDepartment($institution);
- $data = [];
- if($institution == '73000003')
- {
- $data[] = ['application_department'=>'AI-胸片'];
- foreach ($info as $k=>$v)
- {
- $data[] = $v;
- }
- return $data;
- }else{
- return $info;
- }
- }
- public function getNewPart($token)
- {
- // $doctor = $this->getCache($token);
- // $institution = $doctor['institution_id'];
- $info = $this->dict->getNewPart();
- return $info;
- }
- }
|