public function postChartTest($tests_id) { $pid = Session::get('pid'); $demographics = Demographics::find($pid); $datenow = date("D, d M y H:i:s O", time()); $row0 = Tests::find($tests_id); $data['patient'] = array(); $data['yaxis'] = $row0->test_units; $data['xaxis'] = 'Date'; $data['name'] = $row0->test_name; $data['title'] = 'Chart of ' . $row0->test_name . ' over time for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $query1 = DB::table('tests')->where('test_name', '=', $row0->test_name)->where('pid', '=', $pid)->orderBy('test_datetime', 'ASC')->get(); if ($query1) { $i = 0; foreach ($query1 as $row1) { $x = $row1->test_datetime; $y = $row1->test_result; $data['patient'][$i][] = $x; $data['patient'][$i][] = $y; $i++; } } echo json_encode($data); }
public function postTestsImport() { if (Session::get('group_id') != '2' && Session::get('group_id') != '3') { Auth::logout(); Session::flush(); header("HTTP/1.1 404 Page Not Found", true, 404); exit("You cannot do this."); } else { $pid = Input::get('pid'); $tests_id_array = json_decode(Input::get('tests_id_array')); $i = 0; $results = array(); foreach ($tests_id_array as $tests_id) { $data = array('pid' => $pid, 'test_unassigned' => ''); DB::table('tests')->where('tests_id', '=', $tests_id)->update($data); $this->audit('Update'); $results[$i] = Tests::find($tests_id)->toArray(); $provider_id = $results[$i]['test_provider_id']; $from = $results[$i]['test_from']; $test_type = $results[$i]['test_type']; $i++; } $patient_row = Demographics::find($pid)->toArray(); $dob_message = date("m/d/Y", strtotime($patient_row['DOB'])); $patient_name = $patient_row['lastname'] . ', ' . $patient_row['firstname'] . ' (DOB: ' . $dob_message . ') (ID: ' . $pid . ')'; $practice_row = Practiceinfo::find(Session::get('practice_id'))->toArray(); $directory = $practice_row['documents_dir'] . $pid; $file_path = $directory . '/tests_' . time() . '.pdf'; $html = $this->page_intro('Test Results', $practice_id); $html .= $this->page_results($pid, $results, $patient_name); $this->generate_pdf($html, $file_path); $documents_date = date("Y-m-d H:i:s", time()); $test_desc = 'Test results for ' . $patient_name; $pages_data = array('documents_url' => $file_path, 'pid' => $pid, 'documents_type' => $test_type, 'documents_desc' => $test_desc, 'documents_from' => $from, 'documents_date' => $documents_date); if (Session::get('group_id') == '2') { $pages_data['documents_viewed'] = Session::get('displayname'); } $documents_id = DB::table('documents')->insertGetId($pages_data); $this->audit('Add'); if (Session::get('group_id') == '3') { $provider_row = User::find($provider_id)->toArray(); $provider_name = $provider_row['firstname'] . " " . $provider_row['lastname'] . ", " . $provider_row['title'] . " (" . $provider_id . ")"; $subject = "Test results for " . $patient_name; $body = "Test results for " . $patient_name . "\n\n"; foreach ($results as $results_row1) { $body .= $results_row1['test_name'] . ": " . $results_row1['test_result'] . ", Units: " . $results_row1['test_units'] . ", Normal reference range: " . $results_row1['test_reference'] . ", Date: " . $results_row1['test_datetime'] . "\n"; } $body .= "\n" . $from; $data_message = array('pid' => $pid, 'message_to' => $provider_name, 'message_from' => Session::get('user_id'), 'subject' => $subject, 'body' => $body, 'patient_name' => $patient_name, 'status' => 'Sent', 'mailbox' => $provider_id, 'practice_id' => $practice_id, 'documents_id' => $documents_id); DB::table('messaging')->insert($data_message); $this->audit('Add'); } echo $i; } }
/** * Тестирование * @return void */ public function testingAction() { $objForm = new Form_Test_Testing(); $link = $this->getRequest()->getParam('link'); $objApplicantTests = new ApplicantTests(); $applicantTest = $objApplicantTests->getTest($link); if (empty($applicantTest)) { exit; } $applicantId = $applicantTest->applicant_id; $testId = $applicantTest->test_id; $applicantTestId = $applicantTest->id; $applicantScore = $applicantTest->score; $applicantPercent = $applicantTest->percent; $objTests = new Tests(); $test = $objTests->find($testId)->current()->toArray(); $testName = $test['t_name']; $testTime = $test['time']; $objApplicants = new Applicants(); $applicantName = $objApplicants->getName($applicantId); $objQuestion = new Questions(); $questions = $objQuestion->getQuestions($testId); $questions = $this->convertArr($questions, 'tq_id'); $countQuestions = count($questions); $objTestAnswers = new Answers(); $answers = $objTestAnswers->getAnswers(array_keys($questions)); $answers = $this->convertArr($answers, 'tq_id', true); // ключем $answers будет id вопроса $objForm->addElementsForm($questions, $answers); if ($this->getRequest()->isPost()) { //получаем ответы на вопросы и сохраняем if ($objForm->isValid($_POST)) { $objApplicantAnswers = new ApplicantAnswers(); $newAnswers = $this->keyReplace($objForm->getValues(), 'answer_'); foreach ($newAnswers as $answerId => $val) { if ($val) { $newAnswer = $objApplicantAnswers->createRow(array('applicant_tests_id' => $applicantTestId, 'answer_id' => $answerId)); $newAnswer->save(); } else { unset($newAnswers[$answerId]); } } $result = $this->calcTestScore($questions, $answers, $newAnswers); $applicantTest->score = $result['score']; $applicantTest->percent = $result['percent']; $applicantTest->save(); $this->view->sendTest = true; return; } } else { $this->view->testName = $testName; $this->view->applicantName = $applicantName; $this->view->time = $testTime; $this->view->score = $applicantScore; $this->view->percent = $applicantPercent; if (is_null($applicantTest->date)) { // выводим тест // $this->view->objForm = $objForm; $applicantTest->date = new Zend_Db_Expr('NOW()'); $applicantTest->save(); } else { if ($this->_authorize('test', 'view')) { // выводим результаты теста // $objApplicantAnswers = new ApplicantAnswers(); $applicantAnswers = $objApplicantAnswers->getAnswers($applicantTestId); $applicantAnswers = $this->convertArr($applicantAnswers, 'answer_id'); $questions = $this->makeQAArray($questions, $answers, $applicantAnswers); unset($answers); unset($applicantAnswers); $questionCategories = $objTests->getQuestionCategoriesListByTestId($testId); if ($questionCategories) { $questionCategories = $this->calcCategoriesScore($questions, $questionCategories); } $this->view->countQuestions = $countQuestions; $this->view->countQuestionFail = $this->countWrongAnswers($questions); $this->view->questionsAndAnswers = $questions; $this->view->questionCategories = $questionCategories; } } } }
public function postTestsView($tests_id, $pid) { $row = Tests::find($tests_id); $row1 = Demographics::find($pid); $text = '<strong>Patient:</strong> ' . $row1->firstname . " " . $row1->lastname . '<br><br><strong>Type:</strong> ' . $row->test_type . '<br><br><strong>Date:</strong> ' . date('m/d/Y', $row->test_datetime) . '<br><br><strong>Test</strong> ' . $row->test_name . '<br><br><strong>Result:</strong> ' . $row->test_result . ' ' . $row->test_units . ' (' . $row->test_reference . ')<br><br><strong>From:</strong> ' . $row->test_from; echo $text; }