Commit 382ec12c by 赵增煜

处方药限制

parent 3aedb8c6
......@@ -12,7 +12,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
// 药品控制器
class DrugController extends BaseApiController
{
......@@ -65,16 +65,29 @@ public function drugList(Request $request)
$pharmacy_id = $pharmacy->id;
}
$search_input = $request->input('search_input');
// $data = PharmacyDrugModel::where('pharmacy_id', $pharmacy_id)
// ->whereNotNull('dosage_id')
// ->whereHas('drug', function ($query) use ($search_input) {
// $query->where('is_rx', 1);
// if ($search_input) {
// $query->where('name', 'LIKE', "%{$search_input}%")
// ->orWhere('code', 'LIKE', "%{$search_input}%"); // 这里的'%筛选条件%'是你想要匹配的药品名称
// }
// })
// ->paginate(10);
$data = PharmacyDrugModel::where('pharmacy_id', $pharmacy_id)
->whereNotNull('dosage_id')
->whereHas('drug', function ($query) use ($search_input) {
$query->where('is_rx', 1);
if ($search_input) {
$query->where('name', 'LIKE', "%{$search_input}%")
->orWhere('code', 'LIKE', "%{$search_input}%"); // 这里的'%筛选条件%'是你想要匹配的药品名称
}
$query->where('is_rx', 1)
->where(function($subQuery) use ($search_input) {
if ($search_input) {
$subQuery->where('name', 'LIKE', "%{$search_input}%")
->orWhere('code', 'LIKE', "%{$search_input}%");
}
});
})
->paginate(10);
Log::info("drug list sql=>".$data->toSql());
$data->map(function ($row) {
return $row->drug;
});
......@@ -101,6 +114,7 @@ public function drugLimit(Request $request)
$sevenDaysAgo = Carbon::now()->subDays(7);
$prescriptions = PrescriptionModel::where('patient_id', $patient_id)
->where('status',PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)
->where('pharmacy_id', $pharmacy_id)
->where('created_at', '>=', $sevenDaysAgo)
->get();
......
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