Calculating expiry days from expiry date for Aggregation Data Set

Hello all,

We have a data element in an aggregation data set, where user will enter expiry_date.

But for reports we need to calculate expiry days. (days between expiry_date and today)

Since we are using aggregation we cannot use program indicators or program rules. How can we achieve this in DHIS2?

Any hint would be very grateful

Hi Joseph,

I’m not sure that’s achievable out of the box to calculate the difference between 2 dates collected in aggregate data entry.
Just for my information, what type of items are you collecting that requires you to enter expiry date? Drugs? It’s better to use tracker for this where you create a tracker entity type ‘drug’ then tracker entity attribute that collects the generic drug name then create a stage that is repeatable and call it transaction - IN(or something else) that records every transaction for the particular drug including the date received, batch number, lot number, expiration date, quantity and unit of measure. Then you can create another stage to track the transactions - OUT (if you want to record the batch number, lot number, expiration date and then the quantity + unit of measure).

John

1 Like

Hello @jesplana

Thank you so much for your observations. Can you review our requirement, it’s very basic and it looks achievable through data set except for calculating number of days for expiry.

For example

1 Like

Hello @jpatrick,
From a UI perspective it definitely looks achievable but this will only really cover the IN and OUT of items. You can setup your products as Data Elements (DE) and hard code the unit of measure then set the received quantity and issued quantity as CatCombos.

However, this will not cover your need to calculate the expiry date and quantity. I’m sure you can run an SQL query to calculate the dates but you won’t be able to display it on the form or pivot table.

Copying @Scott here as he’s been working on this type of use case.

John

1 Like