179 lines
6.0 KiB
PHP
Executable File

<?php
if(!defined('BASEPATH')){
exit('No direct script access allowed');
}
class Dbcleanmodel extends CI_model{
function __construct() {
parent::__construct();
$this->load->database();
}
function hms_model_delete_all_patient_info($id){
try{
/*
| #caregiver_patient_mapping
| #master_patient_ref
| #patient
| #patient_caregiver_mapping
| #patient_deposit
| #patient_material
| #patient_md_order_lab_order
| #patient_md_order_medication
| #patient_md_order_step3 (table doesn't exist)
| caregiver_patient_clock_in_out
*/
$this->db->select('p.id, p.main_id, p.patient_id, p.ion_user_id');
$this->db->from('patient_details p');
$this->db->where('id', $id);
$query=$this->db->get();
$result=$query->row();
$ion_user_id=isset($result->ion_user_id)?intval($result->ion_user_id):0;
$this->db->where('id', $id);
$this->db->delete('patient_details');
$this->db->where('main_id', $id);
$this->db->delete('patient_details_step2');
$this->db->where('main_id', $id);
$this->db->delete('patient_insurance_info');
$this->db->where('main_id', $id);
$this->db->delete('patient_payment_info');
$this->db->where('patient_id', $id);
$this->db->delete('patient_documents');
$this->db->where('patient_id', $id);
$this->db->delete('patient_md_order');
$this->db->where('patient_id', $id);
$this->db->delete('patient_report');
$this->db->where('patient_id', $id);
$this->db->delete('patient_discharge');
$this->db->where('patient_id', $id);
$this->db->delete('assessment');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step1');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step2');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step3');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step4');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step5');
$this->db->where('patient_id', $id);
$this->db->delete('assessment_step6');
$this->db->where('patient_id', $id);
$this->db->delete('caregiver_patient_clock_in_out');
if($ion_user_id>0){
$this->db->where('id', $ion_user_id);
$this->db->delete('users');
}
return $this->db->affected_rows()==0;
}
catch(Exception $e){
$getMsg="Dbcleanmodel - hms_model_delete_all_patient_info: ".$e->getMessage();
echo $getMsg;
}
}
function hms_model_delete_all_caregiver_info($id){
try{
$this->db->select('cg.id, cg.main_id, cg.caregiver_id, cg.ion_user_id');
$this->db->from('caregiver cg');
$this->db->where('id', $id);
$query=$this->db->get();
$result=$query->row();
$ion_user_id=isset($result->ion_user_id)?intval($result->ion_user_id):0;
$this->db->where('id', $id);
$this->db->delete('caregiver');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_availability');
$this->db->where('cg_id', $id);
$this->db->delete('caregiver_background_check');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_certificate');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_document_signature');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_doc_expire_details');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_experience');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_finger_print_status');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_licenses');
$this->db->where('user_id', $id);
$this->db->delete('caregiver_onboard_registration_token');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_other_references');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_patient_clock_in_out');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_patient_mapping');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_schedule');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_service_mapping');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_step2');
$this->db->where('caregiver_table_id', $id);
$this->db->delete('caregiver_step3');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_verification');
$this->db->where('caregiver_id', $id);
$this->db->delete('caregiver_verification_history');
$this->db->where('user_id', $id);
$this->db->delete('caregiver_video_query');
$this->db->where('caregiver_id', $id);
$this->db->delete('coordinator_caregiver_mapping');
if($ion_user_id>0){
$this->db->where('id', $ion_user_id);
$this->db->delete('users');
}
return $this->db->affected_rows()==0;
}
catch(Exception $e){
$getMsg="Dbcleanmodel - hms_model_delete_all_caregiver_info: ".$e->getMessage();
echo $getMsg;
}
}
}
?>