Commit 7e00f0f4 by 赵增煜

merge冲突合并

parents e6d5f985 765f1511
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
use App\Models\AdminUsers; use App\Models\AdminUsers;
use App\Services\SmsService; use App\Services\SmsService;
use Dcat\Admin\Admin; use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController; use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
use Dcat\Admin\Http\Repositories\Administrator;
use Dcat\Admin\Layout\Content; use Dcat\Admin\Layout\Content;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -194,6 +196,80 @@ public function getLoginSmsCode(Request $request) ...@@ -194,6 +196,80 @@ public function getLoginSmsCode(Request $request)
} }
/** /**
* Model-form for user setting.
*
* @return Form
*/
protected function settingForm()
{
return new Form(new Administrator(), function (Form $form) {
$form->action(admin_url('auth/setting'));
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->tools(function (Form\Tools $tools) {
$tools->disableView();
$tools->disableDelete();
});
$form->display('username', trans('admin.username'));
$form->text('name', trans('admin.name'))->required();
$form->image('avatar', trans('admin.avatar'))->autoUpload();
// $form->password('old_password', trans('admin.old_password'));
$form->password('password', trans('admin.password'))
->minLength(5)
->maxLength(20)
->customFormat(function ($v) {
if ($v == $this->password) {
return;
}
return $v;
});
$form->password('password_confirmation', trans('admin.password_confirmation'))->same('password');
$form->ignore(['password_confirmation', 'old_password']);
$form->saving(function (Form $form) {
if ($form->password && $form->model()->password != $form->password) {
$form->password = bcrypt($form->password);
}
if (! $form->password) {
$form->deleteInput('password');
}
});
$form->saved(function (Form $form) {
return $form
->response()
->success(trans('admin.update_succeeded'))
->redirect('auth/setting');
});
});
}
/**
* Update user setting.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function putSetting()
{
$form = $this->settingForm();
// if (! $this->validateCredentialsWhenUpdatingPassword()) {
// $form->responseValidationMessages('old_password', trans('admin.old_password_error'));
// }
return $form->update(Admin::user()->getKey());
}
/**
* 验证短信验证码 * 验证短信验证码
* *
* @param string $username * @param string $username
......
...@@ -61,6 +61,7 @@ protected function grid() ...@@ -61,6 +61,7 @@ protected function grid()
$grid->column('mobile'); $grid->column('mobile');
// $grid->column('lng'); // $grid->column('lng');
// $grid->column('lat'); // $grid->column('lat');
$grid->column('limit_buy_7', '1天限购');
$grid->column('user.openid'); $grid->column('user.openid');
$grid->column('created_at'); $grid->column('created_at');
$grid->column('updated_at')->sortable(); $grid->column('updated_at')->sortable();
......
...@@ -44,7 +44,7 @@ protected function grid() ...@@ -44,7 +44,7 @@ protected function grid()
$grid->column('drug.dosage_form', '剂型'); $grid->column('drug.dosage_form', '剂型');
$grid->column('drug.factory', '生产厂家'); $grid->column('drug.factory', '生产厂家');
$grid->column('drug.approval_no', '批准文号'); $grid->column('drug.approval_no', '批准文号');
$grid->column('drug.limit_buy_7', '7天限购'); $grid->column('drug.limit_buy_7', '1天限购');
$grid->column('drug.standard_code', '本位码'); $grid->column('drug.standard_code', '本位码');
// $grid->column('dosage.dosage_desc', '用法用量'); // $grid->column('dosage.dosage_desc', '用法用量');
// $grid->column('batch_no'); // $grid->column('batch_no');
......
...@@ -37,9 +37,12 @@ public function form() ...@@ -37,9 +37,12 @@ public function form()
$form->width(4)->time('prescription_period_end', '截止')->format('HH:mm')->rules('required_if:prescription_period_status,1')->setLabelClass(['asterisk'])->default(($data['prescription_period_end'] ?? '')); $form->width(4)->time('prescription_period_end', '截止')->format('HH:mm')->rules('required_if:prescription_period_status,1')->setLabelClass(['asterisk'])->default(($data['prescription_period_end'] ?? ''));
})->default(($data['prescription_period_status'] ?? 0)); })->default(($data['prescription_period_status'] ?? 0));
$this->number('prescription_limit_buy_7', '7日内限购(全局)')->required()->default(($data['prescription_limit_buy_7'] ?? 0))->min(0); $this->number('prescription_limit_buy_7', '1日内限购(全局)')->required()->default(($data['prescription_limit_buy_7'] ?? 1))->min(1)->max(10)->help('最多可设置10');
$this->number('diagnosis_limit', '选择诊断数限制')->required()->default(($data['diagnosis_limit'] ?? 1))->min(1)->max(5)->help('诊断数选择设置1-5');
$this->number('drug_choose_limit', '选择药品限制')->required()->default(($data['drug_choose_limit'] ?? 5))->min(1)->max(5)->help('药品目录选择数,最多可设置5');
// $this->switch('prescription_auto', '医师自动开方')->default(($data['prescription_auto'] ?? 0)); // $this->switch('prescription_auto', '医师自动开方')->default(($data['prescription_auto'] ?? 0));
$this->text('limit_keywords', '限制关键词')->default($data['limit_keywords'] ?? '')->required()->help('多个关键词请用英文逗号分隔');
$this->disableResetButton(); $this->disableResetButton();
} }
......
...@@ -115,12 +115,13 @@ public function drugLimit(Request $request) ...@@ -115,12 +115,13 @@ public function drugLimit(Request $request)
$patient_id = $request->input('patient_id'); $patient_id = $request->input('patient_id');
$pharmacy_id = $request->input('pharmacy_id'); $pharmacy_id = $request->input('pharmacy_id');
$sevenDaysAgo = Carbon::now()->subDays(7); // $sevenDaysAgo = Carbon::now()->subDays(7);
$oneDayAgo = Carbon::now()->subDay();
$prescriptions = PrescriptionModel::where('patient_id', $patient_id) $prescriptions = PrescriptionModel::where('patient_id', $patient_id)
->where('is_voided', PrescriptionModel::IS_VOIDED_FALSE) // 未作废的处方 ->where('is_voided', PrescriptionModel::IS_VOIDED_FALSE) // 未作废的处方
->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS) ->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)
->where('pharmacy_id', $pharmacy_id) // ->where('pharmacy_id', $pharmacy_id)
->where('created_at', '>=', $sevenDaysAgo) ->where('created_at', '>=', $oneDayAgo)
->get(); ->get();
$drugCounts = []; $drugCounts = [];
......
...@@ -71,11 +71,11 @@ public function add(Request $request) ...@@ -71,11 +71,11 @@ public function add(Request $request)
return $this->failed('身份证格式错误'); return $this->failed('身份证格式错误');
} }
$mobile = $data['mobile']; $mobile = $data['mobile'];
$verificationCode = cache()->get("sms_verification_code_{$mobile}"); // $verificationCode = cache()->get("sms_verification_code_{$mobile}");
$code = $data['code']; // $code = $data['code'];
if ($verificationCode != $code) { // if ($verificationCode != $code) {
return $this->failed('验证码错误'); // return $this->failed('验证码错误');
} // }
$idCardInfo = Util::getIdCardInfo($data['id_card']); $idCardInfo = Util::getIdCardInfo($data['id_card']);
$patient->name = $data['name']; $patient->name = $data['name'];
$patient->id_card = $data['id_card']; $patient->id_card = $data['id_card'];
...@@ -108,11 +108,11 @@ public function update(Request $request) ...@@ -108,11 +108,11 @@ public function update(Request $request)
return $this->failed('该问诊人不存在'); return $this->failed('该问诊人不存在');
} }
$mobile = $request->input('mobile'); $mobile = $request->input('mobile');
$verificationCode = cache()->get("sms_verification_code_{$mobile}"); // $verificationCode = cache()->get("sms_verification_code_{$mobile}");
$code = $request->input('code'); // $code = $request->input('code');
if ($verificationCode != $code) { // if ($verificationCode != $code) {
return $this->failed('验证码错误'); // return $this->failed('验证码错误');
} // }
$data->name = $request->input('name'); $data->name = $request->input('name');
$data->id_card = $id_card; $data->id_card = $id_card;
......
...@@ -17,7 +17,7 @@ public function pharmacistList() ...@@ -17,7 +17,7 @@ public function pharmacistList()
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
$pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->get(); $pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->get();
...@@ -35,7 +35,7 @@ public function detail(Request $request) ...@@ -35,7 +35,7 @@ public function detail(Request $request)
// 获取药店信息 // 获取药店信息
$pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
$pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->where('id', $pharmacist_id)->first(); $pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->where('id', $pharmacist_id)->first();
if (! $pharmacist) { if (! $pharmacist) {
...@@ -241,6 +241,12 @@ public function delete(Request $request) ...@@ -241,6 +241,12 @@ public function delete(Request $request)
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('该药店不存在'); return $this->failed('该药店不存在');
} }
// 判断该药店下是否有几个开启的药师
$pharmacist = PharmacistModel::where('pharmacy_id', $pharmacy->id)->where('status', 1)->count();
if ($pharmacist <= 1) {
return $this->failed('无法删除,至少需要一个开启的药师!');
}
$id = $request->input('id'); $id = $request->input('id');
$data = PharmacistModel::where('id', $id)->where('pharmacy_id', $pharmacy->id)->first(); $data = PharmacistModel::where('id', $id)->where('pharmacy_id', $pharmacy->id)->first();
if (! $data) { if (! $data) {
......
...@@ -46,7 +46,7 @@ public function detail(Request $request) ...@@ -46,7 +46,7 @@ public function detail(Request $request)
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
return $this->success($pharmacy); return $this->success($pharmacy);
...@@ -58,7 +58,7 @@ public function correction(Request $request) ...@@ -58,7 +58,7 @@ public function correction(Request $request)
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
$content = $request->input('content'); $content = $request->input('content');
if (empty($content)) { if (empty($content)) {
...@@ -86,7 +86,7 @@ public function prescription(Request $request) ...@@ -86,7 +86,7 @@ public function prescription(Request $request)
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$Pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $Pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $Pharmacy) { if (! $Pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
$prescription = PrescriptionModel::where('id', $id)->where('pharmacy_id', $Pharmacy->id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)->first(); $prescription = PrescriptionModel::where('id', $id)->where('pharmacy_id', $Pharmacy->id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)->first();
if (! $prescription) { if (! $prescription) {
...@@ -138,7 +138,7 @@ public function open(Request $request) ...@@ -138,7 +138,7 @@ public function open(Request $request)
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
$is_open = $request->input('is_open'); $is_open = $request->input('is_open');
......
...@@ -119,7 +119,7 @@ public function create(Request $request) ...@@ -119,7 +119,7 @@ public function create(Request $request)
return $this->failed('用户端暂时无法开处方'); return $this->failed('用户端暂时无法开处方');
$pharmacy = PharmacyModel::find($pharmacy_id); $pharmacy = PharmacyModel::find($pharmacy_id);
if (! $pharmacy) { if (! $pharmacy) {
return $this->failed('药店信息不存在'); return $this->failed('请退出后重新登录!');
} }
} else { } else {
return $this->failed('pharmacy_id不能为空'); return $this->failed('pharmacy_id不能为空');
...@@ -131,21 +131,27 @@ public function create(Request $request) ...@@ -131,21 +131,27 @@ public function create(Request $request)
$prescription->user_id = $authInfo->id; // 获取当前用户ID $prescription->user_id = $authInfo->id; // 获取当前用户ID
// 问诊人信息 // 问诊人信息
$patient = PatientModel::find($patient_id); $patient = PatientModel::find($patient_id);
if (! $patient) {
return $this->failed('问诊人不存在,请选择正确的问诊人');
}
$prescription->patient_id = $patient_id; // 问诊人编号 $prescription->patient_id = $patient_id; // 问诊人编号
$prescription->patient_name = $patient->name; // 问诊人姓名 $prescription->patient_name = $patient->name; // 问诊人姓名
$prescription->patient_age = getAgeByIdCard($patient->id_card); // 问诊人年龄 $prescription->patient_age = getAgeByIdCard($patient->id_card); // 问诊人年龄
$prescription->patient_gender = $patient->gender; // 问诊人性别 $prescription->patient_gender = $patient->gender; // 问诊人性别
// 诊断信息 // 诊断信息
$prescription->diagnosis_id = $diagnosis_id; $prescription->diagnosis_id = $diagnosis_id;
$diagnosis = DiagnosiModel::find($diagnosis_id);
$prescription->diagnosis_name = $diagnosis->name; $diagnosis = DiagnosiModel::whereIn('id', explode(',', $diagnosis_id))->pluck('name')->toArray();
$diagnosis_name = implode(',', $diagnosis);
$prescription->diagnosis_name = $diagnosis_name;
// 问诊问题 // 问诊问题
$inquiry_info = []; $inquiry_info = [];
$is_abnormal = 0; // 是否异常处方单,只有一个问题回答是就是异常 $is_abnormal = 0; // 是否异常处方单,只有一个问题回答是就是异常
foreach ($inquirys as $inquiry) { foreach ($inquirys as $inquiry) {
$inquiry = InquiryModel::find($inquiry['inquiry_id']);
$inquiry_info[] = [ $inquiry_info[] = [
'inquiry_id' => $inquiry['inquiry_id'], 'inquiry_id' => $inquiry['inquiry_id'],
'question' => InquiryModel::find($inquiry['inquiry_id'])->value('question'), 'question' => $inquiry->question,
'answer' => $inquiry['answer'] == 1 ? 1 : 0, // [1 => '是', 0 => '否'] 'answer' => $inquiry['answer'] == 1 ? 1 : 0, // [1 => '是', 0 => '否']
]; ];
// 检查是否有一个answer是1 // 检查是否有一个answer是1
...@@ -259,14 +265,24 @@ public function create(Request $request) ...@@ -259,14 +265,24 @@ public function create(Request $request)
$prescription->pharmacy_id = $pharmacy->id; $prescription->pharmacy_id = $pharmacy->id;
$prescription->pharmacy_name = $pharmacy->name; $prescription->pharmacy_name = $pharmacy->name;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个 // 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist = PharmacistModel::where('status', 1) $pharmacist = PharmacistModel::where('status', PharmacistModel::IS_STATUS_TRUE)
->where('pharmacy_id', $pharmacy_id) ->where('pharmacy_id', $pharmacy_id)
->where(function ($query) { ->where('is_default', PharmacistModel::IS_DEFAULT_TRUE)
$query->where('is_default', 1)
->orWhere('is_default', 0);
})
->inRandomOrder()
->first(); ->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) { if (! $pharmacist) {
return $this->failed('药师信息不存在'); return $this->failed('药师信息不存在');
...@@ -297,15 +313,15 @@ public function create(Request $request) ...@@ -297,15 +313,15 @@ public function create(Request $request)
// 判断是否为医师自动开方 // 判断是否为医师自动开方
// $prescription_auto = $site_config['prescription_auto']; // $prescription_auto = $site_config['prescription_auto'];
if ($randomDoctor->is_auto == 1) { if ($randomDoctor->is_auto == 1) {
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING; // $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
$prescription->save(); // $prescription->save();
// 生成医师开方日志 // // 生成医师开方日志
$doctorLog = new PrescriptionLogModel; // $doctorLog = new PrescriptionLogModel;
$doctorLog->pharmacy_id = $pharmacy_id; // $doctorLog->pharmacy_id = $pharmacy_id;
$doctorLog->pharmacy_name = $pharmacy->name; // $doctorLog->pharmacy_name = $pharmacy->name;
$currentTime = $prescription_at; // $currentTime = $prescription_at;
$doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')'; // $doctorLog->log_info = $randomDoctor->name.'在'.$prescription_at.'为'.$patient->name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_number.')';
$doctorLog->save(); // $doctorLog->save();
} elseif ($randomDoctor->is_auto == 0) { } elseif ($randomDoctor->is_auto == 0) {
// 手动开方发送医师通知短信 // 手动开方发送医师通知短信
if (env('SMS_CHANNEL') == 'chengliye') { if (env('SMS_CHANNEL') == 'chengliye') {
...@@ -327,15 +343,15 @@ public function create(Request $request) ...@@ -327,15 +343,15 @@ public function create(Request $request)
// 药店自动审方(必须处方单待审方) // 药店自动审方(必须处方单待审方)
if ($pharmacy->is_auto == 1 && $prescription->status == PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING) { if ($pharmacy->is_auto == 1 && $prescription->status == PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING) {
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS; // $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
$prescription->save(); // $prescription->save();
// 生成药师审方日志 // // 生成药师审方日志
$pharmacistLog = new PrescriptionLogModel; // $pharmacistLog = new PrescriptionLogModel;
$pharmacistLog->pharmacy_id = $pharmacy_id; // $pharmacistLog->pharmacy_id = $pharmacy_id;
$pharmacistLog->pharmacy_name = $pharmacy->name; // $pharmacistLog->pharmacy_name = $pharmacy->name;
$currentTime = $review_at; // $currentTime = $review_at;
$pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')'; // $pharmacistLog->log_info = $pharmacist->name.'在'.$review_at.'为'.$patient->name.'('.$patient->mobile.')审方(处方单编号:'.$prescription_number.')';
$pharmacistLog->save(); // $pharmacistLog->save();
} elseif ($pharmacy->is_auto == 0) { } elseif ($pharmacy->is_auto == 0) {
// 手动审方发送药店通知短信 // 手动审方发送药店通知短信
if (env('SMS_CHANNEL') == 'chengliye') { if (env('SMS_CHANNEL') == 'chengliye') {
......
<?php
namespace App\Api\Controllers;
use App\Http\Controllers\BaseApiController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class SiteConfigController extends BaseApiController
{
public function test()
{
$site_config = admin_setting_array('site_config');
Log::info('测试', $site_config);
$data = [
'diagnosis_limit' => $site_config['diagnosis_limit'],
'drug_choose_limit' => $site_config['drug_choose_limit'],
];
return $this->success($data);
}
public function config(Request $request)
{
$site_config = admin_setting_array('site_config');
// Log::info('测试', $site_config);
$data = [
'diagnosis_limit' => $site_config['diagnosis_limit'],
'drug_choose_limit' => $site_config['drug_choose_limit'],
];
return $this->success($data);
}
}
...@@ -42,7 +42,7 @@ public function login(Request $request) ...@@ -42,7 +42,7 @@ public function login(Request $request)
return $this->success($data); return $this->success($data);
} else { } else {
return $this->fail('登录错误~'); return $this->failed('登录错误~');
} }
} }
......
...@@ -32,11 +32,71 @@ class PrescriptionCommand extends Command ...@@ -32,11 +32,71 @@ class PrescriptionCommand extends Command
*/ */
public function handle() public function handle()
{ {
$this->info('开始自动审开方...'); while (true) {
// 执行自动开方
$this->autoPrescriptionGen();
// 执行自动审方
$this->autoPrescriptionReview();
$this->info('等待5秒...');
sleep(5);
}
}
// 自动开方
public function autoPrescriptionGen()
{
$this->info('开始自动开方...');
// 如果处方单是审方状态,同时对应的药店开启自动审方
$prescriptions = PrescriptionModel::where('status', PrescriptionModel::PRESCRIPTION_STATUS_PENDING)
->get();
Log::info('自动开方:'.json_encode($prescriptions));
if ($prescriptions->count() <= 0) {
$this->info('没有需要开方的处方单');
return;
}
foreach ($prescriptions as $prescription) {
// 查询对应的医师是手动并且药师为自动
// $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) {
// 更新处方单状态
$prescriptionInfo = PrescriptionModel::find($prescription->id);
if ($prescriptionInfo) {
$prescriptionInfo->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
$prescriptionInfo->save();
// 获取患者信息
$patient = PatientModel::where('id', $prescriptionInfo->patient_id)->first();
if ($patient == null) {
continue;
}
// 生成审方日志
$dateTime = new DateTime($prescription->created_at);
$dateTime->modify('+3 minutes');
$pharmacistLog = new PrescriptionLogModel;
$pharmacistLog->pharmacy_id = $prescription->pharmacy_id;
$pharmacistLog->pharmacy_name = $prescription->pharmacy_name;
$currentTime = $dateTime->format('Y-m-d H:i:s');
$pharmacistLog->log_info = $prescription->doctor_name.'在'.$currentTime.'为'.$prescription->patient_name.'('.$patient->mobile.')开方(处方单编号:'.$prescription->id.')';
$pharmacistLog->save();
$this->info($prescription->id.'开方成功');
}
}
}
}
// 自动审方
public function autoPrescriptionReview()
{
$this->info('开始自动审方...');
// 如果处方单是审方状态,同时对应的药店开启自动审方 // 如果处方单是审方状态,同时对应的药店开启自动审方
$prescriptions = PrescriptionModel::where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING) $prescriptions = PrescriptionModel::where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)
->get(); ->get();
Log::info('自动审方:'.json_encode($prescriptions)); Log::info('自动审方:'.json_encode($prescriptions));
if ($prescriptions->count() <= 0) { if ($prescriptions->count() <= 0) {
$this->info('没有需要审方的处方单'); $this->info('没有需要审方的处方单');
...@@ -45,8 +105,12 @@ public function handle() ...@@ -45,8 +105,12 @@ public function handle()
foreach ($prescriptions as $prescription) { foreach ($prescriptions as $prescription) {
// 查询对应的医师是手动并且药师为自动 // 查询对应的医师是手动并且药师为自动
$pharmacist = PharmacyModel::where('id', $prescription->pharmacy_id)->first(); $pharmacist = PharmacyModel::where('id', $prescription->pharmacy_id)->first();
$doctor = DoctorModel::where('id', $prescription->doctor_id)->first(); // $doctor = DoctorModel::where('id', $prescription->doctor_id)->first();
if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) { // if ($doctor->is_auto == 0 && $pharmacist->is_auto == 1) {
if ($pharmacist == null) {
continue;
}
if ($pharmacist->is_auto == 1) {
// 更新处方单状态 // 更新处方单状态
$prescriptionInfo = PrescriptionModel::find($prescription->id); $prescriptionInfo = PrescriptionModel::find($prescription->id);
if ($prescriptionInfo) { if ($prescriptionInfo) {
...@@ -54,6 +118,9 @@ public function handle() ...@@ -54,6 +118,9 @@ public function handle()
$prescriptionInfo->save(); $prescriptionInfo->save();
// 获取患者信息 // 获取患者信息
$patient = PatientModel::where('id', $prescriptionInfo->patient_id)->first(); $patient = PatientModel::where('id', $prescriptionInfo->patient_id)->first();
if ($patient == null) {
continue;
}
// 生成审方日志 // 生成审方日志
$dateTime = new DateTime($prescription->created_at); $dateTime = new DateTime($prescription->created_at);
$dateTime->modify('+5 minutes'); $dateTime->modify('+5 minutes');
...@@ -67,6 +134,5 @@ public function handle() ...@@ -67,6 +134,5 @@ public function handle()
} }
} }
} }
} }
} }
<?php
namespace App\Console\Commands;
use App\Models\InquiryModel;
use App\Models\PrescriptionModel;
use Illuminate\Console\Command;
class TestCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mohe:test';
/**
* The console command description.
*
* @var string
*/
protected $description = '测试命令';
/**
* Execute the console command.
*/
public function handle()
{
// 刷新问诊问题
$prescriptions = PrescriptionModel::orderBy('id', 'desc')->get();
foreach ($prescriptions as $prescription) {
$inquiry_info = $prescription->inquiry_info;
foreach ($inquiry_info as &$v) {
$v['question'] = InquiryModel::find($v['inquiry_id'])->question;
}
$prescription->inquiry_info = $inquiry_info;
$prescription->save();
}
}
}
...@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel ...@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
// $schedule->command('inspire')->hourly(); // $schedule->command('inspire')->hourly();
$schedule->command('mohe:prescription')->everyMinute(); // $schedule->command('mohe:prescription')->everyMinute();
} }
/** /**
......
...@@ -32,6 +32,16 @@ class PharmacistModel extends Model ...@@ -32,6 +32,16 @@ class PharmacistModel extends Model
self::IS_DEFAULT_TRUE => 'success', self::IS_DEFAULT_TRUE => 'success',
]; ];
// 是否启用[0=否,1=是]
const IS_STATUS_FALSE = 0;
const IS_STATUS_TRUE = 1;
const IS_STATUS_MAP = [
self::IS_STATUS_FALSE => '否',
self::IS_STATUS_TRUE => '是',
];
// 药师关联的药店,多对一 // 药师关联的药店,多对一
public function pharmacy() public function pharmacy()
{ {
......
...@@ -24,8 +24,8 @@ public function up(): void ...@@ -24,8 +24,8 @@ public function up(): void
$table->string('patient_name', 32)->comment('问诊人姓名'); $table->string('patient_name', 32)->comment('问诊人姓名');
$table->integer('patient_age')->default(0)->comment('问诊人年龄'); $table->integer('patient_age')->default(0)->comment('问诊人年龄');
$table->tinyInteger('patient_gender')->default(0)->comment('问诊人性别。[1=男性,2=女性,0=未知]'); $table->tinyInteger('patient_gender')->default(0)->comment('问诊人性别。[1=男性,2=女性,0=未知]');
$table->bigInteger('diagnosis_id')->default(0)->comment('诊断表ID'); $table->string('diagnosis_id', 255)->nullable()->comment('诊断表ID');
$table->string('diagnosis_name', 128)->nullable()->comment('诊断'); $table->string('diagnosis_name', 255)->nullable()->comment('诊断');
$table->text('inquiry_info')->comment('问诊问题'); $table->text('inquiry_info')->comment('问诊问题');
$table->boolean('is_abnormal')->default(0)->comment('是否异常处方[0=否,1=是]'); $table->boolean('is_abnormal')->default(0)->comment('是否异常处方[0=否,1=是]');
......
...@@ -74,3 +74,19 @@ services: ...@@ -74,3 +74,19 @@ services:
ipv4_address: ${DOCKER_IP_PREFIX}.6 ipv4_address: ${DOCKER_IP_PREFIX}.6
entrypoint: entrypoint:
[ "cron", "-f" ] [ "cron", "-f" ]
auto-prescription: # 自动开方审方脚本
restart: always
build:
context: ./docker/php
volumes:
- .:/var/www
environment:
- TZ=${TZ}
# - XDEBUG_CONFIG=client_host=${DOCKER_IP_PREFIX}.1
deploy:
replicas: ${ENABLE_AUTO_PRESCRIPTION}
networks:
net:
ipv4_address: ${DOCKER_IP_PREFIX}.7
entrypoint:
[ "/var/www/artisan", "mohe:prescription" ]
\ No newline at end of file
...@@ -113,22 +113,22 @@ pm = dynamic ...@@ -113,22 +113,22 @@ pm = dynamic
; forget to tweak pm.* to fit your needs. ; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory. ; Note: This value is mandatory.
pm.max_children = 50 pm.max_children = 500
; The number of child processes created on startup. ; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2 ; Default Value: (min_spare_servers + max_spare_servers) / 2
pm.start_servers = 5 pm.start_servers = 50
; The desired minimum number of idle server processes. ; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5 pm.min_spare_servers = 50
; The desired maximum number of idle server processes. ; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 30 pm.max_spare_servers = 300
; The number of rate to spawn child processes at once. ; The number of rate to spawn child processes at once.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
...@@ -145,7 +145,7 @@ pm.max_spare_servers = 30 ...@@ -145,7 +145,7 @@ pm.max_spare_servers = 30
; This can be useful to work around memory leaks in 3rd party libraries. For ; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0 ; Default Value: 0
;pm.max_requests = 500 pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be ; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following information: ; recognized as a status page. It shows the following information:
...@@ -402,7 +402,7 @@ slowlog = /var/log/php-fpm/$pool.log.slow ...@@ -402,7 +402,7 @@ slowlog = /var/log/php-fpm/$pool.log.slow
; Note: on highloaded environment, this can cause some delay in the page ; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms). ; process time (several ms).
; Default Value: no ; Default Value: no
;catch_workers_output = yes catch_workers_output = yes
; Decorate worker output with prefix and suffix containing information about ; Decorate worker output with prefix and suffix containing information about
; the child that writes to the log and if stdout or stderr is used as well as ; the child that writes to the log and if stdout or stderr is used as well as
......
...@@ -59,6 +59,14 @@ ...@@ -59,6 +59,14 @@
$('#download-btn').on('click', () => this.download()); $('#download-btn').on('click', () => this.download());
$('#print-btn').on('click', () => this.print()); $('#print-btn').on('click', () => this.print());
// 使用闭包来保存对当前实例的引用
this.editableDrugListChangeHandler = () => {
this.search();
};
$('#is_eseal').on('change', () => this.search());
console.log('事件绑定完成'); console.log('事件绑定完成');
} }
...@@ -162,6 +170,8 @@ ...@@ -162,6 +170,8 @@
// 将表单添加到搜索表单下方 // 将表单添加到搜索表单下方
$('.search-form').after(formHtml); $('.search-form').after(formHtml);
$(document).find('#editable-drug-list select').select2(); $(document).find('#editable-drug-list select').select2();
$('#editable-drug-list').on('change', 'select', this.editableDrugListChangeHandler);
} }
// 新增:获取剂量数据的方法 // 新增:获取剂量数据的方法
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
// 小程序静默登录 // 小程序静默登录
Route::post('login', 'App\Api\Controllers\UserController@login'); Route::post('login', 'App\Api\Controllers\UserController@login');
Route::get('qrcode', 'App\Api\Controllers\PatientController@getQrCode'); Route::get('qrcode', 'App\Api\Controllers\PatientController@getQrCode');
Route::get('test', 'App\Api\Controllers\DrugController@test'); Route::get('test', 'App\Api\Controllers\SiteConfigController@test');
...@@ -113,4 +114,6 @@ ...@@ -113,4 +114,6 @@
Route::post('/pharmacist-upload', 'App\Api\Controllers\PharmacistController@upload'); Route::post('/pharmacist-upload', 'App\Api\Controllers\PharmacistController@upload');
# 药师删除 # 药师删除
Route::post('/pharmacist-delete', 'App\Api\Controllers\PharmacistController@delete'); Route::post('/pharmacist-delete', 'App\Api\Controllers\PharmacistController@delete');
# 获取系统配置
Route::post('/config', 'App\Api\Controllers\SiteConfigController@config');
}); });
\ No newline at end of file
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