public function delete_prescription($prescription_id)
 {
     global $wpdb;
     $table_prescription = $wpdb->prefix . 'hmgt_priscription';
     $result = $wpdb->query("DELETE FROM {$table_prescription} where priscription_id= " . $prescription_id);
     hmgt_append_audit_log('Delete presciption  ', get_current_user_id());
     return $result;
 }
 public function delete_appointment($appointment_id)
 {
     global $wpdb;
     $table_appointment = $wpdb->prefix . 'hmgt_appointment';
     $result = $wpdb->query("DELETE FROM {$table_appointment} where appointment_id= " . $appointment_id);
     hmgt_append_audit_log('Delete appointment ', get_current_user_id());
     return $result;
 }
 public function delete_report($rid)
 {
     global $wpdb;
     $table_hmgt_report = $wpdb->prefix . 'hmgt_report';
     $result = $wpdb->query("DELETE FROM {$table_hmgt_report} where rid= " . $rid);
     hmgt_append_audit_log('Delete report  ', get_current_user_id());
     return $result;
 }
 public function delete_bloodgroup($blood_id)
 {
     global $wpdb;
     $table_bloodbank = $wpdb->prefix . 'hmgt_blood_bank';
     $result = $wpdb->query("DELETE FROM {$table_bloodbank} where blood_id= " . $blood_id);
     hmgt_append_audit_log('Delete blood group ', get_current_user_id());
     return $result;
 }
 public function delete_ambulance_req($amb_req_id)
 {
     global $wpdb;
     $table_ambulance_req = $wpdb->prefix . 'hmgt_ambulance_req';
     $result = $wpdb->query("DELETE FROM {$table_ambulance_req} where amb_req_id = " . $amb_req_id);
     hmgt_append_audit_log('Delete abmulance request ', get_current_user_id());
     return $result;
 }
 public function delete_duration($duration_id)
 {
     global $wpdb;
     $table_durations = $wpdb->prefix . 'hmgt_sessions_durations';
     $result = $wpdb->query("DELETE FROM {$table_durations} where duration_id= " . $duration_id);
     hmgt_append_audit_log('Delete session  ', get_current_user_id());
     return $result;
 }
 public function delete_bedallocate_record($allocate_id)
 {
     global $wpdb;
     $table_bedallotment = $wpdb->prefix . 'hmgt_bed_allotment';
     $result = $wpdb->query("DELETE FROM {$table_bedallotment}  where bed_allotment_id = {$allocate_id}");
     $table_hmgt_assign_type = $wpdb->prefix . 'hmgt_assign_type';
     $result = $wpdb->query("DELETE FROM {$table_hmgt_assign_type} where parent_id= " . $allocate_id . " AND assign_type = 'nurse-bedallotment'");
     hmgt_append_audit_log('Delete bed allotment detail ', get_current_user_id());
     return $result;
 }
 public function delete_dignosis($dignosis_reportid)
 {
     global $wpdb;
     $table_diagnosis = $wpdb->prefix . 'hmgt_diagnosis';
     $result = $wpdb->query("DELETE FROM {$table_diagnosis} where diagnosis_id = " . $dignosis_reportid);
     hmgt_append_audit_log('Delete diagnosis report ', get_current_user_id());
     return $result;
 }
 public function delete_expense($expense_id)
 {
     global $wpdb;
     $table_income = $wpdb->prefix . 'hmgt_income_expense';
     $result = $wpdb->query("DELETE FROM {$table_income} where income_id= " . $expense_id);
     hmgt_append_audit_log('Delete expense ', get_current_user_id());
     return $result;
 }
 public function delete_medicine($cat_id)
 {
     global $wpdb;
     $table_medicine_category = $wpdb->prefix . 'hmgt_medicine';
     $result = $wpdb->query("DELETE FROM {$table_medicine_category} where medicine_id= " . $cat_id);
     hmgt_append_audit_log('Delete medicine ', get_current_user_id());
     return $result;
 }
 public function hmgt_add_user($data)
 {
     //-------usersmeta table data--------------
     if (isset($data['middle_name'])) {
         $usermetadata['middle_name'] = $data['middle_name'];
     }
     if (isset($data['gender'])) {
         $usermetadata['gender'] = $data['gender'];
     }
     if (isset($data['birth_date'])) {
         $usermetadata['birth_date'] = $data['birth_date'];
     }
     if (isset($data['address'])) {
         $usermetadata['address'] = $data['address'];
     }
     if (isset($data['city_name'])) {
         $usermetadata['city_name'] = $data['city_name'];
     }
     if (isset($data['state_name'])) {
         $usermetadata['state_name'] = $data['state_name'];
     }
     if (isset($data['country_name'])) {
         $usermetadata['country_name'] = $data['country_name'];
     }
     if (isset($data['zip_code'])) {
         $usermetadata['zip_code'] = $data['zip_code'];
     }
     if (isset($data['mobile'])) {
         $usermetadata['mobile'] = $data['mobile'];
     }
     if (isset($data['phone'])) {
         $usermetadata['phone'] = $data['phone'];
     }
     if (isset($data['hmgt_user_avatar'])) {
         $usermetadata['hmgt_user_avatar'] = $data['hmgt_user_avatar'];
     }
     if ($data['role'] == 'doctor') {
         if (isset($data['office_address'])) {
             $usermetadata['office_address'] = $data['office_address'];
         }
         if (isset($data['department'])) {
             $usermetadata['department'] = $data['department'];
         }
         if (isset($data['specialization'])) {
             $usermetadata['specialization'] = $data['specialization'];
         }
         if (isset($data['doc_degree'])) {
             $usermetadata['doctor_degree'] = $data['doc_degree'];
         }
         if (isset($data['visiting_fees'])) {
             $usermetadata['visiting_fees'] = $data['visiting_fees'];
         }
         if (isset($data['home_city_name'])) {
             $usermetadata['home_city'] = $data['home_city_name'];
         }
         if (isset($data['home_state_name'])) {
             $usermetadata['home_state'] = $data['home_state_name'];
         }
         if (isset($data['home_country_name'])) {
             $usermetadata['home_country'] = $data['home_country_name'];
         }
     }
     if ($data['role'] == 'patient') {
         if (isset($data['patient_id'])) {
             $usermetadata['patient_id'] = $data['patient_id'];
         }
         if (isset($data['blood_group'])) {
             $usermetadata['blood_group'] = $data['blood_group'];
         }
         if (isset($data['patient_type'])) {
             $usermetadata['patient_type'] = $data['patient_type'];
         }
         //print_r($usermetadata);
     }
     if (isset($data['patient_type']) == 'outpatient') {
         //$usermetadata['medicine']=$data['medicine'];
         if (isset($data['symptoms'])) {
             $usermetadata['symptoms'] = $data['symptoms'];
         }
         if (isset($data['patient_convert'])) {
             $usermetadata['patient_type'] = 'inpatient';
         }
     }
     if ($data['role'] == 'nurse' || $data['role'] == 'receptionist') {
         if (isset($data['department'])) {
             $usermetadata['department'] = $data['department'];
         }
     }
     //-------users table data-----------------
     if (isset($data['username'])) {
         $userdata['user_login'] = $data['username'];
     }
     if (isset($data['email'])) {
         $userdata['user_email'] = $data['email'];
     }
     $userdata['user_nicename'] = NULL;
     $userdata['user_url'] = NULL;
     if (isset($data['first_name'])) {
         $userdata['display_name'] = $data['first_name'] . " " . $data['last_name'];
     }
     if ($data['password'] != "") {
         $userdata['user_pass'] = $data['password'];
     }
     if ($data['action'] == 'edit') {
         hmgt_append_audit_log('Update user detail  ', get_current_user_id());
         $userdata['ID'] = $data['user_id'];
         $user_id = wp_update_user($userdata);
         $returnans = update_user_meta($user_id, 'first_name', $data['first_name']);
         $returnans = update_user_meta($user_id, 'last_name', $data['last_name']);
         foreach ($usermetadata as $key => $val) {
             $returnans = update_user_meta($user_id, $key, $val);
         }
         return $user_id;
     } else {
         //----------isert code------------------
         $user_id = wp_insert_user($userdata);
         hmgt_append_audit_log('Add new user  ', get_current_user_id());
         $user = new WP_User($user_id);
         $user->set_role($data['role']);
         foreach ($usermetadata as $key => $val) {
             $returnans = add_user_meta($user_id, $key, $val, true);
         }
         if (isset($data['first_name'])) {
             $returnans = update_user_meta($user_id, 'first_name', $data['first_name']);
         }
         if (isset($data['last_name'])) {
             $returnans = update_user_meta($user_id, 'last_name', $data['last_name']);
         }
         return $user_id;
     }
 }
 public function delete_oprationtheater($ot_id)
 {
     global $wpdb;
     $table_ot = $wpdb->prefix . 'hmgt_ot';
     $result = $wpdb->query("DELETE FROM {$table_ot}  where operation_id = {$ot_id}");
     $table_hmgt_assign_type = $wpdb->prefix . 'hmgt_assign_type';
     $result = $wpdb->query("DELETE FROM {$table_hmgt_assign_type} where parent_id= " . $ot_id . " AND assign_type = 'operation_theater'");
     hmgt_append_audit_log('Delete operation  ', get_current_user_id());
     return $result;
 }
 public function delete_message($mid)
 {
     global $wpdb;
     $table_hmgt_message = $wpdb->prefix . 'hmgt_message';
     $result = $wpdb->query("DELETE FROM {$table_hmgt_message} where message_id= " . $mid);
     hmgt_append_audit_log('Delete message ', get_current_user_id());
     return $result;
 }