Files
medicaltracker/public/medical.php
T
Ty Clifford b8045eb068 - The medicine and terminology directories are now organized as compact rows, and each item links to a dynamic database-backed detail page:
Medicines: /medicine.php?id=46
Terms: /term.php?id=13
Key files:
Dynamic medicine page: [public/medicine.php (line 
1)](/Users/tyemeclifford/Documents/GH/workout/public/medicine.php:1)
Dynamic term page: [public/term.php (line 
1)](/Users/tyemeclifford/Documents/GH/workout/public/term.php:1)
Shared lookup/link helpers: [app/bootstrap.php (line 
1220)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:1220)
Reworked medicine directory: [public/nutrition.php (line 
49)](/Users/tyemeclifford/Documents/GH/workout/public/nutrition.php:49)
Reworked terminology page: [public/medical.php (line 
64)](/Users/tyemeclifford/Documents/GH/workout/public/medical.php:64)
Overflow-safe layout CSS: [public/assets/site.css (line 
344)](/Users/tyemeclifford/Documents/GH/workout/public/assets/site.css:344)
2026-06-30 15:41:55 -04:00

151 lines
7.8 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../app/bootstrap.php';
$pdo = app_db();
$pageTitle = 'Medical Terminology Database | Neon Medical Tracker';
$activePage = 'terminology';
$searchQuery = trim((string) ($_GET['q'] ?? ''));
$library = library_search_payload(['q' => $searchQuery, 'limit' => 500]);
$terms = $library['medicalTerms'];
$conditions = $library['medicalConditions'];
$medicines = $library['medicationCatalog'];
$studies = $library['researchStudies'];
$totalMedicines = (int) db_value($pdo, 'SELECT COUNT(*) FROM medication_catalog');
require __DIR__ . '/partials/site-header.php';
?>
<main>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Searchable medical library</p>
<h1>Search terms, conditions, medicines, chemical names, and brands.</h1>
<p>Entries are concise app-authored summaries with links to NIH/NLM systems such as MedlinePlus, RxNorm, DailyMed, PubChem, PubMed, and ClinicalTrials.gov. This is a tracking/reference aid, not medical advice.</p>
</div>
<form class="library-search" method="get" action="/medical.php">
<label>
<span>Search medical library</span>
<input name="q" value="<?= htmlspecialchars($searchQuery, ENT_QUOTES) ?>" placeholder="Try Lipitor, atorvastatin, blood pressure, CBC, metformin">
</label>
<button class="site-primary" type="submit">Search</button>
<?php if ($searchQuery !== ''): ?>
<a class="site-secondary" href="/medical.php">Clear</a>
<?php endif; ?>
</form>
<div class="library-stats" aria-label="Search result counts">
<article><strong><?= count($medicines) ?></strong><span><?= $searchQuery === '' ? 'medicines shown of ' . number_format($totalMedicines) : 'medicine results' ?></span></article>
<article><strong><?= count($terms) ?></strong><span>terms</span></article>
<article><strong><?= count($conditions) ?></strong><span>conditions</span></article>
<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 endif; ?>
</section>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Terminology</p>
<h2>Plain-language medical terms</h2>
</div>
<?php if (!$terms): ?>
<article class="empty-state">
<h3>No terms found.</h3>
<p>Try a broader medical word, lab name, symptom, or abbreviation.</p>
</article>
<?php else: ?>
<div class="library-list">
<?php foreach ($terms 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>
<span><?= htmlspecialchars((string) $term['source_name'], ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-primary" href="<?= htmlspecialchars(term_detail_path($term), ENT_QUOTES) ?>">View term</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">Medication catalog</p>
<h2>Medicines with chemical, brand, RxNorm, DailyMed, and PubChem links</h2>
</div>
<?php if (!$medicines): ?>
<article class="empty-state">
<h3>No medicines found.</h3>
<p>Try a generic name, brand name, chemical name, or medication class.</p>
</article>
<?php else: ?>
<div class="library-list">
<?php foreach ($medicines 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['tracking_note'] ?: 'Medicine reference entry.'), ENT_QUOTES) ?></p>
<div class="library-row-meta">
<span><?= htmlspecialchars((string) ($medicine['class_name'] ?: 'Medication'), ENT_QUOTES) ?></span>
<span>Active: <?= htmlspecialchars((string) ($medicine['active_ingredient'] ?: $medicine['generic_name']), ENT_QUOTES) ?></span>
<span>Brands: <?= htmlspecialchars((string) ($medicine['brand_names'] ?: 'Vary by market'), ENT_QUOTES) ?></span>
</div>
</div>
<div class="library-row-actions">
<a class="site-primary" href="<?= htmlspecialchars(medicine_detail_path($medicine), ENT_QUOTES) ?>">View medicine</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="admin-public-shell">
<div class="site-section-heading">
<p class="site-eyebrow">NIH/NLM study links</p>
<h2>Research categories connected to the listed medicines</h2>
</div>
<div class="term-table">
<?php foreach ($studies as $study): ?>
<article>
<div>
<h3><?= htmlspecialchars($study['title'], ENT_QUOTES) ?></h3>
<span><?= htmlspecialchars($study['category'] . ' / ' . $study['related_medicine'], ENT_QUOTES) ?></span>
</div>
<p><?= htmlspecialchars($study['summary'], ENT_QUOTES) ?></p>
<div class="source-links">
<a href="<?= htmlspecialchars($study['source_url'], ENT_QUOTES) ?>"><?= htmlspecialchars($study['nih_source'], ENT_QUOTES) ?></a>
<a href="<?= htmlspecialchars($study['pubmed_url'], ENT_QUOTES) ?>">PubMed</a>
<a href="<?= htmlspecialchars($study['clinicaltrials_url'], ENT_QUOTES) ?>">ClinicalTrials.gov</a>
</div>
</article>
<?php endforeach; ?>
</div>
</section>
</main>
<?php require __DIR__ . '/partials/site-footer.php'; ?>