296 lines
13 KiB
PHP
Executable File

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Physician extends MX_Controller {
function __construct() {
parent::__construct();
$this->load->model('Physician_model');
//$this->load->library('formLibrary/drag-n-drop-form-builder/FormGenerator');
//$this->load->model('Physician_permission_model');
// if (!$this->ion_auth->in_group(array('admin'))) {
// if(!$this->ion_auth->physician_permission('coordinator_management_menu'))
// redirect('home/permission');
// }
}
public function index() {
// $data['invoice']=array(
// 'TxnDate'=> "2014-09-19",
// 'domain'=>"QBO",
// 'PrintStatus'=> "NeedToPrint"
// );
// $inv_data = json_encode($data);
// echo '<pre>'; print_r($inv_data); echo '</pre>';die;
// $inv = invoice_checking($inv_data);
// echo '<pre>'; print_r($inv); echo '</pre>';die;
$data = array();
$data['data'] = $this->Physician_model->getPhysician();
$this->load->view('home/dashboard'); // just the header file
$this->load->view('physician',$data);
$this->load->view('home/footer'); // just the header file
}
public function addNewView() {
// $npi = npinumber_checking('1467586115');
// echo '<pre>'; print_r($npi); echo '</pre>';die;
$data['phyid'] = 0;
$this->load->view('home/dashboard'); // just the header file
$this->load->view('add_new',$data);
$this->load->view('home/footer'); // just the header file
}
function checkNpi(){
$npi_no=$this->input->get("npi");
$phyid=$this->input->get("phyid");
$response=npinumber_checking($npi_no);
if($response->result_count>0){
$result=$this->Physician_model->checkNPIexist($npi_no,$phyid);
if($result){
$data=array(
'name'=>$response->results[0]->basic->first_name." ".$response->results[0]->basic->middle_name." ".$response->results[0]->basic->last_name,
'address'=>$response->results[0]->addresses[0]->address_1." ".$response->results[0]->addresses[0]->address_2,
'country'=>$response->results[0]->addresses[0]->country_name,
'city'=>$response->results[0]->addresses[0]->city,
'phone'=>$response->results[0]->addresses[0]->telephone_number,
'zipcode'=>$response->results[0]->addresses[0]->postal_code,
'result_count'=>$response->result_count,
'primary'=>$response->results[0]->taxonomies[0]->primary,
'license'=>$response->results[0]->taxonomies[0]->license,
'status'=>'success',
'message'=>'available'
);
}else{
$data=array(
'status'=>'failed',
'message'=>'This NPI no is already exist.'
);
}
}else{
$data=array(
'status'=>'failed',
'message'=>'This NPI no is not valid.'
);
}
echo json_encode($data);
}
public function addNew() {
$id = $this->input->post('id');
$npi = $this->input->post('npi');
$name = $this->input->post('name');
$password = $this->input->post('password');
$email = $this->input->post('email');
$address = $this->input->post('address');
$phone = $this->input->post('phone');
$country = $this->input->post('country');
$city = $this->input->post('city');
// $primary = $this->input->post('isPrimary');
$licenses = $this->input->post('licenses');
$isPrimary = $this->input->post('isPrimary');
if($isPrimary == 'true'){
$primary = 1;
}else{
$primary = 0;
}
$affiliation = $this->input->post('affiliation');
$zipcode = $this->input->post('zipcode');
$notes = $this->input->post('notes');
$fax = $this->input->post('fax');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
// Validating Name Field
$this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[1]|max_length[100]|xss_clean');
// Validating Password Field
if (empty($id)) {
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[5]|max_length[100]|xss_clean');
}
// Validating Email Field
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|max_length[100]|xss_clean');
// Validating Address Field
$this->form_validation->set_rules('address', 'Address', 'trim|required|min_length[1]|max_length[500]|xss_clean');
// Validating Phone Field
$this->form_validation->set_rules('phone', 'Phone', 'trim|required|min_length[1]|max_length[50]|xss_clean');
if ($this->form_validation->run() == FALSE) {
if (!empty($id)) {
$data = array();
// $data['departments'] = $this->department_model->getDepartment();
// $data['doctor'] = $this->doctor_model->getDoctorById($id);
$this->load->view('home/dashboard'); // just the header file
$this->load->view('add_new', $data);
$this->load->view('home/footer'); // just the footer file
} else {
$data = array();
// $data['setval'] = 'setval';
// $data['departments'] = $this->department_model->getDepartment();
$this->load->view('home/dashboard'); // just the header file
$this->load->view('add_new');
$this->load->view('home/footer'); // just the header file
}
} else {
$data = array();
$data = array(
'name' => $name,
'email' => $email,
'address' => $address,
'phone' => $phone
);
$datas = array(
'npi' => $npi,
'name' => $name,
'email' => $email,
'address' => $address,
'phone' => $phone,
'country' => $country,
'city' => $city,
'zipcode' => $zipcode,
'isPrimary' => $primary,
'licenses' => $licenses,
'affiliation' => $affiliation,
'notes' => $notes,
'fax' => $fax,
);
$username = $this->input->post('npi');
if (empty($id)) { // Adding New
if ($this->ion_auth->email_check($email)) {
$this->session->set_flashdata('feedback', 'This Email Address Is Already Registered');
redirect('physician/addNewView');
}
else if ($this->ion_auth->npi_check($npi)) {
$this->session->set_flashdata('feedback', 'This NPI Number Is Already Registered');
redirect('physician/addNewView');
}
else {
//die;
$dfg = 8;
$oauth_uid = '';
$oauth_provider = 'general';
$this->ion_auth->register($username, $password, $email,$dfg,$oauth_uid,$oauth_provider);
$ion_user_id = $this->db->get_where('users', array('email' => $email))->row()->id;
//echo '<pre>'; print_r($datas); echo '</pre>';die;
$this->Physician_model->insertUser($datas);
$user_id_cooardinator_q = $this->db->get_where('physician', array('email' => $email));
$user_id = $user_id_cooardinator_q->result()[0]->id;
$id_info = array('ion_user_id' => $ion_user_id);
$this->Physician_model->updatePhysician($user_id, $id_info);
$name=$name;
$from = array(
'name' => 'HMS Admin',
'email' => 'admin@hms.com'
);
$subject ='Physician created successfully';
$emaildata['emaildata'] = array(
'name' =>$name
);
$to = $email;
$message= $this->load->view('email_template_management/physician_created',$emaildata,TRUE);
send_email($from,$to,$subject,$message);
$this->session->set_flashdata('feedback_success', 'Added');
}
} else { // Updating
// die('uu');
$ion_user_id = $this->db->get_where('physician', array('id' => $id))->row()->ion_user_id;
if (empty($password)) {
$password = $this->db->get_where('users', array('id' => $ion_user_id))->row()->password;
} else {
$password = $this->ion_auth_model->hash_password($password);
}
$this->Physician_model->updateIonUser($username, $email, $password, $ion_user_id);
$this->Physician_model->updatePhysician($id, $datas);
$this->session->set_flashdata('feedback_success', 'Updated');
}
// Loading View
redirect('physician');
}
}
function editPhysician() {
$data = array();
$data['phyid']=$id = $this->input->get('id');
$data['user'] = $this->Physician_model->getPhysicianById($id);
$this->load->view('home/dashboard'); // just the header file
$this->load->view('add_new', $data);
$this->load->view('home/footer'); // just the footer file
}
function getUsers() {
$requestData = $_REQUEST;
$start = $requestData['start'];
$limit = $requestData['length'];
$search = $this->input->post('search')['value'];
if ($limit == -1) {
if (!empty($search)) {
$data['users'] = $this->Physician_model->getPhysicianBysearch($search);
} else {
$data['users'] = $this->Physician_model->getPhysician();
}
} else {
if (!empty($search)) {
$data['users'] = $this->Physician_model->getPhysicianByLimitBySearch($limit, $start, $search);
} else {
$data['users'] = $this->Physician_model->getPhysicianByLimit($limit, $start);
}
}
//$data['users'] = $this->Physician_model->getUsers();
foreach ($data['users'] as $user) {
if ($this->ion_auth->in_group(array('admin'))) {
$options1 = '<a class="btn btn-primary" title="' . lang('edit') . '" href="physician/editPhysician?id='.$user->id.'"><i class="la la-edit"></i> ' . lang('edit') . '</a>';
}
$info[] = array(
$user->npi,
$user->email,
$user->name,
$user->phone,
$options1.' '.$options2,
);
}
if (!empty($data['users'])) {
$output = array(
"draw" => intval($requestData['draw']),
"recordsTotal" => count($data['users']),
"recordsFiltered" => count($data['users']),
"data" => $info
);
} else {
$output = array(
// "draw" => 1,
"recordsTotal" => 0,
"recordsFiltered" => 0,
"data" => []
);
}
echo json_encode($output);
}
public function checkEmail(){
$phyid=$this->input->get("phyid");
$ion_user_id = $this->db->get_where('physician', array('id' => $phyid))->row()->ion_user_id;
$email=$this->input->get('email');
$result=$this->Physician_model->checkEmail($email,$ion_user_id);
echo $result;
}
}
/* End of file doctor.php */
/* Location: ./application/modules/doctor/controllers/doctor.php */