package com.docus.server.record.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.constants.DSKeyConstants;
import com.docus.server.record.common.pojo.entity.TBasic;
import com.docus.server.record.common.pojo.entity.TBasicExtend;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 病案基本信息 Mapper 接口
 * </p>
 *
 * @author jiashi
 * @since 2021-04-14
 */
@Mapper
@DS(DSKeyConstants.RECORD_DS_KEY)
public interface TBasicMapper extends BaseMapper<TBasic> {
    /**
     * 根据住院号和住院次数查询业务系统中病案主键
     *
     * @param inpatientNo 住院号
     * @param admissTimes 住院次数
     * @return 病案主键
     */
    String getPatientIdByInpatientNoAndAdminssTimes(@Param("inpatientNo") String inpatientNo,
                                                    @Param("adminssTimes") Integer admissTimes);

    Integer selectOne(@Param("jzh") String jzh);

    String getPatientId(@Param("jzh") String jzh);

    Integer insertTBasic(@Param("tBasic") TBasic tBasic);

    Integer insertExtend(@Param("tBasicExtend") TBasicExtend tBasicExtend);

    Integer updateTBasic(@Param("tBasic") TBasic tBasic);

    Integer updateExtend(@Param("tBasicExtend") TBasicExtend tBasicExtend);

    List<TBasic> selectBasicListByAdmissDate(@Param("admissStartDate") String admissStartDate,
                                             @Param("admissEndDate") String admissEndDate,
                                             @Param("offset") int offset,
                                             @Param("size") int size);

    /**
     * 查询归档关联顺德人医报告的交叉索引
     *
     * @param patientId 归档系统病案主键
     * @return 归档关联顺德人医报告的交叉索引
     */
    String getSdRyIndexByPatientId(@Param("patientId") String patientId);

    List<TBasic> selectBasicListByCreateOrUpdateTime(@Param("startDate") String queryBasicStartDate,
                                                     @Param("endDate") String queryBasicEndDate,
                                                     @Param("offset") int offset,
                                                     @Param("size") int size);

    List<TBasic> selectBasicListByPatientIds(@Param("patientIds") List<String> patientIds);

    List<Map<String, Object>> getBasicForZYHs(@Param("zyhs") List<String> zyhs);

    /**
     * 查询基础出院数据增量数据
     *
     * @param param
     * @return
     */
    List<Map<String, Object>> getBasicOutData(@Param("param") Map<String, Object> param);

    /**
     * 查询基础创建数据增量数据
     *
     * @param param
     * @return
     */
    List<Map<String, Object>> getBasicData(@Param("param") Map<String, Object> param);
}
