public function postStartFaxMedication() { 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 { ini_set('memory_limit', '196M'); $pid = Session::get('pid'); if (Session::get('job_id') == FALSE) { $job_id = ''; } else { $job_id = Session::get('job_id'); } $rxl_id = Input::get('fax_prescribe_id'); $html = $this->page_medication($rxl_id)->render(); $user_id = Session::get('user_id'); $file_path = __DIR__ . "/../../public/temp/rx_" . time() . "_" . $user_id . ".pdf"; $this->generate_pdf($html, $file_path); while (!file_exists($file_path)) { sleep(2); } $row1 = Rx_list::find($rxl_id); $file_original = $row1->rxl_medication . ' ' . $row1->rxl_dosage . ' ' . $row1->rxl_dosage_unit . ', ' . $row1->rxl_sig . ' ' . $row1->rxl_route . ' ' . $row1->rxl_frequency . ' for ' . $row1->rxl_reason; $result['id'] = $this->fax_document($pid, 'Prescription/Refill Authorization', 'yes', $file_path, $file_original, '', '', $job_id, 'no'); $result['message'] = 'Prescription added to fax queue!'; Session::put('job_id', $result['id']); unlink($file_path); echo json_encode($result); } }