- 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:
Ty Clifford
2026-07-03 16:34:31 -04:00
parent 79128fa98a
commit c1cb93083e
10 changed files with 1250 additions and 130 deletions
+41 -1
View File
@@ -2,6 +2,46 @@
All notable changes to Neon Medical Tracker are documented here.
## [Unreleased] - 2026-07-03
### Added
- Added generated medicine-to-condition and medicine-to-symptom relationship tables.
- Added dynamic medicine detail sections for linked conditions and linked symptom contexts.
- Added dynamic condition and symptom sections for commonly linked medicines.
- Added therapeutic-use enrichment rules so imported medicine rows can show practical common-use context when a clear category match exists.
- Added expanded condition and symptom seed coverage across cardiovascular, respiratory, endocrine, GI, kidney, neurologic, mental health, dermatology, infectious disease, immune, ENT, reproductive, and general medical topics.
- Added openFDA brand-name and substance-name buckets to the medicine source updater.
- Added official medicine-use fields and source links populated from openFDA drug label `indications_and_usage` or `purpose` text.
- Added computed `used_for` values to medicine API payloads so clients can display official label use text when available.
### Changed
- Increased the current SQLite snapshot to 7,646 medicines, 283 conditions, and 308 symptoms, including 200 openFDA label-derived use summaries.
- Rebuilt generated relationship data to 8,077 medicine-to-condition links and 10,590 medicine-to-symptom links.
- Updated medical library search so medicine searches can match linked conditions/symptoms, and condition/symptom searches can match linked medicines.
- Updated medicine catalog, medicine detail, condition, symptom, terminology, and combined-library pages to show "what it is used for" text through one shared helper.
- Updated relationship generation so official medicine-use label text participates in condition and symptom linking.
- Updated openFDA refreshes to fetch label documents first, then fall back to generic, brand, and substance buckets for broader coverage.
- Batched imported medicine upserts inside a SQLite transaction for faster source refreshes.
- Increased SQLite busy timeout for safer first-run migrations and source refreshes.
- Updated `README.md` with current counts, relationship data, and source-refresh behavior.
### Fixed
- Cleaned generated search terms when therapeutic relationship rules change so removed links do not linger in search.
- Tightened relationship rules to avoid broad steroid and chemistry keyword false positives.
- Fixed medicine pages that previously depended on `common_use` only, so medicines now show official "used for" text whenever it exists.
### Verified
- Refreshed public medicine sources with a 500-row-per-source run across RxNorm, DailyMed, and openFDA.
- Refreshed openFDA label-use data with a 200-row run and verified 200 medicine rows have official use summaries.
- Verified `/medicine.php?name=albuterol`, `/condition.php?name=Asthma`, `/symptom.php?name=Wheezing`, and `api.php?action=library_search&q=asthma&limit=10` return `200`.
- Verified official-use medicine pages expose "What It Is Used For", `Used for:` label text, and an openFDA drug label source link.
- Verified albuterol medicine pages show linked Asthma/Wheezing records and Asthma/Wheezing pages show linked albuterol medicines.
- Verified stale adalimumab-to-asthma and celecoxib-to-UTI false positives are removed.
## [Unreleased] - 2026-06-30
### Added
@@ -58,7 +98,7 @@ All notable changes to Neon Medical Tracker are documented here.
- Verified dynamic medicine, symptom, condition, and terminology routes return `200` for representative records.
- Verified legacy `/signup.php` returns `302` to `/tracker.php`.
- Verified `api.php?action=public_signup` returns `404`.
- Verified current SQLite snapshot counts: 6,002 medicines, 242 symptoms, 203 conditions, 23 terms, and 9 research-link categories.
- Verified then-current SQLite snapshot counts: 6,002 medicines, 242 symptoms, 203 conditions, 23 terms, and 9 research-link categories.
- Verified browser layout checks for medicine, symptom, and terminology pages at desktop and mobile widths with no horizontal overflow.
## Earlier Scope
+14 -7
View File
@@ -1,6 +1,6 @@
# Neon Medical Tracker
A dependency-free PHP, HTML5, JavaScript, and SQLite web app for multi-user medical tracking, searchable medical reference data, medication catalog lookup, terminology, symptoms, conditions, NIH/NLM study links, and admin-managed profiles.
A dependency-free PHP, HTML5, JavaScript, and SQLite web app for multi-user medical tracking, searchable medical reference data, medication catalog lookup, common-use and official-label medicine context, terminology, symptoms, conditions, NIH/NLM study links, and admin-managed profiles.
This app is a personal tracking and reference tool. It is not medical advice, diagnosis, treatment guidance, emergency guidance, or a substitute for a clinician or pharmacist.
@@ -42,11 +42,14 @@ data/health_tracker.sqlite
The current SQLite snapshot includes:
- 6,002 medicine catalog records.
- 242 symptom reference records.
- 203 condition reference records.
- 7,646 medicine catalog records.
- 200 openFDA label-derived medicine use summaries.
- 308 symptom reference records.
- 283 condition reference records.
- 23 medical terminology records.
- 9 NIH/NLM research-link categories.
- 8,077 medicine-to-condition links.
- 10,590 medicine-to-symptom links.
The database also stores user profiles, medication logs, vitals, lab results, symptom logs, allergies, appointments, immunizations, optional legacy workout/nutrition/supplement data, theme preferences, and admin state.
@@ -57,10 +60,11 @@ The database also stores user profiles, medication logs, vitals, lab results, sy
- Admin dashboard for creating, editing, activating/deactivating, and deleting profiles.
- Admin medicine-source updater for refreshing catalog data from RxNorm, DailyMed, and openFDA.
- Profile-scoped tracker for medication logs, vitals, lab results, symptoms, allergies, appointments, immunizations, notes, and older wellness data.
- Searchable medicine catalog by generic name, active ingredient, chemical name, common brand names, generic/alternate names, class, family, and source terms.
- Dynamic medicine pages with active ingredient, chemical name, brand names, tracking notes, RxNorm, DailyMed, PubChem, MedlinePlus, PubMed, and ClinicalTrials.gov links.
- Searchable medicine catalog by generic name, active ingredient, chemical name, common brand names, generic/alternate names, class, family, what the medicine is used for, linked conditions, linked symptoms, and source terms.
- Dynamic medicine pages with active ingredient, chemical name, brand names, what the medicine is used for, openFDA label-use source links when available, linked conditions, linked symptom contexts, tracking notes, RxNorm, DailyMed, PubChem, MedlinePlus, PubMed, and ClinicalTrials.gov links.
- Searchable symptom database with body-system categories, tracking notes, urgency-context notes, MedlinePlus links, and dynamic detail pages.
- Searchable condition database with category summaries, tracking notes, MedlinePlus links, and dynamic detail pages.
- Dynamic condition and symptom pages with commonly linked medicines generated from therapeutic-use categories.
- Medical terminology database with plain-language definitions, clinical context, source links, and dynamic detail pages.
- Combined medical library search across symptoms, conditions, terminology, medicines, and research links.
- NIH/NLM study-link categories related to listed medicines and conditions.
@@ -68,7 +72,7 @@ The database also stores user profiles, medication logs, vitals, lab results, sy
## Medicine Catalog Updates
The medicine catalog ships with a curated starter set and the current SQLite snapshot includes thousands of imported medicine concepts. It can be refreshed from public sources.
The medicine catalog ships with a curated starter set and the current SQLite snapshot includes thousands of imported medicine concepts. It can be refreshed from public sources, then re-linked to conditions and symptom contexts.
From the admin dashboard, use the medicine source updater and choose `All sources`, `RxNorm`, `DailyMed`, or `openFDA`.
@@ -80,6 +84,8 @@ frankenphp php-cli scripts/update_medicine_catalog.php 1000 all
For periodic maintenance, run the same command nightly or weekly. The first argument is the max rows per source, from `25` to `5000`; the second argument is `all`, `RxNorm`, `DailyMed`, or `openFDA`.
The updater imports RxNorm ingredient concepts, DailyMed drug names, and openFDA label records. openFDA rows prefer official label `indications_and_usage` text and fall back to label `purpose` text when available, then continue filling generic, brand, and substance buckets for broader catalog coverage. Imported rows are also enriched with rule-based common-use context when the medicine name, class, family, official use text, or source terms clearly match a therapeutic category.
## API
Main API endpoint:
@@ -108,6 +114,7 @@ The old `public_signup` action has been removed.
- PubMed research search: `https://pubmed.ncbi.nlm.nih.gov/`
- ClinicalTrials.gov study search: `https://clinicaltrials.gov/`
- openFDA drug label data: `https://open.fda.gov/apis/drug/label/`
- openFDA drug label searchable fields, including `indications_and_usage` and `purpose`: `https://open.fda.gov/apis/drug/label/searchable-fields/`
## Notes
+999 -55
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+36 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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">
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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>