AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning

This commit is contained in:
Krilly
2026-03-04 13:29:22 +00:00
parent 29a98137a7
commit 57dd294675
13706 changed files with 2114953 additions and 237629 deletions

View File

@@ -0,0 +1,66 @@
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/db/prisma'
import { getCurrentUser } from '@/lib/auth'
import { canAccessWorkspace } from '@/lib/db/workspace-access'
// GET /api/workspaces/[id]/emergency-info
export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }
) {
try {
const user = await getCurrentUser()
if (!user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const workspaceId = params.id
const access = await canAccessWorkspace(user.id, workspaceId)
if (!access) {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
}
// Get workspace with emergency info
const workspace = await prisma.workspace.findUnique({
where: { id: workspaceId },
select: {
patientName: true,
patientDOB: true,
bloodType: true,
allergies: true,
medicalConditions: true,
primaryPhysician: true,
physicianPhone: true,
clinicPhone: true,
emergencyPhone: true,
}
})
// Get active medications
const medications = await prisma.medication.findMany({
where: {
workspaceId,
active: true,
deletedAt: null
},
select: {
id: true,
name: true,
instructions: true
}
})
return NextResponse.json({
info: {
...workspace,
medications
}
})
} catch (error) {
console.error('Failed to fetch emergency info:', error)
return NextResponse.json(
{ error: 'Failed to fetch emergency info' },
{ status: 500 }
)
}
}