-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed delete script files instructions
- Loading branch information
1 parent
6535d3a
commit 1b2c553
Showing
5 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#GITHUB_URL="https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/0.91" | ||
|
||
OPENMRS_SQL_FILE="deletePatientDataForOpenMRS.sql" | ||
OPENELIS_SQL_FILE="deletePatientDataForOpenElis.sql" | ||
OPENERP_SQL_FILE="deletePatientDataForOpenERP.sql" | ||
CURDIR=$(pwd) | ||
|
||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
CYAN='\033[0;36m' | ||
NOCOLOR='\033[0m' | ||
|
||
stop_all_bahmni_services() | ||
{ | ||
|
||
echo -e "${CYAN}Stopping all bahmni related services${NOCOLOR}" | ||
bahmni -i $INVENTORY_FILE stop | ||
|
||
} | ||
|
||
download_and_delete_openmrs_patient_data(){ | ||
echo -e "${CYAN}downloading openmrs delete patient data sql file${NOCOLOR}" | ||
if [ -z $OPENMRS_DB_USER ];then | ||
echo -e "${RED}OPENMRS_DB_USER is unset.Please set the ENVIRONMENT VARIABLE OPENMRS_DB_USER ${NOCOLOR}" | ||
else | ||
echo -e "${CYAN} deleting openmrs patient data${NOCOLOR}" | ||
mysql -u$OPENMRS_DB_USER -p$PASSWORD openmrs < $OPENMRS_SQL_FILE | ||
exitcode=$? | ||
if [ $exitcode -ne 0 ]; then | ||
echo -e "${RED}Failed to delete the openmrs patient data${NOCOLOR}" | ||
else | ||
echo -e "${GREEN} Successfully deleted the openmrs patient data${NOCOLOR}" | ||
fi | ||
fi | ||
} | ||
|
||
download_and_delete_openelis_patient_data(){ | ||
echo -e "${CYAN}downloading openelis delete patient data sql file${NOCOLOR}" | ||
if [ -z "$OPENELIS_DB_USER" ]; | ||
then echo -e "${RED}OPENELIS_DB_USER is unset. Please set the ENVIRONMENT VARIABLE OPENELIS_DB_USER${NOCOLOR}" | ||
else | ||
echo -e "${CYAN}deleting openelis patient data ${NOCOLOR}" | ||
psql -U$OPENELIS_DB_USER clinlims < $OPENELIS_SQL_FILE | ||
exitcode=$? | ||
if [ $exitcode -ne 0 ]; then | ||
echo -e "${RED}Failed to delete the openelis patient data${NOCOLOR}" | ||
else | ||
echo -e "${GREEN} Successfully deleted the openelis patient data${NOCOLOR}" | ||
fi | ||
fi | ||
} | ||
|
||
download_and_delete_openerp_patient_data(){ | ||
echo -e "${CYAN}downloading openerp delete patient data sql file${NOCOLOR}" | ||
if [ -z "$OPENERP_DB_USER" ]; | ||
then echo -e "${RED}OPENERP_DB_USER is unset. Please set the ENVIRONMENT VARIABLE OPENERP_DB_USER${NOCOLOR}" | ||
else | ||
echo -e "${CYAN}deleting openerp patient data${NOCOLOR}" | ||
psql -U$OPENERP_DB_USER openerp < $OPENERP_SQL_FILE | ||
exitcode=$? | ||
if [ $exitcode -ne 0 ]; then | ||
echo -e "${RED}Failed to delete the openerp patient data${NOCOLOR}" | ||
else | ||
echo -e "${GREEN} Successfully deleted the openerp patient data${NOCOLOR}" | ||
fi | ||
fi | ||
} | ||
|
||
start_all_bahmni_services() | ||
{ | ||
echo -e "${CYAN}Starting all bahmni related services${NOCOLOR}" | ||
bahmni -i $INVENTORY_FILE start | ||
} | ||
|
||
stop_all_bahmni_services | ||
download_and_delete_openmrs_patient_data | ||
download_and_delete_openelis_patient_data | ||
download_and_delete_openerp_patient_data | ||
start_all_bahmni_services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
truncate table | ||
sale_order, | ||
sale_order_line, | ||
sale_make_invoice, | ||
sale_order_invoice_rel, | ||
sale_order_line_invoice_rel, | ||
sale_order_line_make_invoice, | ||
sale_order_line_property_rel, | ||
sale_order_tax, | ||
|
||
sale_order_group, | ||
account_invoice_line, | ||
ledger_journal_rel, | ||
reconcile_account_rel, | ||
validate_account_move, | ||
procurement_order, | ||
purchase_order, | ||
purchase_order_line, | ||
purchase_invoice_rel, | ||
stock_picking, | ||
stock_partial_picking, | ||
stock_partial_picking_line, | ||
stock_partial_move, | ||
stock_partial_move_line, | ||
stock_move, | ||
stock_move_split, | ||
stock_move_split_lines, | ||
stock_return_picking_memory, | ||
stock_inventory_move_rel, | ||
stock_move_history_ids, | ||
|
||
account_invoice_line_tax, | ||
account_invoice, | ||
account_invoice_refund, | ||
account_invoice_tax, | ||
account_invoice_cancel, | ||
account_invoice_confirm, | ||
|
||
purchase_order_line_invoice_rel, | ||
stock_warehouse_orderpoint, | ||
purchase_order_taxe, | ||
|
||
account_voucher, | ||
account_bank_statement_line, | ||
account_voucher_line, | ||
account_bank_statement_line_move_rel, | ||
|
||
account_move_line, | ||
account_move_line_relation, | ||
account_analytic_line, | ||
hr_analytic_timesheet; | ||
|
||
truncate table | ||
res_partner_attributes, | ||
res_partner_address, | ||
res_partner_bank_type_field, | ||
res_partner_res_partner_category_rel, | ||
res_partner_category; | ||
|
||
delete from res_partner where not exists (select ru.partner_id from res_users ru where ru.partner_id = res_partner.id) and id != 1; | ||
delete from markers where feed_uri like '%atomfeed/encounter/recent%' OR feed_uri like '%atomfeed/patient/recent%'; | ||
delete from event_records where category = 'product'; | ||
|
||
truncate table event_records_offset_marker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
truncate table result_signature, | ||
referral_result, | ||
referral, | ||
result_inventory, | ||
result, | ||
worksheet_analyte, | ||
note, | ||
report_external_export, | ||
report_external_import, | ||
analysis_qaevent, | ||
analysis_storages, | ||
analysis_users, | ||
analysis, | ||
sample_qaevent, | ||
sample_requester, | ||
sample_human, | ||
sample_newborn, | ||
sample_animal, | ||
sample_environmental, | ||
sample_item, | ||
sample_organization, | ||
sample_projects, | ||
sample, | ||
observation_history, | ||
patient, | ||
patient_identity, | ||
patient_occupation, | ||
person_address, | ||
patient_patient_type, | ||
patient_relations, | ||
organization_contact; | ||
|
||
delete from person where not exists (select p.person_id from provider p where p.person_id = person.id); | ||
delete from markers where feed_uri like '%atomfeed/encounter/recent%' OR feed_uri like '%atomfeed/patient/recent%'; | ||
delete from event_records where category = 'patient'; | ||
|
||
truncate table event_records_offset_marker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
set foreign_key_checks=0; | ||
|
||
truncate table test_order; | ||
truncate table drug_order; | ||
truncate table note; | ||
truncate table obs_relationship; | ||
truncate table concept_proposal; | ||
truncate table concept_proposal_tag_map; | ||
truncate table obs; | ||
truncate table orders; | ||
truncate table drug_order; | ||
truncate table test_order; | ||
truncate table relationship; | ||
truncate table visit_attribute; | ||
truncate table bed_patient_assignment_map; | ||
truncate table encounter_provider; | ||
truncate table episode_encounter; | ||
truncate table order_group; | ||
truncate table encounter; | ||
truncate table appointmentscheduling_appointment; | ||
truncate table appointmentscheduling_appointment_status_history; | ||
truncate table visit_attribute; | ||
truncate table visit; | ||
truncate table patient_identifier; | ||
truncate table appointmentscheduling_appointment_request; | ||
truncate table conditions; | ||
truncate table cohort_member; | ||
truncate table patient_program; | ||
truncate table episode_patient_program; | ||
truncate table patient_program_attribute; | ||
truncate table patient_state; | ||
truncate table patient; | ||
truncate table episode; | ||
truncate table audit_log; | ||
delete from person_address where person_id <> 1; | ||
delete from person_attribute where person_id <> 1; | ||
delete from person_name where not exists | ||
(select u.person_id from users u where person_name.person_id = u.person_id or person_name.person_id = 1) | ||
and not exists (select p.person_id from provider p where person_name.person_id = p.person_id or person_name.person_id = 1); | ||
delete from person where not exists | ||
(select u.person_id from users u where person.person_id = u.person_id or person.person_id = 1) | ||
and not exists (select p.person_id from provider p where person.person_id = p.person_id or person.person_id = 1); | ||
|
||
delete from event_records where category = 'patient' OR category = 'Encounter'; | ||
delete from markers where feed_uri like '%feed/patient/recent%' ; | ||
|
||
truncate table event_records_offset_marker; | ||
|
||
update bed set status="AVAILABLE"; | ||
|
||
set foreign_key_checks=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Set environment variables required for the scripts | ||
export OPENMRS_DB_USER=openmrs-user | ||
export OPENELIS_DB_USER=clinlims | ||
export OPENERP_DB_USER=openerp | ||
export INVENTORY_FILE=local | ||
|
||
# Add executable permission for the scripts | ||
chmod a+x * | ||
|
||
# Start the script execution | ||
sh deletePatientData.sh |