患者详情页支持“编辑手术”流程:单手术直接编辑,多手术先进入手术列表选择 手术弹窗新增编辑模式:禁用设备结构增删,仅允许修改既有手术及设备字段 新增更新手术 API:PATCH /b/patients/:patientId/surgeries/:surgeryId 生命周期查询改为 B 端接口:GET /b/patients/:id/lifecycle 手术提交后支持回到详情并保持手术标签页,提升连续操作效率
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { MESSAGES } from '../../common/messages.js';
|
|
import { PrismaService } from '../../prisma.service.js';
|
|
import {
|
|
buildPatientLifecycleRecords,
|
|
PATIENT_LIFECYCLE_INCLUDE,
|
|
} from '../patient-lifecycle.util.js';
|
|
|
|
@Injectable()
|
|
export class CPatientsService {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
async getFamilyLifecycleByAccount(accountId: number) {
|
|
const account = await this.prisma.familyMiniAppAccount.findUnique({
|
|
where: { id: accountId },
|
|
select: {
|
|
id: true,
|
|
phone: true,
|
|
},
|
|
});
|
|
if (!account) {
|
|
throw new NotFoundException(MESSAGES.AUTH.FAMILY_ACCOUNT_NOT_FOUND);
|
|
}
|
|
|
|
const patients = await this.prisma.patient.findMany({
|
|
where: {
|
|
phone: account.phone,
|
|
},
|
|
include: PATIENT_LIFECYCLE_INCLUDE,
|
|
});
|
|
if (patients.length === 0) {
|
|
throw new NotFoundException(MESSAGES.PATIENT.LIFE_CYCLE_NOT_FOUND);
|
|
}
|
|
|
|
return {
|
|
phone: account.phone,
|
|
patientCount: patients.length,
|
|
lifecycle: buildPatientLifecycleRecords(patients),
|
|
};
|
|
}
|
|
}
|