Error creating patient for large location IDs.

OpenMRS Version: 1.9.2

Question: Hi Everyone,

I am newbie here… posting for the first time in OpenMRS talk. The issue which I’m facing is when I am trying to create a patient in OpenMRS (version 1.9.2), I get the following error message.

As according to this part of the error below, it seems that the location ID of values greater than 1000 are being converted to string. And I have tried this for several location IDs greater than 1000… same error occurs each time.

Any suggestions on this would be highly appreciated. If this issue still persists in OpenMRS, shall I create a ticket for this?

Many thanks…

Do you know how the number has a comma in it? I have never seen that happen before. Is it done custom code of yours?

E.g. instead is 1,440 it should be 1440.

Dear Darius,

That is what I’m unable to figure out that why is it converting it to string… No, it is not customized code. I’m creating a patient from OpenMRS from the ‘Create Patient’ link. Any insight into this would be highly appreciated, as it is blocking our project to function properly. Thanks

Are you able to reproduce this on OpenMRS versions 1.9.9?

This issue can’t be observed unless we have over 1000 locations in the system, which probably doesn’t happen for most of the OpenMRS installations.

Tahira, can you please try to reproduce on 1.9.9, as Daniel suggested?

If you do not have those many locations, just create one new location, go to the database and change its id to that value.

Another question, does it work well if you choose one that has a location of a lower id?

It works for locations lower than 1000. I’ll try to reproduce this error on OpenMRS 1.9.9.

While testing on 1.9.9 still remains, I was able to reproduce the same on 1.11.4. You can just execute “alter table location auto_increment = 1000” to quicken the process.

Just confirmed. Adding the following test to LocationEditorTest fails the test:

public void setAsText_shouldSetUsingIdWithGrouping() throws Exception {
	LocationEditor editor = new LocationEditor();

I think this issue should be ticketed. I’m wondering if any of the OpenMRS implementations have registered more than 1000 locations before.

Ofcourse that should fail because you are supplying an invalid location id that has a comma. So the LocationEditor is behaving correctly as expected. :slight_smile: Simply as the value of 10 but with a comma, would also fail. editor.setAsText(“1,0”);

1 Like

Oops! Okay, I corrected this and the test still fails. :innocent:

What does the test now look like? And what is the failure stack trace?


I tried to reproduce it on OpenMRS 1.9.9, and same error occurred for location ID: 1000. So, I’ll be creating a ticket for this.

public void setAsText_shouldSetUsingIdWithGrouping() throws Exception {
	LocationEditor editor = new LocationEditor();

And the stack trace says:

ERROR - LocationEditor.setAsText(60) |2015-10-15 14:10:52,591| Error setting text: 1,0
java.lang.NumberFormatException: For input string: "1,0"
	at java.lang.NumberFormatException.forInputString(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at org.openmrs.propertyeditor.LocationEditor.setAsText(
	at org.openmrs.propertyeditor.LocationEditorTest.setAsText_shouldSetUsingIdWithGrouping(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
	at org.junit.internal.runners.statements.RunBefores.evaluate(
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(
	at org.junit.internal.runners.statements.RunAfters.evaluate(
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.ParentRunner$
	at org.junit.runners.ParentRunner$1.schedule(
	at org.junit.runners.ParentRunner.runChildren(
	at org.junit.runners.ParentRunner.access$000(
	at org.junit.runners.ParentRunner$2.evaluate(
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(
	at org.junit.internal.runners.statements.RunAfters.evaluate(
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

I’ve found a fix though. Parsing the text using DecimalFormat object with number grouping flag disabled will handle the number formatted in group. However, it is peculiar that the webpage is converting this into grouped format.

I was also able to reproduce this for all ids that have four digits. The problem seems to come from shotPatientForm.jsp at:

form:options items="${locations}" itemValue="locationId" itemLabel="name"

So go ahead and create a ticket.

Here’s the ticket

1 Like

Another work around for this issue is to click “Add Identifier” to add a new row and delete the first one. The newly added identifier won’t have this issue.