diff --git a/config.xml b/config.xml index 6be5981f..2a9c87ef 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + LiveWell An application for bipolar disorder diff --git a/package.json b/package.json index 5ac6fa78..d70b2a8a 100644 --- a/package.json +++ b/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": [ diff --git a/www/scripts/controllers/daily_check_in.js b/www/scripts/controllers/daily_check_in.js index 137117c9..4335449c 100644 --- a/www/scripts/controllers/daily_check_in.js +++ b/www/scripts/controllers/daily_check_in.js @@ -489,7 +489,6 @@ angular.module('livewellApp').controller('DailyCheckInCtrl', function($scope, $l dailyCount: dailyCount, appVersion: version }).execute(); - }); Database.insertWithCallback('daily_check_in', { @@ -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"); } } diff --git a/www/scripts/controllers/weekly_check_in.js b/www/scripts/controllers/weekly_check_in.js index 85d13285..943266e8 100644 --- a/www/scripts/controllers/weekly_check_in.js +++ b/www/scripts/controllers/weekly_check_in.js @@ -148,13 +148,16 @@ 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; @@ -162,8 +165,6 @@ angular.module('livewellApp').controller('WeeklyCheckInCtrl', function($scope, $ $scope.reachoutMessage = cursor.value.message } - console.log("NEW WEEKLY REVIEW MESSAGE: " + $scope.reachoutMessage); - $scope.$apply(); if ($scope.reachoutMessage != null) { diff --git a/www/scripts/services/database.js b/www/scripts/services/database.js index 2aedea15..c835fb00 100644 --- a/www/scripts/services/database.js +++ b/www/scripts/services/database.js @@ -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); @@ -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() { @@ -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; @@ -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(), @@ -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; @@ -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; @@ -755,13 +765,13 @@ 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; @@ -769,13 +779,13 @@ angular.module('livewellApp').service('Database', function (UserData) { } 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; @@ -783,13 +793,13 @@ angular.module('livewellApp').service('Database', function (UserData) { } 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; @@ -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']); diff --git a/www/views/daily_check_in.html b/www/views/daily_check_in.html index 801f963a..167d0436 100644 --- a/www/views/daily_check_in.html +++ b/www/views/daily_check_in.html @@ -4,8 +4,7 @@