%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 error_reporting(0); Class Patient_Story_Model extends CI_Model{ protected $table_name = 'SH_PatientStories'; protected $primary_key = 'PatientStoryID'; protected $order_by = 'PatientStoryPriorityOrder DESC'; /* protected $fields_detail = 'PatientStoryID, PatientStoryTitle, DepartmentName, PatientStoryContent, PatientStoryCondition, HealthConditionTitle, PatientStoryTestimonial, PatientStoryNationality, PatientStoryState, PatientStoryDate, PatientStoryThumbnail, PatientStoryBanner, PatientStoryPriorityOrder, PatientStoryPageURL, SH_PatientStories.Status'; */ protected $fields_detail = 'PatientStoryID, PatientStoryTitle, DepartmentName, PatientStoryContent, PatientStoryCondition, PatientStoryTestimonial, PatientStoryNationality, PatientStoryState, PatientStoryDate, PatientStoryThumbnail, PatientStoryBanner, PatientStoryPriorityOrder, PatientStoryPageURL, SH_PatientStories.Status'; protected $fields_summary = 'PatientStoryID, PatientStoryTitle, PatientStoryContent, PatientStoryThumbnail, PatientStoryBanner, PatientStoryPageURL'; Public function __construct() { parent::__construct(); } function get_patient_story($id){ return $this->db->get_where($this->table_name, array($this->primary_key => $id))->row_array(); } function get_patient_story_by_slug($slug){ return $this->db->get_where($this->table_name, array('PatientStoryPageURL' => $slug))->row_array(); } function get_patient_story_by_name($name){ return $this->db->get_where($this->table_name, array('PatientStoryTitle' => $name))->result_array(); } function get_patient_story_id($slug){ $this->db->select('PatientStoryID'); return $this->db->get_where($this->table_name, array('PatientStoryPageURL' => $slug))->row_array(); } function get_active_patient_stories(){ return $this->get_patient_stories('', '', '', array(), '', 'A', ''); } function get_patient_stories($fields = '', $department_id = '', $condition_id = '', $where = array(), $order_by = '', $status = '', $limit = ''){ 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 ($status != '') { $this->db->where($this->table_name.'.Status', $status); } if ($limit != '') { $this->db->limit($limit); } if (count($where)) { $this->db->where($where); } if($department_id!= ''){ //$this->db->where('FIND_IN_SET(PatientStoryDepartment,'.$department_id.')'); $this->db->where('PatientStoryDepartment',$department_id); } $this->db->group_by('PatientStoryTitle'); if($condition_id!= ''){ $this->db->where('PatientStoryCondition',$condition_id); $this->db->join('SH_HealthLibrary', 'SH_HealthLibrary.HealthConditionID='.$this->table_name.'.PatientStoryCondition'); } $this->db->join('SH_Departments', 'SH_Departments.DepartmentID='.$this->table_name.'.PatientStoryDepartment'); // $this->db->join('SH_HealthLibrary', 'SH_HealthLibrary.HealthConditionID='.$this->table_name.'.PatientStoryCondition'); $Query = $this->db->get($this->table_name); // echo $this->db->last_query(); $result = $Query->result_array(); $Query->free_result(); return $result; } function get_patient_stories_summary($fields = '', $department_id = '', $condition_id = '', $where = array(), $order_by = '', $status = '', $limit = ''){ 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 ($status != '') { $this->db->where($this->table_name.'.Status', $status); } if ($limit != '') { $this->db->limit($limit); } if (count($where)) { $this->db->where($where); } if(is_array($department_id)&&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'].', PatientStoryDepartment)!=',0); $i++; } else{ $this->db->or_where('FIND_IN_SET('.$id['DepartmentID'].', PatientStoryDepartment)!=',0); } } $this->db->group_end(); $this->db->group_by('PatientStoryID'); } else if($department_id!= ''){ $this->db->where('PatientStoryDepartment',$department_id); } if($condition_id!= ''){ $this->db->where('PatientStoryCondition',$condition_id); $this->db->join('SH_HealthLibrary', 'SH_HealthLibrary.HealthConditionID='.$this->table_name.'.PatientStoryCondition'); } $this->db->join('SH_Departments', 'SH_Departments.DepartmentID='.$this->table_name.'.PatientStoryDepartment'); $Query = $this->db->get($this->table_name); $result = $Query->result_array(); $Query->free_result(); return $result; } function get_patient_stories_by_department($fields = '', $department_id = array(), $condition_id = '', $where = array(), $order_by = '', $status = 'A', $limit = ''){ 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 ($status != '') { $this->db->where($this->table_name.'.Status', $status); } */ if(($status = 'A') and ($status != '')) { $this->db->where($this->table_name.'.Status', $status); } if ($limit != '') { $this->db->limit($limit); } if (count($where)) { $this->db->where($where); } 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'].', PatientStoryDepartment)!=',0); $i++; } else{ $this->db->or_where('FIND_IN_SET('.$id['DepartmentID'].', PatientStoryDepartment)!=',0); } } $this->db->group_end(); } //$this->db->group_by('PatientStoryID'); $this->db->group_by('PatientStoryTitle'); if($condition_id!= ''){ $this->db->where('PatientStoryCondition',$condition_id); $this->db->join('SH_HealthLibrary', 'SH_HealthLibrary.HealthConditionID='.$this->table_name.'.PatientStoryCondition'); } $this->db->join('SH_Departments', 'SH_Departments.DepartmentID='.$this->table_name.'.PatientStoryDepartment'); $Query = $this->db->get($this->table_name); $result = $Query->result_array(); $Query->free_result(); return $result; } function insert_patient_story($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 update_patient_story($data, $id) { $data['UpdationDate'] = date('Y-m-d H:i:s'); $this->db->where($this->primary_key, $id); return $this->db->update($this->table_name, $data); } public function delete_patient_story($id) { $this->db->where($this->primary_key, $id); return $this->db->delete($this->table_name); } } ?>