medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
441 stars 211 forks source link

Support Nepali calendar in outgoing SMS #3219

Closed alxndrsn closed 7 years ago

alxndrsn commented 7 years ago

When sending EDDs in SMS messages, allow the date to be formatted using the Bikram sambat (Vikram samvat) calendar. Not to be confused with the Newari sambat (Nepal sambat) calendar.

alxndrsn commented 7 years ago

This might be implemented as an Angular filter, so that in config you can include e.g. {{bikram_sambat:edd}} for an EDD rendered in the Nepali calendar, in place of {{edd}} for an EDD rendered in the Gregorian calendar.

alxndrsn commented 7 years ago

We will also want to be able to re-format dates using Bikram sambat in analytics reports, and possibly use the Bikram sambat month system to define the time periods for analytics calculations. This may inform the implementation used for this ticket.

alxndrsn commented 7 years ago

@bishwas-medic please provide examples of how we want to format dates in EDD SMS.

abbyad commented 7 years ago

Do we also want to be able to use that display date format from configuration?

image

sglangevin commented 7 years ago

Anywhere else in the app that we'd need to render these dates? What about if a nurse is filling in a form in the web app (not sure if that is relevant to the particular project in mind)? Finally, are there other use cases where we would need to support Nepali dates besides ANC?

alxndrsn commented 7 years ago

@sglangevin yes, I'll create separate tickets for the different use cases - they're lower priority than this.

bishwasBhatta commented 7 years ago

Like Gregorian date, Nepalese dates are used in a lot of formats like dd/mm/yy, dd/mm/yyyy, yyyy-mm-dd, dd mmmm yyyy, mmmm dd, yyyy, yyyy mmmm dd etc. The only difference being that we never use the month in the front like mm/dd/yy.

Had a small discussion with the team here and all suggested that the following format would be the best for sending out the EDD: dd mmmm yyyy

Examples: १४ असोज २०७३ , ७ पौष २०६५

alxndrsn commented 7 years ago

Might be useful to consider momentjs's support (or lack of) for other calendars when starting on this work: https://github.com/moment/moment/issues/1454, https://github.com/moment/moment/pull/874, https://github.com/moment/moment/issues/3068

alxndrsn commented 7 years ago

Converter is written over at https://github.com/alxndrsn/bikram-sambat.js:

var todayInBikramSambat = require('bikram-sambat').str_toBik('2017-03-21');

This now needs hooking in somewhere so that scheduled messages can filter included variables, e.g.:

Estimated delivery date is: ${doc.edd | bikram}

It's not immediately clear to me where this should be, but perhaps in kujua-sms.

estellecomment commented 7 years ago

It would also be cool to output २०७२ फागुन २३ rather than 2072-11-23, it would look more human friendly. Gonna do that next...

alxndrsn commented 7 years ago

It would also be cool to output २०७२ फागुन २३ rather than 2072-11-23,

yeah, this should be part of the bikram-sambat lib. Will add.

alxndrsn commented 7 years ago

If you update the BS lib to v 0.2.0, then str_toBik() should give you dates in devanagari script.

estellecomment commented 7 years ago

Aarrrrgh just realized I implemented २०७३ असोज १४ instead of १४ असोज २०७३ :woman_facepalming:

estellecomment commented 7 years ago

@alxndrsn please review : https://github.com/medic/eurodig/pull/1 https://github.com/medic/bikram-sambat.js/pull/1 https://github.com/medic/medic-sentinel/pull/122

estellecomment commented 7 years ago

(there's also PRs against your alxndrsn branches, by mistake. I closed them, ignore.)

alxndrsn commented 7 years ago

This looks good to me, but I'm not familiar with how or when the code in medic-sentinel gets run. Presumably this is before a message will end up in the Reports tab. Is that the case?

estellecomment commented 7 years ago

how or when the code in medic-sentinel gets run

When transitions add messages to a doc, they use lib/messages.js which uses lib/template.js to render the mustache templates in the app_settings. The formatted filters are implemented there.

estellecomment commented 7 years ago

It's in!

AT : replace a set of {#date} ... {\date} tags in app_settings with {#bikram_sambat_date} ... {\bikram_sambat_date} and check it displays dates properly and doesn't mess up unicode. I didn't test other locales than english, that might be a good idea...

SCdF commented 7 years ago

@estellecomment should this be documented somewhere? Note I have no idea where, though possibly in kanso.json, or at least linked from kanso.json

estellecomment commented 7 years ago

Documented in medic-docs : https://github.com/medic/medic-docs/blob/master/configuration/variables_in_messages.md

ngaruko commented 7 years ago

Are you able to confirm that this is working as expected @bishwas-medic ? Thanks

bishwasBhatta commented 7 years ago

@ngaruko yes, we have already started using this feature. I can confirm that it's working as expected. You can close the AT.