- The medicine database is now much bigger and has a real update path.
Added: Live source updater for RxNorm, DailyMed, and openFDA. Admin dashboard panel to refresh medicine sources. CLI updater for periodic jobs: [scripts/update_medicine_catalog.php](/Users/tyemeclifford/Documents/GH/workout/scripts/update_medicine_catalog.php) Update history table: medication_source_updates. Curl fallback for external fetches when PHP stream DNS fails. README instructions for periodic updates. I also ran the imports: Current medication catalog count: 6,002. Latest source imports:RxNorm: 3,875 inserted, 1,125 updated. openFDA: 912 inserted, 88 updated. DailyMed: 95 inserted. Periodic update command: /Users/tyemeclifford/frankenphp php-cli scripts/update_medicine_catalog.php 5000 all
This commit is contained in:
@@ -186,6 +186,22 @@ function adminFormPayload(form) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
function renderRefreshResult(result) {
|
||||
const target = admin$("#medicineSourceRefreshResult");
|
||||
if (!target) return;
|
||||
const rows = (result.sources || []).map((source) => `
|
||||
<article>
|
||||
<strong>${adminEscape(source.source)}: ${adminEscape(source.status)}</strong>
|
||||
<span>${adminNumber(source.inserted)} inserted / ${adminNumber(source.updated)} updated</span>
|
||||
<small>${adminEscape(source.message || "")}</small>
|
||||
</article>
|
||||
`).join("");
|
||||
target.innerHTML = `
|
||||
<p>${adminNumber(result.catalog_count)} medicines in catalog after refresh.</p>
|
||||
<div class="source-refresh-list">${rows}</div>
|
||||
`;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
admin$("#adminProfileSelect").addEventListener("change", async (event) => {
|
||||
adminState.userId = event.target.value;
|
||||
@@ -248,6 +264,27 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
const refreshForm = admin$("#medicineSourceRefreshForm");
|
||||
if (refreshForm) {
|
||||
refreshForm.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const payload = adminFormPayload(refreshForm);
|
||||
const button = refreshForm.querySelector("button[type='submit']");
|
||||
if (button) button.disabled = true;
|
||||
admin$("#medicineSourceRefreshResult").textContent = "Refreshing medicine sources...";
|
||||
try {
|
||||
const result = await adminApi("refresh_medication_sources", payload);
|
||||
renderRefreshResult(result);
|
||||
adminToast("Medicine sources refreshed");
|
||||
} catch (error) {
|
||||
admin$("#medicineSourceRefreshResult").textContent = error.message;
|
||||
adminToast(error.message);
|
||||
} finally {
|
||||
if (button) button.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await loadAdminState();
|
||||
} catch (error) {
|
||||
|
||||
+106
-1
@@ -394,6 +394,64 @@ figcaption a {
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.library-search {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
margin: 12px 0 18px;
|
||||
}
|
||||
|
||||
.library-search label {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
color: var(--muted);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.library-search input {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--panel-2), transparent 6%);
|
||||
color: var(--text);
|
||||
padding: 12px 14px;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.library-search input:focus {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 76%);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.library-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.library-stats article {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: color-mix(in srgb, var(--panel-2), transparent 6%);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.library-stats strong {
|
||||
display: block;
|
||||
color: var(--accent);
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.library-stats span {
|
||||
color: var(--muted);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.site-split,
|
||||
.detail-hero,
|
||||
.signup-layout {
|
||||
@@ -555,6 +613,47 @@ textarea:focus {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.admin-source-panel {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: color-mix(in srgb, var(--panel-2), transparent 5%);
|
||||
padding: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.admin-source-form {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 190px auto;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
.source-refresh-result {
|
||||
color: var(--muted);
|
||||
font-size: 0.88rem;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.source-refresh-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.source-refresh-list article {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--panel), transparent 10%);
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.source-refresh-list span,
|
||||
.source-refresh-list small {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.admin-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
|
||||
@@ -718,7 +817,8 @@ textarea:focus {
|
||||
.site-split,
|
||||
.detail-hero,
|
||||
.signup-layout,
|
||||
.admin-layout {
|
||||
.admin-layout,
|
||||
.admin-source-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
@@ -753,11 +853,16 @@ textarea:focus {
|
||||
.feature-grid,
|
||||
.detail-grid,
|
||||
.admin-stats,
|
||||
.library-stats,
|
||||
.signup-row,
|
||||
.form-grid.two {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.library-search {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.admin-access-row,
|
||||
.admin-user-main,
|
||||
.panel-heading {
|
||||
|
||||
Reference in New Issue
Block a user