Commit 2d2b5e61 by 赵增煜

fix

parent 1aa8b4c3
......@@ -50,9 +50,6 @@ public function prescriptionList(Request $request)
$query = $query->where('doctor_id', $doctor->id);
} elseif ($authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY) { // 药店
$pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first();
if (! $pharmacy) {
return $this->failed('请重新登录!');
}
$query = $query->where('pharmacy_id', $pharmacy->id);
}
......@@ -122,7 +119,7 @@ public function create(Request $request)
return $this->failed('用户端暂时无法开处方');
$pharmacy = PharmacyModel::find($pharmacy_id);
if (! $pharmacy) {
return $this->failed('你查询的药店信息不存在!');
return $this->failed('药店信息不存在');
}
} else {
return $this->failed('pharmacy_id不能为空');
......@@ -262,26 +259,17 @@ public function create(Request $request)
$prescription->pharmacy_id = $pharmacy->id;
$prescription->pharmacy_name = $pharmacy->name;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist = PharmacistModel::where('status', PharmacistModel::IS_STATUS_TRUE)
->where('is_default', PharmacistModel::IS_DEFAULT_TRUE)
->first();
if (! $pharmacist) {
$pharmacist = PharmacistModel::where('status', PharmacistModel::IS_STATUS_TRUE)
$pharmacist = PharmacistModel::where('status', 1)
->where('pharmacy_id', $pharmacy_id)
->where(function ($query) {
$query->where('is_default', 1)
->orWhere('is_default', 0);
})
->inRandomOrder()
->first();
}
// $pharmacist = PharmacistModel::where('status', 1)
// ->where('pharmacy_id', $pharmacy_id)
// ->where(function ($query) {
// $query->where('is_default', 1)
// ->orWhere('is_default', 0);
// })
// ->inRandomOrder()
// ->first();
if (! $pharmacist) {
return $this->failed('该药店暂无可审方药师,请联系管理员!');
return $this->failed('药师信息不存在');
}
Log::info('药师:'.json_encode($pharmacist));
$prescription->pharmacist_id = $pharmacist->id;
......@@ -309,15 +297,15 @@ public function create(Request $request)
// 判断是否为医师自动开方
// $prescription_auto = $site_config['prescription_auto'];
if ($randomDoctor->is_auto == 1) {
// $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
// $prescription->save();
// // 生成医师开方日志
// $doctorLog = new PrescriptionLogModel;
// $doctorLog->pharmacy_id = $pharmacy_id;
// $doctorLog->pharmacy_name = $pharmacy->name;
// $currentTime = $prescription_at;
// $doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')';
// $doctorLog->save();
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
$prescription->save();
// 生成医师开方日志
$doctorLog = new PrescriptionLogModel;
$doctorLog->pharmacy_id = $pharmacy_id;
$doctorLog->pharmacy_name = $pharmacy->name;
$currentTime = $prescription_at;
$doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')';
$doctorLog->save();
} elseif ($randomDoctor->is_auto == 0) {
// 手动开方发送医师通知短信
if (env('SMS_CHANNEL') == 'chengliye') {
......@@ -339,15 +327,15 @@ public function create(Request $request)
// 药店自动审方(必须处方单待审方)
if ($pharmacy->is_auto == 1 && $prescription->status == PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING) {
// $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
// $prescription->save();
// // 生成药师审方日志
// $pharmacistLog = new PrescriptionLogModel;
// $pharmacistLog->pharmacy_id = $pharmacy_id;
// $pharmacistLog->pharmacy_name = $pharmacy->name;
// $currentTime = $review_at;
// $pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
// $pharmacistLog->save();
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
$prescription->save();
// 生成药师审方日志
$pharmacistLog = new PrescriptionLogModel;
$pharmacistLog->pharmacy_id = $pharmacy_id;
$pharmacistLog->pharmacy_name = $pharmacy->name;
$currentTime = $review_at;
$pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
$pharmacistLog->save();
} elseif ($pharmacy->is_auto == 0) {
// 手动审方发送药店通知短信
if (env('SMS_CHANNEL') == 'chengliye') {
......
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