// Manual New Rx entry — blank-start path (V5). Scripted: verbal order for Curtis Dunbar. function ManualEntryForm({ onClose, onSent, nav, showToast }) { const { useState } = React; const [phase, setPhase] = useState('form'); // form | processing | paid const [source, setSource] = useState('verbal'); // verbal | hardcopy | transfer const [takenBy, setTakenBy] = useState('C. Schaffner, PharmD'); const [query, setQuery] = useState(''); const [patient, setPatient] = useState(null); const [open, setOpen] = useState(false); const [drug, setDrug] = useState(''); const [prescriber, setPrescriber] = useState(''); const [sigInput, setSigInput] = useState(''); const [payer, setPayer] = useState('cash'); const normSig = sigInput.trim().replace(/\s+/g, ' ').toUpperCase(); const sigText = SIG_CODES[normSig] || null; const matches = query.trim().length >= 2 && !patient ? PATIENT_DIR.filter(p => p.name.toLowerCase().indexOf(query.trim().toLowerCase()) !== -1).slice(0, 5) : []; const pickPatient = (p) => { setPatient(p); setQuery(p.name); setOpen(false); setPayer(p.plan.id); }; const clearPatient = () => { setPatient(null); setPayer('cash'); }; const a = MANUAL_RX.adj; const gp = a.copay + a.reimb - a.acq; const total = a.copay + a.reimb; const margin = (gp / total * 100).toFixed(1) + '%'; const money = (n) => '$' + n.toFixed(2); const submit = () => { if (phase !== 'form') return; if (!patient) return showToast('Select a patient first.'); if (!(source === 'verbal' && patient.name === 'Curtis Dunbar')) { return showToast('Demo supports the scripted path — verbal order for Curtis Dunbar.'); } if (normSig !== '1C TID X10D') { return showToast('Enter the verbal sig as a code (e.g. 1C TID x10D) so it expands.'); } setPhase('processing'); window.setTimeout(() => setPhase('paid'), 1000); }; return (
Manual Rx entry · new prescription Blank start
{/* Source */}
Source
{[['verbal', 'Verbal order'], ['hardcopy', 'Hard copy'], ['transfer', 'Transfer']].map(s => ( ))}
{source === 'verbal' ? (
Taken by
Verbal orders must be received and entered by a pharmacist.
) : null}
{/* Patient search */}
Patient
{ setQuery(e.target.value); setOpen(true); if (patient) clearPatient(); }} onFocus={() => setOpen(true)}> {open && matches.length ? (
{matches.map(p => (
pickPatient(p)}> {p.name} DOB {p.dob} · {p.store}
))}
) : null}
{patient ? (
✓ Selected {patient.name} DOB {patient.dob} · {patient.store}
) : null}
{/* Prescriber + drug + sig */}
Prescriber setPrescriber(e.target.value)}>
Drug setDrug(e.target.value)}>
Sig
setSigInput(e.target.value)}> {sigText ? ( “{sigText}” ) : ( Sig code will expand on match. )}
Dispense
{/* Billing */}
Billing {patient && patient.plan.id !== 'cash' ? (
) : ( {patient ? 'Cash — no plan on file.' : 'Select a patient to load plan on file.'} )}
{/* Submit / result */}
{phase === 'paid' ? (
PAID SilverScript (Part D) · response in 0.8 s
{money(a.copay)}
Copay
{money(a.reimb)}
Plan paid
{money(total)}
Total
{money(a.acq)}
Acquisition
{money(gp)}
Gross profit · {margin}
) : (
{phase === 'processing' ? ( Adjudicating with SilverScript… ) : null}
)}
); } Object.assign(window, { ManualEntryForm });