コード例 #1
0
 public function finish(Request $request, $patientId)
 {
     if (!HospitalEmployee::isPharmacist()) {
         return response()->json(["success" => false, "error" => 'notlogin or notvalid']);
     }
     $patient = Patient::find($patientId);
     if (!$patient) {
         return response()->json(['success' => false, 'message' => 'patient not found']);
     }
     $drugs = DrugRecord::where('patient_id', $patient->id)->where('check', 0)->where('created_at', '>=', new \DateTime('today'))->get();
     foreach ($drugs as $drug) {
         $drug->check = 1;
         $drug->save();
     }
     $patient->status = 0;
     $patient->save();
     return response()->json(['success' => true, 'data' => $patient->drugRecords]);
 }