Error when uploading Address Hierarchy

I was trying to add new address hierarchy but I get this error message

I have the following installed

Bahmni ver. 0.91 mysqld ver. 5.6.43

Address Hierarchy ver. 2.11.0

Moved to the bahmni category.

@dkayiwa do you know anyone you can recommend to help me with this error. I’ve been stuck with it for 2 weeks now

How are you loading the address hierarchy?

I used a CSV file with just 2 columns, using pipe as the delimiter. I had checked the option to overwrite existing records. My address hierarchy template only has 2 fields.

But now I can’t even access the Address Hierarchy menu because of that error. So far I have tried stopping and starting the module, uninstalling and re-installing the module but the error still persists

Does the error still happen even after the module is uninstalled?

The link is removed from the Admin centre once I uninstall the module

If i just installed the bare OpenMRS and this module, would i be able to reproduce your problem? If yes, what are the exact steps?

I’m not too sure, the OpenMRS was installed with the Bahmni installer that I used

Hi @tapologo Can you please share the addressHierarchy.csv file that you are trying to import.

Hi @binduak This is the adddress hierarchy I used

botswana-address-hierarchy.csv (252 Bytes)

@dkayiwa @binduak I saw this in the logs

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.openmrs.module.addresshierarchy.AddressHierarchyEntry#1748]

So I logged into MYSQL and ran this statement

mysql> select * from address_hierarchy_entry;

From the output I noticed there is no record with address_hierarchy_entry_id = 1748, see below screenshot

Additionally I noticed that my address hierarchy was not loaded properly, see area highlighted red. Is there a way I can flush these entries?


I managed to resolve this by truncating the address_hierarchy_level table and rebuilding the address hierarchy from scratch.

1 Like

Hello @tapologo, i have succumbed to the same problem too, how did you manage to truncate the table despite on my side it outputs an error. TRUNCATE TABLE * from address_hierarchy_level; ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (openmrs.address_hierarchy_entry, CONSTRAINT level_to_level FOREIGN KEY (level_id) REFERENCES openmrs.address_hierarchy_level (address_hierarchy_level_id)) Any solution to this. Thanks

@apuda are you able to delete individual records from the database or that also fails? Did your address hierarchy get uploaded in the DB but not in the correct format as it was the case with mine?

Thanks for your attention on this issue. @tapologo, i didnt try to delete individual records from the database instead i was trying to follow what worked for at the level of address_hierarchy_level table by issuing the TRUNCATE COMMAND, the address hierarcy did not fully get uploaded. is there away i can as well rebuild this address_hierarchy_levelthough the TRUNCATE command has failed due to FOREIGN KEY constraint. Thanks

, on the image,i did forgot to use the comma instead i used the blue highighted code without quotes that caused the issue

@apuda try deleting the the records you added either using timestamp or some other pattern. That should resolve the issue. For me the records which were added were the ones causing the issue

This i have tried and failed,is there a another way which ca yield me positive results than destroying the whole database? @dkayiwa any help here. Thanks

@apuda what is the exact problem that you are facing? Can you also share the server side log via