Bahmni: Unable to save a new patient (NullPointerException)

Hi everyone!

On a fresh installation of Bahmni in Vagrant box (following this article), I am not able to create a new patient. I get the following error message when clicking on Save:

Server log:


SEVERE: Servlet.service() for servlet [openmrs] in context with path [openmrs] threw exception [Request processing failed; nested exception is org.openmrs.module.webservices.rest.web.response.ConversionException: identifiers on class org.openmrs.Patient] with root cause java.lang.NullPointerException at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:750) at org.openmrs.module.webservices.rest.web.ConversionUtil.convertMap(ConversionUtil.java:305) at org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:267) at org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:207) at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:744) at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setConvertedProperties(BaseDelegatingResource.java:612) at org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8.getPatient(PatientResource1_8.java:192) at org.bahmni.module.bahmnicore.web.v1_0.controller.BahmniPatientProfileResource.mapForCreatePatient(BahmniPatientProfileResource.java:138) at org.bahmni.module.bahmnicore.web.v1_0.controller.BahmniPatientProfileResource.create(BahmniPatientProfileResource.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

Any idea?

(If it is not something obvious, I can give some debugging info)

Thanks

Refresh your vagrant and try using a different browser.

Thanks @jaghatise,

Following your advice I’ve done:

  $  vagrant destroy
  $  vagrant up

And it works fine!

But as soon as I add the bahmniapps link in the /var/www/ folder, it brakes (can’t save patients)

I tried to carefully apply these steps again:

  • revert to the original bahmniapps folder (link to /opt/bahmni-web/etc/bahmniapps/)
  • from the host machine, rebuild the openmrs-module-bahmniapps/ui folder
  • create the symlink again
  • add the appropriate access rights (bahmni:bahmni)
  • restart openmrs

Still doesn’t work

Here is the contents of my /var/www/ folder after all the links:

Could it be that I need to checkout and build the openmrs-module-bahmniapps on a specific branch/tag ?


Furthermore, in the documentation, there is a line that I am not sure to understand and confuses me:

The first line is to be applied in the host right? What is that for?

But the other lines from within the vagrant box?

Am I right? (If not, then I probably made a big mistake in my config)

Hello,

Are you saying the patient creation fails when you link bahmniapps to your local folder ?

Which version of bahmni did you install ? Do you have latest bahmniapps in your local ?

Hello @sravanthi17,

Yes exactly. It works perfectly fine with the following config:

But when I change the bahmniapps link to my local openmrs-module-bahmniapps repo,

and I restart, then it stops working

My Bahmni vagrant box version is 0.81. And I have the latest openmrs-module-bahmniapps on master branch.

When you have 0.81 version of Bahmni, openmrs-module-bahmniapps should be checked to corresponding branch (release-0.81)

OK, thanks. That makes sense. I didn’t think of it earlier :confused:

However, I can’t build branch 0.81.

I’ll start another post if needed.

Thanks a lot @sravanthi17

What is the issue with building ?

Here is my build error:

Firefox 46.0.0 (Ubuntu 0.0.0) patient context initialization should set preffered identifier to patient identifier if the configure attribute does not exists FAILED

TypeError: can’t assign to properties of (new String(“1234”)): not an object in /home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/clinical/displaycontrols/patientContext/directives/patientContext.js (line 9) convertBooleanValuesToEnglish/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/clinical/displaycontrols/patientContext/directives/patientContext.js:9:3108 er/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/lodash/dist/lodash.min.js:31:385 at@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/lodash/dist/lodash.min.js:18:190 rr/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/lodash/dist/lodash.min.js:31:172 ne@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/lodash/dist/lodash.min.js:49:464 convertBooleanValuesToEnglish@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/clinical/displaycontrols/patientContext/directives/patientContext.js:9:2849 controller/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/clinical/displaycontrols/patientContext/directives/patientContext.js:9:1282 .then@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/test/unit/clinical/displaycontrols/patientContext/directives/patientContext.spec.js:195:32 controller@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/clinical/displaycontrols/patientContext/directives/patientContext.js:9:648 invoke@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:4535:14 $ControllerProvider/this.$get</</instantiate<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:9380:24 nodeLinkFn@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:8497:34 compileTemplateUrl/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:8770:13 processQueue@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:14991:28 scheduleProcessQueue/<@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:15007:27 $RootScopeProvider/this.$get</Scope.prototype.$eval@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:16251:16 $RootScopeProvider/this.$get</Scope.prototype.$digest@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:16069:15 $RootScopeProvider/this.$get</Scope.prototype.$apply@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:16359:13 done@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular/angular.js:10791:36 handleResponse@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular-mocks/angular-mocks.js:1272:9 createHttpBackendMock/$httpBackend.flush@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular-mocks/angular-mocks.js:1631:9 @/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/test/unit/clinical/displaycontrols/patientContext/directives/patientContext.spec.js:203:13

Firefox 46.0.0 (Ubuntu 0.0.0) programService test updatePatientProgram FAILED

Expected { dateEnrolled : ‘2016-01-01T00:00:00+0700’, states : [ ], uuid : ‘Some UUID’, dateCompleted : ‘2016-01-12T07:00:00+0700’, outcome : null, attributes : [ { attributeType : { uuid : ‘079b73c6-b854-11e5-9584-0800274a5156’ }, value : ‘123’, uuid : ‘6ccf5c9c-9f8c-4e46-b40b-c203b033f6d7’ }, { attributeType : { uuid : ‘07ae82e4-b854-11e5-9584-0800274a5156’ }, value : ‘2016-01-12T00:00:00.000+0000’, uuid : ‘12cac096-ac84-419f-88c3-f140a3c13d98’ } ] } to equal { attributes : [ { uuid : ‘6ccf5c9c-9f8c-4e46-b40b-c203b033f6d7’, attributeType : { uuid : ‘079b73c6-b854-11e5-9584-0800274a5156’ }, value : ‘123’ }, { uuid : ‘12cac096-ac84-419f-88c3-f140a3c13d98’, attributeType : { uuid : ‘07ae82e4-b854-11e5-9584-0800274a5156’ }, value : ‘2016-01-12T00:00:00.000+0000’ } ], states : [ ], outcome : null, dateCompleted : ‘2016-01-12T05:30:00+0530’, dateEnrolled : ‘2016-01-01T00:00:00+0530’, uuid : ‘Some UUID’ }. @/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/test/unit/common/domain/services/programService.spec.js:616:13 handleResponse@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular-mocks/angular-mocks.js:1270:24 createHttpBackendMock/$httpBackend.flush@/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/app/components/angular-mocks/angular-mocks.js:1631:9 @/home/romain/repos/bahmni/openmrs-module-bahmniapps/ui/test/unit/common/domain/services/programService.spec.js:622:9

Error 2 looks like something similar than Bahmniapps: 2 tests failing in the release-0.81 branch

Thats a miss from our end. Sorry for that. This is fixed in Master and soon will be pushed to 0.81.

Mean while you can manually change the line

to

programAttributes: {‘Aadhar Number’: {description: ‘Aadhar Number’, value: ‘1234’}},

Please build it again after making the above change.

Please ignore error 2 for now. The pull request is still under review and not yet merged.

Cool thanks. That works.

I had to switch my timezone to IST to make the tests all pass (or use grunt --force). Now it works perfect.

Thanks @sravanthi17 for the help

1 Like

@mksrom / @sravanthi17 - as a point of reference, we (PIH) have a fork of release-0.81 of bahmniapps in which we have either backported from master, or applied new fixes, in order to successfully build without forcing tests, and without having to use IST. You can find that code here:

https://github.com/PIH/openmrs-module-bahmniapps

We’d certainly welcome these backports and fixes to be applied to the upstream release-0.81 branch as well.

Thanks, Mike

1 Like

Thanks @mseaton for your interest in fixing. We will merge it soon.