%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
Class Doctor_Model extends CI_Model{
protected $table_name = 'SH_DoctorProfile';
protected $primary_key = 'DoctorID';
protected $order_by = 'DoctorPriorityOrder DESC, DesignationPriority DESC, DesignationRank ASC';
protected $fields_detail = 'DoctorID, DoctorTitle, DoctorName, DoctorDesignation, DesignationTitle, DoctorGender, DoctorProfilePic,
DoctorNationality, DoctorLanguage, DoctorDepartment, GROUP_CONCAT(DepartmentName SEPARATOR ", ") as DepartmentNames, DoctorOPDSchedule, DoctorBriefProfile,
DoctorQualification, DoctorSpecialization, DoctorClinicalInterest, DoctorWorkExperience,
DoctorAcheivements, DoctorMemberships, DoctorResearchPublication, DoctorResume, DoctorPriorityOrder,
DoctorPageURL, SH_DoctorProfile.Status as Status';
protected $fields_summary = 'DoctorID, DoctorTitle, DoctorName, DoctorDesignation, DesignationTitle, GROUP_CONCAT(DepartmentName SEPARATOR ", ") as DepartmentNames, DoctorProfilePic, DepartmentName, DoctorPageURL';
Public function __construct()
{
parent::__construct();
}
function get_doctor_by_id($id){
return $this->db->get_where($this->table_name, array($this->primary_key => $id))->result_array()[0];
}
function get_Doctor($id){
$this->db->group_by('DoctorID');
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
$Query = $this->db->get($this->table_name);
$result = $Query->result_array();
$Query->free_result();
return $result;
return $this->db->get_where($this->table_name, array($this->primary_key => $id))->result_array()[0];
}
function get_doctor_details($id){
$this->db->select($this->fields_detail);
$this->db->group_by('DoctorID');
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
return $this->db->get_where($this->table_name, array($this->primary_key => $id))->result_array()[0];
}
function get_Doctor_by_slug($slug){
return $this->db->get_where($this->table_name, array('DoctorPageURL' => $slug))->row_array();
}
function get_Doctor_by_name($name){
return $this->db->get_where($this->table_name, array('DoctorName' => $name))->result_array();
}
function get_doctor_id($slug){
$this->db->select('DoctorID');
return $this->db->get_where($this->table_name, array('DoctorPageURL' => $slug))->row_array();
}
function get_Doctor_by_designation($designation_id, $fields='', $status=''){
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields_detail);
}
if($designation_id){
$this->db->where('DoctorDesignation', $designation_id);
}
if ($status != '') {
$this->db->where($this->table_name.'.Status', $status);
}
$this->db->order_by($this->order_by);
$this->db->join('SH_Departments', 'SH_Departments.DepartmentID='.$this->table_name.'.DoctorDepartment');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
return $this->db->get($this->table_name)->result_array();
}
function get_Doctor_by_department($department_id, $fields='', $status=''){
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields_detail);
}
if($department_id){
$this->db->where('DoctorDepartment', $department_id);
}
if ($status != '') {
$this->db->where($this->table_name.'.Status', $status);
}
$this->db->order_by($this->order_by);
$this->db->join('SH_Departments', 'SH_Departments.DepartmentID='.$this->table_name.'.DoctorDepartment');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
return $this->db->get($this->table_name)->result_array();
}
function get_OPD_schedule($doctor_id){
$this->db->select('*');
$OPD_schedule = $this->db->get_where('SH_OPD_SCHEDULE', array('drid' => $doctor_id))->result_array();
return $OPD_schedule;
}
function get_doctor_departments($id){
$this->db->select('SH_Departments.DepartmentName');
$this->db->where('DoctorID', $id);
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$Query = $this->db->get();
$result = $Query->result_array();
$Query->free_result();
return $result;
}
function get_doctor_departments_id($doctor_id){
$this->db->select('DoctorDepartment');
$this->db->where('DoctorID', $doctor_id);
$Query = $this->db->get($this->table_name);
$result = $Query->row_array();
$Query->free_result();
return $result;
}
function get_doctors($fields = '', $where = array(), $designation_id = '', $department_id = '', $limit = '', $order_by = '', $status = '', $except = array() ){
if($department_id!=''){
$sub_departments = $this->db->query('Select DepartmentID from SH_Departments where FIND_IN_SET(DepartmentParentID,"'.$department_id.'")!=0')->result_array();
if(count($sub_departments)){
$i = 0;
$this->db->group_start();
foreach($sub_departments as $id){
if($i==0){
$this->db->where('FIND_IN_SET('.$id['DepartmentID'].', DoctorDepartment)!=',0);
$i++;
}
else{
$this->db->or_where('FIND_IN_SET('.$id['DepartmentID'].', DoctorDepartment)!=',0);
}
}
$this->db->group_end();
}
else{
$department_ids = explode(',',$department_id);
if(count($department_ids)>1){
$i = 0;
$this->db->group_start();
foreach($department_ids as $id){
if($i==0){
$this->db->where('FIND_IN_SET('.$id.', DoctorDepartment)!=',0);
$i++;
}
else{
$this->db->or_where('FIND_IN_SET('.$id.', DoctorDepartment)!=',0);
}
}
$this->db->group_end();
}
else{
$this->db->where('FIND_IN_SET("'.$department_id.'", DoctorDepartment)!=',0);
}
}
}
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields_detail);
}
if($order_by != ''){
$this->db->order_by($order_by);
}
else{
$this->db->order_by($this->order_by);
}
if (count($where)) {
$this->db->where($where);
}
if ($status != '') {
$this->db->where($this->table_name.'.Status', $status);
}
if($designation_id!=''){
$this->db->where('DoctorDesignation', $designation_id);
}
if(count($except)){
$this->db->where_not_in($this->primary_key,$except);
}
$this->db->group_by('DoctorID');
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
$Query = $this->db->get($this->table_name);
$result = $Query->result_array();
$Query->free_result();
return $result;
}
function get_doctors_summary($fields = '', $where = array(), $designation_id = '', $department_id = '', $limit = '', $order_by = '', $status=''){
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields_summary);
}
if($order_by != ''){
$this->db->order_by($order_by);
}
else{
$this->db->order_by($this->order_by);
}
if (count($where)) {
$this->db->where($where);
}
if ($status != '') {
$this->db->where($this->table_name.'.Status', $status);
}
if($designation_id){
$this->db->where('DoctorDesignation', $designation_id);
}
if($department_id){
$this->db->where('FIND_IN_SET('.$department_id.', DoctorDepartment)!=',0);
}
$this->db->group_by('DoctorID');
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
$Query = $this->db->get($this->table_name);
$result = $Query->result_array();
$Query->free_result();
return $result;
}
function get_doctors_by_department($fields = '', $department_id = array(), $designation_id = '', $where = array(), $limit = '', $order_by = '', $status=''){
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields_detail);
}
if($order_by != ''){
$this->db->order_by($order_by);
}
else{
$this->db->order_by($this->order_by);
}
if (count($where)) {
$this->db->where($where);
}
if ($status != '') {
$this->db->where($this->table_name.'.Status', $status);
}
if($designation_id != ''){
$this->db->where('DoctorDesignation', $designation_id);
}
if(count($department_id)){
$i = 0;
$this->db->group_start();
foreach($department_id as $id){
if($i==0){
$this->db->where('FIND_IN_SET('.$id['DepartmentID'].', DoctorDepartment)!=',0);
$i++;
}
else{
$this->db->or_where('FIND_IN_SET('.$id['DepartmentID'].', DoctorDepartment)!=',0);
}
}
$this->db->group_end();
}
$this->db->group_by('DoctorID');
$this->db->join('SH_Departments', 'FIND_IN_SET(DepartmentID, DoctorDepartment)!=0');
$this->db->join('SH_Designations', 'SH_Designations.DesignationID='.$this->table_name.'.DoctorDesignation');
$Query = $this->db->get($this->table_name);
$result = $Query->result_array();
$Query->free_result();
return $result;
}
function insert_doctor($data){
$data['CreationDate'] = $data['UpdationDate'] = date('Y-m-d H:i:s');
$success = $this->db->insert($this->table_name, $data);
if ($success) {
return $this->db->insert_id();
} else {
return FALSE;
}
}
public function upd_schedule($upd_opdschld,$docids) {
$cnt = count($upd_opdschld['day']);
$delrecrd = $this->db->query("delete from `SH_OPD_SCHEDULE` where drid='".$docids."'");
for($i=0; $i<$cnt; $i++){
$DAY = $upd_opdschld['day'][$i];
$ST_TIME = $upd_opdschld['time_first'][$i];
$time_end = $upd_opdschld['time_end'][$i];
$drid = $upd_opdschld['drid'][$i];
$que = $this->db->query("select * from `SH_OPD_SCHEDULE` where drid='".$docids."'");
$numss = $que->num_rows();
foreach($que->result_array() as $rewdata)
{
$doctorsid = $rewdata['drid'];
$SID = $rewdata['id'];
}
$this->db->query("insert into `SH_OPD_SCHEDULE` set drid='".$docids."',dayname='".$DAY."' , start_time='".$ST_TIME."', end_time='".$time_end."'");
}
if($success) {
return $drid;
} else {
return FALSE;
}
}
/*********** edit ************/
public function update_doctor($data, $id) {
$data['UpdationDate'] = date('Y-m-d H:i:s');
$this->db->where($this->primary_key, $id);
$success = $this->db->update($this->table_name, $data);
if ($success) {
return $id;
} else {
return FALSE;
}
}
public function delete_doctor($id) {
$this->db->where($this->primary_key, $id);
return $this->db->delete($this->table_name);
}
}
?>