package com.openhis.clinical.service.impl;

import java.util.Date;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.core.common.utils.SecurityUtils;
import com.openhis.clinical.domain.ProcedurePerformer;
import com.openhis.clinical.mapper.ProcedurePerformerMapper;
import com.openhis.clinical.service.IProcedurePerformerService;

/**
 * 手术与治疗执行人管理Service业务层处理
 *
 * @author system
 * @date 2025-02-20
 */
@Service
public class ProcedurePerformerServiceImpl extends ServiceImpl<ProcedurePerformerMapper, ProcedurePerformer>
    implements IProcedurePerformerService {

    @Override
    public boolean addPerformRecord(Long procedureId, Date now) {
        Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
        ProcedurePerformer procedurePerformer = new ProcedurePerformer();
        procedurePerformer
            // 执行记录id
            .setProcedureId(procedureId)
            // 执行开始时间
            .setStartTime(now)
            // 执行人
            .setPractitionerId(practitionerId);
        int result = baseMapper.insert(procedurePerformer);
        return result > 0;
    }
}