Commit 9c1c7b76 by 赵增煜

新增审方接口

parent 71e84059
......@@ -75,7 +75,7 @@ public function prescription(Request $request)
{
$id = $request->input('id');
if (empty($id) || ! filter_var($id, FILTER_VALIDATE_INT)) {
return $this->failed('无效的 ID,ID 不能为空且必须为整数');
return $this->failed('ID 不能为空且必须为整数');
}
$authInfo = auth('api')->user();
$doctor = DoctorModel::where('user_id', $authInfo->id)->first();
......@@ -88,6 +88,8 @@ public function prescription(Request $request)
}
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
if ($prescription->save()) {
# TODO 增加开方日志
return $this->success('开方成功');
} else {
return $this->failed('开方失败');
......
......@@ -4,6 +4,7 @@
use App\Http\Controllers\BaseApiController;
use App\Models\PharmacyCorrectionModel;
use App\Models\PrescriptionModel;
use App\Models\PharmacyModel;
use Illuminate\Http\Request;
......@@ -74,5 +75,27 @@ public function correction(Request $request)
}
// 药店审方
public function approval(Request $request) {}
public function prescription(Request $request) {
$id = $request->input('id');
if (empty($id) || ! filter_var($id, FILTER_VALIDATE_INT)) {
return $this->failed('ID 不能为空且必须为整数');
}
$authInfo = auth('api')->user();
$Pharmacy = PharmacyModel::where('user_id', $authInfo->id)->first();
if (! $Pharmacy) {
return $this->failed('药店信息不存在');
}
$prescription = PrescriptionModel::where('id', $id)->where('pharmacy_id', $Pharmacy->id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)->first();
if( $prescription ){
return $this->failed('该处方已审核');
}
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
if ($prescription->save()) {
# TODO 增加审方日志
return $this->success('审方成功');
} else {
return $this->failed('审方失败');
}
}
}
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