Skip to content

Commit

Permalink
Added alert when more than just None are selected in Early Warning Si…
Browse files Browse the repository at this point in the history
…gns.

* Additional data reported in clinical status updates.
* Updated Cordova dependencies.
  • Loading branch information
audaciouscode committed May 19, 2017
1 parent fa20afc commit 851e5f8
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 221 deletions.
9 changes: 4 additions & 5 deletions config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="edu.northwestern.cbits.livewell" version="3.3.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="edu.northwestern.cbits.livewell" version="3.3.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>LiveWell</name>
<description>
An application for bipolar disorder
Expand All @@ -16,9 +16,8 @@
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<icon src="icon.png" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.1" />
<engine name="android" spec="^6.2.3" />
<plugin name="cordova-plugin-device" spec="~1.1.4" />
<plugin name="phonegap-plugin-push" spec="~1.9.2">
<param name="SENDER_ID" value="XXXXXXX" />
</plugin>
<plugin name="cordova-plugin-whitelist" spec="~1.3.1" />
<plugin name="phonegap-plugin-push" spec="~1.9.2" />
</widget>
112 changes: 63 additions & 49 deletions package.json
@@ -1,51 +1,65 @@
{
"name": "LiveWell",
"version": "0.0.1",
"description": "LiveWell application, expert system and notifications for bipolar intervention",
"author": "Mark Begale",
"contributors": [
{
"name": "Mark Begale",
"email": "m-begale@northwestern.edu"
"name": "LiveWell",
"version": "0.0.1",
"description": "LiveWell application, expert system and notifications for bipolar intervention",
"author": "Mark Begale",
"contributors": [
{
"name": "Mark Begale",
"email": "m-begale@northwestern.edu"
}
],
"dependencies": {
"angular": "^1.4.0",
"angular-resource": "^1.4.0",
"angular-route": "^1.4.0",
"cordova": "5.3.1",
"cordova-android": "^6.2.3",
"cordova-plugin-device": "~1.1.4",
"cordova-plugin-whitelist": "~1.3.1",
"font-awesome": "^4.3.0",
"moment": "^2.10.2",
"phonegap-plugin-push": "~1.9.2"
},
"devDependencies": {
"angular-mocks": "^1.4.0",
"chai": "^2.1.2",
"chai-as-promised": "^5.0.0",
"eslint": "^1.3.1",
"mocha": "^2.2.1",
"sinon": "^1.14.1",
"testem": "^0.8.0-0",
"wd": "^0.3.11"
},
"keywords": [
"bipolar"
],
"scripts": {
"init": "npm install && npm_config_env=test npm_config_server=http://127.0.0.1:3000 npm run set_endpoint && npm run set_endpoint && npm run build:prepare && npm run browser:add_platform && npm run android:add_platform && npm run add_plugins",
"set_endpoint": "echo \"{\\\"environment\\\":\\\"$npm_config_env\\\",\\\"server\\\":\\\"$npm_config_server\\\"}\" > src/config.json && sed s%ACCESS_ORIGIN%$npm_config_server%g config > config.xml",
"android:add_platform": "./node_modules/.bin/cordova platform remove android && ./node_modules/.bin/cordova platform add android@4.0.0",
"android:build": "npm run build:prepare && ./node_modules/.bin/cordova build android",
"android:simulator": "npm run android:build && ./node_modules/.bin/cordova run android",
"browser:add_platform": "./node_modules/.bin/cordova platform remove browser && ./node_modules/.bin/cordova platform add browser && npm run add_plugins",
"add_plugins": "",
"browser:build": "npm run build:prepare && ./node_modules/.bin/cordova build browser",
"browser:simulator": "npm run browser:build && ./node_modules/.bin/cordova run browser",
"build:all": "npm run browser:build && npm run android:build",
"build:clean": "rm -rf www && mkdir -p www/js www/css",
"build:prepare": "npm run build:clean && cp -r src/* www/",
"eslint": "./node_modules/.bin/eslint src && ./node_modules/.bin/eslint test",
"eslint:src": "./node_modules/.bin/eslint src",
"eslint:test": "./node_modules/.bin/eslint test",
"serve": "npm run build:prepare && ./node_modules/.bin/cordova run browser"
},
"cordova": {
"plugins": {
"cordova-plugin-device": {},
"cordova-plugin-whitelist": {},
"phonegap-plugin-push": {}
},
"platforms": [
"android"
]
}
],
"dependencies": {
"angular": "^1.4.0",
"angular-resource": "^1.4.0",
"angular-route": "^1.4.0",
"cordova": "5.3.1",
"font-awesome": "^4.3.0",
"moment": "^2.10.2"
},
"devDependencies": {
"angular-mocks": "^1.4.0",
"chai": "^2.1.2",
"chai-as-promised": "^5.0.0",
"eslint": "^1.3.1",
"mocha": "^2.2.1",
"sinon": "^1.14.1",
"testem": "^0.8.0-0",
"wd": "^0.3.11"
},
"keywords": [
"bipolar"
],
"scripts": {
"init": "npm install && npm_config_env=test npm_config_server=http://127.0.0.1:3000 npm run set_endpoint && npm run set_endpoint && npm run build:prepare && npm run browser:add_platform && npm run android:add_platform && npm run add_plugins",
"set_endpoint": "echo \"{\\\"environment\\\":\\\"$npm_config_env\\\",\\\"server\\\":\\\"$npm_config_server\\\"}\" > src/config.json && sed s%ACCESS_ORIGIN%$npm_config_server%g config > config.xml",
"android:add_platform": "./node_modules/.bin/cordova platform remove android && ./node_modules/.bin/cordova platform add android@4.0.0",
"android:build": "npm run build:prepare && ./node_modules/.bin/cordova build android",
"android:simulator": "npm run android:build && ./node_modules/.bin/cordova run android",
"browser:add_platform": "./node_modules/.bin/cordova platform remove browser && ./node_modules/.bin/cordova platform add browser && npm run add_plugins",
"add_plugins": "",
"browser:build": "npm run build:prepare && ./node_modules/.bin/cordova build browser",
"browser:simulator": "npm run browser:build && ./node_modules/.bin/cordova run browser",
"build:all": "npm run browser:build && npm run android:build",
"build:clean": "rm -rf www && mkdir -p www/js www/css",
"build:prepare": "npm run build:clean && cp -r src/* www/",
"eslint": "./node_modules/.bin/eslint src && ./node_modules/.bin/eslint test",
"eslint:src": "./node_modules/.bin/eslint src",
"eslint:test": "./node_modules/.bin/eslint test",
"serve": "npm run build:prepare && ./node_modules/.bin/cordova run browser"
}
}
}
8 changes: 4 additions & 4 deletions plugins/android.json
Expand Up @@ -7,17 +7,17 @@
"files": {}
},
"installed_plugins": {
"cordova-plugin-whitelist": {
"cordova-plugin-app-version": {
"PACKAGE_NAME": "edu.northwestern.cbits.livewell"
},
"cordova-plugin-device": {
"PACKAGE_NAME": "edu.northwestern.cbits.livewell"
},
"phonegap-plugin-push": {
"SENDER_ID": "334078391843",
"cordova-plugin-whitelist": {
"PACKAGE_NAME": "edu.northwestern.cbits.livewell"
},
"cordova-plugin-app-version": {
"phonegap-plugin-push": {
"SENDER_ID": "334078391843",
"PACKAGE_NAME": "edu.northwestern.cbits.livewell"
}
},
Expand Down
10 changes: 8 additions & 2 deletions www/scripts/controllers/daily_review.js
Expand Up @@ -56,9 +56,15 @@ angular.module('livewellApp').controller('DailyReviewCtrl', function($scope, $ro
dailyCount = parseInt(localStorage['dailyCheckInCount']);
}

if (dailyCount >= 4) {
var toReport = null;

if (dailyCount >= 5) {
$scope.updatedClinicalStatus = ClinicalStatusUpdate.execute();

toReport = $scope.updatedClinicalStatus;
} else {

toReport = ClinicalStatusUpdate.noExecute();
// console.log('4 OR FEWER RESPONSES -- NOT UPDATING STATUS CODE');
}

Expand All @@ -79,7 +85,7 @@ angular.module('livewellApp').controller('DailyReviewCtrl', function($scope, $ro

(new PurpleRobot()).emitReading('livewell_clinicalstatus', {
sessionGUID: sessionID,
status: $scope.updatedClinicalStatus,
status: toReport,
clinicalStatus: clinicalStatus
}).execute();

Expand Down
82 changes: 46 additions & 36 deletions www/scripts/controllers/ews.js
Expand Up @@ -8,40 +8,50 @@
* Controller of the livewellApp
*/
angular.module('livewellApp')
.controller('EwsCtrl', function ($scope,$location,UserData,UserDetails,Guid) {
$scope.pageTitle = "Weekly Check In";

$scope.ews = UserData.query('ews');

$scope.onClick=function() {
var responses = $('form').serializeArray();

console.log('EWS RESPONSE LENGTH: ' + responses.length);

if (responses.length > 0) {
var el = JSON.stringify(responses || {name:'ews', value:null});

var clinicalStatus = JSON.parse(localStorage['clinicalStatus']);

var sessionID = Guid.create();

var payload = {
userId: UserDetails.find,
survey: 'ews',
questionDataLabel: 'ews',
questionValue: el,
sessionGUID: sessionID,
savedAt: new Date(),
clinicalStatus: clinicalStatus
};

console.log('EWS RESPONSE: ' + JSON.stringify(payload));

(new PurpleRobot()).emitReading('livewell_survey_data',payload).execute();

$location.path('/ews2');
} else {
alert('Please choose at least one answer to continue. Select "None" if no other answer applies.');
}
}
.controller('EwsCtrl', function ($scope,$location,UserData,UserDetails,Guid) {
$scope.pageTitle = "Weekly Check In";

$scope.ews = UserData.query('ews');

$scope.onClick=function() {
var responses = $('form').serializeArray();

if (responses.length > 0) {
var hasNone = false;

for (var i = 0; i < responses.length; i++) {
if (responses[i]['value'] == 'None') {
hasNone = true;
}
}

if (hasNone && responses.length > 1) {
alert('"None" cannot be selected with other options.');
} else {
var el = JSON.stringify(responses || {name:'ews', value:null});

var clinicalStatus = JSON.parse(localStorage['clinicalStatus']);

var sessionID = Guid.create();

var payload = {
userId: UserDetails.find,
survey: 'ews',
questionDataLabel: 'ews',
questionValue: el,
sessionGUID: sessionID,
savedAt: new Date(),
clinicalStatus: clinicalStatus
};

console.log('EWS RESPONSE: ' + JSON.stringify(payload));

(new PurpleRobot()).emitReading('livewell_survey_data',payload).execute();

$location.path('/ews2');
}
} else {
alert('Please choose at least one answer to continue. Select "None" if no other answer applies.');
}
};
});
52 changes: 31 additions & 21 deletions www/scripts/controllers/ews2.js
Expand Up @@ -15,28 +15,38 @@ angular.module('livewellApp')
$scope.onClick=function(){
var responses = $('form').serializeArray();

console.log('EWS RESPONSE LENGTH: ' + responses.length);

if (responses.length > 0) {
var el = JSON.stringify(responses || {name:'ews', value:null});
var sessionID = Guid.create();

var clinicalStatus = JSON.parse(localStorage['clinicalStatus']);

var payload = {
userId: UserDetails.find,
survey: 'ews2',
questionDataLabel: 'ews2',
questionValue: el,
sessionGUID: sessionID,
savedAt: new Date(),
clinicalStatus: clinicalStatus
};

(new PurpleRobot()).emitReading('livewell_survey_data',payload).execute();
console.log(JSON.stringify(payload));

$location.path('/');
var hasNone = false;

for (var i = 0; i < responses.length; i++) {
if (responses[i]['value'] == 'None') {
hasNone = true;
}
}

if (hasNone && responses.length > 1) {
alert('"None" cannot be selected with other options.');
} else {
var el = JSON.stringify(responses || {name:'ews', value:null});
var sessionID = Guid.create();

var clinicalStatus = JSON.parse(localStorage['clinicalStatus']);

var payload = {
userId: UserDetails.find,
survey: 'ews2',
questionDataLabel: 'ews2',
questionValue: el,
sessionGUID: sessionID,
savedAt: new Date(),
clinicalStatus: clinicalStatus
};

(new PurpleRobot()).emitReading('livewell_survey_data',payload).execute();
console.log(JSON.stringify(payload));

$location.path('/');
}
} else {
alert('Please choose at least one answer to continue. Select "None" if no other answer applies.');
}
Expand Down
2 changes: 2 additions & 0 deletions www/scripts/controllers/fetch_content.js
Expand Up @@ -78,6 +78,8 @@ angular.module('livewellApp').controller('FetchContentCtrl', function ($scope,$h

if (oldVersion == undefined || newVersion > oldVersion) {
localStorage[el.route] = JSON.stringify(newStatus);

// TODO
}
}
}
Expand Down

0 comments on commit 851e5f8

Please sign in to comment.