Coming back to this with a proposal/vision for a destination for date & time handling within the OpenMRS Platform…
To date (pun intended), OpenMRS has used MySQL’s datetime
data type to store dates & times and we use a boolean “estimated” workaround (e.g., birthdate_estimated
flag) to indicate when a date ± time is an estimated value. This has failed us on multiple fronts:
- Fails to support partial dates/times in many cases where data model doesn’t have “estimated” workaround
- Estimated dates/times are ambiguous (our boolean workaround fails to distinguish between estimates to day, month, year, etc.
- All of our time data are ambiguous (no timezone information stored in the database)
- Not aligned with FHIR
Proposal for better date/time support
Scenario | Approach |
---|---|
Date & time with partial date/time support |
|
Date & time without need for partial date/time support |
|
Date with partial date support |
|
Date without partial date support |
|
Time with partial time support |
|
Time without partial time support |
|
Assumptions
- Changes the data model could be rolled out over time or we could have a date/time hackathon to refactor across the board.
- During the transition of datetime data, server timezone would be assumed when converting data from
datetime
totimestamp
- Where we add/refactor support for partial data, any existing attribute would become the interpreted value and the string “value” attribute would be added to the data model for backwards compatibility (any code dealing with partial data would be refactored to use the new
string
attribute and place the suitable proxy date/time value into the existing attribute)
Example
person.birthdate_estimated (boolean)
is deprecatedperson.birthdateValue (string)
is added to contain actual data collected (full or partial) in FHIR formatperson.birthdate (date)
remains as an interpretation ofbirthdateValue
(e.g., “2023” → 2023-01-01 just as we do now)
All code reading person.birthdate
could continue to hum along unchanged; however, we would now be able to explicitly store and faithfully reproduce estimated birthdates like “1980” or “May 1980”.