Commit 63381db1 by 赵增煜

merge

parents b004237f 7196e7ea
......@@ -205,11 +205,14 @@ public function delete(Request $request)
if (! $pharmacy) {
return $this->failed('该药店不存在');
}
// 判断该药店下是否有几个开启的药师
# 判断该药店下是否有几个开启的药师
$pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->where('status', 1)->count();
if ($pharmacist <= 1) {
if( $pharmacist <= 1 ){
return $this->failed('无法删除,至少需要一个开启的药师!');
}
$id = $request->input('id');
$data = PharmacistModel::where('id', $id)->where('pharmacy_id', $pharmacy->id)->first();
if (! $data) {
......
......@@ -262,14 +262,24 @@ public function create(Request $request)
$prescription->pharmacy_id = $pharmacy->id;
$prescription->pharmacy_name = $pharmacy->name;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist = PharmacistModel::where('status', 1)
$pharmacist = PharmacistModel::where('status', PharmacistModel::IS_STATUS_TRUE)
->where('pharmacy_id', $pharmacy_id)
->where(function ($query) {
$query->where('is_default', 1)
->orWhere('is_default', 0);
})
->inRandomOrder()
->where('is_default', PharmacistModel::IS_DEFAULT_TRUE)
->first();
if (! $pharmacist) {
$pharmacist = PharmacistModel::where('status', PharmacistModel::IS_STATUS_TRUE)
->where('pharmacy_id', $pharmacy_id)
->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('药师信息不存在');
......@@ -300,15 +310,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') {
......@@ -330,15 +340,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') {
......
......@@ -59,6 +59,11 @@ public function autoPrescriptionGen()
// 查询对应的医师是手动并且药师为自动
// $pharmacist = PharmacyModel::where('id', $prescription->pharmacy_id)->first();
$doctor = DoctorModel::where('id', $prescription->doctor_id)->first();
if ($doctor == null) {
continue;
}
// if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if ($doctor->is_auto == 1) {
// 更新处方单状态
......@@ -68,6 +73,11 @@ public function autoPrescriptionGen()
$prescriptionInfo->save();
// 获取患者信息
$patient = PatientModel::where('id', $prescriptionInfo->patient_id)->first();
if ($patient==null) {
continue;
}
// 生成审方日志
$dateTime = new DateTime($prescription->created_at);
$dateTime->modify('+3 minutes');
......@@ -101,6 +111,11 @@ public function autoPrescriptionReview()
$pharmacist = PharmacyModel::where('id', $prescription->pharmacy_id)->first();
// $doctor = DoctorModel::where('id', $prescription->doctor_id)->first();
// if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if ($pharmacist == null) {
continue;
}
if ($pharmacist->is_auto == 1) {
// 更新处方单状态
$prescriptionInfo = PrescriptionModel::find($prescription->id);
......@@ -109,6 +124,9 @@ public function autoPrescriptionReview()
$prescriptionInfo->save();
// 获取患者信息
$patient = PatientModel::where('id', $prescriptionInfo->patient_id)->first();
if($patient==null) {
continue;
}
// 生成审方日志
$dateTime = new DateTime($prescription->created_at);
$dateTime->modify('+5 minutes');
......
......@@ -28,7 +28,7 @@ class TestCommand extends Command
public function handle()
{
// 刷新问诊问题
$prescriptions = PrescriptionModel::all();
$prescriptions = PrescriptionModel::orderBy('id', 'desc')->get();
foreach ($prescriptions as $prescription) {
$inquiry_info = $prescription->inquiry_info;
foreach ($inquiry_info as &$v) {
......
......@@ -13,7 +13,9 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
// $schedule->command('mohe:prescription')->everyMinute();
# $schedule->command('mohe:prescription')->everyMinute();
}
/**
......
......@@ -34,7 +34,6 @@ class PharmacistModel extends Model
// 是否启用[0=否,1=是]
const IS_STATUS_FALSE = 0;
const IS_STATUS_TRUE = 1;
const IS_STATUS_MAP = [
......
......@@ -90,3 +90,4 @@ services:
ipv4_address: ${DOCKER_IP_PREFIX}.7
entrypoint:
[ "/var/www/artisan", "mohe:prescription" ]
......@@ -66,6 +66,10 @@
$('#is_eseal').on('change', () => this.search());
<<<<<<< HEAD
=======
>>>>>>> master
console.log('事件绑定完成');
}
......@@ -170,7 +174,7 @@
// 将表单添加到搜索表单下方
$('.search-form').after(formHtml);
$(document).find('#editable-drug-list select').select2();
$('#editable-drug-list').on('change', 'select', this.editableDrugListChangeHandler);
}
......
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