c1cb93083e
Changed: Added official_use, source name, and source URL fields to the medicine schema in [app/bootstrap.php (line 200)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:200). Added shared display helpers and API used_for output in [app/bootstrap.php (line 1848)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:1848). Updated openFDA imports to pull indications_and_usage first, then purpose, and store source links in [app/bootstrap.php (line 3060)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:3060). Updated the medicine detail page to show “What It Is Used For” plus the openFDA label link in [public/medicine.php (line 72)](/Users/tyemeclifford/Documents/GH/workout/public/medicine.php:72). Updated catalog/list contexts to use the same helper, including [public/nutrition.php (line 66)](/Users/tyemeclifford/Documents/GH/workout/public/nutrition.php:66). Updated docs/counts in [README.md (line 45)](/Users/tyemeclifford/Documents/GH/workout/README.md:45) and [CHANGELOG.md (line 15)](/Users/tyemeclifford/Documents/GH/workout/CHANGELOG.md:15). Database is updated to 7,646 medicines, with 200 openFDA label-derived use summaries, 8,077 medicine-condition links, and 10,590 medicine-symptom links. Verified: Refreshed openFDA label-use data with scripts/update_medicine_catalog.php 200 openFDA. /medicine.php?id=7644, /medicine.php?id=6, /nutrition.php?q=serdexmethylphenidate, /api.php?action=library_search&q=ADHD&limit=5, and / all returned 200. Confirmed the page shows “What It Is Used For”, “Used for: ...”, and an openFDA label source link. Stock php -l was not available in this workspace, but the FrankenPHP bootstrap and route/API smoke tests executed successfully. Sources used: openFDA drug label fields and openFDA query parameters.
83 lines
4.2 KiB
PHP
83 lines
4.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../app/bootstrap.php';
|
|
$pdo = app_db();
|
|
|
|
$pageTitle = 'Medicine Catalog | Neon Medical Tracker';
|
|
$activePage = 'medicines';
|
|
$searchQuery = trim((string) ($_GET['q'] ?? ''));
|
|
$library = library_search_payload(['q' => $searchQuery, 'limit' => 500]);
|
|
$medicines = $library['medicationCatalog'];
|
|
$totalMedicines = (int) db_value($pdo, 'SELECT COUNT(*) FROM medication_catalog');
|
|
$photo = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/A_large_mixed_salad.jpg/1024px-A_large_mixed_salad.jpg';
|
|
require __DIR__ . '/partials/site-header.php';
|
|
?>
|
|
<main>
|
|
<section class="detail-hero reverse">
|
|
<figure>
|
|
<img src="<?= htmlspecialchars($photo, ENT_QUOTES) ?>" alt="Large mixed salad">
|
|
<figcaption>
|
|
Photo: <a href="https://commons.wikimedia.org/wiki/File:A_large_mixed_salad.jpg">A large mixed salad</a>
|
|
by Jmabel, <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.
|
|
</figcaption>
|
|
</figure>
|
|
<div>
|
|
<p class="site-eyebrow">Medicine catalog</p>
|
|
<h1>Search medicines by generic, chemical, brand, and alternate names.</h1>
|
|
<p>The catalog includes common medicines and links each one to RxNorm, DailyMed, PubChem, MedlinePlus, PubMed, and ClinicalTrials.gov searches.</p>
|
|
<a class="site-primary" href="/tracker.php">Open medical tracker</a>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="admin-public-shell">
|
|
<form class="library-search" method="get" action="/nutrition.php">
|
|
<label>
|
|
<span>Search medicine catalog</span>
|
|
<input name="q" value="<?= htmlspecialchars($searchQuery, ENT_QUOTES) ?>" placeholder="Try Zoloft, sertraline, insulin, acetaminophen, blood pressure">
|
|
</label>
|
|
<button class="site-primary" type="submit">Search</button>
|
|
<?php if ($searchQuery !== ''): ?>
|
|
<a class="site-secondary" href="/nutrition.php">Clear</a>
|
|
<?php endif; ?>
|
|
</form>
|
|
<div class="library-stats" aria-label="Medicine result count">
|
|
<article><strong><?= count($medicines) ?></strong><span><?= $searchQuery === '' ? 'shown of ' . number_format($totalMedicines) . ' medicines' : 'medicine results' ?></span></article>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="admin-public-shell">
|
|
<div class="site-section-heading">
|
|
<p class="site-eyebrow">Catalog directory</p>
|
|
<h2>Medicine records</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(medicine_used_for_text($medicine), 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>
|
|
</main>
|
|
<?php require __DIR__ . '/partials/site-footer.php'; ?>
|