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]); }
public function drugRecordDelete($drugId) { if (!HospitalEmployee::isDoctor()) { return response()->json(["success" => false, "error" => 'notlogin or notvalid']); } $drug = DrugRecord::where('drug_id', $drugId)->first(); $drug->delete(); return response()->json(["success" => true, "meessage" => 'deleted drug record']); }