Ejemplo n.º 1
0
 public function patientReport(Request $request, $patientId)
 {
     if (!HospitalEmployee::isNurse()) {
         return response()->json(["success" => false, "error" => 'notlogin or notvalid']);
     }
     $height = $request->input('height');
     $weight = $request->input('weight');
     $pressure = $request->input('pressure');
     $error = [];
     if (!$height) {
         $error[] = 'height_not_found';
     }
     if (!$weight) {
         $error[] = 'weight_not_found';
     }
     if (!$pressure) {
         $error[] = 'pressure_not_found';
     }
     if (sizeof($error) != 0) {
         return response()->json(["success" => false, "message" => $error]);
     }
     $patientReport = new PatientReport();
     $patientReport->patient_id = $patientId;
     $patientReport->height = $height;
     $patientReport->weight = $weight;
     $patientReport->pressure = $pressure;
     $patientReport->save();
     return response()->json(["success" => true, "data" => $patientReport, "meessage" => 'saved record patient']);
 }
Ejemplo n.º 2
0
 public static function create(array $attributes = [])
 {
     $employee = new HospitalEmployee();
     $employee->firstname = $attributes['firstname'];
     $employee->lastname = $attributes['lastname'];
     $employee->tel = $attributes['tel'];
     $employee->email = $attributes['email'];
     $employee->role = $attributes['role'];
     if ($attributes['role'] == 'Doctor') {
         $employee->specialty = $attributes['specialty'];
     }
     $employee->valid = false;
     $employee->save();
     // this will also create the User for authentication
     $user = new User();
     // duplicate personal id to username
     $user->username = $attributes['username'];
     $user->password = Hash::make($attributes['password']);
     $user->userable_id = $employee->emp_id;
     $user->userable_type = 'App\\HospitalEmployee';
     $user->save();
     return $employee;
 }
Ejemplo n.º 3
0
 public function discardStaff($empId)
 {
     if (!HospitalEmployee::isStaff()) {
         return response()->json(["success" => false, "error" => 'notlogin or notvalid']);
     }
     $emp = HospitalEmployee::where('emp_id', $empId)->first();
     $usr = User::find($empId);
     if ($emp->valid) {
         // echo 'valid=false';
         return response()->json(["success" => false, "error" => 'valid = true']);
     }
     // DB::table('HospitalEmployee')->where('emp_id',$empId)->delete();
     $emp->delete();
     $usr->delete();
     return response()->json(["success" => true]);
 }
Ejemplo n.º 4
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]);
 }
Ejemplo n.º 5
0
 public function drugAllergic(Request $request, $patientId)
 {
     if (!HospitalEmployee::isDoctor()) {
         return response()->json(["success" => false, "error" => 'notlogin or notvalid']);
     }
     $drugAllergic = $request->input('drugAllergic');
     $error = [];
     if (!$drugAllergic) {
         $error[] = 'drugAllergic_not_found';
     }
     if (sizeof($error) != 0) {
         return response()->json(["success" => false, "message" => $error]);
     }
     $drAllergic = Patient::where('id', $patientId)->first();
     $drAllergic->drugAllergic = $drugAllergic;
     $drAllergic->save();
     return response()->json(["success" => true, "message" => 'saved drugAllergic record']);
 }
Ejemplo n.º 6
0
 public function deleteDoctorTime($doctor_time_id)
 {
     if (!HospitalEmployee::isDoctor()) {
         return response()->json(["success" => false, "messages" => ['notlogin or notvalid']]);
     }
     // if(!HospitalEmployee::isDoctor())
     //     return response()->json(["success" = false];
     $doctorTime = DoctorTime::where('doctorTime_id', $doctor_time_id)->first();
     if ($doctorTime) {
         $doctorTime->delete();
     }
     return response()->json(["success" => true]);
 }
Ejemplo n.º 7
0
 public static function getAppointmentPatient($patient_id)
 {
     if ($patient_id == null) {
         return ["success" => false, "message" => 'patient_not_found'];
     }
     // if(Patient::where('personal_id',$personal_id)->first()  ==null)
     //     return ["success" => false,
     //             "message" => 'this_patient_does_not_exist_in_database'
     //            ];
     $appointments = Appointment::orderBy('time', 'desc')->where('patient_id', $patient_id)->get();
     $result = [];
     foreach ($appointments as $appointment) {
         $doctor = HospitalEmployee::where('emp_id', $appointment->emp_id)->first();
         $result[] = ["doctor" => $doctor, "appointment" => $appointment];
     }
     if (sizeof($appointments) > 0) {
         return $result;
     } else {
         return [];
     }
 }
 public function getPhoto($emp_id)
 {
     // $entry = Fileentry::where('emp_id', '=', $emp_id)->firstOrFail();
     $employee = HospitalEmployee::where('emp_id', $emp_id)->first();
     $file = Storage::disk('local')->get($emp_id . '.' . $employee->photo_extension);
     $ext = $employee->photo_extension;
     if ($ext == 'jpeg') {
         return (new Response($file, 200))->header('Content-Type', 'image/jpeg');
     } else {
         if ($ext == 'jpg') {
             return (new Response($file, 200))->header('Content-Type', 'image/jpeg');
         } else {
             if ($ext == 'gif') {
                 return (new Response($file, 200))->header('Content-Type', 'image/gif');
             } else {
                 if ($ext == 'png') {
                     return (new Response($file, 200))->header('Content-Type', 'image/png');
                 }
             }
         }
     }
 }
 public function doctor()
 {
     $getDoctor = [];
     $doctors = HospitalEmployee::where('role', 'Doctor')->where('valid', true)->get();
     foreach ($doctors as $doctor) {
         $getDoctor[] = ['firstname' => $doctor->firstname, 'lastname' => $doctor->lastname, 'id' => $doctor->emp_id, 'specialty' => $doctor->specialty];
     }
     return response()->json(["success" => true, "data" => $getDoctor]);
 }
Ejemplo n.º 10
0
 public static function getFreeSlotBySpecialty($specialty)
 {
     $doctors = HospitalEmployee::where('role', 'Doctor')->where('specialty', $specialty)->get();
     $result = [];
     foreach ($doctors as $doctor) {
         $doctor_id = $doctor->emp_id;
         $result = array_merge($result, DoctorTIme::getFreeSlotByDoctor($doctor_id));
     }
     return $result;
 }