- 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) {
|
||||
|
||||
Reference in New Issue
Block a user