delete from om_protocol_item where scheduled_procedure_step_id in (select id from om_scheduled_procedure_step where requested_procedure_id in (select id from om_requested_procedure where order_id in (select id from om_order where encounter_id in (select id from om_encounter where visit_number is null))));
delete from om_worklist_entry where scheduled_procedure_step_id in (select id from om_scheduled_procedure_step where requested_procedure_id in (select id from om_requested_procedure where order_id in (select id from om_order where encounter_id in (select id from om_encounter where visit_number is null))));
delete from om_scheduled_procedure_step where requested_procedure_id in (select id from om_requested_procedure where order_id in (select id from om_order where encounter_id in (select id from om_encounter where visit_number is null)));
delete from om_requested_procedure where order_id in (select id from om_order where encounter_id in (select id from om_encounter where visit_number is null));
delete from om_order where encounter_id in (select id from om_encounter where visit_number is null);
delete from om_lab_order where encounter_id in (select id from om_encounter where visit_number is null);
delete from om_lab_order_specimen where lab_order_id in (select id from om_lab_order where encounter_id in (select id from om_encounter where visit_number is null));
delete from om_lab_order_parent where om_lab_order_id in (select id from om_lab_order where encounter_id in (select id from om_encounter where visit_number is null));
delete from om_observation_abnormalflags where om_observation_id in (select id from om_observation where order_id in (select id from om_lab_order where encounter_id in (select id from om_encounter where visit_number is null)));
delete from om_encounter where visit_number is null;
