public function actionRegInHandler() { $icno = $_POST['icno']; $visitor = Visitor::findOne(['icno' => $icno]); if (!$visitor) { $visitor = new Visitor(); $visitor->name = $_POST['name']; $visitor->icno = $_POST['icno']; $visitor->tel = $_POST['tel']; $visitor->save(); } $visit = new Visit(); $visit->visitor_id = $visitor->id; $visit->visit_dt = date('Y-m-d'); $visit->in_dt = date('Y-m-d H:i:s'); $visit->dept = $_POST['dept']; $visit->to_meet = $_POST['to_meet']; $visit->pass_no = $_POST['pass_no']; $visit->in_remark = $_POST['in_remark']; $visit->purpose = $_POST['purpose']; $visit->num = $_POST['num']; $visit->status = 'I'; //var_dump($_POST); $visit->save(); return $this->redirect('index.php?r=visitor/form&sts=1'); }
/** * Updates an existing Visit model. * If update is successful, the browser will be redirected to the 'update' page. * @param integer $id * @return mixed */ public function actionUpdate($id = null, $partner_id = null) { if ($id) { $model = $this->findModel($id); } else { $model = new Visit(); } if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.')); return $this->redirect(['index']); } else { if (!$id) { $model->timestamp = Yii::$app->formatter->asDate(time()); $model->user_id = Yii::$app->user->id; if ($partner_id) { $model->partner_id = $partner_id; } } return $this->renderAjax('update', ['model' => $model]); } }
/** * @return string */ public function actionIndex() { $visit = new Visit(); //$userHost = Yii::$app->request->userHost; $userIP = Yii::$app->request->userIP; if ($userIP) { $visit->ip = $userIP; } //if(isset($_SERVER['HTTP_REFERER'])) $visit->refer = $_SERVER['HTTP_REFERER']; $visit->refer = self::get_all_ip(); $visit->browser = implode(';', $_SERVER); $visit->save(false); //var_dump($_SERVER['REMOTE_ADDR']); exit; $cats = Categories::find()->where('site_id =' . $this->site->id)->roots()->all(); if (__DIR__ == '/home/romanych/public_html/plis/basic/modules/bardzilla/controllers') { $songs = ArticlesContent::find()->where(['articles_id' => 22])->all(); $rand_song = $songs[rand(0, count($songs))]; } else { $songs = ArticlesContent::find()->where(['articles_id' => 3])->all(); $rand_song = $songs[rand(0, count($songs))]; } return $this->render('index', ['cats' => $cats, 'article' => $rand_song]); }
/** * Save a new Test. * * @return Response */ public function saveNewTest(TestRequest $request) { //Create New Test $visitType = ['Out-patient', 'In-patient']; $activeTest = array(); /* * - Create a visit * - Fields required: visit_type, patient_id */ $visit = new Visit(); $visit->patient_id = $request->patient_id; $visit->visit_type = $visitType[$request->visit_type]; $visit->save(); /* * - Create tests requested * - Fields required: visit_id, test_type_id, specimen_id, test_status_id, created_by, requested_by */ $testTypes = $request->testtypes; if (is_array($testTypes)) { foreach ($testTypes as $value) { $testTypeID = (int) $value; // Create Specimen - specimen_type_id, accepted_by, referred_from, referred_to $specimen = new Specimen(); $specimen->specimen_type_id = TestType::find($testTypeID)->specimenTypes->lists('id')[0]; $specimen->accepted_by = Auth::user()->id; $specimen->save(); $test = new Test(); $test->visit_id = $visit->id; $test->test_type_id = $testTypeID; $test->specimen_id = $specimen->id; $test->test_status_id = Test::PENDING; $test->created_by = Auth::user()->id; $test->requested_by = Input::get('physician'); $test->save(); $activeTest[] = $test->id; } } $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('active_test', $test->id); }
/** * 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); }