/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $dataAccess = new ClientMng(); $dataAccess1 = new DataAccess(); $id = $dataAccess1->currentUserID(); $patient = $dataAccess->getPatient($id); $list = ['userid' => $id, 'firstName' => $patient["firstName"], 'lastName' => $patient["lastName"], 'dob' => "{$request->year}-{$request->month}-{$request->day}", 'email' => $patient["email"], 'gender' => $request->sex, 'height' => $request->height, 'weight' => $request->weight, 'mobileNum' => $request->phone, 'homeNum' => $request->home_phone, 'address' => $request->address, 'city' => $request->city, 'postalCode' => $request->postal_code, 'state' => $request->state, 'country' => $request->country, 'occupation' => $request->occupation, 'maritalStatus' => $request->status, 'nextOfKin' => $request->next_kin]; $dataAccess->clientInfoSave($list, Auth::user()->email); $json = json_encode(array("data" => $list)); // // $server = ['Content-Type'=>"application/json"]; // //"$uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null" // $postRequest = Request::create('/api/clients', 'POST', [], [], [], [], $json); $headers = $postRequest->headers; $headers->set('Content-Type', 'application/json'); $headers->set('Accept', 'application/json'); //echo print_r($headers); $response = Route::dispatch($postRequest); // $postRequest->headers = array('CONTENT_TYPE'=> 'application/json'); // $postRequest->attributes = $json; // $response = Route::dispatch($postRequest); //echo print_r($postRequest); //echo $postRequest; //// // $headers = array(); // $headers[] = 'Content-Type: application/json'; // $username = "******"; // $password = "******"; // // // create a new cURL resource // $ch = curl_init(); // // // set URL and other appropriate options // curl_setopt($ch, CURLOPT_URL, "http://localhost:8000/api/clients"); // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_HTTPGET, TRUE); // curl_setopt($ch, CURLOPT_POSTFIELDS, $json); // curl_setopt ($ch, CURLOPT_PORT , 8089); // // // grab URL and pass it to the browser // $response = curl_exec($ch); // echo print_r($response); // $info = curl_getinfo($ch); // echo print_r($info["http_code"]); // //// if ($response === false) //// { //// // throw new Exception('Curl error: ' . curl_error($crl)); //// print_r('Curl error: ' . curl_error($response)); //// } // //echo $response; // // // close cURL resource, and free up system resources // curl_close($ch); return redirect('home'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //expected request $list = ['firstName' => $request->data['firstName'], 'lastName' => $request->data['lastName'], 'email' => $request->data['email'], 'password' => bcrypt($request->data['password'])]; $dataAccess = new DataAccess(); $dataAccess->register($list); return Response::json(array('error' => false, 'data' => array('User Created')), 200); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $dataAccess = new DataAccess(); $dataAccessVisit = new VisitsMng(); $userid = $dataAccess->userIdByEmail($request->email); $list = ['userid' => $userid, 'email' => $request->email, 'height' => $request->height, 'weight' => $request->weight, 'date' => "{$request->year}-{$request->month}-{$request->day}", 'symptoms' => $request->symptoms, 'allergies' => $request->allergies, 'time' => $request->time, 'end_time' => $request->end_time]; $dataAccessVisit->visitSave($list); return redirect('/clientlist'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $dataAccess = new DataAccess(); // $clients = $dataAccess->getClientsApi(); $email = Input::get('email'); $password = Input::get('password'); $result = $dataAccess->checkLogin($email, $password); return Response::json(array('error' => false, 'data' => $result), 200); }
/** * test for saving * * @return void */ public function testSave() { $dataAccess = new DataAccess(); $dataAccess->saveMedications('test1', '15'); $dataAccess->saveMedications('test2', '40'); $testMedication = Medication::where('name', 'test1')->firstOrFail(); $this->assertEquals('40', $testMedication->quantity); $testMedication = Medication::where('name', 'test2')->firstOrFail(); $this->assertEquals('55', $testMedication->quantity); }
/** * test for saving events through data access * * @return void */ public function testDataAccessEventMethod() { $dataAccess = new DataAccess(); //save event to database $dataAccess->eventSave($dataAccess->userIdByEmail("*****@*****.**"), "Test1", "Sat Mar 12 2016 11:30:00 GMT+0000", "Sat Mar 12 2016 11:30:00 GMT+0000", "*****@*****.**", "user1"); $dataAccess->eventSave($dataAccess->userIdByEmail("*****@*****.**"), "Test2", "Sun Mar 13 2016 11:30:00 GMT+0000", "Sun Mar 13 2016 11:30:00 GMT+0000", "*****@*****.**", "user1"); $dataAccess->eventSave($dataAccess->userIdByEmail("*****@*****.**"), "Test3", "Mon Mar 14 2016 11:30:00 GMT+0000", "Mon Mar 14 2016 11:30:00 GMT+0000", "*****@*****.**", "user1"); $this->seeInDatabase('calendar', ['title' => 'Test1']); $this->seeInDatabase('calendar', ['title' => 'Test2']); $this->seeInDatabase('calendar', ['title' => 'Test3']); }
/** * test for getting events through RESTFUL API * * @return void */ public function testGetEvents() { $dataAccess = new DataAccess(); //assert that it does not return an empty lists $this->assertNotEquals(null, $dataAccess->getEvents()); }
/** * test for getting notes with doctor id * * @return void */ public function testGetNoteWithID() { $dataAccess = new DataAccess(); //Dr john Doe's notes $this->assertNotEquals(null, $dataAccess->getNotes(1)); }
/** * test for getting clients through RESTFUL API * * @return void */ public function testGetClientRecordApi() { $dataAccess = new DataAccess(); //assert that it does not return an empty list of clients $this->assertNotEquals(null, $dataAccess->getClientsApi()); //get detailed client through id, assert its not null $this->assertNotEquals(null, $dataAccess->getDetailedClientsApi($dataAccess->userIdByEmail('*****@*****.**'))); //get clients vists, assert its not null $this->assertNotEquals(null, $dataAccess->getVisits(1)); }