Commit 0bb778bc by 赵增煜

处方单列表

parent 765a84b0
...@@ -30,17 +30,18 @@ public function drugList(Request $request) ...@@ -30,17 +30,18 @@ public function drugList(Request $request)
return $this->success($data); return $this->success($data);
} }
# 药品7日内限购 // 药品7日内限购
public function drugLimit(Request $request) public function drugLimit(Request $request)
{ {
$drug_id = $request->input('drug_id'); $drug_id = $request->input('drug_id');
# 判断当前药品有没有设置7日内限购 // 判断当前药品有没有设置7日内限购
$drug = DrugModel::query()->find($drug_id); $drug = DrugModel::query()->find($drug_id);
# 当前药品未设置则使用全局的7日内限购 // 当前药品未设置则使用全局的7日内限购
$limit_num = 0; $limit_num = 0;
if( $drug->limit_num == 0 ){ if ($drug->limit_num == 0) {
} }
return $this->success($limit_num); return $this->success($limit_num);
} }
......
...@@ -46,7 +46,7 @@ public function add(Request $request) ...@@ -46,7 +46,7 @@ public function add(Request $request)
$idCardInfo = Util::getIdCardInfo($data['id_card']); $idCardInfo = Util::getIdCardInfo($data['id_card']);
$data['gender'] = $idCardInfo['gender']; $data['gender'] = $idCardInfo['gender'];
# $data['age'] = $idCardInfo['age']; // $data['age'] = $idCardInfo['age'];
$res = PatientModel::create($data); $res = PatientModel::create($data);
if ($res) { if ($res) {
return $this->success($res); return $this->success($res);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
// 问诊人控制器 // 问诊人控制器
class PrescriptionController extends BaseApiController class PrescriptionController extends BaseApiController
{ {
public function test() public function test()
{ {
// 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来 // 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
...@@ -35,13 +34,42 @@ public function test() ...@@ -35,13 +34,42 @@ public function test()
public function prescriptionList(Request $request) public function prescriptionList(Request $request)
{ {
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$userInfo = User::with(['doctor', 'pharmacist'])->find($authInfo->id);
$query = PrescriptionModel::query(); $query = PrescriptionModel::query();
// TODO 判断当前登录的用户角色 // TODO 判断当前登录的用户角色
# $userInfo = User::with(['doctor', 'pharmacist'])->find($authInfo->id);
if( $authInfo->last_login_type == User::LOGIN_TYPE_USER ){
$query->where('user_id', $authInfo->id);
}else if( $authInfo->last_login_type == User::LOGIN_TYPE_DOCTOR ){ // 医师
$doctor = DoctorModel::query()->where('user_id', $authInfo->id)->first();
$query->where('doctor_id', $doctor->id);
}else if( $authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY ){ // 药店
$pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first();
$query->where('pharmacy_id', $pharmacy->id);
}
$prescription = $query->get(); # 时间段
$start_time = $request->input('start_time');
$end_time = $request->input('end_time');
if ($start_time && $end_time) {
$query->whereBetween('created_at', [$start_time, $end_time]);
} else if ($start_time) {
$query->where('created_at', '>=', $start_time);
} else if ($end_time) {
$query->where('created_at', '<=', $end_time);
}
# 状态
$status = $request->input('status');
if ($status) {
$query->where('status', $status);
}
# 分页
$page = $request->input('page', 1);
$perPage = $request->input('per_page', 10);
$prescription = $query->orderBy('id','desc')->paginate($perPage, ['*'], 'page', $page);
# $prescription = $query->paginate(10);
return $this->success($prescription); return $this->success($prescription);
} }
...@@ -122,5 +150,4 @@ public function create(Request $request) ...@@ -122,5 +150,4 @@ public function create(Request $request)
return $this->success($data); return $this->success($data);
} }
} }
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