- 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 @@ $relatedSymptoms = [];
|
||||
$relatedTerms = [];
|
||||
$relatedMedicines = [];
|
||||
$relatedStudies = [];
|
||||
$linkedMedicines = [];
|
||||
if ($condition) {
|
||||
$linkedMedicines = linked_medicines_for_condition($pdo, (int) $condition['id']);
|
||||
$related = library_search_payload(['q' => (string) $condition['name'], 'limit' => 8]);
|
||||
$relatedSymptoms = $related['medicalSymptoms'];
|
||||
$relatedTerms = $related['medicalTerms'];
|
||||
$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);
|
||||
}
|
||||
@@ -69,6 +78,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 ($relatedSymptoms || $relatedTerms || $relatedMedicines || $relatedStudies): ?>
|
||||
<section class="admin-public-shell">
|
||||
<div class="site-section-heading">
|
||||
@@ -111,7 +146,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>
|
||||
|
||||
+1
-1
@@ -149,7 +149,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['tracking_note'] ?: 'Medicine reference entry.'), 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>
|
||||
<span>Active: <?= htmlspecialchars((string) ($medicine['active_ingredient'] ?: $medicine['generic_name']), ENT_QUOTES) ?></span>
|
||||
|
||||
+60
-1
@@ -12,9 +12,14 @@ $activePage = 'medicines';
|
||||
|
||||
$relatedStudies = [];
|
||||
$referenceLinks = [];
|
||||
$linkedConditions = [];
|
||||
$linkedSymptoms = [];
|
||||
$useSourceLinks = [];
|
||||
if ($medicine) {
|
||||
$genericName = (string) $medicine['generic_name'];
|
||||
$like = '%' . $genericName . '%';
|
||||
$linkedConditions = linked_conditions_for_medicine($pdo, (int) $medicine['id']);
|
||||
$linkedSymptoms = linked_symptoms_for_medicine($pdo, (int) $medicine['id']);
|
||||
$relatedStudies = db_all(
|
||||
$pdo,
|
||||
"SELECT *
|
||||
@@ -25,6 +30,7 @@ if ($medicine) {
|
||||
[$like, $like, $like]
|
||||
);
|
||||
$referenceLinks = medicine_reference_links($medicine);
|
||||
$useSourceLinks = medicine_use_source_link($medicine);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
}
|
||||
@@ -45,7 +51,7 @@ require __DIR__ . '/partials/site-header.php';
|
||||
<div>
|
||||
<p class="site-eyebrow">Medicine detail</p>
|
||||
<h1><?= htmlspecialchars(ucfirst((string) $medicine['generic_name']), ENT_QUOTES) ?></h1>
|
||||
<p><?= htmlspecialchars((string) ($medicine['common_use'] ?: 'Medicine reference entry.'), ENT_QUOTES) ?></p>
|
||||
<p><?= htmlspecialchars(medicine_used_for_text($medicine), ENT_QUOTES) ?></p>
|
||||
</div>
|
||||
<div class="record-actions">
|
||||
<a class="site-primary" href="/tracker.php">Open tracker</a>
|
||||
@@ -62,6 +68,17 @@ require __DIR__ . '/partials/site-header.php';
|
||||
|
||||
<section class="admin-public-shell">
|
||||
<div class="record-detail-grid">
|
||||
<article class="record-field wide">
|
||||
<span>What It Is Used For</span>
|
||||
<p><?= htmlspecialchars(medicine_used_for_text($medicine), ENT_QUOTES) ?></p>
|
||||
<?php if ($useSourceLinks): ?>
|
||||
<div class="source-links">
|
||||
<?php foreach ($useSourceLinks as $label => $url): ?>
|
||||
<a href="<?= htmlspecialchars((string) $url, ENT_QUOTES) ?>"><?= htmlspecialchars((string) $label, ENT_QUOTES) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
<article class="record-field">
|
||||
<span>Active Ingredient</span>
|
||||
<p><?= htmlspecialchars((string) ($medicine['active_ingredient'] ?: $medicine['generic_name']), ENT_QUOTES) ?></p>
|
||||
@@ -93,6 +110,48 @@ require __DIR__ . '/partials/site-header.php';
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($linkedConditions || $linkedSymptoms): ?>
|
||||
<section class="admin-public-shell">
|
||||
<div class="site-section-heading">
|
||||
<p class="site-eyebrow">Clinical links</p>
|
||||
<h2>Linked conditions and symptoms</h2>
|
||||
</div>
|
||||
<div class="library-list">
|
||||
<?php foreach ($linkedConditions as $condition): ?>
|
||||
<article class="library-row">
|
||||
<div class="library-row-main">
|
||||
<h3><?= htmlspecialchars((string) $condition['name'], ENT_QUOTES) ?></h3>
|
||||
<p><?= htmlspecialchars((string) ($condition['link_note'] ?: $condition['overview']), ENT_QUOTES) ?></p>
|
||||
<div class="library-row-meta">
|
||||
<span><?= htmlspecialchars((string) $condition['category'], ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars((string) $condition['link_relationship'], 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 ($linkedSymptoms as $symptom): ?>
|
||||
<article class="library-row">
|
||||
<div class="library-row-main">
|
||||
<h3><?= htmlspecialchars((string) $symptom['name'], ENT_QUOTES) ?></h3>
|
||||
<p><?= htmlspecialchars((string) ($symptom['link_note'] ?: $symptom['plain_language_description']), ENT_QUOTES) ?></p>
|
||||
<div class="library-row-meta">
|
||||
<span><?= htmlspecialchars((string) $symptom['category'], ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars((string) $symptom['link_relationship'], ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="library-row-actions">
|
||||
<a class="site-secondary" href="<?= htmlspecialchars(symptom_detail_path($symptom), ENT_QUOTES) ?>">View symptom</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($relatedStudies): ?>
|
||||
<section class="admin-public-shell">
|
||||
<div class="site-section-heading">
|
||||
|
||||
@@ -63,7 +63,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['tracking_note'] ?: 'Medicine reference entry.'), 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>
|
||||
<span>Active: <?= htmlspecialchars((string) ($medicine['active_ingredient'] ?: $medicine['generic_name']), ENT_QUOTES) ?></span>
|
||||
|
||||
+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>
|
||||
|
||||
+1
-1
@@ -93,7 +93,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>
|
||||
<span><?= htmlspecialchars((string) ($medicine['brand_names'] ?: 'Brands vary'), ENT_QUOTES) ?></span>
|
||||
|
||||
Reference in New Issue
Block a user