Commit 382ec12c by 赵增煜

处方药限制

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