Skip to content

Commit

Permalink
Merge pull request #614 from praekeltfoundation/feature-edd-update
Browse files Browse the repository at this point in the history
Date format
  • Loading branch information
DevChima authored Oct 24, 2023
2 parents 3718bd9 + 697c9ca commit 7ea1a04
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
17 changes: 13 additions & 4 deletions go-app-ussd_popi_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ go.app = function() {
var contact = self.im.user.answers.contact;
var id_type = _.get(contact, "fields.identification_type");
var channel = _.get(contact, "fields.preferred_channel");
var baby_dob1 = _.get(contact, "fields.baby_dob1", null);
var baby_dob2 = _.get(contact, "fields.baby_dob2", null);
var baby_dob3 = _.get(contact, "fields.baby_dob3", null);
var edd = _.get(contact, "fields.edd", null);
baby_dob1 = (baby_dob1) ? baby_dob1.split('T')[0] : baby_dob1;
baby_dob2 = (baby_dob2) ? baby_dob2.split('T')[0] : baby_dob2;
baby_dob3 = (baby_dob3) ? baby_dob3.split('T')[0] : baby_dob3;
edd = (edd) ? edd.split('T')[0] : edd;

var context = {
msisdn: utils.readable_msisdn(self.im.user.addr, "27"),
channel: channel || $("None"),
Expand Down Expand Up @@ -394,10 +403,10 @@ go.app = function() {
"FALSE": $("No")
}, _.toUpper(_.get(contact, "fields.research_consent")), $("None")),
dobs: _.map(_.filter([
new moment(_.get(contact, "fields.baby_dob1", null)),
new moment(_.get(contact, "fields.baby_dob2", null)),
new moment(_.get(contact, "fields.baby_dob3", null)),
new moment(_.get(contact, "fields.edd", null)),
new moment(baby_dob1),
new moment(baby_dob2),
new moment(baby_dob3),
new moment(edd),
], _.method("isValid")), _.method("format", "DD-MM-YYYY")).join(", ") || $("None")
};
var sms_text = $([
Expand Down
17 changes: 13 additions & 4 deletions src/ussd_popi_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ go.app = function() {
var contact = self.im.user.answers.contact;
var id_type = _.get(contact, "fields.identification_type");
var channel = _.get(contact, "fields.preferred_channel");
var baby_dob1 = _.get(contact, "fields.baby_dob1", null);
var baby_dob2 = _.get(contact, "fields.baby_dob2", null);
var baby_dob3 = _.get(contact, "fields.baby_dob3", null);
var edd = _.get(contact, "fields.edd", null);
baby_dob1 = (baby_dob1) ? baby_dob1.split('T')[0] : baby_dob1;
baby_dob2 = (baby_dob2) ? baby_dob2.split('T')[0] : baby_dob2;
baby_dob3 = (baby_dob3) ? baby_dob3.split('T')[0] : baby_dob3;
edd = (edd) ? edd.split('T')[0] : edd;

var context = {
msisdn: utils.readable_msisdn(self.im.user.addr, "27"),
channel: channel || $("None"),
Expand Down Expand Up @@ -234,10 +243,10 @@ go.app = function() {
"FALSE": $("No")
}, _.toUpper(_.get(contact, "fields.research_consent")), $("None")),
dobs: _.map(_.filter([
new moment(_.get(contact, "fields.baby_dob1", null)),
new moment(_.get(contact, "fields.baby_dob2", null)),
new moment(_.get(contact, "fields.baby_dob3", null)),
new moment(_.get(contact, "fields.edd", null)),
new moment(baby_dob1),
new moment(baby_dob2),
new moment(baby_dob3),
new moment(edd),
], _.method("isValid")), _.method("format", "DD-MM-YYYY")).join(", ") || $("None")
};
var sms_text = $([
Expand Down
4 changes: 2 additions & 2 deletions test/ussd_popi_rapidpro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ describe("ussd_popi_rapidpro app", function() {
passport_number: "A12345",
passport_origin: "mw",
research_consent: "TRUE",
edd: "2020-06-04",
baby_dob1: "2018-03-02",
edd: "2020-06-04T00:00:00.000000Z",
baby_dob1: "2018-03-02T00:00:00.000000Z",
prebirth_messaging: "1"
},
})
Expand Down

0 comments on commit 7ea1a04

Please sign in to comment.