package org.example.service;

import org.example.entity.PatientExam;
import org.example.mapper.PatientExamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 患者检查报告服务
 */
@Service
public class PatientExamService {

    @Autowired
    private PatientExamMapper patientExamMapper;

    /**
     * 根据患者ID查询检查报告列表
     */
    public List<PatientExam> findByPatientId(Long patientId) {
        return patientExamMapper.findByPatientId(patientId);
    }

    /**
     * 根据ID查询检查报告
     */
    public PatientExam findById(Long id) {
        return patientExamMapper.findById(id);
    }

    /**
     * 保存检查报告
     */
    public void save(PatientExam exam) {
        if (exam.getId() == null) {
            patientExamMapper.insert(exam);
        } else {
            patientExamMapper.update(exam);
        }
    }

    /**
     * 删除检查报告
     */
    public void deleteById(Long id) {
        patientExamMapper.deleteById(id);
    }
}
