Unable to Register Patient

Android: 7.x App Version: 2.8.4-debug.1-build:0

Error stack

2020-08-25 17:38:39.091 2053-2053/? D/AndroidRuntime: Shutting down VM 2020-08-25 17:38:39.091 2053-2053/? E/OpenMRS: #47 OpenMRSLogger.lambda$new$0$OpenMRSLogger() : Uncaught exception is: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String org.openmrs.mobile.models.PersonName.getGivenName()’ on a null object reference at org.openmrs.mobile.utilities.PatientComparator.compareFullPersonName(PatientComparator.kt:92) at org.openmrs.mobile.utilities.PatientComparator.comparePatients(PatientComparator.kt:39) at org.openmrs.mobile.utilities.PatientComparator.findSimilarPatient(PatientComparator.kt:24) at org.openmrs.mobile.activities.addeditpatient.AddEditPatientPresenter$6.onResponse(AddEditPatientPresenter.java:362) at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 2020-08-25 17:38:39.091 2053-2053/? E/OpenMRS: #47 OpenMRSLogger.lambda$new$0$OpenMRSLogger() : Uncaught exception is: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String org.openmrs.mobile.models.PersonName.getGivenName()’ on a null object reference at org.openmrs.mobile.utilities.PatientComparator.compareFullPersonName(PatientComparator.kt:92) at org.openmrs.mobile.utilities.PatientComparator.comparePatients(PatientComparator.kt:39) at org.openmrs.mobile.utilities.PatientComparator.findSimilarPatient(PatientComparator.kt:24) at org.openmrs.mobile.activities.addeditpatient.AddEditPatientPresenter$6.onResponse(AddEditPatientPresenter.java:362) at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Hi @ssmusoke , registering new patients is working for me (Android 9) . Did you try registering a second time? @rishabh997 Can you confirm?

The error is pointing on org.openmrs.mobile.models.PersonName.getGivenName() which I provided on the registration form and also failed on 2.8.4 released version

@ssmusoke Can you try on a different device? with different android version

I am looking into the stack trace once and see if anything can produce a null pointer for future reference… Can you try doing a clean install once as we made a lot of changes in schemas so there might be errors, and also anothe device too. Will look into the error as it seems to be API specific

I am using Genymotion with a factory reset image at each run so it is always clean

@f4ww4z fails on Android 7 and 9 with the same error. Do you want me to try it on 10 too?

@ssmusoke I tried running on emulator (API level 28 ) and It woked fine for me, @rishabh997 did it work for you ?

I don’t know the reason why only @ssmusoke is facing this error, but as a safety measure, we can add null point checks at Line 92 in patient comparator… cc: @f4ww4z

1 Like

@rishabh997 Yes that is correct - will probably solve the issues being faced, need to handle null on both sides especially for unidentified patients

1 Like

Strange I have pulled the latest code from the master branch and it all seems to work now, I am totally confused by the way

even i have no clue why only you were facing this issue, nevertheless, we will add NPE checks so that no one faces this error by any chance… Thanks for pointing out :slight_smile:

1 Like

Yes @ssmusoke thanks for posting this, we can definitely add a patch for this.

1 Like