Exemple #1
0
 public static function unitTest()
 {
     $response = '';
     $response .= "<br/>starting Data Point tests <br/>";
     $response .= 'Testing updateUserDataPoint: ';
     DataPoint::updateUserDataPoint(TEST_USER_ID, DataPoint::$BLOOD_PRESSURE, '121/50');
     $value = DataPoint::getValueForDataPoint(DataPoint::$BLOOD_PRESSURE, TEST_USER_ID);
     if ($value == '121/50') {
         $response .= 'Passed';
     } else {
         $response .= 'Failed';
     }
     $response .= '<br/>';
     $response .= 'Testing getHistoryListForDataPoint: ';
     $dataPointList = DataPoint::getHistoryListForDataPointAsArray(DataPoint::$BLOOD_PRESSURE, TEST_USER_ID);
     if (sizeof($dataPointList) > 0) {
         $response .= 'Passed';
     } else {
         $response .= 'Failed';
     }
     $response .= '<br/>';
     $response .= 'Testing deleteDataPointHistory: ';
     DataPoint::deleteDataPointHistory(TEST_USER_ID, DataPoint::$BLOOD_PRESSURE);
     $dataPointList = DataPoint::getHistoryListForDataPointAsArray(DataPoint::$BLOOD_PRESSURE, TEST_USER_ID);
     if (sizeof($dataPointList) == 0) {
         $response .= 'Passed';
     } else {
         $response .= 'Failed';
     }
     $response .= '<br/>';
     return $response;
 }
Exemple #2
0
 if ($lastResetTime > $twoHoursAgo) {
     $curNumKicks = DataPoint::getNumDataPointsWithinReset(DataPoint::$BABY_KICK, $userId);
 } else {
     $curNumKicks = DataPoint::getNumDataPointsWithinTwoHours(DataPoint::$BABY_KICK, $userId);
 }
 boldError('curNumKicks is: ' . (string) $curNumKicks);
 $curNumKicksBeforeIncrement = $curNumKicks;
 // $curNumKicks is -1 if the method errored out
 if ($curNumKicks < 0) {
     echo json_encode(array('status' => 'error', 'error' => 'couldn\'t get current number of kicks'));
     exit;
 }
 $oldNumKicks = DataPoint::getMostRecentKickCount($userId, DataPoint::$BABY_KICK);
 // if the current number of records is successfully gotten from the database
 // increment the number of kicks then update the value in the database
 $completed = DataPoint::updateUserDataPoint($userId, DataPoint::$BABY_KICK, ++$curNumKicks);
 if (!$completed) {
     echo json_encode(array('status' => 'error', 'error' => 'failed insert'));
     exit;
 }
 // if the number of kicks before the update is greater than the amount after the update
 // then that means the patient never reached 10 kicks in an hour, so send an alert email
 // but disregard the case where people start from 0 and go to 1 kick
 if ($oldNumKicks >= $curNumKicks && $curNumKicksBeforeIncrement != 0 && $timesBeenEmailed < 1) {
     $data = array('email' => $patientEmail, 'subject' => 'Irregular Kick Count', 'textArgs' => json_encode(array('name' => $patientFirstName)));
     $user_group_admin_id = Group::getGroupAdminByUser($userId);
     $user_group_admin = User::findById($user_group_admin_id)->getAdditionalInfo();
     $userGroupAdminEmail = $user_group_admin->email;
     $userGroupAdminName = $user_group_admin->first_name;
     $provider_data = array('email' => $userGroupAdminEmail, 'subject' => 'Patient With Irregular Kick Count', 'textArgs' => json_encode(array('patient_first_name' => $patientFirstName, 'patient_last_name' => $patientLastName, 'patient_phone_number' => $patientPhone, 'patient_email' => $patientEmail, 'patient_provider_name' => $providerName, 'admin_first_name' => $userGroupAdminName)));
     // send an email to the user