123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <?php
- declare (strict_types=1);
- namespace app\zskk\servies;
- use app\admin\model\dict\Commondata;
- use app\admin\servies\bi\BaseQcBiServies;
- use app\zskk\model\BiInspectReport;
- use app\zskk\model\ExamReport;
- use app\zskk\model\HrRecord;
- use app\zskk\model\InspectReport;
- use app\zskk\model\MedicalInformation;
- use think\facade\Cache;
- class BiServies extends BaseQcBiServies
- {
- public $examModel = null;
- public $inspectModel = null;
- public $inspecItemtModel = null;
- public $hrrecordModel = null;
- public $medicalInformation = null;
- public function __construct(ExamReport $examModel,InspectReport $inspectModel,HrRecord $hrrecordModel,MedicalInformation $medicalInformation, BiInspectReport $biInspectReport)
- {
- // parent::__construct();
- $this->examModel = $examModel;
- $this->inspectModel = $inspectModel;
- $this->hrrecordModel = $hrrecordModel;
- $this->medicalInformation = $medicalInformation;
- $this->inspecItemtModel = $biInspectReport;
- }
- public function getMedicalData()
- {
- $data = $this->medicalInformation->field('DIAGNOSENAME,count(*) as c')->limit(50)->group('DIAGNOSENAME')->select()->toArray();
- $arr = [];
- foreach ($data as $v)
- {
- $diagnose = explode(';',$v['DIAGNOSENAME']);
- foreach ($diagnose as $value)
- {
- if(isset($arr[$value]))
- {
- $arr[$value] ++;
- }else{
- $arr[$value] = 1;
- }
- }
- }
- $return = [];
- foreach ($arr as $k=>$v)
- {
- $return[] = ['name'=>$k,'value'=>$v];
- }
- return $return;
- }
- public function getAllNum()
- {
- $exam = $this->_getExamCount();
- $inspect = $this->_getInspectCount();
- $arr = [];
- foreach ($exam as $k=>$v)
- {
- $data = [];
- $data['name']=$k;
- $data['exam'] = $v;
- if($inspect[$k] ?? '')
- {
- $data['inspect'] = $inspect[$k];
- }else{
- $data['inspect'] = 0;
- }
- $arr[$data['exam']+$data['inspect']] = $data;
- }
- krsort($arr);
- $array = array_slice($arr, 0, 20);
- return $array;
- }
- public function getExamData()
- {
- $uploadNum = $this->_getExamUpload();
- $hrNum = $this->_getExamHr();
- $data = [];
- foreach ($hrNum as $k=>$v)
- {
- $arr = [];
- $arr['upload'] = $k;
- $arr['num'] = $v;
- $arr['hr'] = $uploadNum[$k] ?? 0;
- $data[] = $arr;
- }
- return $data;
- }
- public function _getExamUpload()
- {
- return $this->examModel->group('DEVICETYPE_CODE')->where("DEVICETYPE_CODE != ''")->column('count(*)','DEVICETYPE_CODE');
- }
- public function _getExamHr()
- {
- return $this->hrrecordModel->alias('h')
- ->join(['dict_exam_project'=>'d'],'d.XM_CODE=h.ITEMNAMECODE')
- ->group('d.modality')
- ->column('count(*)','modality');
- }
- public function _getExamCount()
- {
- return $this->examModel->group('ORGNAME')->column('count(*)','ORGNAME');
- }
- public function _getInspectCount()
- {
- return $this->inspectModel->group('ORGNAME')->column('count(*)','ORGNAME');
- }
- public function getRepeatExam()
- {
- $handelData = $this->getRepeatDatas($this->examModel,'HR_ITEMNAME');
- // 获取患者数量
- $count = $this->getPatientCount([]);
- $MPIS = $handelData['MPIS'];
- // 重复报告数量
- $repeat = count($MPIS);
- $percent = round($repeat/$count*100);
- return ['percent'=>$percent];
- }
- public function getRepeatDatas($model,$itemname)
- {
- $this->baseModel = $model;
- $this->hrItemnameKey = $itemname;
- // 获取重复数据
- $repeatDatas = $this->getRepeatData([]);
- // 处理重复数据
- $handelData = $this->handleRepeatData($repeatDatas);
- return $handelData;
- }
- public function getRepeatExamProject()
- {
- $handelData = $this->getRepeatDatas($this->examModel,'HR_ITEMNAME');
- return array_slice($handelData['LAB_HR_ITEMNAMES'],0,10);
- }
- public function getRepeatInspect()
- {
- $handelData = $this->getRepeatDatas($this->inspectModel,'LAB_HR_ITEMNAME');
- // 获取患者数量
- $count = $this->getPatientCount([]);
- $MPIS = $handelData['MPIS'];
- // 重复报告数量
- $repeat = count($MPIS);
- $percent = round($repeat/$count*100);
- return ['percent'=>$percent];
- }
- public function getRepeatInspectDoctor()
- {
- $handelData = $this->getRepeatDatas($this->inspectModel,'LAB_HR_ITEMNAME');
- $MPIS = $handelData['MPIS'];
- // 医生情况
- $doctor = $this->getDoctor([], $MPIS);
- return $this->makeIdReturn($doctor['doctor']['items'],$doctor['doctor']['all']);
- }
- public function makeIdReturn($data,$all)
- {
- $i = 1;
- foreach ($data as $k=>$v)
- {
- $data[$k]['id'] = $i;
- $data[$k]['percent'] = round($v['value']/$all*100).'%';
- $data[$k]['value'] = $v['value'].'次';
- $i++;
- }
- return $data;
- }
- public function getRepeatExamDoctor()
- {
- $handelData = $this->getRepeatDatas($this->examModel,'HR_ITEMNAME');
- $MPIS = $handelData['MPIS'];
- // 医生情况
- $doctor = $this->getDoctor([], $MPIS);
- return $this->makeIdReturn($doctor['doctor']['items'],$doctor['doctor']['all']);
- }
- public function getRepeatInspectProject()
- {
- $handelData = $this->getRepeatDatas($this->inspectModel,'LAB_HR_ITEMNAME');
- return array_slice($handelData['LAB_HR_ITEMNAMES'],0,10);
- }
- public function getAllBhrReason()
- {
- $record = $this->hrrecordModel->where('HR_STATUS',2)->group('BHR_REASON')->field('BHR_REASON,count(*)')->select()->toArray();
- // foreach ($record as $k=>$v)
- // {
- // $record[$k]['BHR_REASON'] = mb_substr($v['BHR_REASON'],0,3);
- // }
- return $record;
- }
- public function getHrExamItem()
- {
- $this->hrBaseModel = $this->hrrecordModel;
- $this->ITEMNAMETYPE = 1;
- $hr = $this->getHrItem([]);
- $arr = $hr['items'];
- foreach ($arr as $k=>$v)
- {
- $arr[$k]['percent'] = round($v['value']/$hr['all']*100).'%';
- }
- return $arr;
- }
- public function getHrInspectItem()
- {
- $this->hrBaseModel = $this->hrrecordModel;
- $this->ITEMNAMETYPE = 2;
- $hr = $this->getHrItem([]);
- $arr = $hr['items'];
- foreach ($arr as $k=>$v)
- {
- $arr[$k]['percent'] = round($v['value']/$hr['all']*100).'%';
- }
- return $arr;
- }
- public function unLookRepeatInspectDoctor()
- {
- $handelData = $this->getRepeatDatas($this->inspectModel,'LAB_HR_ITEMNAME');
- $MPIS = $handelData['MPIS'];
- // 医生情况
- $doctor = $this->getDoctor([], $MPIS);
- // 有互认提示但未查看,直接进行了重复检查检验的医生构成比
- return $this->makeLookReturn($doctor['un_call_doctor']['items']);
- }
- public function unLookRepeatExamDoctor()
- {
- $handelData = $this->getRepeatDatas($this->examModel,'HR_ITEMNAME');
- $MPIS = $handelData['MPIS'];
- // 医生情况
- $doctor = $this->getDoctor([], $MPIS);
- // 有互认提示但未查看,直接进行了重复检查检验的医生构成比
- return $this->makeLookReturn($doctor['un_call_doctor']['items']);
- }
- public function LookRepeatExamDoctor()
- {
- $handelData = $this->getRepeatDatas($this->examModel,'HR_ITEMNAME');
- $MPIS = $handelData['MPIS'];
- // 医生情况
- $doctor = $this->getDoctor([], $MPIS);
- // 有互认提示并已查看,也进行了重复检查检验的医生构成比
- return $this->makeLookReturn($doctor['call_doctor']['items']);
- }
- public function makeLookReturn($data)
- {
- $arr = [];
- foreach ($data as $k=>$v)
- {
- $arr[$k]['label'] = $v['label'];
- $arr[$k]['数量'] = $v['value'];
- }
- return $arr;
- }
- public function getLeida()
- {
- $types = $this->inspecItemtModel->field('count(*) c, ITEMTYPE')->group('ITEMTYPE')->select()->toArray();
- $hrs = $this->hrrecordModel->field('count(*) c, ITEMTYPE')->group('ITEMTYPE')->select()->toArray();
-
- $model = new Commondata();
- $dicts = $model
- ->field(['code','name'])
- ->where('type', '13')
- ->where('status', 1)
- ->order('weigh asc, id asc')
- ->select()
- ->toArray();
-
- $indicator = array();
- $hr = [
- 'name' => '互认',
- ];
- $type = [
- 'name' => '上传',
- ];
- foreach($dicts as $dict) {
- $key = 'key'.$dict['code'];
- $tmp = [
- 'key' => $key,
- 'name' => $dict['name'],
- 'max' => 0
- ];
- $hr[$key] = 0;
- $type[$key] = 0;
- $max = 0;
- foreach($types as $_type) {
- if('key'.$_type['ITEMTYPE'] == $key) {
- $type[$key] = $_type['c'];
- }
- $max = max($max, $_type['c']);
- }
- foreach($hrs as $_hr) {
- if('key'.$_hr['ITEMTYPE'] == $key) {
- $hr[$key] = $_hr['c'];
- }
- $max = max($max, $_hr['c']);
- }
- $indicator[] = $tmp;
- }
- foreach($indicator as &$_indicator) {
- $_indicator['max'] = $max;
- }
- $data = [
- 'indicator' => $indicator,
- 'val' => [
- $type, $hr
- ]
- ];
- // $data = [
- // 'indicator' => [
- // ['key' => 'key1', 'max' => 10000, 'name' => 'Name1'],
- // ['key' => 'key2', 'max' => 10000, 'name' => 'Name2'],
- // ['key' => 'key3', 'max' => 10000, 'name' => 'Name3'],
- // ['key' => 'key4', 'max' => 10000, 'name' => 'Name4'],
- // ['key' => 'key5', 'max' => 10000, 'name' => 'Name5'],
- // ['key' => 'key6', 'max' => 10000, 'name' => 'Name6'],
- // ],
- // 'val' => [
- // [
- // 'name' => '上传',
- // 'key1' => 2342,
- // 'key2' => 2452,
- // 'key3' => 4335,
- // 'key4' => 7469,
- // 'key5' => 6572,
- // 'key6' => 9864,
- // ],
- // [
- // 'name' => '互认',
- // 'key1' => 1342,
- // 'key2' => 5452,
- // 'key3' => 3335,
- // 'key4' => 4469,
- // 'key5' => 6572,
- // 'key6' => 2864,
- // ]
- // ]
- // ];
- return $data;
- // halt($data);
- }
- public function getBhrInstitution()
- {
- $data = $this->hrrecordModel->group('ORGNAME')->field('count(*) c,ORGNAME')->order('c desc')->limit(20)->select();
- foreach ($data as $k=>$v)
- {
- $data[$k]['id'] = $k+1;
- $data[$k]['c'] = $v['c'].'次';
- }
- return $data;
- }
- }
|