// CHW Portal — drawer for resident detail + campaign composer + app shell // ─────────────────────────────────────────────── // Resident detail drawer // ─────────────────────────────────────────────── const ChwDrawer = ({ resident, onClose, onCompose }) => { if (!resident) return null; const r = resident; const consentList = [ ['contact', 'Contact'], ['share', 'Share with partners'], ['home', 'Home visits'], ['research', 'Research'], ['hipaa', 'HIPAA'], ]; return (
e.stopPropagation()}>

{r.first} {r.last}

{r.age} · {r.town}, MA · DOB {r.dob} {r.tags.includes('High priority') && High priority}
{r.tags.map(t => {t})}

Contact

Phone
{r.phone}
Email
{r.email || }
Preferred
{r.preferred} · {r.bestTime}
Language
{r.language}
Coordinator
{r.coordinator}

Health

Conditions
{r.conditions.length === 0 ? None reported : r.conditions.map(c => {c})}
Provider
{r.provider}
Insurance
{r.insurance}
Lives alone
{r.livesAlone ? 'Yes' : 'No'}

Access to care

Transport
{r.transport}
Mobility
{r.mobility.length === 0 ? None : r.mobility.join(', ')}
Distance to clinic
{r.distance} miles

Services interested in

{r.services.length === 0 && None selected} {r.services.map(s => {s})}

Consents on file

{consentList.map(([k, l]) => (
{r.consents[k] ? : } {l}
))}
alert('Full access log for this resident opens here.')} />

Activity

{r.lastContact && (
Last contacted by {r.coordinator}
{formatDate(r.lastContact)} · {daysAgo(r.lastContact)} days ago
)}
Registered
{formatDate(r.registered)}
); }; // ─────────────────────────────────────────────── // Campaign composer modal // ─────────────────────────────────────────────── const ChwComposer = ({ recipients, cohortName, onClose, onSend }) => { const [channel, setChannel] = React.useState('text'); const [template, setTemplate] = React.useState(null); const [subject, setSubject] = React.useState(''); const [body, setBody] = React.useState(''); const [scheduled, setScheduled] = React.useState(false); const [scheduleDate, setScheduleDate] = React.useState(''); const reachable = { text: recipients.filter(r => r.preferred === 'Text message' || r.phone), call: recipients.filter(r => r.phone), email: recipients.filter(r => r.email), mail: recipients.filter(r => true), }; const applyTemplate = (t) => { setTemplate(t.id); setSubject(t.subject); setBody(t.body); }; const previewWith = recipients[0] || { first: 'Resident', town: 'your town', coordinator: 'your coordinator' }; const renderPreview = (str) => str .replace(/\{\{first\}\}/g, previewWith.first) .replace(/\{\{town\}\}/g, previewWith.town) .replace(/\{\{coordinator\}\}/g, previewWith.coordinator); return (
e.stopPropagation()}> {/* Sidebar */}
Sending to
{cohortName || `${recipients.length} resident${recipients.length === 1 ? '' : 's'}`}
{recipients.length} resident{recipients.length === 1 ? '' : 's'} · only those who consented
{recipients.slice(0, 14).map(r => ( {r.first} {r.last[0]}. ))} {recipients.length > 14 && +{recipients.length - 14} more}
Channel
{[ { v: 'text', l: 'Text message', s: 'Best for short updates', ic: 'msg', count: reachable.text.length }, { v: 'email', l: 'Email', s: 'Longer, formatted', ic: 'mail', count: reachable.email.length }, { v: 'call', l: 'Phone call list', s: 'For coordinator follow-up', ic: 'phone', count: reachable.call.length }, { v: 'mail', l: 'Print mailers', s: 'Postal — no internet needed', ic: 'home', count: reachable.mail.length }, ].map(c => (
setChannel(c.v)}>
{c.l} {c.s}
{c.count}/{recipients.length}
))}
Templates
{EQ_CAMPAIGN_TEMPLATES.map(t => ( ))}
{/* Main */}

{template ? 'Compose from template' : 'New message'}

HIPAA-compliant · audit logged
{(channel === 'email' || channel === 'mail') && (
setSubject(e.target.value)} placeholder="Free vaccine clinic at {{town}} Town Hall" />
)}