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.
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
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.
Ofcourse that should fail because you are supplying an invalid location id
that has a comma.
So the LocationEditor is behaving correctly as expected.
Simply as the value of 10 but with a comma, would also fail.
editor.setAsText(“1,0”);
public void setAsText_shouldSetUsingIdWithGrouping() throws Exception {
LocationEditor editor = new LocationEditor();
editor.setAsText("1,0");
Assert.assertNotNull(editor.getValue());
}
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(LocationEditor.java:53)
at org.openmrs.propertyeditor.LocationEditorTest.setAsText_shouldSetUsingIdWithGrouping(LocationEditorTest.java:27)
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(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
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.
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.