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"; } echo "
\n"; if (isset($atlas_data[$x]["image"])) { echo "\n"; } else { echo "




























\n"; } if (isset($atlas_data[$x]["misc"])) { // Show caption (uses "misc" column) echo "

" . $atlas_data[$x]["misc"] . "
\n"; print_footer(); exit; } else { // Print out topic print_topic($x); if ($x % 2 == 1) echo "

\n"; // Split every two } } print_footer(); exit; } function print_topic($topic_row) { ?> \n"; } else { 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:\n"; if (!empty($atlas_data[$topic_row]["normal_values"])) echo "Normal % blood-PB, marrow-BM, lymphoid tissue-LN:\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:\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:\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
RBC
for direct comparison

"; } } } if (!empty($atlas_data[$topic_row]["misc"])) echo "Misc:\n"; echo "
\n"; } ///////////////////////////////////////////////////////////////////////////////////////////////// // DEFAULT VIEW - FLOWCHART if (empty($atlas_topic_row) && empty($compare_topics)) { ?>
Thymus Lymph Node Mucosa-Associated Lymphoid Tissue Spleen Peripheral Blood/Red Blood Cells Peripheral Blood/Neutrophils Peripheral Blood/Lymphocytes Peripheral Blood/Monocytes Peripheral Blood/Eosinophils/Basophils Peripheral Blood/Platelets Bone Marrow/Erythroid Bone Marrow/Granulocytes and Precursors Bone Marrow/Monocytes and Precursors Bone Marrow/Megakaryocytes and Precursors Bone Marrow/Lymphoid/T-cells Bone Marrow/Lymphoid/NK Cells Bone Marrow/Granulocytes/Neutrophilic Bone Marrow/Granulocytes/Eosinophilic Bone Marrow/Granulocytes/Basophilic Bone Marrow/Lymphoid/B-cells Bone Marrow/Lymphoid/Plasma Cells
Click image for full size


Bone Marrow: Erythroid (RBCs and Precursors)

Bone Marrow: Granulocytes and Precursors

Bone Marrow: Neutrophilic

Bone Marrow: Eosinophilic

Bone Marrow: Basophilic

Bone Marrow: Monocytes and Precursors

Bone Marrow: Megakaryocytes and Precursors

Bone Marrow: T-cells

Bone Marrow: B-cells

Bone Marrow: Plasma Cells

Bone Marrow: NK Cells

Thymus

Lymph Node

Mucosa-Associated Lymphoid Tissue (MALT)

Spleen

Peripheral Blood: Red Blood Cells

Peripheral Blood: Neutrophils

Peripheral Blood: Eosinophils and Basophils

Peripheral Blood: Monocytes

Peripheral Blood: Lymphocytes

Peripheral Blood: Platelets

\n"; echo "\n"; echo "\n"; echo "\n"; // Default view for ($x = 0; $x < count($atlas_parent_nodes); $x++) { // Loop through all entries if ($atlas_parent_nodes[$x] == $parent_node && $atlas_level1[$x] == $level1 && $atlas_level2[$x] == $level2 && $atlas_level3[$x] == $level3 && $atlas_level4[$x] == $level4) { $bgcolor == '#eeeeee' ? $bgcolor = '#dddddd' : $bgcolor = '#eeeeee'; $cellcolor == '#cccccc' ? $cellcolor = '#bbbbbb' : $cellcolor = '#cccccc'; if ($atlas_topic_names[$x] == '') break; echo "\n"; if ($atlas_level5[$x] == 'Normal') { echo "\n"; } elseif ($atlas_level5[$x] == 'Abnormal') { echo "\n"; } else { echo "\n"; } if (!stristr($atlas_topic_names[$x], 'diagram')) { // Link to show diagram only page echo "\n"; } else { echo "\n"; } echo "\n"; echo "\n"; } } echo "\n"; echo "\n"; echo "\n"; } echo "


\n"; echo " Test your knowledge: Peripheral Blood Smear
\n"; echo " Test your knowledge: Multiple Choice Quiz (Bone Marrow Components)
\n"; echo " Test your knowledge: Multiple Choice Quiz (Peripheral Blood Components)
\n"; echo " Test your knowledge: Glossary Matching - All Terms

\n"; echo "
\n"; // Write php output to static atlas.html file print_footer(); if (empty($compare_topics) && empty($atlas_topic_row)) { file_put_contents('atlas.html', ob_get_contents()); } ob_end_flush(); exit; ?>