Date of Birth is saved incorrectly

Observed result

Date of Birth is decremented by one day after saving of a new patient.

Before saving

After saving

Expected result

Patient is saved with the entered date of birth.

Steps to reproduce

  1. Go to the “Create New” menu entry:
  2. Enter date of birth “01.01.2000”, then anything in the other mandatory fields
  3. Click on the “Save” button

Note: The problem appears only if you enter the date of birth in the highlighted field. If you enter it via the age there is no problem.


Bahmni Installation

  • Can be reproduced with local installation of Bahmni 0.86
  • Can be reproduce on the demo platform as well.

Client info

  • Ubuntu 16.04
  • Chrome Version 53.0.2785.143 (64-bit)
  • Germany, timezone CET

What is your general process for such bug reports? Is this forum the right place for it?

There’s another problem with the display of the date of birth. This time it is displayed incremented.

Observed result

The date of birth displayed in the general patient overview is incremented by one compared to the patient registration view.



Expected result

The date of birth is everywhere the same.

Steps to reproduce

  1. Create a new patient
  2. Enter the age of the patient by clicking entering the number of years. Then fill in all the other mandatory information and save the patient.
  3. Take note of the date of birth.
  4. Search for the patient in the “Clinical” area
  5. Go to the patient details
  6. Compare the date of birth with the first one

I just stumbled across this issue in your Mingle backlog:

Maybe you can copy my first report into it. The second one might be a different problem.

Yes, this is the right forum.

Can you check please check the timezone in server and your machine? While bahmni installation did you set it to the right timezone ?

The timezone of the server is “Asia/Kolkata” and that of my browser is “Europe/Berlin” which is as intended.

If I set the server timezone to “Europe/Berlin” everything works as expected.

Thought this problems seems to be of theoretical nature it might be useful to fix it for the demo platform.

Here is what I have found out this afternoon about the causation of the problem:

(1) The AngularJS makes a REST request to “bahmnicore-omod” to create the patient. In this step the date of birth is transformed into a timestamp with the time-zone-offset from the server.

Request URL:
Request Method:POST
Status Code:200 OK
Remote Address:

Request payload

  "patient": {
    "person": {
      "birthdate": "2015-02-19T16:54:48.494+0100",




(2) The request for the patient details to the OpenMRS REST API doesn’t contain the time information anymore, but still the information about the time-zone-offset

Request URL:
Request Method:GET
Status Code:200 OK
Remote Address:

birthdate: "2015-02-19T00:00:00.000+0530"

(Probably handled by this class in OpenMRS directly:

(3) If the client is behind in time, it will display the wrong date.

Thanks for the detailed writeup @janux.

We are already aware of Timezone issues in Bahmni – since we encountered them some months ago. Unfortunately the fixes are non-trivial, and we don’t expect production instances to currently encounter this issue. It usually happens in Demo instances – surely, and also when someone from a different timezone logs on to see data in another place — or someone installs Bahmni in a specific timezone but configures it for use in a different timezone.

Since usually Bahmni is installed within premises – its not an issue currently in production locations. It can become an issue easily for cloud based deployments (like the demo instance) running in different timezones.

We have the following 2 tickets logged in Mingle already. Have a look: #2903 Alert the user about client/server timezone different #2738 Timezone issues in Drug-o-gram, ObsToObsFlowsheet Display Control and Date of birth

1 Like

I do not understand why there is a time and time zone attached to the date of birth at all.

These changes would fix the problem described in post #1 (and probably the one from post #3 , unfortunately I don’t know how to reproduce this today) as well:

[janux@ultrabook-jm ui]$ git diff
diff --git a/ui/app/common/util/dateUtil.js b/ui/app/common/util/dateUtil.js
index f45ceb8..9472fbb 100644
--- a/ui/app/common/util/dateUtil.js
+++ b/ui/app/common/util/dateUtil.js
@@ -269,9 +269,15 @@ Bahmni.Common.Util.DateUtil = {
     parseServerDateToDate: function (longDate) {
         return longDate ? moment(longDate, "YYYY-MM-DDTHH:mm:ss.SSSZZ").toDate() : null;
+    parseServerDateToCalendarDate: function (longDate) {
+        return longDate ? moment(longDate, "YYYY-MM-DD").toDate() : null;
+    },
     getDateTimeInSpecifiedFormat: function (date, format) {
         return date ? moment(date).format(format) : null;
     getISOString: function (date) {
         return date ? moment(date).toDate().toISOString() : null;
diff --git a/ui/app/registration/mappers/openmrsPatientMapper.js b/ui/app/registration/mappers/openmrsPatientMapper.js
index 93f7855..9d8b60f 100644
--- a/ui/app/registration/mappers/openmrsPatientMapper.js
+++ b/ui/app/registration/mappers/openmrsPatientMapper.js
@@ -26,6 +26,9 @@ angular.module('bahmni.registration').factory('openmrsPatientMapper', ['patient'
             parseDate = function (dateStr) {
                 return Bahmni.Common.Util.DateUtil.parseServerDateToDate(dateStr);
+            parseCalendarDate = function (dateStr) {
+                return Bahmni.Common.Util.DateUtil.parseServerDateToCalendarDate(dateStr);
+            },
             mapAddress = function (preferredAddress) {
                 return preferredAddress || {};
@@ -40,7 +43,7 @@ angular.module('bahmni.registration').factory('openmrsPatientMapper', ['patient'
                 openmrsPatient = openmrsPatient.patient;
                 var openmrsPerson = openmrsPatient.person;
                 var patient = patientModel.create();
-                var birthDate = parseDate(openmrsPerson.birthdate);
+                var birthDate = parseCalendarDate(openmrsPerson.birthdate);
                 patient.uuid = openmrsPatient.uuid;
                 patient.givenName = openmrsPerson.preferredName.givenName;
                 patient.middleName = openmrsPerson.preferredName.middleName;

Can I dare to create a pull request for this?

It seems like you are not too excited about this workaround. The good thing about it is that it actually works, probably for all the problematic cases.

When searching for a better solution I found out that there is – from my point of view – a problem with the test case “should map birth date in dd-mm-yyyy format”. If you add a console.log statement after the patient mapping you will see that the birthdate is actually not in this format but still includes a time zone. It looks like this: “Sun Mar 05 2017 00:00:00 GMT+0100 (CET)” (see full object dump).

I tried to store a string with the format “DD-MM-YYYY” in the field patient.birthdate (see b50932). Unfortunately, Angular refuses to display such a string as date field (see stacktrace).

An acceptable workaround might be to configure the Angular date display in a way to it ignores the time and time zone (see But I have to give up for today as vagrant suddenly fails to mount the source dir :dizzy_face:

Fixing the date issue is something I would like to see. But, unfortunately I don’t think it’s a simple fix. It may be simple for a particular screen, in which case you can raise a pull request for that, but overall the impact of dates is wide in Bahmni… since its integral to all screens – registration, consultation, document upload, reporting, etc. So - we will need to spend time testing that it works across all screens when client and server timezones are different.

Besides the demo server online, there hasn’t been a real usecase to actually cause us to spend the effort.

We may do it sometime in the future. Meanwhile if you have the bandwidth to raise a pull request to fix this, and have tested it sufficiently based on your usecases, please let us know. We will be happy to review/merge it.