setSpreadsheetKey('0AuPh9cI948YxdEoxRFg4VUkyc0FlNzE1Wjl1Ul9wQlE');
$query->setWorksheetId('od6');
$wsEntry = $service->getWorksheetEntry($query);
} catch (Exception $e) {
die('ERROR: ' . $e->getMessage());
}
$atlas_php_last_updated = strtotime($wsEntry->updated); // Dynamic
$atlas_html_last_updated = strtotime(date("F d Y H:i:s.", filemtime('atlas.html'))); // Static
if (empty($compare_topics) && empty($atlas_topic_row)) {
// Redirect to previously generated static html page if no recent Google Spreadsheets update
if ($atlas_php_last_updated < $atlas_html_last_updated) {
header('Location: atlas.html');
exit;
}
}
*/
header('Location: atlas.html');
exit;
if (empty($compare_topics) && empty($atlas_topic_row)) {
// Else the rest of the php script below will run and overwrite atlas.html file
// Sends me an email of atlas updates
$to = 'vietomatic@gmail.com';
$subject = 'Atlas updated!';
$message = 'The atlas was recently updated. Please run the atlas_generate script to update static pages.';
$headers = 'From: vietomatic@gmail.com' . "\r\n" .
'Reply-To: vietomatic@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
setSpreadsheetKey("0AuPh9cI948YxdEoxRFg4VUkyc0FlNzE1Wjl1Ul9wQlE");
$query->setWorksheetId("od6");
} catch (Exception $e) {
die('ERROR: ' . $e->getMessage());
}
// Grab full atlas hierarchy list to generate links for main image map page
if (empty($compare_topics)) {
// Get a list of the 2nd to 8th row and put into an array
// 1:Parent Node | 2:Level 1 | 3:Level 2 | 4:Level 3 | 5:Level 4 | 6:Level 5 | 7:Topic Name
$max_columns = 8;
$query->setReturnEmpty(true);
$query->setMinCol(2);
$query->setMaxCol($max_columns);
$query->setMinRow(2);
$cellFeed = $service->getCellFeed($query);
// Populate the data_arrays
$array_counter = 1;
foreach ($cellFeed as $cellEntry) {
if ($array_counter == 1) {
$atlas_parent_nodes[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 2) {
$atlas_level1[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 3) {
$atlas_level2[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 4) {
$atlas_level3[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 5) {
$atlas_level4[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 6) {
$atlas_level5[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 7) {
$atlas_topic_names[] = $cellEntry->getCell()->getText();
$atlas_rows[] = $cellEntry->getCell()->getRow();
}
// Reset array counter when all of row data (end of column) is entered
$array_counter < ($max_columns - 1) ? $array_counter++ : $array_counter = 1;
}
} elseif (isset($compare_topics)) {
// Get a list of the 2nd to 16th row and put into an array
// 0:Parent Node | 1:Level 1 | 2:Level 2 | 3:Level 3 | 4:Level 4 | 5:Level 5 | 6:Topic Names | 7:Microscopic Features | 8:Normal Values | 9:May Resemble | 10:Differential Diagnosis | 11: Classic Immunophenotype | 12:Cartoon | 13:Image | 14:Misc | 15:Additional Images
$max_columns = 17;
$query->setReturnEmpty(true);
$query->setMinCol(2);
$query->setMaxCol($max_columns);
$query->setMinRow(min($compare_topics));
$query->setMaxRow(max($compare_topics));
$cellFeed = $service->getCellFeed($query);
// Populate the data_arrays
$x = 0;
$y = 0;
$all_fields = array ("parent_node", "level_1", "level_2", "level_3", "level_4", "level_5", "topic_name", "microscopic_features", "normal_values", "may_resemble", "differential_diagnoses", "classic_immunophenotype", "cartoon", "image", "misc", "additional_images");
foreach ($cellFeed as $cellEntry) { // Make a 2-dimensional array of all topics selected
if (in_array($cellEntry->getCell()->getRow(), $compare_topics)) {
$atlas_data[$x][$all_fields[$y]] = $cellEntry->getCell()->getText();
$y++;
if ($y == ($max_columns - 1)) {
$y = 0;
$x++;
}
}
}
for ($x = 0; $x < count($atlas_data); $x++) {
if (stristr($atlas_data[$x]["topic_name"], "diagram")) { // Show full page diagram
echo "‹ Back to Main Atlas
\n";
echo "" . $atlas_data[$x]["topic_name"] . "
\n";
echo "
\n";
}
?>
" . $atlas_data[$topic_row]["parent_node"] . " ›› " . $atlas_data[$topic_row]["level_1"] . " ›› " . $atlas_data[$topic_row]["level_5"] . "
\n";
echo "
" . $atlas_data[$topic_row]["topic_name"] . "\n";
if ($atlas_data[$topic_row]["image"] != '') { // Print out javascript code for each magnification effect
?>
" width="300" height="225" />
Click Here for Full Size
\n";
if (!empty($atlas_data[$topic_row]["additional_images"])) {
unset($additional_images);
$additional_images = explode(",", str_replace(" ", "", $atlas_data[$topic_row]["additional_images"]));
for ($n = 0; $n < count($additional_images); $n++) {
$num = $n + 1;
echo "
Additional Image $num\n";
}
echo "
\n";
}
}
echo "
›
Microscopic Features:- " . str_replace("\n", "
- ", $atlas_data[$topic_row]["microscopic_features"]) . "
\n";
if (!empty($atlas_data[$topic_row]["normal_values"])) echo "
›
Normal % blood-PB, marrow-BM, lymphoid tissue-LN:- " . str_replace("\n", "
- ", $atlas_data[$topic_row]["normal_values"]) . "
\n";
// Show popup link [set by {row_id} within the Atlas Google Spreadsheet]
if (preg_match_all('#\{(.*?)\}#', $atlas_data[$topic_row]["may_resemble"], $match, PREG_PATTERN_ORDER)) {
for ($r = 0; $r < count($match[1]); $r++) {
$patterns[] = '/' . $match[1][$r] . '/';
if ($topic_row % 2 == 1) { // Show popup on the correct side
$replacements[] = "
[Compare]$popup_side";
} else {
$replacements[] = "
[Compare]$popup_side";
}
}
$atlas_data[$topic_row]["may_resemble"] = preg_replace($patterns, $replacements, $atlas_data[$topic_row]["may_resemble"], 1);
}
$brackets = array("{", "}");
$atlas_data[$topic_row]["may_resemble"] = str_replace($brackets, "", $atlas_data[$topic_row]["may_resemble"]);
echo "
›
May Resemble:- " . str_replace("\n", "
- ", $atlas_data[$topic_row]["may_resemble"]) . "
\n";
if (!empty($atlas_data[$topic_row]["differential_diagnoses"])) {
echo "
›
Differential Diagnoses:\n";
echo "
" . str_replace("\n", " ", $atlas_data[$topic_row]["differential_diagnoses"]) . " |
\n";
}
if (!empty($atlas_data[$topic_row]["classic_immunophenotype"])) echo "
›
Classic Immunophenotype:- " . str_replace("\n", "
- ", $atlas_data[$topic_row]["classic_immunophenotype"]) . "
\n";
if (!empty($atlas_data[$topic_row]["cartoon"])) {
echo "
›
Cartoon Image:
\n";
// Adjust RBC size according to cartoon scale
$factor_twos = Array ('Megakaryocyte*','Dyslobated (Abnormal Lobation) Megakaryocyte*','Hypolobated Megakaryocytes (Increased)*','Staghorn-shaped Megakaryocyte*');
$no_shows = Array ('Normal Lymph Node*','Rouleaux*','Infectious-Microfilaria*','Infectious-Trypanosoma*','Follicular Lymphoma*','Mantle Cell Lymphoma*','Burkitt Lymphoma*','MALT Lymphoma (e.g. Gastric)*');
if (in_array($atlas_data[$topic_row]["topic_name"], $factor_twos)) {
$factor = 97/2;
} else {
$factor = 97/1;
}
if (!(bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad')) {
if (!in_array($atlas_data[$topic_row]["topic_name"], $no_shows)) {
echo "
Click and drag
for direct comparison";
}
}
}
if (!empty($atlas_data[$topic_row]["misc"])) echo "
›
Misc:- " . $atlas_data[$topic_row]["misc"] . "
\n";
echo "
\n";
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// DEFAULT VIEW - FLOWCHART
if (empty($atlas_topic_row) && empty($compare_topics)) {
?>