// Screen: Fill Queue — board + rejections workbench + refills due
function FillQueue({ scope, tab, setTab, nav, cards, setCards }) {
const { useState } = React;
const [openRx, setOpenRx] = useState(null);
const [wcQuery, setWcQuery] = useState('');
const [reworked, setReworked] = useState({});
const [toast, showToast] = useToast();
const visible = cards.filter(r => scope === 'all' || r.store.toLowerCase() === scope);
const open = cards.find(c => c.rx === openRx);
const verify = (rxId) => {
setCards(cs => cs.map(c => c.rx === rxId ? { ...c, stage: 3, wait: 1, timeline: [...c.timeline.slice(0, -1), ['7:58a', 'Verified by C. Schaffner, PharmD'], ['—', 'In filling']] } : c));
setOpenRx(null);
showToast('Rx ' + rxId + ' verified — sent to Filling.');
};
// Will-call matches (Ready column only)
const q = wcQuery.trim().toLowerCase();
const wcHits = q.length > 1 ? visible.filter(c => c.stage === 4 && c.patient.toLowerCase().includes(q)) : [];
const wcBins = [...new Set(wcHits.map(h => h.bin))].join(', ');
const wcDue = wcHits.reduce((a, h) => a + (h.copayDue || 0), 0);
const flagBadge = (flag) => {
if (flag === 'compound') return Lab;
if (flag === 'cii') return C-II;
if (flag === 'neg-margin') return Margin;
if (flag === 'dur') return Interaction;
return null;
};
const openRejections = REJECTIONS.filter(r => !reworked[r.id]).length;
return (
{/* Tabs + will-call search */}
{tab === 'queue' ? (
{wcHits.length > 0 ? (
{wcHits.length} item{wcHits.length > 1 ? 's' : ''} · Bin {wcBins} · Copay due ${wcDue.toFixed(2)}
) : null}
⌕
setWcQuery(e.target.value)}>
) : null}
{/* ---- Queue board ---- */}
{tab === 'queue' ? (
{QUEUE_STAGES.map((stage, si) => {
const colCards = visible.filter(r => r.stage === si);
return (
{'0' + (si + 1)}
{stage}
{colCards.length}
{colCards.map(r => (
h.rx === r.rx) ? ' hit' : '')}
onClick={() => setOpenRx(r.rx)}>
{r.rx}
= 15 ? ' slow' : '')}>
{r.stage === 4 ? (r.bin || 'ready') : r.wait + ' min'}
{r.drug}
{r.patient} · {r.payer}
{r.store}
{flagBadge(r.flag)}
))}
{colCards.length === 0 ? (
Clear
) : null}
);
})}
) : null}
{/* ---- Rejections workbench ---- */}
{tab === 'rejections' ? (
12 claims rejected this week · {openRejections} unresolved below · 4 are Premera prior-auth holds on compounds.
| Patient | Claim | Payer | Reject code | Suggested fix | Value | |
{REJECTIONS.map(r => (
|
|
{r.drug} |
{r.payer} |
{r.code} · {r.meaning} |
{r.fix} |
{r.value} |
{reworked[r.id]
? Reworked
: }
|
))}
) : null}
{/* ---- Refills due ---- */}
{tab === 'refills' ? (
10 refills due in the next window · 2 awaiting prescriber renewal.
| Patient | Medication | Last filled | Due | Auto-refill | Status | |
{REFILLS_DUE.map((r, i) => (
|
|
{r.drug} |
{r.last} |
{r.due} |
{r.auto ? Auto : —} |
{r.status === 'renewal'
? Renewal request sent to prescriber
: Due}
|
{r.status !== 'renewal'
?
: null}
|
))}
) : null}
{/* Drawer / Verification station */}
{open && open.stage === 2 ? (
setOpenRx(null)} showToast={showToast}>
) : null}
{open && open.stage !== 2 ? (
setOpenRx(null)} nav={nav} showToast={showToast}>
) : null}
);
}
Object.assign(window, { FillQueue });