Error when uploading Address Hierarchy

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

thanks for the instant response @dkayiwa, i tried loading the Uganda address hierarchy and now it does not allow me even to register a single patient on the system. let me try to share the server side logs over

@dkayiwa,am failing to access the server side logs,how can i navigate to it… as for the error i get is here Address Hierarchy Error causing address fileds not to be filled -
is there a way of deleting the address hierarchy i uploaded or resetting it to the default, thanks @dkayiwa i did follow the above and it worked for me though on the address field on patient registration, i still see two blank boxes… Thanks

@dkayiwa, i am trying following this solution Error when uploading Address HierarchyBahmni v. 0.87 and if it works, will surely let you know …Thanks