- Conditions now use the same database/detail-page model as medicines, terminology, and symptoms.

What changed:
Rebuilt the Conditions page into a searchable condition database: 
[public/workouts.php (line 
1)](/Users/tyemeclifford/Documents/GH/workout/public/workouts.php:1)
Added dynamic condition detail pages, e.g. 
/condition.php?name=Type%202%20Diabetes or /condition.php?id=2: 
[public/condition.php (line 
1)](/Users/tyemeclifford/Documents/GH/workout/public/condition.php:1)
Added condition detail/link lookup helpers: [app/bootstrap.php (line 
1680)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:1680)
Expanded the seeded condition catalog to 203 conditions with categories, 
tracking notes, and MedlinePlus links: [app/bootstrap.php (line 
636)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:636)
Updated combined medical search to link conditions internally with “View 
condition”: [public/medical.php (line 
48)](/Users/tyemeclifford/Documents/GH/workout/public/medical.php:48)
Updated related records on symptom/term pages to point to condition 
detail pages.
Updated README route docs: [README.md (line 
21)](/Users/tyemeclifford/Documents/GH/workout/README.md:21)
This commit is contained in:
Ty Clifford
2026-06-30 16:35:27 -04:00
parent 0d492451c7
commit e45324fde4
8 changed files with 462 additions and 42 deletions
+145
View File
@@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
require __DIR__ . '/../app/bootstrap.php';
$pdo = app_db();
$condition = find_medical_condition_item($pdo, $_GET);
$pageTitle = $condition
? (string) $condition['name'] . ' | Condition Detail | Neon Medical Tracker'
: 'Condition Not Found | Neon Medical Tracker';
$activePage = 'conditions';
$relatedSymptoms = [];
$relatedTerms = [];
$relatedMedicines = [];
$relatedStudies = [];
if ($condition) {
$related = library_search_payload(['q' => (string) $condition['name'], 'limit' => 8]);
$relatedSymptoms = $related['medicalSymptoms'];
$relatedTerms = $related['medicalTerms'];
$relatedMedicines = $related['medicationCatalog'];
$relatedStudies = $related['researchStudies'];
} else {
http_response_code(404);
}
require __DIR__ . '/partials/site-header.php';
?>
<main>
<?php if (!$condition): ?>
<section class="admin-public-shell record-shell">
<p class="site-eyebrow">Condition database</p>
<h1>Condition not found.</h1>
<p>The requested condition link does not match a current database record.</p>
<a class="site-primary" href="/workouts.php">Search conditions</a>
</section>
<?php else: ?>
<section class="admin-public-shell record-shell">
<div class="record-heading">
<div>
<p class="site-eyebrow">Condition detail</p>
<h1><?= htmlspecialchars((string) $condition['name'], ENT_QUOTES) ?></h1>
<p><?= htmlspecialchars((string) $condition['overview'], ENT_QUOTES) ?></p>
</div>
<div class="record-actions">
<a class="site-primary" href="/tracker.php">Open tracker</a>
<a class="site-secondary" href="/workouts.php?q=<?= rawurlencode((string) $condition['name']) ?>">Condition search</a>
</div>
</div>
<div class="record-meta">
<span><?= htmlspecialchars((string) $condition['category'], ENT_QUOTES) ?></span>
<span>ID <?= htmlspecialchars((string) $condition['id'], ENT_QUOTES) ?></span>
</div>
</section>
<section class="admin-public-shell">
<div class="record-detail-grid">
<article class="record-field wide">
<span>Common Tracking</span>
<p><?= htmlspecialchars((string) $condition['common_tracking'], ENT_QUOTES) ?></p>
</article>
<article class="record-field wide">
<span>Source</span>
<div class="source-links">
<a href="<?= htmlspecialchars((string) $condition['source_url'], ENT_QUOTES) ?>"><?= htmlspecialchars((string) $condition['source_name'], ENT_QUOTES) ?></a>
</div>
</article>
</div>
</section>
<?php if ($relatedSymptoms || $relatedTerms || $relatedMedicines || $relatedStudies): ?>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Connected records</p>
<h2>Database matches for this condition</h2>
</div>
<div class="library-list">
<?php foreach ($relatedSymptoms as $symptom): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars((string) $symptom['name'], ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) $symptom['plain_language_description'], ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) $symptom['category'], ENT_QUOTES) ?></span>
<span><?= htmlspecialchars((string) ($symptom['body_system'] ?: 'Symptom'), ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars(symptom_detail_path($symptom), ENT_QUOTES) ?>">View symptom</a>
</div>
</article>
<?php endforeach; ?>
<?php foreach ($relatedTerms as $term): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars((string) $term['term'], ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) $term['plain_language_definition'], ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) $term['category'], ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars(term_detail_path($term), ENT_QUOTES) ?>">View term</a>
</div>
</article>
<?php endforeach; ?>
<?php foreach ($relatedMedicines as $medicine): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars(ucfirst((string) $medicine['generic_name']), ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) ($medicine['common_use'] ?: $medicine['class_name']), ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) ($medicine['class_name'] ?: 'Medication'), ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars(medicine_detail_path($medicine), ENT_QUOTES) ?>">View medicine</a>
</div>
</article>
<?php endforeach; ?>
<?php foreach ($relatedStudies as $study): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars((string) $study['title'], ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) $study['summary'], ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) $study['category'], ENT_QUOTES) ?></span>
<span><?= htmlspecialchars((string) $study['related_medicine'], ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars((string) $study['source_url'], ENT_QUOTES) ?>">Study link</a>
</div>
</article>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<?php endif; ?>
</main>
<?php require __DIR__ . '/partials/site-footer.php'; ?>
+18 -11
View File
@@ -45,22 +45,29 @@ require __DIR__ . '/partials/site-header.php';
<article><strong><?= count($studies) ?></strong><span>study links</span></article>
</div>
<div class="detail-grid">
<?php foreach ($conditions as $condition): ?>
<article>
<h2><?= htmlspecialchars($condition['name'], ENT_QUOTES) ?></h2>
<p><strong><?= htmlspecialchars($condition['category'], ENT_QUOTES) ?></strong></p>
<p><?= htmlspecialchars($condition['overview'], ENT_QUOTES) ?></p>
<p><?= htmlspecialchars($condition['common_tracking'], ENT_QUOTES) ?></p>
<a class="site-secondary" href="<?= htmlspecialchars($condition['source_url'], ENT_QUOTES) ?>">Source</a>
</article>
<?php endforeach; ?>
</div>
<?php if (!$conditions): ?>
<article class="empty-state">
<h3>No conditions found.</h3>
<p>Try another medicine, symptom, lab, or tracking term.</p>
</article>
<?php else: ?>
<div class="library-list">
<?php foreach ($conditions as $condition): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars((string) $condition['name'], ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) $condition['overview'], ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) $condition['category'], ENT_QUOTES) ?></span>
<span><?= htmlspecialchars((string) $condition['source_name'], ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-primary" href="<?= htmlspecialchars(condition_detail_path($condition), ENT_QUOTES) ?>">View condition</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
+1 -1
View File
@@ -106,7 +106,7 @@ require __DIR__ . '/partials/site-header.php';
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars((string) $condition['source_url'], ENT_QUOTES) ?>">Source</a>
<a class="site-secondary" href="<?= htmlspecialchars(condition_detail_path($condition), ENT_QUOTES) ?>">View condition</a>
</div>
</article>
<?php endforeach; ?>
+1 -1
View File
@@ -84,7 +84,7 @@ require __DIR__ . '/partials/site-header.php';
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars((string) $condition['source_url'], ENT_QUOTES) ?>">Source</a>
<a class="site-secondary" href="<?= htmlspecialchars(condition_detail_path($condition), ENT_QUOTES) ?>">View condition</a>
</div>
</article>
<?php endforeach; ?>
+55 -25
View File
@@ -4,39 +4,69 @@ declare(strict_types=1);
require __DIR__ . '/../app/bootstrap.php';
$pdo = app_db();
$pageTitle = 'Condition Tracking | Neon Medical Tracker';
$pageTitle = 'Condition Database | Neon Medical Tracker';
$activePage = 'conditions';
$conditions = db_all($pdo, 'SELECT * FROM medical_conditions ORDER BY category, name');
$photo = 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Cycling_in_Amsterdam_%28893%29.jpg/1280px-Cycling_in_Amsterdam_%28893%29.jpg';
$searchQuery = trim((string) ($_GET['q'] ?? ''));
$library = library_search_payload(['q' => $searchQuery, 'limit' => 500]);
$conditions = $library['medicalConditions'];
$totalConditions = (int) db_value($pdo, 'SELECT COUNT(*) FROM medical_conditions');
require __DIR__ . '/partials/site-header.php';
?>
<main>
<section class="detail-hero">
<div>
<p class="site-eyebrow">Condition tracking</p>
<h1>Track readings, symptoms, labs, and medications by condition.</h1>
<p>Use structured logs for blood pressure, glucose, pain, oxygen, temperature, lab results, medications, and notes. The condition library links back to NIH/NLM patient-information sources.</p>
<a class="site-primary" href="/tracker.php">Open tracker</a>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Condition database</p>
<h1>Search conditions by name, category, overview, and tracking context.</h1>
<p>Condition entries are concise reference summaries with MedlinePlus source links. They support tracking and discussion, not diagnosis or treatment decisions.</p>
</div>
<form class="library-search" method="get" action="/workouts.php">
<label>
<span>Search conditions</span>
<input name="q" value="<?= htmlspecialchars($searchQuery, ENT_QUOTES) ?>" placeholder="Try diabetes, asthma, migraine, kidney, depression, arthritis">
</label>
<button class="site-primary" type="submit">Search</button>
<?php if ($searchQuery !== ''): ?>
<a class="site-secondary" href="/workouts.php">Clear</a>
<?php endif; ?>
</form>
<div class="library-stats" aria-label="Condition result count">
<article><strong><?= count($conditions) ?></strong><span><?= $searchQuery === '' ? 'shown of ' . number_format($totalConditions) . ' conditions' : 'condition results' ?></span></article>
</div>
<figure>
<img src="<?= htmlspecialchars($photo, ENT_QUOTES) ?>" alt="People cycling outdoors">
<figcaption>
Photo: <a href="https://commons.wikimedia.org/wiki/File:Cycling_in_Amsterdam_(893).jpg">Cycling in Amsterdam (893)</a>
by FaceMePLS, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA 2.0</a>.
</figcaption>
</figure>
</section>
<section class="detail-grid">
<?php foreach ($conditions as $condition): ?>
<article>
<h2><?= htmlspecialchars($condition['name'], ENT_QUOTES) ?></h2>
<p><strong><?= htmlspecialchars($condition['category'], ENT_QUOTES) ?></strong></p>
<p><?= htmlspecialchars($condition['overview'], ENT_QUOTES) ?></p>
<p><?= htmlspecialchars($condition['common_tracking'], ENT_QUOTES) ?></p>
<a class="site-secondary" href="<?= htmlspecialchars($condition['source_url'], ENT_QUOTES) ?>">MedlinePlus</a>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Catalog directory</p>
<h2>Condition records</h2>
</div>
<?php if (!$conditions): ?>
<article class="empty-state">
<h3>No conditions found.</h3>
<p>Try a diagnosis name, body system, symptom, medicine, lab, or tracking phrase.</p>
</article>
<?php endforeach; ?>
<?php else: ?>
<div class="library-list">
<?php foreach ($conditions as $condition): ?>
<article class="library-row">
<div class="library-row-main">
<h3><?= htmlspecialchars((string) $condition['name'], ENT_QUOTES) ?></h3>
<p><?= htmlspecialchars((string) $condition['overview'], ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) $condition['category'], ENT_QUOTES) ?></span>
<span><?= htmlspecialchars((string) $condition['source_name'], ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-primary" href="<?= htmlspecialchars(condition_detail_path($condition), ENT_QUOTES) ?>">View condition</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
</main>
<?php require __DIR__ . '/partials/site-footer.php'; ?>