Files
medicaltracker/public/term.php
T
Ty Clifford e45324fde4 - 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)
2026-06-30 16:35:27 -04:00

129 lines
6.4 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../app/bootstrap.php';
$pdo = app_db();
$term = find_medical_term_item($pdo, $_GET);
$pageTitle = $term
? (string) $term['term'] . ' | Medical Term | Neon Medical Tracker'
: 'Medical Term Not Found | Neon Medical Tracker';
$activePage = 'terminology';
$relatedMedicines = [];
$relatedConditions = [];
$relatedStudies = [];
if ($term) {
$related = library_search_payload(['q' => (string) $term['term'], 'limit' => 8]);
$relatedMedicines = $related['medicationCatalog'];
$relatedConditions = $related['medicalConditions'];
$relatedStudies = $related['researchStudies'];
} else {
http_response_code(404);
}
require __DIR__ . '/partials/site-header.php';
?>
<main>
<?php if (!$term): ?>
<section class="admin-public-shell record-shell">
<p class="site-eyebrow">Medical terminology</p>
<h1>Term not found.</h1>
<p>The requested terminology link does not match a current database record.</p>
<a class="site-primary" href="/medical.php">Search terminology</a>
</section>
<?php else: ?>
<section class="admin-public-shell record-shell">
<div class="record-heading">
<div>
<p class="site-eyebrow">Medical term</p>
<h1><?= htmlspecialchars((string) $term['term'], ENT_QUOTES) ?></h1>
<p><?= htmlspecialchars((string) $term['plain_language_definition'], ENT_QUOTES) ?></p>
</div>
<div class="record-actions">
<a class="site-primary" href="/tracker.php">Open tracker</a>
<a class="site-secondary" href="/medical.php?q=<?= rawurlencode((string) $term['term']) ?>">Library search</a>
</div>
</div>
<div class="record-meta">
<span><?= htmlspecialchars((string) $term['category'], ENT_QUOTES) ?></span>
<span>ID <?= htmlspecialchars((string) $term['id'], ENT_QUOTES) ?></span>
</div>
</section>
<section class="admin-public-shell">
<div class="record-detail-grid">
<article class="record-field wide">
<span>Clinical Context</span>
<p><?= htmlspecialchars((string) $term['clinical_context'], ENT_QUOTES) ?></p>
</article>
<article class="record-field wide">
<span>Source</span>
<div class="source-links">
<a href="<?= htmlspecialchars((string) $term['source_url'], ENT_QUOTES) ?>"><?= htmlspecialchars((string) $term['source_name'], ENT_QUOTES) ?></a>
</div>
</article>
</div>
</section>
<?php if ($relatedConditions || $relatedMedicines || $relatedStudies): ?>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Connected records</p>
<h2>Database matches for this term</h2>
</div>
<div class="library-list">
<?php foreach ($relatedConditions 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>
</div>
</div>
<div class="library-row-actions">
<a class="site-secondary" href="<?= htmlspecialchars(condition_detail_path($condition), ENT_QUOTES) ?>">View condition</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>
<span><?= htmlspecialchars((string) ($medicine['brand_names'] ?: 'Brands vary'), 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'; ?>