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?
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?
Hi Fernando,
I’d tentatively suggest you look at Predictors (Home - DHIS2 Documentation). 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. If Predictors do turn out to be a viable solution for you, please do share your experience with the community.
Cheers, Sam.
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: How to calculate previous month value in DHIS2 data entry form? – DHIS2 Web Portal
Basically, I’m calculating the closing balance and saving it for next period and getting automatically opening balance value in the next period.
Thanks
Thank you, Samuel, for your suggestions and help.
Hi, Julhas.
Thank you for your help.
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?
Hi Norberto,
Sure, you can ping me on skype: juhas08.
Thanks
Hi Julhas, I sent you an invitation yesterday on skype. Can you please add me with norbertob.pi
Thanks,
Hi Norberto, I didn’t get your invitation. Let me add you.
Thanks
Hi @fernando,
@SamuelJohnson is exactly correct. Predictors enable you to do this without having to make any custom scripts. You’re use-case is fairly simple.
Hope this helps and please let me know if you have any questions.
Scott
Informative!!!