package org.example.service;

import org.example.entity.PatientOrder;
import org.example.mapper.PatientOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 患者医嘱信息服务
 */
@Service
public class PatientOrderService {

    @Autowired
    private PatientOrderMapper patientOrderMapper;

    /**
     * 根据患者ID查询医嘱信息列表
     */
    public List<PatientOrder> findByPatientId(Long patientId) {
        return patientOrderMapper.findByPatientId(patientId);
    }

    /**
     * 根据ID查询医嘱信息
     */
    public PatientOrder findById(Long id) {
        return patientOrderMapper.findById(id);
    }

    /**
     * 保存医嘱信息
     */
    public void save(PatientOrder order) {
        if (order.getId() == null) {
            patientOrderMapper.insert(order);
        } else {
            patientOrderMapper.update(order);
        }
    }

    /**
     * 删除医嘱信息
     */
    public void deleteById(Long id) {
        patientOrderMapper.deleteById(id);
    }
}
