public function create() { $user = Confide::user(); //throw new Exception($user); if (Request::isMethod('GET')) { $patient = Patient::find($user->id); return View::make('home/patient/create', compact('user', 'patient')); } elseif (Request::isMethod('POST')) { // Create a new Appointment with the given data $user = Confide::user(); $user->fill(Input::all()); $user->save(); // If patient already exists in system $patient = Patient::find($user->id); if ($patient != null) { // Retreive Patient } else { // Create a new account for the Patient $account = new Account(); $account->patient_id = $user->id; $account->save(); // Create a new Patient $patient = new Patient(); $patient->fill(Input::all()); //$patient->dob = new Date(); $patient->user_id = $user->id; $patient->save(); } return Redirect::route('home.index'); } }
public function actionAddPatient() { $this->authenUser(); $formAddPatient = new formAddPatient(); $addPatient = new Patient(); $systemCities = SystemCity::model()->findAll(); $systemCitiesData = $this->generateSystemCities($systemCities); if (isset($_POST['formAddPatient'])) { $addPatient->attributes = $_POST['formAddPatient']; $addPatient->profile_creator = $this->userId; $addPatient->regDate(); $addPatient->save(); if ($addPatient->pid != NULL) { $patientAddress = $_POST['formAddPatient']['address']; $patientCity = $_POST['formAddPatient']['city']; if ($patientAddress != '' || $patientCity != '') { $addPatientAddress = new PatientAddress(); $addPatientAddress->patient_pid = $addPatient->pid; if ($patientAddress != '') { $addPatientAddress->address = $patientAddress; } if ($patientCity != '') { $addPatientAddress->city_id = $patientCity; } $addPatientAddress->save(); $this->redirect(array('manage/selectPatient')); } } Yii::app()->end(); } $formAddPatient->generatePassword(); $this->render('addPatient', array('formAddPatient' => $formAddPatient, 'systemCitiesData' => $systemCitiesData)); }
public function postRegister() { $validationRules = array('email' => 'required|email|unique:users', 'password' => 'required|min:8|confirmed', 'type' => 'required'); $formValidator = Validator::make(Input::all(), $validationRules); if ($formValidator->passes()) { // creatting new user $createUser = new User(); $createUser->email = Input::get('email'); $createUser->type = Input::get('type'); $createUser->password = Hash::make(Input::get('password')); $createUser->status = 'OFF'; $createUser->save(); // checking to create if user is patient or physician if ($createUser->type == 'PHYSICIAN') { $createPhysisician = new Physician(); $createPhysisician->user_id = $createUser->id; $createPhysisician->save(); } if ($createUser->type == 'PATIENT') { $createPatient = new Patient(); $createPatient->user_id = $createUser->id; $createPatient->save(); } return Redirect::to('user/login')->with('success', ' Account created, please login'); } else { return Redirect::back()->withInput()->withErrors($formValidator); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $rules = array('patient_number' => 'required|unique:patients,patient_number', 'name' => 'required', 'gender' => 'required', 'dob' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(Input::all()); } else { // store $patient = new Patient(); $patient->patient_number = Input::get('patient_number'); $patient->name = Input::get('name'); $patient->gender = Input::get('gender'); $patient->dob = Input::get('dob'); $patient->email = Input::get('email'); $patient->address = Input::get('address'); $patient->phone_number = Input::get('phone_number'); $patient->created_by = Auth::user()->id; try { $patient->save(); $url = Session::get('SOURCE_URL'); return Redirect::to($url)->with('message', 'Successfully created patient!'); } catch (QueryException $e) { Log::error($e); } // redirect } }
function approve($id) { if ($_POST) { $rs = new Patient($id); $rs->from_array($_POST); $rs->save(); } }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aPatient !== null) { if ($this->aPatient->isModified() || $this->aPatient->isNew()) { $affectedRows += $this->aPatient->save($con); } $this->setPatient($this->aPatient); } if ($this->aVisit !== null) { if ($this->aVisit->isModified() || $this->aVisit->isNew()) { $affectedRows += $this->aVisit->save($con); } $this->setVisit($this->aVisit); } if ($this->aPharma !== null) { if ($this->aPharma->isModified() || $this->aPharma->isNew()) { $affectedRows += $this->aPharma->save($con); } $this->setPharma($this->aPharma); } if ($this->aDosage !== null) { if ($this->aDosage->isModified() || $this->aDosage->isNew()) { $affectedRows += $this->aDosage->save($con); } $this->setDosage($this->aDosage); } if ($this->isNew()) { $this->modifiedColumns[] = VisitMedicinePeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = VisitMedicinePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += VisitMedicinePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Store a newly created patient in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Patient::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $patient = new Patient(); $patient->name = Input::get('name'); // $patient->save(); $patient->dob = Input::get('dob'); //$patient->save(); if (Input::has('email')) { $patient->email = Input::get('email'); // $patient->save(); } else { $patient->email = 'N/A'; //$patient->save(); } $patient->gender = Input::get('gender'); //$patient->save(); $patient->age = Input::get('age'); //$patient->save(); $patient->city = Input::get('city'); //$patient->save(); $patient->country = Input::get('country'); // $patient->save(); $patient->address = Input::get('address'); //$patient->save(); if (Input::get('phone') == '') { $patient->phone = 'N/A'; } else { $patient->phone = Input::get('phone'); } // $patient->save(); if (Input::get('cnic') == '') { $patient->cnic = 'N/A'; } else { $patient->cnic = Input::get('cnic'); } //$patient->save(); if (Input::get('note') == '') { $patient->note = 'N/A'; } else { $patient->note = Input::get('note'); } //$patient->save(); $patient->status = "OPD"; $patient->patient_id = "P0" . $patient->id; $patient->save(); if (Input::has('email')) { $data = ['name' => Input::get('name')]; Mail::queue('emails.patient_welcome', $data, function ($message) { $message->to(Input::get('email'), Input::get('name'))->subject('Welcome to EMR!'); }); } return Redirect::route('patients.index'); }
public function insert() { //echo "in insert controller"; include 'model/patient.php'; $patient = new Patient($_POST["username"], $_POST["password"], $_POST["name"], $_POST["age"], $_POST["contact"], $_POST["doctor"], $_POST["hospital"]); // var_dump($patient); // die(); $patient->save(); header('location: view/patient/registered.php'); }
public function store() { if (Request::ajax()) { $data = array("agenda_id" => Input::get("agenda_id"), "patient" => Input::get("patient"), "reason" => Input::get("reason"), "fecha" => Input::get("fecha"), "start" => Input::get("start"), "end" => Input::get("end")); $rules = array("agenda_id" => 'required', "patient" => 'required|min:2|max:100', "reason" => 'required|min:2|max:200', "fecha" => 'required|min:1|max:100', "start" => 'required|min:1|max:100', "end" => 'required|min:1|max:100'); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores if ($validation->fails()) { return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray())); } else { $agenda = Agenda::find(Input::get('agenda_id')); $user = User::where('email', Input::get('patient'))->orWhere('username', Input::get('patient'))->first(); if ($user) { $patient = Patient::where('user_id', $user->id)->first(); if (!$patient) { $patient = new Patient(); $patient->user_id = $user->id; $patient->save(); } $docPatient = DoctorPatient::where('patient_id', $patient->id)->where('doctor_id', $agenda->doctor_id)->first(); if (!$docPatient) { $docPatient = new DoctorPatient(); $docPatient->patient_id = $patient->id; $docPatient->doctor_id = $agenda->doctor_id; $docPatient->save(); } $apo = new Appointment(); $apo->patient_id = $patient->id; $apo->agenda_id = $agenda->id; $apo->day = Input::get("fecha"); $apo->start_date = Input::get('start'); $apo->end_date = Input::get('end'); $apo->reason = Input::get('reason'); if ($agenda->appointment_state == 0) { $apo->state = 'confirmed'; } else { $apo->state = 'pending'; } $apo->save(); if ($apo) { if ($agenda->appointment_state == 0) { $mgs = new MgsAppointment(); $mgs->appointment_id = $apo->id; $mgs->text = "Su cita fue Confirmada"; $mgs->save(); } return Response::json(array('success' => true)); } } else { return Response::json(array('success' => false, 'errors' => 'El usuario no existe')); } } } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $response = null; $patient = new Patient(); // se valida que la petición sea por post if (Request::isMethod('POST')) { // se validan las entradas antes de intentar crear un nuevo usuario Log::info(Input::all()); if ($this->isValidForAdd()) { if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.IDENTIFICATION_TYPE_ID')))) { $patient->identificationTypeId = Input::get(Config::get('constants.PATIENT.ATTRS.IDENTIFICATION_TYPE_ID')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.MARITAL_STATUS_ID')))) { $patient->maritalStatusId = Input::get(Config::get('constants.PATIENT.ATTRS.MARITAL_STATUS_ID')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.NAME')))) { $patient->name = Input::get(Config::get('constants.PATIENT.ATTRS.NAME')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.LASTNAME')))) { $patient->lastname = Input::get(Config::get('constants.PATIENT.ATTRS.LASTNAME')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.IDENTIFICATION_NUMBER')))) { $patient->identificationNumber = Input::get(Config::get('constants.PATIENT.ATTRS.IDENTIFICATION_NUMBER')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.PLACEBIRTH')))) { $patient->placebirth = Input::get(Config::get('constants.PATIENT.ATTRS.PLACEBIRTH')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.BIRTHDATE')))) { $patient->birthdate = Input::get(Config::get('constants.PATIENT.ATTRS.BIRTHDATE')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.GENDER')))) { $patient->gender = Input::get(Config::get('constants.PATIENT.ATTRS.GENDER')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.OCCUPATION')))) { $patient->occupation = Input::get(Config::get('constants.PATIENT.ATTRS.OCCUPATION')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.RESIDENCE_CITY')))) { $patient->residenceCity = Input::get(Config::get('constants.PATIENT.ATTRS.RESIDENCE_CITY')); } if (!empty(Input::get(Config::get('constants.PATIENT.ATTRS.ADDRESS')))) { $patient->address = Input::get(Config::get('constants.PATIENT.ATTRS.ADDRESS')); } $patient->save(); // seguardan los datos de los responsables $custodians = Input::get(Config::get('constants.CUSTODIANS')); foreach ($custodians as $custodian) { $this->storeCustodian($custodian, $patient->patientId); } $response = $this->responseCreatedSuccessfulElement($patient, new PatientTransformer()); } else { $response = $this->respondWithError($this->getErrors(), self::CODE_WRONG_ARGUMENTS); } } return $response; }
public function actionSeed() { $patients = new Patient(); $patients->attributes = array('name' => '鍾**', 'sex' => 1, 'birthday' => '1989-10-21', 'birth_weight' => 3000, 'telphone' => '08-735****', 'cellphone' => '0917******', 'address' => '屏東市**********', 'doctor_id' => 1, 'icd' => ''); $patients->save(); $patients = new Patient(); $patients->attributes = array('name' => '林**', 'sex' => 1, 'birthday' => '1989-08-12', 'birth_weight' => 3000, 'telphone' => '08-735****', 'cellphone' => '0917******', 'address' => '新北市*******', 'doctor_id' => 1, 'icd' => ''); $patients->save(); $icd = new Icd(); $icd->attributes = array('name' => '1號疾病', 'description' => ''); $icd->save(); $icd = new Icd(); $icd->attributes = array('name' => '2號疾病', 'description' => ''); $icd->save(); }
/** * 匯入病歷 */ public function actionPatients() { $this->currentActive = '病歷'; $excel = new ExcelUploadForm(); $rows = array(); $errors = array(); if (isset($_POST['ExcelUploadForm'])) { $excel->attributes = $_POST['ExcelUploadForm']; $excel->file = CUploadedFile::getInstance($excel, 'file'); $transaction = Yii::app()->db->beginTransaction(); try { if ($excel->validate()) { $rows = $excel->getContents(); foreach ($rows as $i => $row) { if ($i != ExcelUploadForm::HEADER) { $patient = new Patient(); $patient->id = $row[1]; $patient->name = $row[2]; $patient->sex = $this->_getConvertSexData($row[3]); $patient->birthday = $row[4]; $patient->telphone = $row[5]; $patient->cellphone = $row[6]; $patient->address = $row[7]; $patient->birth_weight = $row[8]; $patient->family_history = $row[9]; $patient->pregnancy_history = $row[10]; $patient->fetus = $row[11]; if (!$patient->save()) { $errorData = array($patient->name => $patient->getErrors()); $errors[] = $errorData; } } } $transaction->commit(); } else { $errors[] = array('Excel' => $excel->getErrors()); } } catch (Exception $e) { $transaction->rollBack(); $errors = $e->getMessage(); } $this->_setFlashMessage($errors); $this->redirect($this->createUrl("/excel/import/{$this->action->id}")); } $this->render('upload', array('excel' => $excel)); }
/** * Display a listing of the resource. * GET /patientregistration * * @return Response */ public function registration() { $destinationPath = public_path('patient_image/'); $link_address = "/view/patients_managment/appointment"; $patient_id = null; $rules = array('field_email' => 'required|email', 'field_password' => 'required|min:3|confirmed', 'field_password' => 'required|min:3', 'field_name' => 'required', 'field_dob' => 'required', 'field_gender' => 'required', 'field_religion' => 'required', 'field_visitNo' => 'required'); $data = Input::all(); // Create a new validator instance. $validator = Validator::make($data, $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator); } else { if (!Input::hasFile('field_image')) { return Redirect::back()->withErrors("Image is required"); } else { $photo_fileName = null; if (Input::hasFile('field_image')) { $photo = Input::file('field_image'); $photo_fileName = strtotime(date('Y-m-d H:i:s')) . md5($photo->getClientOriginalName()) . "." . $photo->getClientOriginalExtension(); $photo->move($destinationPath, $photo_fileName); } $user = new User(); $user->email = Input::get('field_email'); $user->password = Hash::make(Input::get('field_password')); $user->access_level = '4'; if ($user->save()) { $patient = new Patient(); $patient->name = $data['field_name']; $patient->dob = $data['field_dob']; $patient->gender = $data['field_gender']; $patient->religion = $data['field_religion']; $patient->no_of_visit = $data['field_visitNo']; $patient->image = $photo_fileName; $patient->report = $user->id; if ($patient->save()) { return Redirect::route('login'); } else { return Redirect::back()->withErrors('Something Went wrong, please try again'); } } else { return Redirect::back()->withErrors('Something Went wrong, please try again'); } } } }
public function actionCreate() { $patient = new Patient(); $doctors = Doctor::model()->findAll(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($patient); if (isset($_POST['Patient'])) { if (empty($_POST['Patient']['id'])) { unset($_POST['Patient']['id']); } $patient->attributes = $_POST['Patient']; if ($patient->save()) { Yii::app()->user->setFlash('success', '儲存成功.'); $this->redirect(array('update', 'id' => $patient->id)); } } $this->render('create', array('patient' => $patient, 'doctors' => $doctors)); }
public function executeAddPatient(sfWebRequest $request) { if ($request->isMethod('Post')) { /*$a = new Criteria(); $designation_record = DesignationPeer::DoSelectOne($a); $department_id = $designation_record->getDepartmentId();*/ $patient = new Patient(); $dob = $this->getRequestParameter('dob[year]') . '-' . $this->getRequestParameter('dob[month]') . '-' . $this->getRequestParameter('dob[day]'); $patient->setName($this->getRequestParameter('name')); $patient->setCnic($this->getRequestParameter('cnic')); $patient->setDob($dob); $patient->setGender($this->getRequestParameter('gender[0]')); $patient->setContactCell($this->getRequestParameter('contact_cell')); $patient->setStatus(Constant::RECORD_STATUS_ACTIVE); $patient->save(); $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Patient Added Successfully'); $this->redirect('Patient/list'); } // end if }
/** * Show the form for creating a new resource. * GET /patients/create * * @return Response */ public function patienstRegistration() { $destinationPath = public_path('patient_image/'); $link_address = "/view/patients_managment/appointment"; $patient_id = null; $rules = ['field_name' => 'required', 'field_dob' => 'required', 'field_gender' => 'required', 'field_religion' => 'required', 'field_visitNo' => 'required']; $data = Input::all(); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator); } else { if (!Input::hasFile('field_image')) { return Redirect::back()->withErrors("Image is required"); } else { $photo_fileName = null; if (Input::hasFile('field_image')) { $photo = Input::file('field_image'); $photo_fileName = strtotime(date('Y-m-d H:i:s')) . md5($photo->getClientOriginalName()) . "." . $photo->getClientOriginalExtension(); $photo->move($destinationPath, $photo_fileName); } $patient = new Patient(); $patient->name = $data['field_name']; $patient->dob = $data['field_dob']; $patient->gender = $data['field_gender']; $patient->religion = $data['field_religion']; $patient->no_of_visit = $data['field_visitNo']; $patient->image = $photo_fileName; if ($patient->save()) { $patient_id = $patient->id; return Redirect::route('view.patients_managment', array('option' => 'create'))->with('success', 'Successfully Created!<br/><a href="appointment/' . $patient_id . '">click here </a><p>for make new appointment</p>'); } else { return Redirect::route('view.patients_managment', array('option' => 'create'))->with('error', 'Something Went Wrong. Try Again.'); } } } }
public function actionCreatePatientAndSick() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $name = StringHelper::filterString($request->getPost('name')); $dob = StringHelper::filterString($request->getPost('dob')); $gender = StringHelper::filterString($request->getPost('gender')); $user_id = StringHelper::filterString($request->getPost('user_id')); $relation = StringHelper::filterString($request->getPost('relationshipWithUser')); $blood = StringHelper::filterString($request->getPost('bloodType')); $sicks = StringHelper::filterString($request->getPost('sicks')); $patient_model = new Patient(); $patient_model->name = $name; $patient_model->dob = $dob; $patient_model->gender = $gender; $patient_model->last_updated = time(); $patient_model->bloodType = $blood; $patient_model->relationshipWithUser = $relation; $patient_model->save(FALSE); $user_patient = new UserPatient(); $user_patient->user_id = $user_id; $user_patient->patient_id = $patient_model->patient_id; $user_patient->save(FALSE); $sick_arr = json_decode($sicks); foreach ($sick_arr as $sick) { $model = new PatientSick(); $model->patient_id = $user_patient->patient_id; $model->sick_id = $sick; $model->save(FALSE); $this->createScheduleSick($sick, $patient_id); } $this->retVal->message = "Success"; $this->retVal->patient_id = $patient_model->patient_id; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } header('Content-type: application/json'); echo CJSON::encode($this->retVal); Yii::app()->end(); } }
die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe); } catch (Exception $e) { SmartTest::instance()->progress(); } RedBean_OODB::setEngine("myisam"); SmartTest::instance()->canwe = "performance monitor"; R::gen("Patient"); $patient = new Patient(); $patient->surname = "Van Dalen"; $patient->address = "Street 1"; $patient->save(); for ($i = 0; $i < 100; $i++) { $patient = new Patient(); $patient->surname = "Waals {$i} "; $patient->address = "Street 2{$i} "; $patient->save(); } $dummy = new Patient(); $dummy->address = "lane"; $db->exec("insert into searchindex VALUES(null,'filler1',0) "); $db->exec("insert into searchindex VALUES(null,'filler2',0) "); $db->exec("insert into searchindex VALUES(null,'filler3',0) "); $db->exec("insert into searchindex VALUES(null,'filler4',0) "); $db->exec("insert into searchindex VALUES(null,'filler5',0) "); $db->exec("insert into searchindex VALUES(null,'patient.address',0) "); $db->exec("update searchindex set cnt=100 where ind='patient.address' "); $db->exec("update searchindex set cnt=0 where ind!='patient.address' "); if (count($db->get("SHOW INDEX FROM patient")) !== 1) { die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe); } else { SmartTest::instance()->progress();
public function createPatientUser($attr) { $flag = FALSE; $flag_2 = FALSE; $patient_model = new Patient(); $patient_model->setAttributes($attr); if ($patient_model->save(FALSE)) { $flag = TRUE; } $user_patient = new UserPatient(); $user_patient->user_id = $attr['user_id']; $user_patient->patient_id = $patient_model->patient_id; if ($user_patient->save(FALSE)) { $flag_2 = TRUE; } if ($flag && $flag_2) { return $patient_model->patient_id; } return FALSE; }
public function testRandomData_ParamSetOff_ReturnsFalse() { Yii::app()->params['pseudonymise_patient_details'] = false; $attributes = array('hos_num' => 5550101, 'first_name' => 'Rod', 'last_name' => 'Flange', 'dob' => '1979-09-08', 'title' => 'MR', 'primary_phone' => '0208 1111111', 'address_id' => 1); $patient = new Patient(); $patient->setAttributes($attributes); $patient->save(); $this->assertEquals($attributes['hos_num'], $patient->getAttribute('hos_num'), 'Data should not have changed.'); }
public function savePatient() { $adminId = Session::get('admin_id'); if (!isset($adminId)) { return json_encode(array('message' => 'not logged')); } $email = Input::get('email'); if ($this->isDuplicatePatient($email) === "no") { $patient = new Patient(); $patient->name = Input::get('name'); $patient->gender = Input::get('gender'); $patient->email = $email; $patient->contact_number = Input::get('contact_number'); $patient->country = Input::get('country'); $patient->institute_id = Session::get('institute_id'); $patient->status = "active"; $patient->created_at = date("Y-m-d h:i:s"); $patient->updated_at = date("Y-m-d h:i:s"); $patient->save(); return json_encode(array('message' => 'done')); } else { return json_encode(array('message' => 'duplicate')); } }
/** * Function for processing the requests we receive from the external system * and putting the data into our system. * * @var array lab_requests */ public function process($labRequest) { //First: Check if patient exists, if true dont save again $patient = Patient::where('external_patient_number', '=', $labRequest->patient->id)->get(); if (!$patient->first()) { $patient = new Patient(); $patient->external_patient_number = $labRequest->patient->id; $patient->patient_number = $labRequest->patient->id; $patient->name = $labRequest->patient->fullName; $gender = array('Male' => Patient::MALE, 'Female' => Patient::FEMALE); $patient->gender = $gender[$labRequest->patient->gender]; $patient->dob = $labRequest->patient->dateOfBirth; $patient->address = $labRequest->address->address; $patient->phone_number = $labRequest->address->phoneNumber; $patient->created_by = User::EXTERNAL_SYSTEM_USER; $patient->save(); } else { $patient = $patient->first(); } //We check if the test exists in our system if not we just save the request in stagingTable if ($labRequest->parentLabNo == '0') { $testTypeId = TestType::getTestTypeIdByTestName($labRequest->investigation); } else { $testTypeId = null; } if (is_null($testTypeId) && $labRequest->parentLabNo == '0') { $this->saveToExternalDump($labRequest, ExternalDump::TEST_NOT_FOUND); return; } //Check if visit exists, if true dont save again $visitType = array('ip' => 'In-patient', 'op' => 'Out-patient'); //Should be a constant $visit = Visit::where('visit_number', '=', $labRequest->patientVisitNumber)->where('visit_type', '=', $visitType[$labRequest->orderStage])->get(); if (!$visit->first()) { $visit = new Visit(); $visit->patient_id = $patient->id; $visit->visit_type = $visitType[$labRequest->orderStage]; $visit->visit_number = $labRequest->patientVisitNumber; // We'll save Visit in a transaction a little bit below } else { $visit = $visit->first(); if (strcmp($visitType[$labRequest->orderStage], $visit->visit_type) != 0) { $visit = new Visit(); $visit->patient_id = $patient->id; $visit->visit_type = $visitType[$labRequest->orderStage]; $visit->visit_number = $labRequest->patientVisitNumber; } } $test = null; //Check if parentLabNO is 0 thus its the main test and not a measure if ($labRequest->parentLabNo == '0') { //Check via the labno, if this is a duplicate request and we already saved the test $test = Test::where('external_id', '=', $labRequest->labNo)->get(); if (!$test->first()) { //Specimen $specimen = new Specimen(); $specimen->specimen_type_id = TestType::find($testTypeId)->specimenTypes->lists('id')[0]; // We'll save the Specimen in a transaction a little bit below $test = new Test(); $test->test_type_id = $testTypeId; $test->test_status_id = Test::NOT_RECEIVED; $test->created_by = User::EXTERNAL_SYSTEM_USER; //Created by external system 0 $test->requested_by = $labRequest->requestingClinician; $test->external_id = $labRequest->labNo; DB::transaction(function () use($visit, $specimen, $test) { $visit->save(); $specimen->save(); $test->visit_id = $visit->id; $test->specimen_id = $specimen->id; $test->save(); }); $this->saveToExternalDump($labRequest, $test->id); return; } } $this->saveToExternalDump($labRequest, null); }
public function postaddPatient() { if (Request::ajax()) { $data = array("agenda_id" => Input::get("agenda_id"), "first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email")); $rules = array("agenda_id" => 'required', "first_name" => 'required|min:2|max:50', "last_name" => 'required|min:2|max:50', "email" => 'required|email|min:1|max:50'); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores if ($validation->fails()) { return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray())); } else { $password = $this->generaPass(); $agenda = Agenda::find(Input::get('agenda_id')); $user = new User(); $user->first_name = Input::get("first_name"); $user->last_name = Input::get("last_name"); $user->email = Input::get("email"); $user->password = $password; $user->username = Input::get("first_name") . Input::get("last_name"); $user->activated = 1; $user->save(); if ($user) { $doctorUser = Sentry::getUserProvider()->findByLogin($user->email); $doctorsyGroup = Sentry::getGroupProvider()->findByName('Patients'); $doctorUser->addGroup($doctorsyGroup); $profile = new Profile(); $profile->user_id = $user->id; $profile->save(); $patient = new Patient(); $patient->user_id = $user->id; $patient->save(); $docPatient = new DoctorPatient(); $docPatient->patient_id = $patient->id; $docPatient->doctor_id = $agenda->doctor_id; $docPatient->save(); $subject = 'Registro por Clinica | smartdoctorappointments.com'; $name = $user->first_name; $email = $user->email; $data = array('name' => $user->first_name . " " . $user->last_name, 'password' => $password, 'email' => $user->email); Mail::send('email.userpatiendadd', $data, function ($message) use($name, $email, $subject) { $message->to($email, $name); $message->subject($subject); }); return Response::json(array('success' => true, 'email' => Input::get("email"))); } else { return Response::json(array('success' => false, 'errors' => 'Error al registrar este usuario.')); } } } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->truncate(); DB::table('patients')->truncate(); DB::table('doctors')->truncate(); DB::table('clinics')->truncate(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'diego10', 'first_name' => 'Diego', 'last_name' => 'Serras', 'activated' => 1)); $c1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'jose10', 'first_name' => 'Jose', 'last_name' => 'Gonzalez', 'activated' => 1)); $c1_ = new Clinic(); $c1_->user_id = $c1->id; $c1_->name = "Clinica Medica Raul Ortega"; $c1_->save(); $c2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'alber10', 'first_name' => 'Alberto', 'last_name' => 'Perdomo', 'activated' => 1)); $c2_ = new Clinic(); $c2_->user_id = $c2->id; $c2_->name = "Clinica Medica Jose Pineda"; $c2_->save(); $d1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'martha10', 'first_name' => 'Martha', 'last_name' => 'Mendoza', 'activated' => 1)); $d1_ = new Doctor(); $d1_->user_id = $d1->id; $d1_->clinic_id = $c2_->id; $d1_->save(); $d2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'jairo10', 'first_name' => 'Jairo', 'last_name' => 'Flores', 'activated' => 1)); $d2_ = new Doctor(); $d2_->user_id = $d2->id; $d2_->clinic_id = $c2_->id; $d2_->save(); $d3 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'gabriela10', 'first_name' => 'Gabriela', 'last_name' => 'del Cid', 'activated' => 1)); $d3_ = new Doctor(); $d3_->user_id = $d3->id; $d3_->clinic_id = $c2_->id; $d3_->save(); $d4 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'keiry10', 'first_name' => 'Keiry', 'last_name' => 'Rivas', 'activated' => 1)); $d4_ = new Doctor(); $d4_->user_id = $d4->id; $d4_->save(); $d5 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'mabel10', 'first_name' => 'Mabel', 'last_name' => 'Mendoza', 'activated' => 1)); $d5_ = new Doctor(); $d5_->user_id = $d5->id; $d5_->save(); $p1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'John10', 'first_name' => 'Jonh', 'last_name' => 'Smith', 'activated' => 1)); $p1_ = new Patient(); $p1_->user_id = $p1->id; $p1_->save(); $p2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Orlando10', 'first_name' => 'Orlando', 'last_name' => 'Arias', 'activated' => 1)); $p2_ = new Patient(); $p2_->user_id = $p2->id; $p2_->main = $p1_->id; $p2_->relationship = 'son'; $p2_->save(); $p3 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Alejandra10', 'first_name' => 'Alejandra', 'last_name' => 'Cerna', 'activated' => 1)); $p3_ = new Patient(); $p3_->user_id = $p3->id; $p3_->main = $p1_->id; $p3_->relationship = 'daughter'; $p3_->save(); $p4 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Maria10', 'first_name' => 'Maria', 'last_name' => 'Polio', 'activated' => 1)); $p4_ = new Patient(); $p4_->user_id = $p4->id; $p3_->main = $p1_->id; $p3_->relationship = 'wife'; $p4_->save(); $p5 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Rodrigo10', 'first_name' => 'Rodrigo', 'last_name' => 'Jandres', 'activated' => 1)); $p5_ = new Patient(); $p5_->user_id = $p5->id; $p5_->save(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Patient::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $patient = new Patient(); $ward = Wards::find(Input::get('ward')); // $patient->ward_id = $ward->id; $patient->ward_id = $ward->id; // $patient->save(); $patient->name = Input::get('name'); // $patient->save(); $patient->dob = Input::get('dob'); // $patient->save(); if (Input::has('email')) { $patient->email = Input::get('email'); // $patient->save(); } else { $patient->email = 'N/A'; // $patient->save(); } $patient->gender = Input::get('gender'); // $patient->save(); $patient->age = Input::get('age'); // $patient->save(); $patient->city = Input::get('city'); // $patient->save(); $patient->country = Input::get('country'); // $patient->save(); $patient->address = Input::get('address'); // $patient->save(); // $patient->ward = Input::get('ward'); // $patient->save(); $patient->bed = Input::get('bed'); // $patient->save(); // $beds = Beds::find('status'); // $beds ='active'; // $beds->save(); // exit(); // $patient->$bedid ='active'; // $bedid->save(); $patient->status = 'IPD'; $patient->room = Input::get('room'); // $patient->save(); if (Input::get('phone') == '') { $patient->phone = 'N/A'; } else { $patient->phone = Input::get('phone'); } // $patient->save(); if (Input::get('cnic') == '') { $patient->cnic = 'N/A'; } else { $patient->cnic = Input::get('cnic'); } // $patient->save(); if (Input::get('note') == '') { $patient->note = 'N/A'; } else { $patient->note = Input::get('note'); } // $patient->save(); $patient->patient_id = "P0" . $patient->id; $patient->save(); \Illuminate\Support\Facades\DB::update("update beds set status='inactive' where id='{$patient->bed}'"); \Illuminate\Support\Facades\DB::update("update rooms set status='inactive' where id='{$patient->room}'"); echo "this is"; // if(Input::has('email')){ // $data = ['name' => Input::get('name')]; // Mail::queue('emails.patient_welcome', $data, function($message) // { // $message->to(Input::get('email'), Input::get('name'))->subject('Welcome to EMR!'); // }); // } // "agya"; // // return Redirect::to('ipd_patient'); }
public function save() { $family_planning = ""; $other_illness_listing = ""; $other_allergies_listing = ""; $patient = ""; $family_planning = $this->input->post('family_planning_holder', TRUE); if ($family_planning == null) { $family_planning = ""; } $drug_prophylaxis = $this->input->post('drug_prophylaxis_holder', TRUE); if ($drug_prophylaxis == null) { $drug_prophylaxis = ""; } $other_illness_listing = $this->input->post('other_illnesses_holder', TRUE); if ($other_illness_listing == null) { $other_illness_listing = ""; } $other_chronic = $this->input->post('other_chronic', TRUE); if ($other_chronic != "") { if ($other_illness_listing) { $other_illness_listing = $other_illness_listing . "," . $other_chronic; } else { $other_illness_listing = $other_chronic; } } //Other allergies $other_allergies_list = $this->input->post('other_allergies_listing', TRUE); //List of drug allergies. $drug_allergies = $this->input->post('drug_allergies_holder', TRUE); if ($drug_allergies == null) { $drug_allergies = ""; } if ($drug_allergies != "") { if ($other_allergies_list) { $other_allergies_listing = $other_allergies_list . "," . $drug_allergies; } else { $other_allergies_listing = $drug_allergies; } } else { $other_allergies_listing = $other_allergies_list; } //Patient Information & Demographics $new_patient = new Patient(); $new_patient->Medical_Record_Number = $this->input->post('medical_record_number', TRUE); $new_patient->Patient_Number_CCC = $this->input->post('patient_number', TRUE); $new_patient->First_Name = $this->input->post('first_name', TRUE); $new_patient->Last_Name = $this->input->post('last_name', TRUE); $new_patient->Other_Name = $this->input->post('other_name', TRUE); $new_patient->Dob = $this->input->post('dob', TRUE); $new_patient->Pob = $this->input->post('pob', TRUE); $new_patient->Gender = $this->input->post('gender', TRUE); $new_patient->Pregnant = $this->input->post('pregnant', TRUE); $new_patient->Start_Weight = $this->input->post('weight', TRUE); $new_patient->Start_Height = $this->input->post('height', TRUE); $new_patient->Start_Bsa = $this->input->post('surface_area', TRUE); $new_patient->Weight = $this->input->post('weight', TRUE); $new_patient->Height = $this->input->post('height', TRUE); $new_patient->Sa = $this->input->post('surface_area', TRUE); $new_patient->Phone = $this->input->post('phone', TRUE); $new_patient->SMS_Consent = $this->input->post('sms_consent', TRUE); $new_patient->Physical = $this->input->post('physical', TRUE); $new_patient->Alternate = $this->input->post('alternate', TRUE); //Patient History $new_patient->Partner_Status = $this->input->post('partner_status', TRUE); $new_patient->Disclosure = $this->input->post('disclosure', TRUE); $new_patient->Fplan = $family_planning; $new_patient->Other_Illnesses = $other_illness_listing; $new_patient->Other_Drugs = $this->input->post('other_drugs', TRUE); $new_patient->Adr = $other_allergies_listing; //other drug allergies $new_patient->Support_Group = $this->input->post('support_group_listing', TRUE); $new_patient->Smoke = $this->input->post('smoke', TRUE); $new_patient->Alcohol = $this->input->post('alcohol', TRUE); $new_patient->Tb = $this->input->post('tb', TRUE); $new_patient->tb_category = $this->input->post('tbcategory', TRUE); $new_patient->Tbphase = $this->input->post('tbphase', TRUE); $new_patient->Startphase = $this->input->post('fromphase', TRUE); $new_patient->Endphase = $this->input->post('tophase', TRUE); //Program Information $new_patient->Date_Enrolled = $this->input->post('enrolled', TRUE); $new_patient->Current_Status = $this->input->post('current_status', TRUE); //$new_patient -> Status_Change_Date = $this -> input -> post('status_started', TRUE); $new_patient->Source = $this->input->post('source', TRUE); $new_patient->Transfer_From = $this->input->post('transfer_source', TRUE); $new_patient->drug_prophylaxis = $this->input->post('drug_prophylaxis', TRUE); $new_patient->Facility_Code = $this->session->userdata('facility'); $new_patient->Service = $this->input->post('service', TRUE); $new_patient->Start_Regimen = $this->input->post('regimen', TRUE); $new_patient->Current_Regimen = $this->input->post('regimen', TRUE); $new_patient->Start_Regimen_Date = $this->input->post('service_started', TRUE); $new_patient->Tb_Test = $this->input->post('tested_tb', TRUE); $new_patient->Pep_Reason = $this->input->post('pep_reason', TRUE); $new_patient->who_stage = $this->input->post('who_stage', TRUE); $new_patient->drug_prophylaxis = $drug_prophylaxis; $new_patient->isoniazid_start_date = $this->input->post('iso_start_date', TRUE); $new_patient->isoniazid_end_date = $this->input->post('iso_end_date', TRUE); $spouse_no = $this->input->post('match_spouse'); $patient_no = $this->input->post('patient_number'); $child_no = $this->input->post('match_parent'); $new_patient->save(); //Map patient to spouse if ($spouse_no != NULL) { $this->merge_spouse($patient_no, $spouse_no); } //Map child to parent/guardian if ($child_no != NULL) { $this->merge_parent($patient_no, $child_no); } $sql = "SELECT MAX(id) as id FROM patient"; $query = $this->db->query($sql); $result = $query->result_array(); $auto_id = $result[0]['id']; $patient = $this->input->post('patient_number', TRUE); $direction = $this->input->post('direction', TRUE); if ($direction == 0) { $this->session->set_userdata('msg_save_transaction', 'success'); $this->session->set_flashdata('dispense_updated', 'Patient: ' . $this->input->post('first_name', TRUE) . " " . $this->input->post('last_name', TRUE) . ' was Saved'); redirect("patient_management"); } else { if ($direction == 1) { redirect("dispensement_management/dispense/{$auto_id}"); } } }