TRUNCATE TABLE case_details;
TRUNCATE TABLE daily_subtask_vital_map;
TRUNCATE TABLE daily_subtasks;
TRUNCATE TABLE daily_tasks;
TRUNCATE TABLE departmentwise_consumption_items;
TRUNCATE TABLE departmentwise_consumptions;
TRUNCATE TABLE emergency_details;
TRUNCATE TABLE good_receipt_details;
TRUNCATE TABLE ipd_admission;
TRUNCATE TABLE ipd_bed_charge_details;
TRUNCATE TABLE ipd_bed_details;
TRUNCATE TABLE ipd_birth_records;
TRUNCATE TABLE ipd_case_visit_transfer;
TRUNCATE TABLE ipd_discharge_details;
TRUNCATE TABLE ipd_patient_consultant;
TRUNCATE TABLE ipd_patient_consultant_visit;
TRUNCATE TABLE lab_analyte_comments;
TRUNCATE TABLE lab_booking;
TRUNCATE TABLE lab_booking_details;
TRUNCATE TABLE lab_booking_tat;
TRUNCATE TABLE lab_report_attachments;
TRUNCATE TABLE lab_report_result;
TRUNCATE TABLE login_attempts;
TRUNCATE TABLE opd_doctor_appointments;
TRUNCATE TABLE ot_bookings;
TRUNCATE TABLE ot_staff_details;
TRUNCATE TABLE patient_advance_balance;
TRUNCATE TABLE patient_payments;
TRUNCATE TABLE patient_rule_map;
TRUNCATE TABLE patient_service_charge_details;
TRUNCATE TABLE patient_service_charges;
TRUNCATE TABLE patient_vitals;
TRUNCATE TABLE pharmacy_billing_header;
TRUNCATE TABLE pharmacy_billing_item;
TRUNCATE TABLE pharmacy_return_header;
TRUNCATE TABLE pharmacy_return_items;
TRUNCATE TABLE prescriptions;
TRUNCATE TABLE prescriptions_wise_observations;
TRUNCATE TABLE prescriptionwise_medicine_test;
TRUNCATE TABLE purchase_order_items;
TRUNCATE TABLE purchase_order_receipt_items;
TRUNCATE TABLE purchase_order_receipts;
TRUNCATE TABLE purchase_order_return_items;
TRUNCATE TABLE purchase_order_returns;
TRUNCATE TABLE purchase_orders;
TRUNCATE TABLE purchase_requisitions;
TRUNCATE TABLE purchase_requisitions_details;
TRUNCATE TABLE rule_criteria;
TRUNCATE TABLE rule_logics;
TRUNCATE TABLE rule_master;
TRUNCATE TABLE shift_assignments;
TRUNCATE TABLE staff_attendance;
TRUNCATE TABLE staff_leave_details;
TRUNCATE TABLE staff_leave_request;
TRUNCATE TABLE staff_monthly_payslip;
TRUNCATE TABLE staff_payslip_allowance;
TRUNCATE TABLE stock_item_requisition;
TRUNCATE TABLE task_staff_assignments;
TRUNCATE TABLE taskwise_assignment_tracker;
TRUNCATE TABLE tmp_group_permissions;
TRUNCATE TABLE tmp_lab_grp_analytes;
TRUNCATE TABLE vendor_payments;
TRUNCATE TABLE visit_details;
TRUNCATE TABLE tpa_patient_claim_workflow;
TRUNCATE TABLE tpa_payment_dtls;
TRUNCATE TABLE icd_codewise_prescriptions;
TRUNCATE TABLE patient_symptom_disease;

Update bed
Set is_occupied = 'N';

/*
delete 
from contacts
where data_source = 'patient'
and data_source_id not in (select id from patients)


delete 
from contacts
where data_source = 'kin'
and data_source_id not in (select id from next_ofkin)
*/
