package com.yihu.ehr.basic.patient.service;

import com.yihu.ehr.basic.patient.dao.XMedicalCardsDao;
import com.yihu.ehr.entity.patient.MedicalCards;
import com.yihu.ehr.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 卡管理实现类.
 *
 */
@Transactional
@Service
public class MedicalCardsService extends BaseJpaService<MedicalCards, XMedicalCardsDao> {
    @Autowired
    private XMedicalCardsDao medicalCardsDao;

    /**
     * 就诊卡新增&修改
     */
    public MedicalCards MCardCreate(MedicalCards card) throws Exception{
        return medicalCardsDao.save(card);
    }

    /**
     * 就诊卡删除
     */
    public void MCardDel(Long id) throws Exception{
        medicalCardsDao.delete(id);
    }

    /**
     * 就诊卡详细信息
     */
    public MedicalCards getMCard(Long id) throws Exception{
        return medicalCardsDao.findOne(id);
    }

    public List<MedicalCards> getBycardNoStr(String cardNoStr) {
        String [] cardNos = cardNoStr.split(",");
        List<MedicalCards> medicalCardses = medicalCardsDao.getBycardNoStr(cardNos);
        return medicalCardses;
    }
}