Commit e7cf05a2 by 赵增煜

处方单手动开具增加开方日志

parent d1a9e4bd
......@@ -5,8 +5,11 @@
use App\Http\Controllers\BaseApiController;
use App\Models\DoctorCorrectionModel;
use App\Models\DoctorModel;
use App\Models\PatientModel;
use App\Models\PrescriptionLogModel;
use App\Models\PrescriptionModel;
use App\Models\User;
use Datetime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
......@@ -62,22 +65,32 @@ public function upload(Request $request)
// 医师开方接口
public function prescription(Request $request)
{
$id = $request->input('id');
if (empty($id) || ! filter_var($id, FILTER_VALIDATE_INT)) {
return $this->failed('ID 不能为空且必须为整数');
$prescription_id = $request->input('id');
if (empty($prescription_id)) {
return $this->failed('ID 不能为空');
}
$authInfo = auth('api')->user();
$doctor = DoctorModel::where('user_id', $authInfo->id)->first();
if (! $doctor) {
return $this->failed('医师信息不存在');
}
$prescription = PrescriptionModel::where('id', $id)->first();
$prescription = PrescriptionModel::where('id', $prescription_id)->first();
if ($prescription->doctor_id != $doctor->id) {
return $this->failed('您没有权限开方该处方');
}
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
if ($prescription->save()) {
// TODO 增加开方日志
// 获取患者信息
$patient = PatientModel::where('id', $prescription->patient_id)->first();
// 生成医师开方日志
$dateTime = new DateTime($prescription->created_at);
$dateTime->modify('+3 minutes');
$prescription_at = $dateTime->format('Y-m-d H:i:s');
$doctorLog = new PrescriptionLogModel;
$doctorLog->pharmacy_id = $prescription->pharmacy_id;
$doctorLog->pharmacy_name = $prescription->pharmacy_name;
$doctorLog->log_info = $doctor->mame.'在'.$prescription_at.'为'.$prescription->patient_name.'('.$patient->mobile.')开具处方单(处方单编号:'.$prescription_id.')';
$doctorLog->save();
return $this->success('开方成功');
} else {
......
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