import { Controller, Get, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentFamilyActor } from '../../auth/current-family-actor.decorator.js';
import { FamilyAccessTokenGuard } from '../../auth/family-access/family-access.guard.js';
import type { FamilyActorContext } from '../../common/family-actor-context.js';
import { CPatientsService } from './c-patients.service.js';

/**
 * C 端患者控制器：家属跨院聚合查询。
 */
@ApiTags('患者管理(C端)')
@ApiBearerAuth('bearer')
@Controller('c/patients')
@UseGuards(FamilyAccessTokenGuard)
export class CPatientsController {
  constructor(private readonly patientsService: CPatientsService) {}

  /**
   * 根据当前登录手机号查询跨院生命周期。
   */
  @Get('my-lifecycle')
  @ApiOperation({ summary: '按当前登录手机号查询患者生命周期' })
  getMyLifecycle(@CurrentFamilyActor() actor: FamilyActorContext) {
    return this.patientsService.getFamilyLifecycleByAccount(actor.id);
  }
}
