org_id;; } //疫苗统计 public static function vaccine() { $where = []; if(self::$org_id){ $where['organization_id']=self::$org_id; } $data ['sum_num'] = Vaccine::where($where)->count(); $data['have_num'] = Vaccine::where($where)->sum('stock'); $data['less_num'] = Vaccine::where($where)->where(['stock'=>0])->count();//取苗钟数 $data['today_schedule'] = Order::where(['order_status'=>1])->where($where)->where('product_type',4)->where('created_at','>',date('Y-m-d H:i:s',time()))->count(); $data['today_vaccine'] = Order::where(['product_type'=>4])->where($where)->with('orderPatient','appoint_start_time',strtotime('today'))->count();//接诊患者(人次) return $data; } //实时数据 public static function service() { $where = []; if(self::$org_id){ $where['organization_id']=self::$org_id; } $data['schedule_paitent'] = Order::where(['order_status'=>1])->where($where)->whereIn('product_type',[3,4,5])->where('created_at','>',date('Y-m-d H:i:s',time()))->count(); $data['schedule_docter'] = SchedulePeriod::distinct('docter_id')->where($where)->where('schedule_date',date('Y-m-d H:i:s',time()))->count(); // $data['paitent_num'] = Order::where(['order_status'=>1])->distinct()->count()->BgroupBy('patient_id'); $data['paitent_num'] = Order::whereHas('orderPatient',function ($query){ $query->where(['appoint_start_time'=>strtotime('today')]); })->where(['product_type'=>4])->where($where)->count();//接诊患者(人次) return $data; } //订单概况 public static function nurse() { //3.门诊预约 4.疫苗接种预约 5.儿保预约 $where = []; if(self::$org_id){ $where['organization_id']=self::$org_id; } $nurse_num[] = Order::where('product_type',3)->where($where)->count(); $nurse_num[] = Order::where('product_type',4)->where($where)->count(); $nurse_num[] = Order::where('product_type',5)->where($where)->count(); return $nurse_num; } //排班统计 public static function schedule() { $where = []; if(self::$org_id){ $where['organization_id']=self::$org_id; } $ids = SchedulePeriod::where('schedule_date',date("Y-m-d"))->where($where)->distinct('docter_id')->pluck('docter_id')->toArray(); $data = ['clinic_num'=>0,'vaccine_num'=>0,'nurse_num'=>0]; if(empty($ids)){ return $data; }; $docters = Docter::whereIn('id',$ids)->get(['id','type'])->GroupBy('type'); foreach ($docters as $key => $val){ if($key === 1){ $data['clinic_num'] = count($val); } else if($key == 2){ $data['vaccine_num'] = count($val); } else if($key == 3){ $data['nurse_num'] = count($val); } } return $data; } //门诊统计 public static function clinc() { $orgId = self::$org_id; $order = Order::where(['product_type'=>3,'organization_id'=>$orgId]); $today = $order->where('created_at','>=',date('Y-m-d'))->whereNotIn('order_status',[1,5,6])->count(); $docters = Schedule::where(['organization'=>$orgId,'schedule_date'=>date('Y-m-d',time())])->count(); $yesterday = $order->whereBetween(date('Y-m-d',[strtotime('-1days'),date('Y-m-d')]))->whereNotIn('order_status',[1,5,6])->count(); $yesterday = $order->whereBetween(date('Y-m-d',[strtotime('-1days'),date('Y-m-d')]))->whereNotIn('order_status',[1,5,6])->count(); return []; } }