public function register(Request $request)
 {
     //---------- เช็คกรณีที่personal_id มีอยู่ในระบบแล้ว-------------
     if (Patient::where('personal_id', $request->input('personal_id'))->first()) {
         return response()->json(["success" => false, "message" => ['this_personal_id_has_been_used']]);
     }
     $error = [];
     $personal_id = $request->input('personal_id');
     $password = $request->input('password');
     $firstname = $request->input('firstname');
     $lastname = $request->input('lastname');
     $birthdate = $request->input('birthdate');
     $address = $request->input('address');
     $gender = $request->input('gender');
     $religion = $request->input('religion');
     $nationality = $request->input('nationality');
     $bloodtype = $request->input('bloodtype');
     $tel = $request->input('tel');
     $email = $request->input('email');
     $remark = $request->input('remark');
     if (!$personal_id) {
         $error[] = 'personal_id_not_found';
     }
     if (!$password) {
         $error[] = 'password_not_found';
     }
     if (!$firstname) {
         $error[] = 'firstname_not_found';
     }
     if (!$lastname) {
         $error[] = 'lastname_not_found';
     }
     if (!$birthdate) {
         $error[] = 'birthdate_not_found';
     }
     if (!$address) {
         $error[] = 'address_not_found';
     }
     if (!$gender) {
         $error[] = 'gender_not_found';
     }
     if (!$nationality) {
         $error[] = 'nationality_not_found';
     }
     if (!$bloodtype) {
         $error[] = 'bloodtype_not_found';
     }
     if (!$tel) {
         $error[] = 'tel_not_found';
     }
     if (!$email) {
         $error[] = 'email_not_found';
     }
     if (sizeof($error) == 0) {
         $patient = Patient::create(['personal_id' => $personal_id, 'password' => $password, 'firstname' => $firstname, 'lastname' => $lastname, 'birthdate' => $birthdate, 'address' => $address, 'gender' => $gender, 'religion' => $religion, 'nationality' => $nationality, 'bloodtype' => $bloodtype, 'tel' => $tel, 'email' => $email, 'remark' => $remark]);
         return response()->json(["success" => true, "data" => $patient->toArray()]);
     } else {
         return response()->json(["success" => false, "message" => $error]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(PatientRequest $request)
 {
     DB::transaction(function ($request) use($request) {
         $data = $request->all();
         $data['pid'] = Agency::find($data['agency_id'])->pid();
         $data['created_by'] = Auth::user()->id;
         $data['updated_by'] = Auth::user()->id;
         Patient::create($data);
     });
     flash()->success('Record added.');
     return redirect('records');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function post_register(PatientRegRequest $request)
 {
     //
     $input = $request->all();
     $password = bcrypt($request->input('password'));
     $input['password'] = $password;
     $input['activation_code'] = str_random(60) . $request->input('email');
     $register = \App\Patient::create($input);
     $data = ['first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'code' => $input['activation_code']];
     $this->sendEmail($data, $input);
     Session::flash('success', "Cek email untuk mengaktivasi akun");
     return redirect()->route('patient.register');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (App::environment() === 'production') {
         exit('Do not seed in production environment');
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     DB::table('patients')->truncate();
     Patient::create(['id' => 1, 'name' => 'S. Sudarshan', 'dob' => '1980-12-01', 'gender' => 'male', 'maritalStatus' => 'married', 'address' => 'lorem ipsum', 'homePhoneNumber' => null, 'mobileNumber' => '981890899', 'email' => null, 'annualIncome' => 300000, 'occupation' => 'bussiness', 'education' => 'College', 'religion' => 'Hindu', 'voterId' => 'qw12340', 'adharId' => null, 'aliveChildrenCount' => 2, 'deceasedChildrenCount' => 0]);
     $patientHistory['patientId'] = 1;
     $patientHistory['eventId'] = 2;
     $patientHistory['registeredBy'] = 2;
     $patientHistory['diagnosis_status'] = 'Pending';
     DB::table('patient_history')->insert($patientHistory);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PatientAdminRequest $request)
 {
     //
     $data = array();
     $data['user_id'] = 3;
     $data['first_name'] = $request->get('first_name');
     $data['last_name'] = $request->get('last_name');
     $data['gender'] = $request->get('gender');
     $data['birth_date'] = $request->get('birth_date');
     $data['email'] = $request->get('email');
     $data['password'] = $request->get('password');
     $data['mobile'] = $request->get('mobile');
     $data['telephone'] = $request->get('telephone');
     $hasil = \App\Patient::create($data);
     Session::flash('success', "Data pasien berhasil ditambahkan");
     return redirect()->route('admin.patient.index');
 }
 public function store(PatientRequest $Request)
 {
     Patient::create($Request->all());
     session()->flash('flash_message', 'A new patient has been created');
     return redirect('dash');
 }