Deleting patient, consultation, appointment and lab test records in Healthcare

I have been testing Healthcare alongside live operations of HR, payroll and accounting and would like to flush my test healthcare data before initial go live of some healthcare functions.

It appears that the cancel and delete function which is broadly available in accounting is not available in healthcare.

I understand in a fully live environment how this might have advantages, but would rather not have my test data cluttering and confusing the system for the next several years.

Could someone advise the best approach to removing?

Hi, May be you are missing some roles, you can use Role Permissions Manager to update delete rights for all required documents.
Thanks

Thanks. I gave system manager the permission to delete lab tests, patients, samples and consultations and have made some progress.

Unfortunately I have submitted some consultations and although a red delete button appears when they are selected I am unable to delete as they have been submitted. In accounting land I would first “cancel” then delete, but this option is not available and of course I cannot remove the patients that are linked to these consultations.

Hi, use the permission manager itself to update cancel rights for consultation, you should be able to delete once cancelled.
Thanks

Your suggestions worked fine in the other cases but it seems that there is a snag with Consultation.

You will see here that there is no “Cancel” option on the pull down.

That I am the one that submitted and so I guess there should not be an issue of ownership

That I have the role System Manager.

And that System Manager has permission to Cancel Consultations.

I am sorry but I have just noted that the submitted Lab Tests also not not permit cancellation

Your document is in not saved status, not sure why. Can you try Menu/Reload an see if the Cancel button appears instad of Update.
BTW why don’t you delete company transaction or reinstall the site or even try setting up a new site.
Thanks

When I first select the consultation I get the red Delete button. Using this produces the usual cannot delete a submitted doc response. Many reloads do not lead to cancel appearing. BTW using update produces the following “Not allowed to change Age after submission”.

On a more radical approach to record deletion. I am afraid that as I pointed out in my first post. I am adding Healthcare to an existing live system with good payroll, HR and accounting data and do not want to foul that. So a clean install is not a real option.

An existing ERPNext live system?
Being very careful you could log into your DB and delete problematic data rows like Consultations from the relevant healthcare table’s with your SQL GUI App
Just be a bit careful as an appointment might have created an invoice, Doctors Payslip etc etc.

You could always export all of your accounting data from within ERPnext and then do fresh reinstall reimporting required info.

Experimenting on a live production site is always going to be problematic…Best create a test version to run alongside your live version to try these things out.

2 Likes

Ok, got that… can you raise a github issue, will try to push a fix.
Thanks

Will do. BTW it is not first my choice to develop and run live but with such wide functionality it is tricky and time consuming to move segments of customization and/or data between 2 instances.

I have recently upgraded to 10.1.27…

The cancel/delete functions are much improved for patient/medical record/sample/consultation. Unfortunately lab test offers to cancel a submitted test but fails with the error below:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 45, in cancel
doc.cancel()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 839, in cancel
self._cancel()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 829, in _cancel
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 310, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 895, in run_post_save_methods
self.run_method(“on_cancel”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 758, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1027, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1010, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 752, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/healthcare/doctype/lab_test/lab_test.py”, line 20, in on_cancel
delete_lab_test_from_medical_record(self)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/healthcare/doctype/lab_test/lab_test.py”, line 247, in delete_lab_test_from_medical_record
if(medical_record_id[0][0]):
IndexError: tuple index out of range

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 45, in cancel
doc.cancel()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 839, in cancel
self._cancel()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 829, in _cancel
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 310, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 895, in run_post_save_methods
self.run_method(“on_cancel”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 758, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1027, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1010, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 752, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/healthcare/doctype/lab_test/lab_test.py”, line 20, in on_cancel
delete_lab_test_from_medical_record(self)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/healthcare/doctype/lab_test/lab_test.py”, line 247, in delete_lab_test_from_medical_record
if(medical_record_id[0][0]):
IndexError: tuple index out of range

You can track the git hub issue.

All fixed. Thanks everyone

1 Like