Commit 4ecd7fa3 by 赵增煜

开方bug修复

parent 59a9ef05
......@@ -17,6 +17,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
// 问诊人控制器
class PrescriptionController extends BaseApiController
{
......@@ -98,7 +99,7 @@ public function detail(Request $request)
public function create(Request $request)
{
$authInfo = auth('api')->user();
Log::info("开方请求参数:" . json_encode($request->all()));
Log::info('开方请求参数:'.json_encode($request->all()));
$pharmacy_id = $request->input('pharmacy_id', 0);
$patient_id = $request->input('patient_id');
$diagnosis_id = $request->input('diagnosis_id');
......@@ -202,16 +203,20 @@ public function create(Request $request)
return $prescriptionCounts->get($doctorId, 0) < $prescription_limit;
})->values()->all();
// 随机取一个随机医师
$randomDoctor = DoctorModel::whereIn('id', $availableDoctors)
->where('status', DoctorModel::STATUS_TRUE)
->inRandomOrder()
->first();
$randomQuery = DoctorModel::query()->where('status', DoctorModel::STATUS_TRUE);
if (count($availableDoctors) > 0) {
$randomQuery->whereIn('id', $availableDoctors);
}
$randomDoctor = $randomQuery->inRandomOrder()->first();
// $randomDoctor = DoctorModel::whereIn('id', $availableDoctors)
// ->where('status', DoctorModel::STATUS_TRUE)
// ->inRandomOrder()
// ->first();
} else {
$randomDoctor = DoctorModel::inRandomOrder()->where('status', DoctorModel::STATUS_TRUE)->first();
}
# 记录开方医师信息
Log::info("医师:" . json_encode($randomDoctor));
// 记录开方医师信息
Log::info('医师:'.json_encode($randomDoctor));
$prescription->doctor_id = $randomDoctor->id;
$prescription->doctor_name = $randomDoctor->name;
$prescription->doctor_online_hospital_name = $randomDoctor->online_hospital_name;
......@@ -232,7 +237,7 @@ public function create(Request $request)
})
->inRandomOrder()
->first();
Log::info("药师:" . json_encode($pharmacist));
Log::info('药师:'.json_encode($pharmacist));
$prescription->pharmacist_id = $pharmacist->id;
$prescription->pharmacist_name = $pharmacist->name;
$prescription->pharmacist_license_number = $pharmacist->license_number;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment