Currently duration_units is a concept without any metadata which can help converting the duration to auto_expire_date of drug order.
We need a standard mechanism by which these concepts can be interpreted to determine auto_expire_dates from the start date.
What is an existing standard that has well-known external codes for the duration units we need to support? If we can't find anything better, we can go with Y, M, W, D, H, M, S from http://en.wikipedia.org/wiki/ISO_8601#Durations
Does the upgrade helper module need to help with this?
How should we handle "Time(s)"? The method signature in Dev Notes isn't sufficient for this
If the startDate has no time component and the duration is provided, then the autoExpireDate should be computed until just before midnight (23:59:59.999) e.g If the prescription is for 4 days from august 1st, the autoExpireDate should be august 4th at 23.59:59.999pm (and importantly, the dev working on this ticket should be aware that the underlying API is going to push stop dates of 00:00:00 to be 23:59:59), see also
We are going to use concept reference mappings to indicate the underlying meaning of the duration unit concepts.
- Ask Andy Kanter to add a concept source representing the standard we choose. Find the duration unit concepts in the CIEL concept dictionary, and ask Andy Kanter to add reference mappings for them. (E.g. CIEL 1073 should be mapped to "ISO 8601 Duration:W")
- Add instructions to the 1.10 wiki pages describing how someone not using the CIEL dictionary can add this source and mappings
- Add a utility method like: Date addDuration(Date indexDate, double num, Concept durationUnit).
- Under the hood I would use joda time (if we've already included that in OpenMRS core)
- I'd expect this method to have hardcoded behaviors knowing about the units we care about
- To Do: change this so we can handle Time(s). E.g. maybe it should be Date inferAutoExpireDate(DrugOrder)
- Main point: just have a single utility method that handles exactly the case we care about – we're not trying to introduce a generic unit conversion framework at this point.