Issues stopping TB drug orders with the current date as the stop date

In EndTB 1.5 the TB drug tab in the clinical app allows the prescribing of drugs with an indefinite duration until a stop date is specified. The problem we are having is that we are unable to stop a drug on the current date: An example of the resulting error message is “20:40 PGT 2017 to null)’ failed to validate with reason: dateActivated: Date Activated cannot be in the future ‘DC DrugOrder(100.064 of Clofazimine (Cfz) from Sat Jun 24 11:20:40 PGT 2017 to null)’ failed to validate with reason: dateActivated: Date activated cannot be in the future”

Setting the system time on the client computer back an hour resolves the problem.

So is the failed validation a result of the validation checking the current system time on the client computer and comparing it to the server time as part of the validation? That is, if the client computer for any reason is running ahead of the server the validation will fail. If this is the case it might be good to make some allowance for discrepancies between system time on the client computer and on the server.

As a workaround, is it possible to configure the medications module to allow manual entry of time as well as date for stopping the drug (ie so that you can manually enter a time that is older than the current server time)?

Also, is the validation rule for stopping a drug with indefinite duration configurable at implementation (even if in groovy) or is it coded into an omod that would need to be recompiled?

We are facing similar issue occassionally in our implementation also.

The fix for this would be to change the check at backend to not consider time and only consider date. As a workaround, we can send only date information with time as 00:00:00 (start of today) instead of sending the current time. In that way, the time in ‘dateActivated’ will always be less than the currentTime and the check will be done only for the date.

Steps to reproduce:

  1. Set the client system’s time ahead by 1 minute
  2. Go to medication tab for any patient with active medications
  3. Stop any drug Error is thrown saying: “dateActivated is in future”

Analysis: dateActivated is the date on which the action (Stop) is done. In this case, it will be current date. This is obtained using new Date() that gives the date with current system’s time which is ahead of server’s time by 1 minute. In the backend, a check is performed to see if the dateActivated is in future which checks with the current system time of server. As the check fails error is thrown.

@pramidat

Apologies, I should have posted back. We updated our server configuration by adding an NTP client and pointing it to NTP.org’s time servers. As far as I’m aware we haven’t encountered this issue since that change was made.