package thyyxxk.webserver.service.inpatient;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import thyyxxk.webserver.dao.his.inpatient.ConventionsDao;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.conventions.ConventionDetail;
import thyyxxk.webserver.entity.inpatient.conventions.RoughConvention;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.TokenUtil;

import java.util.List;

/**
 * @author dj
 */
@Slf4j
@Service
public class ConventionsService {
    private final ConventionsDao dao;

    @Autowired
    public ConventionsService(ConventionsDao dao) {
        this.dao = dao;
    }

    public ResultVo<List<RoughConvention>> getRoughConventions(String inpatientNo, Integer admissTimes) {
        return ResultVoUtil.success(dao.getRoughConventions(inpatientNo, admissTimes));
    }

    public ResultVo<List<ConventionDetail>> getDetailConventions(String inpatientNo, String actOrderNo) {
        return ResultVoUtil.success(dao.getConventionDetail(inpatientNo, actOrderNo));
    }

    public ResultVo<String> retractConventions(List<String> actOrderNos) {
        log.info("取消三大常规条目，操作员：{}，医嘱号：{}", TokenUtil.getInstance().getTokenUserId(), actOrderNos);
        dao.retractConvention(TokenUtil.getInstance().getTokenUserId(), actOrderNos);
        return ResultVoUtil.success("操作成功。");
    }

}
