- The medicine and terminology directories are now organized as compact rows, and each item links to a dynamic database-backed detail page:
Medicines: /medicine.php?id=46 Terms: /term.php?id=13 Key files: Dynamic medicine page: [public/medicine.php (line 1)](/Users/tyemeclifford/Documents/GH/workout/public/medicine.php:1) Dynamic term page: [public/term.php (line 1)](/Users/tyemeclifford/Documents/GH/workout/public/term.php:1) Shared lookup/link helpers: [app/bootstrap.php (line 1220)](/Users/tyemeclifford/Documents/GH/workout/app/bootstrap.php:1220) Reworked medicine directory: [public/nutrition.php (line 49)](/Users/tyemeclifford/Documents/GH/workout/public/nutrition.php:49) Reworked terminology page: [public/medical.php (line 64)](/Users/tyemeclifford/Documents/GH/workout/public/medical.php:64) Overflow-safe layout CSS: [public/assets/site.css (line 344)](/Users/tyemeclifford/Documents/GH/workout/public/assets/site.css:344)
This commit is contained in:
@@ -1217,6 +1217,84 @@ function db_value(PDO $pdo, string $sql, array $params = []): mixed
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
function medicine_detail_path(array $medicine): string
|
||||
{
|
||||
return '/medicine.php?id=' . rawurlencode((string) ($medicine['id'] ?? ''));
|
||||
}
|
||||
|
||||
function term_detail_path(array $term): string
|
||||
{
|
||||
return '/term.php?id=' . rawurlencode((string) ($term['id'] ?? ''));
|
||||
}
|
||||
|
||||
function find_medication_catalog_item(PDO $pdo, array $query): ?array
|
||||
{
|
||||
$id = filter_var($query['id'] ?? null, FILTER_VALIDATE_INT);
|
||||
if ($id !== false && $id > 0) {
|
||||
return db_one($pdo, 'SELECT * FROM medication_catalog WHERE id = ?', [$id]);
|
||||
}
|
||||
|
||||
$name = trim((string) ($query['name'] ?? $query['q'] ?? ''));
|
||||
if ($name === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return db_one(
|
||||
$pdo,
|
||||
"SELECT *
|
||||
FROM medication_catalog
|
||||
WHERE lower(generic_name) = lower(?)
|
||||
OR lower(active_ingredient) = lower(?)
|
||||
OR lower(chemical_name) = lower(?)
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN lower(generic_name) = lower(?) THEN 0
|
||||
WHEN lower(active_ingredient) = lower(?) THEN 1
|
||||
ELSE 2
|
||||
END,
|
||||
generic_name
|
||||
LIMIT 1",
|
||||
[$name, $name, $name, $name, $name]
|
||||
);
|
||||
}
|
||||
|
||||
function find_medical_term_item(PDO $pdo, array $query): ?array
|
||||
{
|
||||
$id = filter_var($query['id'] ?? null, FILTER_VALIDATE_INT);
|
||||
if ($id !== false && $id > 0) {
|
||||
return db_one($pdo, 'SELECT * FROM medical_terms WHERE id = ?', [$id]);
|
||||
}
|
||||
|
||||
$term = trim((string) ($query['term'] ?? $query['q'] ?? ''));
|
||||
if ($term === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return db_one(
|
||||
$pdo,
|
||||
"SELECT *
|
||||
FROM medical_terms
|
||||
WHERE lower(term) = lower(?)
|
||||
ORDER BY term
|
||||
LIMIT 1",
|
||||
[$term]
|
||||
);
|
||||
}
|
||||
|
||||
function medicine_reference_links(array $medicine): array
|
||||
{
|
||||
$links = [
|
||||
'RxNorm' => $medicine['rxnorm_url'] ?? '',
|
||||
'PubChem' => $medicine['pubchem_url'] ?? '',
|
||||
'DailyMed' => $medicine['dailymed_url'] ?? '',
|
||||
'MedlinePlus' => $medicine['medlineplus_url'] ?? '',
|
||||
'PubMed' => $medicine['pubmed_url'] ?? '',
|
||||
'Studies' => $medicine['clinicaltrials_url'] ?? '',
|
||||
];
|
||||
|
||||
return array_filter($links, static fn ($url) => trim((string) $url) !== '');
|
||||
}
|
||||
|
||||
function db_key_values(PDO $pdo, string $sql, array $params = []): array
|
||||
{
|
||||
$rows = db_all($pdo, $sql, $params);
|
||||
|
||||
Reference in New Issue
Block a user