feat: add care execution workspace

This commit is contained in:
2026-07-03 00:35:04 -07:00
parent df7c2efcc5
commit b6b15acc69
20 changed files with 4270 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import {
beds,
buildings,
campuses,
careTasks,
chronicConditions,
elders,
floors,
@@ -92,6 +93,18 @@ type SeedHealthReview = {
vitalIndex: number;
};
type SeedCareTask = {
assigneeLabel: string;
careType: "daily_care" | "meal" | "medication" | "rehab" | "inspection" | "cleaning" | "other";
completedHoursAgo?: number;
elderName: string;
executionNotes: string;
priority: "low" | "normal" | "high" | "urgent";
scheduledHoursOffset: number;
status: "pending" | "in_progress" | "completed" | "cancelled";
title: string;
};
const DEFAULT_ROOMS: SeedRoom[] = [
{ campusName: "主院区", buildingName: "护理楼", floorName: "一层", floorLevel: 1, code: "A101", name: "阳光房", capacity: 2 },
{ campusName: "主院区", buildingName: "护理楼", floorName: "一层", floorLevel: 1, code: "A102", name: "康养房", capacity: 2 },
@@ -374,6 +387,60 @@ const DEFAULT_HEALTH_REVIEWS: SeedHealthReview[] = [
},
];
const DEFAULT_CARE_TASKS: SeedCareTask[] = [
{
elderName: "王桂兰",
title: "晨间协助洗漱与翻身",
careType: "daily_care",
priority: "normal",
status: "pending",
scheduledHoursOffset: 1,
assigneeLabel: "一号护理组",
executionNotes: "",
},
{
elderName: "孙秀梅",
title: "膝关节康复训练陪同",
careType: "rehab",
priority: "high",
status: "in_progress",
scheduledHoursOffset: -1,
assigneeLabel: "康复护理组",
executionNotes: "已完成热身,等待康复师复核动作。",
},
{
elderName: "周玉珍",
title: "餐前血糖记录与助餐",
careType: "meal",
priority: "normal",
status: "completed",
scheduledHoursOffset: -4,
completedHoursAgo: 3,
assigneeLabel: "二号护理组",
executionNotes: "餐前血糖已记录,午餐摄入约八成。",
},
{
elderName: "赵国华",
title: "重点照护夜间巡检补记",
careType: "inspection",
priority: "urgent",
status: "pending",
scheduledHoursOffset: -2,
assigneeLabel: "夜班护理组",
executionNotes: "",
},
{
elderName: "刘长青",
title: "用药提醒与胸痛询问",
careType: "medication",
priority: "high",
status: "pending",
scheduledHoursOffset: 3,
assigneeLabel: "三号护理组",
executionNotes: "",
},
];
function hasRows(rows: unknown[]): boolean {
return rows.length > 0;
}
@@ -558,6 +625,31 @@ export async function seedDefaultWorkspaceData(organizationId: string): Promise<
}),
);
const now = new Date();
await transaction.insert(careTasks).values(
DEFAULT_CARE_TASKS.map((task) => {
const elderId = elderIdByName.get(task.elderName);
if (!elderId) {
throw new Error("默认护理任务初始化失败");
}
const completedAt = task.completedHoursAgo === undefined ? undefined : new Date(now.getTime() - task.completedHoursAgo * 60 * 60 * 1000);
return {
organizationId,
elderId,
title: task.title,
careType: task.careType,
priority: task.priority,
status: task.status,
scheduledAt: new Date(now.getTime() + task.scheduledHoursOffset * 60 * 60 * 1000),
assigneeLabel: task.assigneeLabel,
executionNotes: task.executionNotes,
completedAt,
};
}),
);
await transaction.insert(healthProfiles).values(
DEFAULT_HEALTH_PROFILES.map((profile) => {
const elderId = elderIdByName.get(profile.elderName);
@@ -577,7 +669,6 @@ export async function seedDefaultWorkspaceData(organizationId: string): Promise<
}),
);
const now = new Date();
const vitalRows = await transaction
.insert(vitalRecords)
.values(