Error when uploading Address HierarchyBahmni v. 0.87

Hey, can anyone tell my what I’m doing wrong with this file? I am trying to upload it for my address hierarchy and I am getting the following error. I am using this documentation: Address Hierarchy Module - Documentation - OpenMRS Wiki I am also, attempting to import as .csv so I have “,” (minus the quotes) and checked to over write the existing hierarchy.

Please see attached file! I had to save it as .txt to upload it but it is a .csv file 1GechaanAddressnewnospace.txt (6.7 KB)

Thank you in advance for your help! :slight_smile:

Can anyone help with this? @sravanthi17 or @swathivarkala?

Hi @dnelson, Can you please share your Address Template from Manage Address Template page.

Sure, thank you @binduak… here’s a screen shot…

Please let me know if you see what I’m doing wrong. THANK YOU!

Hi @dnelson, I have uploaded the csv file that you have shared and I didn’t face any issue. It uploaded successfully. You can find the same in below screenshot.

I have imported the file as .csv, used delimter as “,” and checked the box to overwrite the existing hierarchy. Can you please change the tag <org.openmrs.layout.address.AddressTemplate> to <org.openmrs.layout.web.address.AddressTemplate> in your Address Template, not sure this is the one causing the error. Let us know if you are still facing the issue.

Hi @dnelson, changes made but not allowing me to save.

It seems that originally uploaded an incorrect file that seemed to load several “blank” lines but I just can’t seem to overwrite it. It’s so frustrating. Any way to put the original data in the applicable tables, perhaps?

I worked with @binduak to resolve issue.

Based on this error in the openmrs log: Caused by: java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (openmrs.address_hierarchy_entry, CONSTRAINT parent-to-parent FOREIGN KEY (parent_id) REFERENCES address_hierarchy_entry (address_hierarchy_entry_id) ON DELETE CASCADE) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (openmrs.address_hierarchy_entry, CONSTRAINT parent-to-parent FOREIGN KEY (parent_id) REFERENCES address_hierarchy_entry (address_hierarchy_entry_id) ON DELETE CASCADE)

She first had me do the following in the db:

  1. set foreign_key_checks=0;
  2. delete from address_hierarchy_entry;
  3. INSERT INTO openmrs.address_hierarchy_entry (name, level_id, parent_id, user_generated_id, latitude, longitude, elevation, uuid) VALUES (‘Chattisgarh’, 3, null, null, null, null, null, ‘379e8e56-dd36-42c5-9b35-04ec5842c123’)
  4. set foreign_key_checks=1;

I then was successfully able to import my address hierarchy with no errors.
Thank you so much @binduak! Issue resolved!

3 Likes