if ($b->receivePayment($data)) { header('Location: index.php?billing&success=b'); } else { printError("Failed to receive payment."); } break; case 'processEDTDisplay': $t = new Treatment(); $b = new Billing(); $edts = $t->getUnprocessedEDTs($data['pid']); $b->displayUnprocessedEDTs($edts); break; case 'processAllEDTs': $success = true; $b = new Billing(); $t = new Treatment(); $all = $t->getUnprocessedEDTs($data['pid']); foreach ($all as $e) { if (!$b->processEDT($e['edtid'])) { $success = false; break; } } if ($success) { header('Location: index.php?billing&success=b'); } else { printError("Failed to process all EDT records."); } break; case 'closeAccount': $b = new Billing();
/** * @param $record * @param $event_id * @param $group_id * @param $debug */ function schedule_surveys($record, $event_id, $group_id, $debug) { global $Proj, $project_id, $user_rights, $table_pk; /** * if the user is in a DAG */ if ($user_rights['group_id'] != "") { /** * does this record exist? */ $q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' LIMIT 1"); if (db_num_rows($q) > 0) { /** * is the record in this users DAG? */ $q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' AND field_name = '__GROUPID__' AND value = '{$user_rights['group_id']}' LIMIT 1"); if (db_num_rows($q) < 1) { /** * record is not in Users DAG! */ REDCap::logEvent('Scheduled record is not in users DAG', '', '', $record, $event_id, $project_id); exit; } } } /** * check to see if the subject has an existing schedule on an existing arm */ $sub = "SELECT DISTINCT e.arm_id from redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id"; $sched_arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = $project_id AND arm_id IN (" . pre_query($sub) . ")"); if ($sched_arm_result) { $trt = Treatment::getTrtInfo($record); if ($debug) { error_log(print_r($trt, true)); } $tx_start_date = $trt['rfxstdtc']; $rand_date = $trt['rand_date']; $dates = array(); $arm_num = db_result($sched_arm_result, 0, 'arm_num'); if (isset($arm_num) && $arm_num != '') { // subject has an existing schedule. keep existing event_id > arm structure if ($arm_num != '1') { // make sure we don't put anything in the first arm $q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip"); if ($q) { while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty /** * get the event date ($rand_date for baseline and $tx_start_date + day_offset) */ $row['day_offset'] = $arm_num != $trt['timing_arm_num'] ? $trt['timing_offsets'][$row['descrip']] : $row['day_offset']; if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) { $this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null; } else { $this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null; } $dates[$row['event_id']] = $this_event_date; } db_free_result($q); } } else { REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id); } } else { // subject's schedule is new. put dates into event_ids for this arm $arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = '$project_id' AND arm_name = '{$trt['arm']}'"); if ($arm_result) { $arm_num = db_result($arm_result, 0, 'arm_num'); if ($arm_num != '1') { $q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip"); if ($q) { while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty /** * get the event date ($rand_date for baseline and $tx_start_date + day_offset) */ if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) { $this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null; } else { $this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null; } $dates[$row['event_id']] = $this_event_date; } db_free_result($q); } } else { REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id); } db_free_result($arm_result); } } if ($debug) { error_log(print_r($dates, true)); } if (!empty($dates)) { /** * do we have an existing schedule? */ $sql = "SELECT c.event_date, c.baseline_date, e.* FROM redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id AND e.arm_id IN (" . pre_query($sub) . ")"; $sched_result = db_query($sql); if ($sched_result) { $sql_all = array(); $sql_errors = array(); if (db_num_rows($sched_result) > 0) { while ($sched_row = db_fetch_assoc($sched_result)) { $base_date = in_array($sched_row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; /** * if the scheduled date is in the $dates array, we don't care about it, so ignore it and remove from $dates * if we have an existing schedule and the dates have changed, update the schedule and remove from $dates * if the base date has changed, update it and the schedule * whatever is left will be new dates, insert into schedule */ if ($dates[$sched_row['event_id']] == $sched_row['event_date']) { unset($dates[$sched_row['event_id']]); } if (isset($dates[$sched_row['event_id']]) && $dates[$sched_row['event_id']] != '' && $sched_row['event_date'] != $dates[$sched_row['event_id']]) { // the date has changed. update the date. $sql = "UPDATE redcap_events_calendar SET event_date = '{$dates[$sched_row['event_id']]}' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND event_date = '{$sched_row['event_date']}'"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event"); } else { $sql_errors[] = $sql; } } else { error_log($sql); } unset($dates[$sched_row['event_id']]); } if ($base_date != $sched_row['baseline_date']) { // the base_date has changed. this will only occur if the treatment start date or randomization date are changed in the study. $sql = "UPDATE redcap_events_calendar SET baseline_date = '" . prep($base_date) . "' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND baseline_date = '{$sched_row['baseline_date']}'"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event"); } else { $sql_errors[] = $sql; } } else { error_log($sql); } unset($dates[$sched_row['event_id']]); } } foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule $base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; if (isset($date) && $date != "") { //Add to table $sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; } else { $sql_errors[] = $sql; } } else { error_log($sql); } } else { REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id); } } log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling"); } else { foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule $base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; if (isset($date) && $date != "") { //Add to table $sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; } else { $sql_errors[] = $sql; } } else { error_log($sql); } } else { REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id); } } log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling"); } } db_free_result($sched_result); } db_free_result($sched_arm_result); } }
public function actionGetTreatment() { if (!isset($_GET['q'])) { throw new CHttpException(401, 'Missing diagnosis name'); } $lat = @$_GET['lat']; $long = @$_GET['long']; $diagnosisName = @$_GET['q']; $data = array(); $diagnosis = Diagnosis::model()->findByAttributes(array('name' => $diagnosisName)); if (!$diagnosis) { throw new CHttpException(401, 'Invalid diagnosis name'); } $treatment = Treatment::model()->findByAttributes(array('diagnosis_id' => $diagnosis->id)); $data['action'] = $treatment->action; $diagnosisType = DiagnosisTypes::model()->findByAttributes(array('diagnosis_id' => $diagnosis->id)); $doctors = Doctors::model()->findAllByAttributes(array('type' => $diagnosisType->doctor_type_id)); //how to compute for nearest place for the doctor foreach ($doctors as $d) { $data['doctors'][] = array('id' => $d->id, 'name' => $d->getFullname(), 'address' => $d->address, 'type' => $diagnosisType->doctorType->name, 'contact_no' => $d->contact_no, 'schedule' => $d->schedule, 'other_info' => $d->other_info, 'lat' => $d->lat, 'long' => $d->long); } echo CJSON::encode($data); }
function runAdmin() { global $results; $a = new Admin(); // New patient $data = array('pname' => 'TEST1', 'dob' => '01/01/1989', 'address' => '123 Fake St.', 'contact_phone' => '5197817372', 'contact_email' => '*****@*****.**', 'emerg_name' => 'Tori', 'emerg_phone' => '6138367372'); $data2 = array('pname' => 'TEST2', 'dob' => '01/01/1989', 'address' => '123 Fake St.', 'contact_phone' => '5197817372', 'contact_email' => '*****@*****.**', 'emerg_name' => 'Tori', 'emerg_phone' => '6138367372'); $results['admin_newPatient'] = $a->addPatient($data); $a->addPatient($data2); // Try to add a patient that already exists $attempt = array('pname' => 'TEST1'); $results['admin_newPatientNot'] = !$a->addPatient($attempt); $patients = $a->getAllPatients(); $emps = $a->getAllPhysicians(); $pid = array_search('TEST1', $patients); // Update patient // Prereq: Patient exists $newData = array('pid' => $pid, 'address' => '123 Updated St.', 'contact_phone' => '5197817372', 'contact_email' => '*****@*****.**'); $where = array('field' => 'pid', 'value' => $pid); $results['admin_updatePatient'] = $a->updatePatient($newData); // Check in patient // Prereq: Checked in patient $a->checkInPatient(array('pid' => array_search('TEST2', $patients), 'indate' => date('m/d/Y'), 'eidin' => key($emps))); $results['admin_datePatients'] = $a->getPatientsOnDate(date('m/d/Y')); // Get patient vists // Prereq: At least 1 EDT record for patient $t = new Treatment(); $edt = array('pid' => $pid, 'dateperf' => '11/30/2010', 'activitytype' => 'E', 'enames' => current($emps), 'description' => "Today I did things", 'duration' => '1', 'outcome' => 'Yay?', 'cost' => 100); $results['admin_patientVisits'] = $t->newEDT($edt) && $a->getPatientVisits($pid); // Get patients based on physician // Prereq: Checked in patient $results['admin_physicianReleasedAdmitted'] = $a->getPhysiciansPatients(key($emps)); // Check out a patient // Prereq: Checked in patient $results['admin_checkOutPatient'] = $a->checkOutPatient(array('pid' => array_search('TEST2', $patients), 'outdate' => date('m/d/Y'), 'eidout' => key($emps))); }
public function checkOutPatient($data) { if (!$this->isPatient($data['pid']) || !checkFilled($data) || !verifyDate($data['outdate']) || !checkNumber($data['eidout']) || !checkNumber($data['pid']) || !$this->isCheckedIn($data['pid'])) { return false; } $where = array('field' => 'pid', 'value' => $data['pid']); // Add up costs of EDT records for that visit $total = 0; $t = new Treatment(); $edts = $t->getEDTRecords($data['pid'], true); foreach ($edts as $e) { $total = $total + $e['cost']; } $data['totalbill'] = $total; unset($data['pid']); // remove pid from elements return $this->dbh->update('CheckInOuts', $data, $where, true); }
?> </h1> </div> </td> </tr> <tr style="width:100%;"> <td> <table width="100%" dir="rtl"> <tr> <td style="width:25%;"></td> <td style="width:50%;"> <?php $treatment = new Treatment(); echo '<form method="post" action="' . $treatment->addTreatment() . '">'; ?> <table width="314"> <tr> <td width="85">تاريخ المعاينة</td> <td width="178"> ajaaaaaaaaax* </td> </tr> <tr> <td> نوع المعاينة </td>