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.
185 lines
9.6 KiB
PHP
185 lines
9.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../app/bootstrap.php';
|
|
$pdo = app_db();
|
|
|
|
$symptom = find_medical_symptom_item($pdo, $_GET);
|
|
$pageTitle = $symptom
|
|
? (string) $symptom['name'] . ' | Symptom Detail | Neon Medical Tracker'
|
|
: 'Symptom Not Found | Neon Medical Tracker';
|
|
$activePage = 'symptoms';
|
|
|
|
$relatedTerms = [];
|
|
$relatedConditions = [];
|
|
$relatedMedicines = [];
|
|
$relatedStudies = [];
|
|
$linkedMedicines = [];
|
|
if ($symptom) {
|
|
$linkedMedicines = linked_medicines_for_symptom($pdo, (int) $symptom['id']);
|
|
$related = library_search_payload(['q' => (string) $symptom['name'], 'limit' => 8]);
|
|
$relatedTerms = $related['medicalTerms'];
|
|
$relatedConditions = $related['medicalConditions'];
|
|
$relatedMedicines = $related['medicationCatalog'];
|
|
$relatedStudies = $related['researchStudies'];
|
|
if ($linkedMedicines) {
|
|
$linkedIds = array_fill_keys(array_map(static fn(array $row): int => (int) $row['id'], $linkedMedicines), true);
|
|
$relatedMedicines = array_values(array_filter(
|
|
$relatedMedicines,
|
|
static fn(array $row): bool => !isset($linkedIds[(int) $row['id']])
|
|
));
|
|
}
|
|
} else {
|
|
http_response_code(404);
|
|
}
|
|
|
|
require __DIR__ . '/partials/site-header.php';
|
|
?>
|
|
<main>
|
|
<?php if (!$symptom): ?>
|
|
<section class="admin-public-shell record-shell">
|
|
<p class="site-eyebrow">Symptom database</p>
|
|
<h1>Symptom not found.</h1>
|
|
<p>The requested symptom link does not match a current database record.</p>
|
|
<a class="site-primary" href="/symptoms.php">Search symptoms</a>
|
|
</section>
|
|
<?php else: ?>
|
|
<section class="admin-public-shell record-shell">
|
|
<div class="record-heading">
|
|
<div>
|
|
<p class="site-eyebrow">Symptom detail</p>
|
|
<h1><?= htmlspecialchars((string) $symptom['name'], ENT_QUOTES) ?></h1>
|
|
<p><?= htmlspecialchars((string) $symptom['plain_language_description'], ENT_QUOTES) ?></p>
|
|
</div>
|
|
<div class="record-actions">
|
|
<a class="site-primary" href="/tracker.php">Open tracker</a>
|
|
<a class="site-secondary" href="/symptoms.php?q=<?= rawurlencode((string) $symptom['name']) ?>">Symptom search</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="record-meta">
|
|
<span><?= htmlspecialchars((string) $symptom['category'], ENT_QUOTES) ?></span>
|
|
<span><?= htmlspecialchars((string) ($symptom['body_system'] ?: 'Symptom'), ENT_QUOTES) ?></span>
|
|
<span>ID <?= htmlspecialchars((string) $symptom['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) $symptom['common_tracking'], ENT_QUOTES) ?></p>
|
|
</article>
|
|
<article class="record-field wide">
|
|
<span>Urgency Context</span>
|
|
<p><?= htmlspecialchars((string) $symptom['urgency_note'], ENT_QUOTES) ?></p>
|
|
</article>
|
|
<article class="record-field wide">
|
|
<span>Source</span>
|
|
<div class="source-links">
|
|
<a href="<?= htmlspecialchars((string) $symptom['source_url'], ENT_QUOTES) ?>"><?= htmlspecialchars((string) $symptom['source_name'], ENT_QUOTES) ?></a>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
</section>
|
|
|
|
<?php if ($linkedMedicines): ?>
|
|
<section class="admin-public-shell">
|
|
<div class="site-section-heading">
|
|
<p class="site-eyebrow">Medicine links</p>
|
|
<h2>Commonly linked medicines</h2>
|
|
</div>
|
|
<div class="library-list">
|
|
<?php foreach ($linkedMedicines 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['link_note'] ?: medicine_used_for_text($medicine)), ENT_QUOTES) ?></p>
|
|
<div class="library-row-meta">
|
|
<span><?= htmlspecialchars((string) ($medicine['class_name'] ?: 'Medication'), ENT_QUOTES) ?></span>
|
|
<span><?= htmlspecialchars((string) $medicine['link_relationship'], 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; ?>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($relatedTerms || $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 symptom</h2>
|
|
</div>
|
|
<div class="library-list">
|
|
<?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 ($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(medicine_used_for_text($medicine), 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'; ?>
|