From 948af162dd3539e77372f0472f0eb7240e6f6fd4 Mon Sep 17 00:00:00 2001
From: Alex Gilleran {{resultText}} Detailed Results Belowg=uqZkrKAwzf5urFB$VwB9b#`q;(r7(@e
ze(}Q374OkgrRERjS=UfG6GcvY>9Di#Q&-6?qq^BFL*l5#v6yy{P(T~>rRiEk!9oJQ
zjsv&
j#X;wxC!VdN-${?}wHqr9Z<|r$F6F_k
z4PisEt@b!d068xLOTQuzoE&E*A&cL**6Kr^9WBEG8Fl!^CyKUlG;4s8WxO`B$kB^a
zwLl*{tLo5S%gUIQ<7QKU$sB<=s>>Gqlnm_w86UyHZg#ybJe*8$Om{t#&eB>}zp_@@
zgXMqptNGg8=Ex${EHk9&?+ge9a;a+kWX=|!B&wbXo3j{*S*<|rbfQ$=qHIxwO-X
-
-
-
-
- Child's Name
- {{details.name_of_child}}
- Date of Test
- {{details.test_date}}
-
-
-Date of Birth
- {{details.dob_child}}
- Age of Child
- {{details.age_of_child}}
- {{questionnaire.title}}
-
-
-
-
- {{results}}
- Number
- Question
- Your Response
-
-
- {{if answer.comments}}
- {{##}}
- {{metadata.text}}
- {{answer.metadata.text}}
-
-
- {{/if}}
- {{/results}}
-Comment
- {{answer.comments}}
-
-{{/allResults}}
\ No newline at end of file
diff --git a/lambda/mark-and-send/index.js b/lambda/mark-and-send/index.js
deleted file mode 100644
index bfe57bd..0000000
--- a/lambda/mark-and-send/index.js
+++ /dev/null
@@ -1,68 +0,0 @@
-//https://hooks.zapier.com/hooks/catch/2318292/9cdxwr/
-
-let https = require("https");
-const fetch = require("isomorphic-fetch");
-var dataFunctions = require("wmg-common/data-functions");
-var markupJs = require("markup-js");
-var mark = dataFunctions.mark;
-var combineAll = dataFunctions.combineAll;
-var strings = require("wmg-common/strings");
-const fs = require('fs');
-
-process.env["PATH"] =
- process.env["PATH"] + ":" + process.env["LAMBDA_TASK_ROOT"];
-
-console.log("Loading function");
-
-/*
- POST with these parameters:
- {
- "recipient_email":
- You're receiving this email because {{details.name_of_parent}} completed the Watch Me Grow app for CHILD’S NAME. The Watch - Me Grow app tracks developmental progress for children aged between approximately 12 to 24 months. It has been designed - to facilitate early identification of developmental problems. + You're receiving this email because {{details.name_of_parent}} completed the Watch Me Grow app for {{details.first_name_of_child}}. + {{details.last_name_of_child}}. The Watch Me Grow app tracks developmental progress for children aged between approximately + 12 to 24 months. It has been designed to facilitate early identification of developmental problems.
+{{if concern}} ++ + It is highly likely that this child has developmental issues. It is strongly recommended that referral for further assessment + and early intervention through a paediatrician or other child development health professional is done. Also continue to monitor + the child over time. + +
+{{else}} ++ + Developmental issues in this child are unlikely. No further follow-up necessary at this point. Continue ongoing monitoring + as usual. + +
+{{/if}} +Child's Name | -{{details.first_name_of_child}} {{{{details.last_name_of_child}} | +{{details.first_name_of_child}} {{details.last_name_of_child}} | Date of Test | -{{details.test_date}} | +{{details.test_date_formatted}} |
Date of Birth | -{{details.dob_child}} | +{{details.dob_child_formatted}} | Age of Child | {{details.age_of_child}} |
{{resultText}}
-Detailed Results Below
- {{allResults}}Number | -Question | -Your Response | +Number | +Question | +Response |
---|---|---|---|---|---|
- All children grow and develop at their own pace. Please follow this link for more information: Learn the signs - act early. + For further information on child development please go to Learn the signs - act early.
- This was sent because you completed a questionnaire for the Watch Me Grow pilot. -
+ This information has also been provided to the parent. + \ No newline at end of file diff --git a/lambda/wmg-email/Reminder.html b/lambda/wmg-email/Reminder.html new file mode 100644 index 0000000..182164b --- /dev/null +++ b/lambda/wmg-email/Reminder.html @@ -0,0 +1,4 @@ +Thank you for previously completing the Watch Me Grow app. It is recommended that you complete this when your child is aged +approximately 12, 18 and 24 months. This is a reminder to complete the Watch Me Grow app for your child again. As before, +these results will be sent via email. These can also be sent to your nominated health professional. Please go to the +Watch Me Grow app. \ No newline at end of file diff --git a/lambda/wmg-email/Results.html b/lambda/wmg-email/Results.html index 578b708..16ac1ab 100644 --- a/lambda/wmg-email/Results.html +++ b/lambda/wmg-email/Results.html @@ -11,11 +11,11 @@Number | -Question | -Your Response | +Number | +Question | +Response |
---|---|---|---|---|---|
All children grow and develop at their own pace. Please follow this link for more information: Learn the signs - act early. diff --git a/lambda/wmg-email/index.js b/lambda/wmg-email/index.js index 75e2aee..dd5d5d0 100644 --- a/lambda/wmg-email/index.js +++ b/lambda/wmg-email/index.js @@ -3,7 +3,7 @@ let https = require("https"); var aws = require("aws-sdk"); const moment = require("moment"); -var ses = new aws.SES(); +const mailgunJs = require("mailgun-js"); var markupJs = require("markup-js"); var fs = require("fs"); const fetch = require("isomorphic-fetch"); @@ -11,6 +11,15 @@ var dataFunctions = require("wmg-common/data-functions"); var mark = dataFunctions.mark; var combineAll = dataFunctions.combineAll; var strings = require("wmg-common/strings"); +var questionnaires = require("wmg-common/questionnaires"); +const _ = require("lodash"); + +const FORMAT = "dddd, MMMM Do YYYY"; + +const mailgun = mailgunJs({ + apiKey: process.env.MAILGUN_API_KEY, + domain: "auto.watchmegrow.care" +}); process.env["PATH"] = process.env["PATH"] + ":" + process.env["LAMBDA_TASK_ROOT"]; @@ -26,7 +35,7 @@ console.log("Loading function"); } */ -exports.handler = function(event, context) { +exports.handler = function(event, context, callback) { console.log("Event: " + JSON.stringify(event)); if (!event.details.recipient_email) { @@ -40,17 +49,36 @@ exports.handler = function(event, context) { ? strings.result.concerns : strings.result.noConcerns; - const parentEmailPromise = sendParentEmail(event, concern, combinedResults, resultStrings); - const zapierPromise = sendToZapier(event, concern); - const basePromises = [parentEmailPromise, zapierPromise]; + event.details = Object.assign(event.details, { + test_date_formatted: moment(event.details.test_date).format(FORMAT), + dob_child_formatted: moment(event.details.dob_child).format(FORMAT) + }); + + const parentEmailPromise = sendParentEmail( + //Promise.resolve(); + event, + concern, + combinedResults, + resultStrings + ); + const zapierPromise = sendToZapier(event, concern); //Promise.resolve(); + const basePromises = [ + parentEmailPromise, + zapierPromise, + addToReminderList(event) + ]; const promises = event.details.doctor_email - ? basePromises.concat([sendDoctorEmail(event, concern, combinedResults, resultStrings)]) + ? basePromises.concat([ + sendDoctorEmail(event, concern, combinedResults, resultStrings) + ]) : basePromises; Promise.all(promises) - .then(context.succeed("Successfully executed")) - .catch(e => context.fail("Internal Error: " + e.message)); + .then(result => { + callback(null, result); + }) + .catch(e => callback(e)); }; function sendToZapier(event, concern) { @@ -60,7 +88,7 @@ function sendToZapier(event, concern) { results: event.results, concern: concern, details: Object.assign(event.details, { - ageInDays: moment().diff(moment(event.details.dob_child), 'days') + ageInDays: moment().diff(moment(event.details.dob_child), "days") }) }), headers: { @@ -69,9 +97,9 @@ function sendToZapier(event, concern) { }); } -function sendParentEmail(event, concern, combinedResults, resultStrings) { - const templateBody = fs.readFileSync(__dirname + "/Results.html", "utf-8"); +const templateBody = fs.readFileSync(__dirname + "/Results.html", "utf-8"); +function sendParentEmail(event, concern, combinedResults, resultStrings) { var message = markupJs.up(templateBody, { details: event.details, concern: concern, @@ -80,40 +108,19 @@ function sendParentEmail(event, concern, combinedResults, resultStrings) { }); var params = { - Destination: { - ToAddresses: [event.details.recipient_email], - CcAddresses: ["mail@watchmegrow.care"] - }, - Message: { - Body: { - Html: { - Data: message, - Charset: "UTF-8" - } - }, - Subject: { - Data: "Watch Me Grow Results for " + event.details.first_name_of_child, - Charset: "UTF-8" - } - }, - Source: "mail@watchmegrow.care" //hardcoded verified email source for Amazon SES sandbox + from: "mail@watchmegrow.care", + to: event.details.recipient_email, + cc: "mail@watchmegrow.care", + subject: "Watch Me Grow Results for " + event.details.first_name_of_child, + html: message }; - return new Promise((accept, reject) => - ses.sendEmail(params, function(err, data) { - if (err) { - console.log(err, err.stack); - reject(err); - } else { - accept(data); - } - }) - ); + return mailgun.messages().send(params); } -function sendDoctorEmail(event, concern, combinedResults, resultStrings) { - const doctorTemplateBody = fs.readFileSync(__dirname + "/Doctor.html", "utf-8"); +const doctorTemplateBody = fs.readFileSync(__dirname + "/Doctor.html", "utf-8"); +function sendDoctorEmail(event, concern, combinedResults, resultStrings) { var message = markupJs.up(doctorTemplateBody, { details: event.details, concern: concern, @@ -122,37 +129,54 @@ function sendDoctorEmail(event, concern, combinedResults, resultStrings) { }); var params = { - Destination: { - ToAddresses: [event.details.doctor_email], - CcAddresses: ["mail@watchmegrow.care"] - }, - Message: { - Body: { - Html: { - Data: message, - Charset: "UTF-8" - } - }, - Subject: { - Data: - "Watch Me Grow Results for " + - event.details.first_name_of_child + - " " + - event.details.last_name_of_child, - Charset: "UTF-8" - } - }, - Source: "mail@watchmegrow.care" //hardcoded verified email source for Amazon SES sandbox + from: "mail@watchmegrow.care", + to: event.details.doctor_email, + subject: + "Watch Me Grow Results for " + + event.details.first_name_of_child + + " " + + event.details.last_name_of_child, + html: message + }; + + return mailgun.messages().send(params); +} + +const reminderTemplateBody = fs.readFileSync( + __dirname + "/Reminder.html", + "utf-8" +); + +function addToReminderList(event) { + const completed = Object.keys(event.results).reduce((soFar, current) => { + soFar[current] = true; + return soFar; + }, {}); + + const data = { + completed, + dob: event.details.dob_child }; - return new Promise((accept, reject) => - ses.sendEmail(params, function(err, data) { - if (err) { - console.log(err, err.stack); - reject(err); - } else { - accept(data); - } + const newVars = {}; + newVars[event.details.first_name_of_child] = data; + + const varsPromise = mailgun + .lists("reminders@auto.watchmegrow.care") + .members(event.details.recipient_email) + .info() + .then(memberObj => { + const member = memberObj.member; + return Promise.resolve(member && member.vars ? member.vars : {}); }) - ); + .catch(e => Promise.resolve({})); + + return varsPromise.then(vars => { + return mailgun.lists("reminders@auto.watchmegrow.care").members().create({ + name: event.details.name_of_parent, + address: event.details.recipient_email, + upsert: "true", + vars: _.merge(vars, newVars) + }); + }); } diff --git a/lambda/wmg-email/package.json b/lambda/wmg-email/package.json index 261c619..8292b2e 100644 --- a/lambda/wmg-email/package.json +++ b/lambda/wmg-email/package.json @@ -3,6 +3,8 @@ "version": "0.0.1", "dependencies": { "isomorphic-fetch": "^2.2.1", + "lodash": "^4.17.4", + "mailgun-js": "^0.11.2", "markup-js": "^1.5.21", "moment": "^2.18.1", "wmg-common": "file:../../common" diff --git a/lambda/wmg-email/yarn.lock b/lambda/wmg-email/yarn.lock index 549bd4e..a3718a6 100644 --- a/lambda/wmg-email/yarn.lock +++ b/lambda/wmg-email/yarn.lock @@ -2,20 +2,202 @@ # yarn lockfile v1 +agent-base@2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7" + dependencies: + extend "~3.0.0" + semver "~5.0.1" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ast-types@0.x.x: + version "0.9.12" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.12.tgz#b136300d67026625ae15326982ca9918e5db73c9" + +async@~2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7" + dependencies: + lodash "^4.14.0" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +bytes@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339" + +co@~3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/co/-/co-3.0.6.tgz#1445f226c5eb956138e68c9ac30167ea7d2e6bda" + +combined-stream@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +data-uri-to-buffer@0: + version "0.0.4" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-0.0.4.tgz#46e13ab9da8e309745c8d01ce547213ebdb2fe3f" + +debug@2, debug@~2.6.0: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +degenerator@~1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-1.0.4.tgz#fcf490a37ece266464d9cc431ab98c5819ced095" + dependencies: + ast-types "0.x.x" + escodegen "1.x.x" + esprima "3.x.x" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + encoding@^0.1.11: version "0.1.12" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" dependencies: iconv-lite "~0.4.13" +escodegen@1.x.x: + version "1.8.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" + dependencies: + esprima "^2.7.1" + estraverse "^1.9.1" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.2.0" + +esprima@3.x.x: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +esprima@^2.7.1: + version "2.7.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" + +estraverse@^1.9.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +extend@3, extend@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +file-uri-to-path@0: + version "0.0.2" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-0.0.2.tgz#37cdd1b5b905404b3f05e1b23645be694ff70f82" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +ftp@~0.3.5: + version "0.3.10" + resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" + dependencies: + readable-stream "1.1.x" + xregexp "2.0.0" + +get-uri@2: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-2.0.0.tgz#713e47cbcbaeab38f88af1cdfc85fa7f09b00738" + dependencies: + data-uri-to-buffer "0" + debug "2" + extend "3" + file-uri-to-path "0" + ftp "~0.3.5" + readable-stream "2" + +http-proxy-agent@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-1.0.0.tgz#cc1ce38e453bf984a0f7702d2dd59c73d081284a" + dependencies: + agent-base "2" + debug "2" + extend "3" + +https-proxy-agent@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6" + dependencies: + agent-base "2" + debug "2" + extend "3" + +iconv-lite@0.4.15: + version "0.4.15" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" + iconv-lite@~0.4.13: version "0.4.18" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" -is-stream@^1.0.1: +inflection@~1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416" + +inflection@~1.3.0: + version "1.3.8" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.3.8.tgz#cbd160da9f75b14c3cc63578d4f396784bf3014e" + +inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ip@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.0.1.tgz#c7e356cdea225ae71b36d70f2e71a92ba4e42590" + +ip@^1.1.4: + version "1.1.5" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" + +is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + isomorphic-fetch@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" @@ -23,14 +205,61 @@ isomorphic-fetch@^2.2.1: node-fetch "^1.0.1" whatwg-fetch ">=0.10.0" +levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +lodash@^4.14.0, lodash@^4.17.4: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +lru-cache@~2.6.5: + version "2.6.5" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.6.5.tgz#e56d6354148ede8d7707b58d143220fd08df0fd5" + +mailgun-js@^0.11.2: + version "0.11.2" + resolved "https://registry.yarnpkg.com/mailgun-js/-/mailgun-js-0.11.2.tgz#e88da86d52ab8810f07a8eb09bde84ec8b7cfa29" + dependencies: + async "~2.4.0" + debug "~2.6.0" + form-data "~2.1.1" + inflection "~1.12.0" + is-stream "^1.1.0" + path-proxy "~1.0.0" + promisify-call "^2.0.2" + proxy-agent "~2.0.0" + tsscmp "~1.0.0" + markup-js@^1.5.21: version "1.5.21" resolved "https://registry.yarnpkg.com/markup-js/-/markup-js-1.5.21.tgz#389128703a565964574d0e357e142add3be46d79" +mime-db@~1.27.0: + version "1.27.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" + +mime-types@^2.1.12: + version "2.1.15" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" + dependencies: + mime-db "~1.27.0" + moment@^2.18.1: version "2.18.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +netmask@~1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" + node-fetch@^1.0.1: version "1.7.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5" @@ -38,9 +267,183 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" +optionator@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +pac-proxy-agent@1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-1.1.0.tgz#34a385dfdf61d2f0ecace08858c745d3e791fd4d" + dependencies: + agent-base "2" + debug "2" + extend "3" + get-uri "2" + http-proxy-agent "1" + https-proxy-agent "1" + pac-resolver "~2.0.0" + raw-body "2" + socks-proxy-agent "2" + +pac-resolver@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-2.0.0.tgz#99b88d2f193fbdeefc1c9a529c1f3260ab5277cd" + dependencies: + co "~3.0.6" + degenerator "~1.0.2" + ip "1.0.1" + netmask "~1.0.4" + thunkify "~2.1.1" + +path-proxy@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/path-proxy/-/path-proxy-1.0.0.tgz#18e8a36859fc9d2f1a53b48dee138543c020de5e" + dependencies: + inflection "~1.3.0" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +promisify-call@^2.0.2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/promisify-call/-/promisify-call-2.0.4.tgz#d48c2d45652ccccd52801ddecbd533a6d4bd5fba" + dependencies: + with-callback "^1.0.2" + +proxy-agent@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-2.0.0.tgz#57eb5347aa805d74ec681cb25649dba39c933499" + dependencies: + agent-base "2" + debug "2" + extend "3" + http-proxy-agent "1" + https-proxy-agent "1" + lru-cache "~2.6.5" + pac-proxy-agent "1" + socks-proxy-agent "2" + +raw-body@2: + version "2.2.0" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.2.0.tgz#994976cf6a5096a41162840492f0bdc5d6e7fb96" + dependencies: + bytes "2.4.0" + iconv-lite "0.4.15" + unpipe "1.0.0" + +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +semver@~5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a" + +smart-buffer@^1.0.13: + version "1.1.15" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-1.1.15.tgz#7f114b5b65fab3e2a35aa775bb12f0d1c649bf16" + +socks-proxy-agent@2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-2.1.1.tgz#86ebb07193258637870e13b7bd99f26c663df3d3" + dependencies: + agent-base "2" + extend "3" + socks "~1.1.5" + +socks@~1.1.5: + version "1.1.10" + resolved "https://registry.yarnpkg.com/socks/-/socks-1.1.10.tgz#5b8b7fc7c8f341c53ed056e929b7bf4de8ba7b5a" + dependencies: + ip "^1.1.4" + smart-buffer "^1.0.13" + +source-map@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" + dependencies: + amdefine ">=0.0.4" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +thunkify@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" + +tsscmp@~1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.5.tgz#7dc4a33af71581ab4337da91d85ca5427ebd9a97" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +unpipe@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + whatwg-fetch@>=0.10.0: version "2.0.3" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" +with-callback@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/with-callback/-/with-callback-1.0.2.tgz#a09629b9a920028d721404fb435bdcff5c91bc21" + "wmg-common@file:../../common": version "0.0.2" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +xregexp@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" diff --git a/src/components/pages/result/result.js b/src/components/pages/result/result.js index cd34e6c..5764570 100644 --- a/src/components/pages/result/result.js +++ b/src/components/pages/result/result.js @@ -31,7 +31,7 @@ const Result = React.createClass({ eventAction: this.props.results.concern ? "concern" : "no-concern" }); - sendResults(this.props.details, this.props.results); + // sendResults(this.props.details, this.props.results); }, getInitialStage() { diff --git a/src/send-results.js b/src/send-results.js index a77aa91..02cff0c 100644 --- a/src/send-results.js +++ b/src/send-results.js @@ -4,19 +4,17 @@ import strings from "../common/strings"; import questionnaires from "wmg-common/questionnaires"; import { combineQuestionsAndAnswers } from "wmg-common/data-functions"; -const FORMAT = "dddd, MMMM Do YYYY"; - export default function sendResults(details, results) { const ageInMonths = moment().diff(details.babyDob, "months"); const metadata = { recipient_email: details.parentEmail, - test_date: moment().format(FORMAT), + test_date: moment().toISOString, name_of_parent: details.parentName, first_name_of_child: details.babyFirstName, last_name_of_child: details.babyLastName, gender_of_child: details.babyGender, - dob_child: details.babyDob.format(FORMAT), + dob_child: details.babyDob.toISOString(), doctor_email: details.doctorEmail, age_of_child: ageInMonths < 24 ? ageInMonths + " months"