Skip to content

Commit

Permalink
Misc. bug fixes.
Browse files Browse the repository at this point in the history
* Updated notifications and notification logic.
* Added PR data transmissions.
  • Loading branch information
audaciouscode committed Aug 7, 2017
1 parent 72f051d commit ca23660
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 42 deletions.
2 changes: 1 addition & 1 deletion config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="edu.northwestern.cbits.livewell" version="3.3.5" 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.6" 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 Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "LiveWell",
"version": "0.0.1",
"version": "3.3.6",
"description": "LiveWell application, expert system and notifications for bipolar intervention",
"author": "Mark Begale",
"contributors": [
Expand Down
15 changes: 10 additions & 5 deletions www/scripts/controllers/daily_check_in.js
Expand Up @@ -489,7 +489,6 @@ angular.module('livewellApp').controller('DailyCheckInCtrl', function($scope, $l
dailyCount: dailyCount,
appVersion: version
}).execute();

});

Database.insertWithCallback('daily_check_in', {
Expand All @@ -508,11 +507,17 @@ angular.module('livewellApp').controller('DailyCheckInCtrl', function($scope, $l
$scope.reachoutMessage = null;

if (cursor != null) {
if (cursor.value.reachout_code == 1 || cursor.value.reachout_code == 2) {
$scope.emergency = true;
$scope.warningPhoneNumber = $scope.phoneNumber;
} else if (cursor.value.message != null) {
if (cursor.value.message != null) {
$scope.reachoutMessage = cursor.value.message
$scope.warningPhoneNumber = $scope.phoneNumber;
}

if (cursor.value.reachout_code == 1 || cursor.value.reachout_code == 2) {
$("#continue_modal_warning").removeClass("alert-warning");
$("#continue_modal_warning").addClass("alert-danger");
} else {
$("#continue_modal_warning").removeClass("alert-danger");
$("#continue_modal_warning").addClass("alert-warning");
}
}

Expand Down
15 changes: 8 additions & 7 deletions www/scripts/controllers/weekly_check_in.js
Expand Up @@ -148,22 +148,23 @@ angular.module('livewellApp').controller('WeeklyCheckInCtrl', function($scope, $
}

Database.insertWithCallback('weekly_check_in', dbObject, function() {
console.log('000001');

Database.updateWeeklyReachout(function() {
console.log('000002');

Database.filter('clinical_weekly_reachout', 'updated', IDBKeyRange.lowerBound(0), "prev", function(cursor) {
console.log("GOT MESSAGE");
if (_.where(JSON.parse(localStorage.team), { role: 'Psychiatrist' })[0] != undefined)
{
$scope.phoneNumber = _.where(JSON.parse(localStorage.team), {
role: 'Psychiatrist'
})[0].phone;
} else {
$scope.phoneNumber = '312-503-1886';
}

$scope.reachoutMessage = null;

if (cursor != null) {
$scope.reachoutMessage = cursor.value.message
}

console.log("NEW WEEKLY REVIEW MESSAGE: " + $scope.reachoutMessage);

$scope.$apply();

if ($scope.reachoutMessage != null) {
Expand Down
44 changes: 29 additions & 15 deletions www/scripts/services/database.js
Expand Up @@ -377,11 +377,11 @@ angular.module('livewellApp').service('Database', function (UserData) {

if (duration <= sleepRoutineRanges.LessSevere) {
sleepDurationList.push(-2);
} else if (duration < sleepRoutineRanges.Less && duration >= sleepRoutineRanges.LessSevere) {
} else if (duration < sleepRoutineRanges.Less && duration > sleepRoutineRanges.LessSevere) {
sleepDurationList.push(-1);
} else if (duration >= sleepRoutineRanges.Less && duration <= sleepRoutineRanges.More) {
sleepDurationList.push(0);
} else if (duration > sleepRoutineRanges.More && duration <= sleepRoutineRanges.MoreSevere) {
} else if (duration > sleepRoutineRanges.More && duration < sleepRoutineRanges.MoreSevere) {
sleepDurationList.push(1);
} else if (duration >= sleepRoutineRanges.MoreSevere) {
sleepDurationList.push(2);
Expand Down Expand Up @@ -420,15 +420,19 @@ angular.module('livewellApp').service('Database', function (UserData) {
}

database.calculateClinicalReachout(statusCodes, wellnessList, medicationList, sleepDurationList, reachoutList, notifyList, function(newReachoutItem) {
database.insertWithCallback('clinical_reachout', {
var dbObject = {
updated: Date.now(),
reachout_code: newReachoutItem['reachout_code'],
provider_call: newReachoutItem['provider_call'],
provider_email: newReachoutItem['provider_email'],
coach_email: newReachoutItem['coach_email'],
message: newReachoutItem['message'],
notify: newReachoutItem['notify'],
}, callback);
notify: newReachoutItem['notify']
};

(new PurpleRobot()).emitReading('livewell_app_expert_system_daily_reachout', dbObject).execute();

database.insertWithCallback('clinical_reachout', dbObject, callback);
});
}
}, function() {
Expand Down Expand Up @@ -529,6 +533,11 @@ angular.module('livewellApp').service('Database', function (UserData) {
newStatusCode = 3;
}
}

(new PurpleRobot()).emitReading('livewell_app_expert_system_status_code', {
current_code: newStatusCode,
prior_code: lastStatusCode
}).execute();

var lastServerUpdate = 0;

Expand All @@ -542,6 +551,7 @@ angular.module('livewellApp').service('Database', function (UserData) {
if (lastServerUpdate > 0) {
var delta = Date.now() - lastServerUpdate;


if (delta > (1000 * 60 * 60 * 24 * 4)) {
database.insertWithCallback('clinical_status', {
updated: Date.now(),
Expand Down Expand Up @@ -713,19 +723,19 @@ angular.module('livewellApp').service('Database', function (UserData) {
} else if (statusCodes[0] == 2 && statusCodes[1] == 1) {
if (wellnessSevenMildModerateUp > wellnessSevenMildModerateDown) { // Clinical Status to Prodromal-Mania (6)
reachout['reachout_code'] = 6;
reachout['message'] = 'Looks like you may be having early warning signs of mania. Call your psychiatrist to check in.';
reachout['message'] = 'Looks like you may be having early warning signs of mania. This could put you at risk for a manic episode. Call your psychiatrist to check in.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
} else if (wellnessSevenMildModerateUp < wellnessSevenMildModerateDown) { // Clinical Status to Prodromal-Depression (7)
reachout['reachout_code'] = 7;
reachout['message'] = 'Looks like you may be having early warning signs of depression. Call your psychiatrist to check in.';
reachout['message'] = 'Looks like you may be having early warning signs of depression. This could put you at risk for a depressive episode. Call your psychiatrist to check in.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
} else { // Clinical Status to Prodromal (8)
reachout['reachout_code'] = 8;
reachout['message'] = 'Looks like you may be having early warning signs. Call your psychiatrist to check in.';
reachout['message'] = 'Looks like you may be having early warning signs. This could put you at risk for a mood episode. Call your psychiatrist to check in.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
Expand All @@ -739,7 +749,7 @@ angular.module('livewellApp').service('Database', function (UserData) {
reachout['coach_email'] = true;
} else if (wellnessList[0] == -3 && wellnessSevenModerateDown >= 4) { // Worsening Symptoms-Depression (10)
reachout['reachout_code'] = 10;
reachout['message'] = 'Looks like you may be having worsening symptoms of depression. Call your psychiatrist to check in. ';
reachout['message'] = 'Looks like you may be having worsening symptoms of depression. Call your psychiatrist to check in.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
Expand All @@ -755,41 +765,41 @@ angular.module('livewellApp').service('Database', function (UserData) {
if (medicationList[0] < 2) {
if (medicationFourAll == 0) { // High Risk-Medications-Mail (12)
reachout['reachout_code'] = 12;
reachout['message'] = 'Looks like you have been missing medication doses. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been missing medication doses. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
} else if (medicationFourAll == 1) { // High Risk-Medications-Call (13)
reachout['reachout_code'] = 13;
reachout['message'] = 'Looks like you have been missing medication doses. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been missing medication doses. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = false;
reachout['coach_email'] = false;
}
} else if (sleepDurationList[0] == -2) {
if (sleepDurationFourLessSevere >= 3) { // High Risk-Sleep Less-Mail (14)
reachout['reachout_code'] = 14;
reachout['message'] = 'Looks like you have been sleeping too little. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been sleeping too little. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
} else if (sleepDurationFourLessSevere == 2) { // High Risk-Sleep Less-Call (15)
reachout['reachout_code'] = 15;
reachout['message'] = 'Looks like you have been sleeping less than usual. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been sleeping less than usual. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = false;
reachout['coach_email'] = false;
}
} else if (sleepDurationList[0] == 2) {
if (sleepDurationFourMoreSevere == 4) { // High Risk-Sleep More-Mail (16)
reachout['reachout_code'] = 16;
reachout['message'] = 'Looks like you have been sleeping too much. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been sleeping too much. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = true;
reachout['coach_email'] = true;
} else if (sleepDurationFourMoreSevere == 3) { // High Risk-Sleep More-Call (17)
reachout['reachout_code'] = 17;
reachout['message'] = 'Looks like you have been sleeping more than usual. Call your psychiatrist to discuss any problems you may be having.';
reachout['message'] = 'Looks like you have been sleeping more than usual. This could put you at risk for symptoms. Call your psychiatrist to discuss any problems you may be having.';
reachout['provider_call'] = true;
reachout['provider_email'] = false;
reachout['coach_email'] = false;
Expand Down Expand Up @@ -1057,6 +1067,10 @@ angular.module('livewellApp').service('Database', function (UserData) {
}
}
}

(new PurpleRobot()).emitReading('livewell_app_expert_system_daily_review', {
review_code: dbObject['finalCode']
}).execute();

database.insertWithCallback('daily_review', dbObject, function() {
callback(dbObject['finalCode']);
Expand Down
19 changes: 8 additions & 11 deletions www/views/daily_check_in.html
Expand Up @@ -4,8 +4,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body alert-danger">
{{ selectedWarningMessage }}
<br/>
<p>{{ selectedWarningMessage }}</p>
<br/>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
Expand All @@ -19,15 +18,13 @@
<div id="continue" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body alert-warning">
<br/>
<div class="alert alert-danger" ng-show="emergency">
Looks like you are in a crisis we recommend that you call your psychiatrist, call 9-1-1, or go to the nearest emergency room.
<br/>
<a ng-show="warningPhoneNumber != null" class="btn btn-primary" href="tel:{{warningPhoneNumber}}">Call Your Psychiatrist Now</a>
</div>
<div class="alert alert-wadning" ng-hide="emergency || reachoutMessage == null">
{{ reachoutMessage }}
<div class="modal-body alert-warning" id="warning_message">
<div class="alert alert-warning" id="continue_modal_warning" ng-hide="reachoutMessage == null">
<p>{{ reachoutMessage }}<p>
<br />
<center>
<a ng-show="warningPhoneNumber != null" class="btn btn-primary" href="tel:{{ warningPhoneNumber }}">Call Your Psychiatrist Now</a>
</center>
</div>
<a ng-href="#/daily_review/{{nextId}}" class="btn btn-primary btn-full" >Continue to Daily Review</a>
<br/>
Expand Down
10 changes: 8 additions & 2 deletions www/views/questionGroups/question_group.html
Expand Up @@ -2,8 +2,14 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body alert-warning">
<div class="alert alert-warning" ng-hide="reachoutMessage == null">
{{ reachoutMessage }}
<br/>
<div class="alert alert-warning">
<p>{{ reachoutMessage }}</p>

<br />
<center>
<a class="btn btn-primary" href="tel:{{ phoneNumber }}">Call Your Psychiatrist Now</a>
</center>
</div>
<button type="button" class="btn btn-primary btn-full" data-dismiss="modal">Continue</button>
</div>
Expand Down

0 comments on commit ca23660

Please sign in to comment.