- Fixed. Medicines now show “what it is used for” from official label data when available, with curated/common-use text as the fallback.
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.
This commit is contained in:
+36
-1
@@ -14,12 +14,21 @@ $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);
|
||||
}
|
||||
@@ -74,6 +83,32 @@ require __DIR__ . '/partials/site-header.php';
|
||||
</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">
|
||||
@@ -115,7 +150,7 @@ require __DIR__ . '/partials/site-header.php';
|
||||
<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>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user