Retrieve previous month data value of a data element and put it in the current month data entry

Hi, everyone.

How can I retrieve the data values of previous month and show it in the current months data entry?

Any help on how how I can do this is DHIS2 is welcome?

1 Like

Hi Fernando,

I’d tentatively suggest you look at Predictors (https://docs.dhis2.org/master/en/user/html/manage_predictor.html). I’ve never implemented them myself (perhaps someone who has can chime in with advice?), but they’re designed for exactly the use case you have here - they allow you to automatically (as scheduled) calculate the current value for a data element based on values held in other data elements over a specified period (eg last month).

Since I’ve not worked with them, and have no idea how ‘buggy’ they are, no warranties (express or implied) can be provided. :wink: If Predictors do turn out to be a viable solution for you, please do share your experience with the community.

Cheers, Sam.

2 Likes

Hi @fernando,

I wrote the below script for opening balance calculation:

dhis2.util.on( ‘dhis2.de.event.formReady’, function( event,iReVg2xgFPL ) {
var periodN= $( ‘#selectedPeriodId’ ).val();// From DHIS2 Selection Param
var nextPeriod=(+periodN) + (+1); //201611,201612,201613
var nextPeriodSeperate=periodN.toString().substring(0, 4);
var year=parseInt(nextPeriodSeperate.trim());
var month=parseInt(periodN % 100);
if(month==12){
year++;
month=01;
nextPeriod=year+‘01’;
}
$(’.selectedDate’).val(nextPeriod);
});

You will get detail on this post: http://dhis2trainingland.com/eportal/?tutorial=how-to-calculate-previous-month-value-in-dhis2-data-entry-form

Basically, I’m calculating the closing balance and saving it for next period and getting automatically opening balance value in the next period.

Thanks

1 Like

Thank you, Samuel, for your suggestions and help.

1 Like

Hi, Julhas.

Thank you for your help.

1 Like

Hi Julhas, I hope all is well. This is very helpful. I just don’t know where/how exactly to put the code. Do you mind to guide me?

1 Like

Hi Norberto,

Sure, you can ping me on skype: juhas08.

Thanks

2 Likes

Hi Julhas, I sent you an invitation yesterday on skype. Can you please add me with norbertob.pi

Thanks,

1 Like

Hi Norberto, I didn’t get your invitation. :slightly_smiling_face: Let me add you.

Thanks

1 Like