|
@@ -8,6 +8,8 @@ use App\Http\Controllers\Controller;
|
|
use App\Models\CdmsUsers;
|
|
use App\Models\CdmsUsers;
|
|
use App\Models\Docter;
|
|
use App\Models\Docter;
|
|
use App\Models\DocterOrganization;
|
|
use App\Models\DocterOrganization;
|
|
|
|
+use App\Models\DocterSetting;
|
|
|
|
+use App\Models\Doctertimes;
|
|
use App\Models\Order;
|
|
use App\Models\Order;
|
|
use App\Models\Organization;
|
|
use App\Models\Organization;
|
|
use App\Models\PatientRemark;
|
|
use App\Models\PatientRemark;
|
|
@@ -15,6 +17,7 @@ use App\Models\Schedule;
|
|
use App\Models\SchedulePeriod;
|
|
use App\Models\SchedulePeriod;
|
|
use App\Models\SystemConfig;
|
|
use App\Models\SystemConfig;
|
|
use App\Models\TimePeriod;
|
|
use App\Models\TimePeriod;
|
|
|
|
+use App\Models\WeekSchedule;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
use EasyWeChat\Factory;
|
|
use EasyWeChat\Factory;
|
|
use Encore\Admin\Facades\Admin;
|
|
use Encore\Admin\Facades\Admin;
|
|
@@ -25,7 +28,7 @@ class ApiController extends Controller
|
|
{
|
|
{
|
|
public function getDocter()
|
|
public function getDocter()
|
|
{
|
|
{
|
|
- return Docter::get(['name as text','id'])->toArray();
|
|
|
|
|
|
+ return Docter::pluck(['name','id'])->toArray();
|
|
}
|
|
}
|
|
public function paitent_remark()
|
|
public function paitent_remark()
|
|
{
|
|
{
|
|
@@ -478,4 +481,97 @@ class ApiController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function updateDocterSetting()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id',1);
|
|
|
|
+ if(empty($docter_id)){
|
|
|
|
+ return apiReturn(604,'参数错误');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //添加时间段
|
|
|
|
+ if(2 == 3){
|
|
|
|
+ $data = ['docter_id'=>$docter_id,'am_start'=>'8:30','am_end'=>'11:30','pm_start'=>'12:00','pm_end'=>'15:00','ev_start'=>'19:00','ev_end'=>'22:00','service_time'=>15];
|
|
|
|
+ $amtimes[] = explode(':',$data['am_start']);
|
|
|
|
+ $amtimes[] = explode(':',$data['am_end']);
|
|
|
|
+// $amcha = ($amtimes[1][0] - $amtimes[0][0])*60 +($amtimes[1][1] - $amtimes[0][1]);
|
|
|
|
+// $amCount = $amcha/$data['service_time'];
|
|
|
|
+ $amCount = intval(floor((strtotime($data['am_end']) - strtotime($data['am_start'])) / (60*$data['service_time'])));
|
|
|
|
+
|
|
|
|
+ $pmtimes[] = explode(':',$data['pm_start']);
|
|
|
|
+ $pmtimes[] = explode(':',$data['pm_end']);
|
|
|
|
+ $pmCount =intval(floor((strtotime($data['pm_end']) - strtotime($data['pm_start'])) / (60*$data['service_time'])));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $evtimes[] = explode(':',$data['ev_start']);
|
|
|
|
+ $evtimes[] = explode(':',$data['ev_end']);
|
|
|
|
+ $evcha = ($evtimes[1][0] - $evtimes[0][0])*60 +($evtimes[1][1] - $evtimes[0][1]);
|
|
|
|
+ $evCount = $evcha/$data['service_time'];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$amCount;$i++){
|
|
|
|
+ $amdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['am_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['am_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($amdata);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$pmCount;$i++){
|
|
|
|
+ $pmdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['pm_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['pm_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($pmdata);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$evCount;$i++){
|
|
|
|
+ $evdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['ev_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['ev_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($evdata);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $config = [['startTime'=>"08:30","endTime"=>"11:30"],["startTime"=>"13:30","endTime"=>"16:00"],["startTime"=>"18:30","endTime"=>"19:30"]];
|
|
|
|
+ $setting = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'type'=>2,
|
|
|
|
+ 'status'=>2,
|
|
|
|
+ 'show_days'=>7,
|
|
|
|
+ 'service_num'=>7,
|
|
|
|
+ 'service_time'=>json_encode($config)
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $is_have = DocterSetting::where(['docter_id'=>$docter_id])->value('id');
|
|
|
|
+ if($is_have){
|
|
|
|
+ DocterSetting::where(['docter_id'=>$docter_id])->update($setting);
|
|
|
|
+ } else {
|
|
|
|
+ DocterSetting::insert($setting);
|
|
|
|
+ }
|
|
|
|
+ return apiReturn(200,'ok');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getWeekSchedule()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id');
|
|
|
|
+ $org_id = request('org_id');
|
|
|
|
+ $role = request('role'); //1社区管理员 2医生
|
|
|
|
+ $type = request('type');
|
|
|
|
+
|
|
|
|
+ $docter_setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
|
|
+ if(!empty($docter_setting)){
|
|
|
|
+ $time_period = object_array(json_decode($docter_setting->service_time));
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[0]['startTime']),intval($time_period[0]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[1]['startTime']),intval($time_period[1]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[2]['startTime']),intval($time_period[2]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|