using PoJun.Dapper.IRepository;
using ASHermed.SinoInterface.Entity.Test;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ASHermed.SinoInterface.Repository.MySql;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.ContractModel;
using ASHermed.SinoInterface.Api.ContractModel.App.Entity;
using ASHermed.SinoInterface.Api.ContractModel.App.Model;
using ASHermed.SinoInterface.Api.ContractModel.TCTrans;

namespace ASHermed.SinoInterface.Api.IRepository
{

    public interface IPubPatInfoRepository : IBaseRepositoryToASHermed_SinoInterface<Pub_Pat_Info>
    {
        int InsertPubPatInfo(Pub_Pat_Info patInfo);
        int UpdatePubPatInfo(Pub_Pat_Info patInfo, int isNewPat = 0);

        /// <summary>
        /// 更新患者信息
        /// 这个方法拷贝的<see cref="UpdatePubPatInfo(Pub_Pat_Info,int)"/>,
        /// 但与它不同的是：可以将<see cref="Pub_Pat_Info.InsuranceCardUrl"/>(保险卡图片字段)的值更新为null
        /// </summary>
        /// <param name="patInfo"></param>
        /// <param name="isNewPat"></param>
        /// <returns></returns>
        Task<int> UpdatePubPatInfoAsync(Pub_Pat_Info patInfo, int isNewPat = 0);

        int UpdatePubPatInfo(PatWithRelationShip patInfo);
        Pub_Pat_Info SelectByPatId(string id);
        Pub_Pat_Info GetPatByCardId(string id);
        Pub_Pat_Info GetPatByName(string fName, string lName, string phone);
        Pub_Pat_Info SelectById(int id);
        List<Pub_Pat_Info> SelectByIds(List<int> ids);
        PatWithRelationShip SelectPatById(int id);
        Pub_Pat_Info SelectByMrn(string mrn);

        /// <summary>
        /// 查询包括已删除的数据
        /// </summary>
        /// <param name="mrn"></param>
        /// <returns></returns>
        Pub_Pat_Info SelectAllByMrn(string mrn);

        List<Pub_Pat_Info> SelectPatsByMrn(List<string> mrns);
        Pub_Pat_Info SelectByLinKingOpenId(string openid);
        int UpdatePatByLinKing(string linkingopenid, int patid);
        List<PatWithRelationShip> SelectByUserWithRelationTime(int userId, string type);
        List<PatWithRelationShip> SelectByUserWithRelationByApp(int userId);
        List<Pub_Pat_Info> GetUserRelationship(int userId);
        List<PubPatInfoMapUser> GetPubPatInfoList(int userID);
        List<Pub_Pat_Info> GetUserRelation(int userId);

        int UpdatePatClinicCard(int id, string cardNo, string cardType);


        IEnumerable<MyAppointment> GetOutMyAppointment(int userId, int type, int pat, DateTime begin, DateTime end);
        IEnumerable<MyAppointment> GetOutMyAppointmentForPat(List<int> patids);
        IEnumerable<MyAppointment> GetOutMyAppointmentForUnconfirmed(List<int> patids, DateTime begin, DateTime end);
        MyAppointmentDetail GetOutMyAppointmentDetail(int Id);


        IEnumerable<MyAppointment> GetonlineMyAppointment(int type, List<int> pat, DateTime begin, DateTime end, bool isInsuranceUser);

        List<MyAppointment> GetCignaAppointment(int userId, int type, int pat, DateTime begin, DateTime end);
        MyAppointmentDetail GetonlineMyAppointmentDetail(int Id);


        IEnumerable<MyAppointment> GetVaccineMyAppointment(int userId, int type, int pat, DateTime begin, DateTime end);
        MyAppointmentDetail GetVaccineMyAppointmentDetail(int Id);


        IEnumerable<MyAppointment> GetNucleicAcidMyAppointment(int userId, int type, int pat, DateTime begin, DateTime end);
        MyAppointmentDetail GetNucleicAcidMyAppointmentDetail(int Id);
        Pub_User_Info GetUserByPatId(int patId, string source = "sino");
        Pub_User_Info GetUserByPatIdForJob(int patId);
        Pub_User_Info GetUserByPatIds(int patId);
        DocIMInfo GetImIdByDocId(int docId);
        int InsertGroupInfo(string groupId, int userId, int patId, int docId, int helpId, string orderNo);
        int UpdateGroupOrder(Tencent_Group_Record group);
        int SynchroGroupOrder(int PatId, int DocId, string OrderNo);
        Tencent_Group_Record IsExistGroup(int userId, int patId, int docId);
        Tencent_Group_Record IsExistGroupByPat(int patId, int docId);
        List<Tencent_Group_Record> GetGroupsByPat(int patId);
        int DeleteGroupMember(int groupId);
        int GroupForbiddenUser(string groupId, bool isForbidden);
        int CancelPatDefult(int userId);
        List<Pub_User_Info> GetAptByCondition();
        int PatInsuranceComform(string uId, bool isAgree);
        int InsertOutVaccineApptFlow(Out_Vaccine_Appt_Flow model);
        int InsertOutVaccineAppt(Out_Vaccine_Appt model);
        int UpdateOutVaccineApptStauts(int flowid);
        int UpdateOutVaccineApptStautsForId(List<int> ids, int status);
        int UpdateOutVaccineMapCall(List<int> ids);
        /// <summary>
        /// status 4全部 3排队中 2待预约  1带接种
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        List<VaccineApptForUser> GetOutVaccineApptList(List<int> ids, int status);
        VaccineApptForUser GetOutVaccineApptForId(int id);
        List<Out_Vaccine_Appt> GetOldOutApptData();
        List<VaccineApptIsAdd> VaccineApptIsAdd(string patname, string phone);
        List<VaccineApptForUser> ApptForUser(List<int> ids, int language = 1);
        List<VaccineApptForUser> CompanyApptForUser(List<int> ids, int language = 1);
        int UpdateOutVaccineAppt(List<Out_Vaccine_Appt> model);
        List<AllVaccineForCall> GetAllVaccineForCall();
        AllVaccineForCall GetVaccineForId(int id);
        List<VaccineApptForUser> GetOutVaccineApptForCall(Out_Vaccine_Appt_Call model);
        Out_Vaccine_Appt_Call GetVaccineAppCall(int id);
        List<Pub_Pat_Info> GetPubPatUserList(int userid, string name);
        List<Pub_Pat_Info> GetMarkingPat();

        int UpdatePatInfo(PatUpdateModel model);

        List<Pub_Map_User_Pat> GetPatIdsByUserId(int userID);
        int UpdateMapUserPatRelation(int userid);
        List<Pub_Pat_Info> GetSignOffPats(string times);
        Pub_Pat_Info GetPatByCondition(string phone, string lastName, string firstName);

        Task<List<Pub_Pat_Info>> GetPatsByConditionAsync(string phone, string lastName, string firstName, int gender, string birthday); 

        int SavePatMrn(int id, string mrn);
        int SavePatTcInfo(int id, string patId, string patMrn, string mrn);
        List<PatTcInfo> GetAllPatForMrn();
        List<Pub_Map_User_Pat> GetUserPatByPatId(int patId);

        Task<Pub_Pat_Info> GetPubPatInfoByIdAsync(int patId);

        Out_Vaccine_Map_Call GetUserPatsVaccAptCount(int userID);

        List<Pub_Pat_Info> GetUserPatHasSignOff(int userID);
        int PatSignOff(int patId);
        int ReadMyPatReport(int patId);
        List<Pub_Pat_Info> GetPatInfo();
        int UpdatePatGender(List<int> ls);

        List<Pub_Pat_Info> GetSpaiclPats();
        int UpdatePatName(int Id, string xing, string ming);
        List<Pub_Sign_Report> GetPubSignReportByPatId(int patId);
        /// <summary>
        /// 多对多通过患者找绑定用户
        /// </summary>
        /// <param name="patId"></param>
        /// <returns></returns>
        List<Pub_User_Info> GetUsersByPatId(int patId);
        /// <summary>
        /// 多对多通过用找所属患者
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        List<Pub_Pat_Info> GetPatientsByUserId(int userId);
        List<Pub_Map_User_Pat> GetMapUserPat(int userid, List<int> patids);

        /// <summary>
        /// 查询用户所有的绑定关系
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        List<Pub_Map_User_Pat> GetMapsByUserId(int userId);
        Task<List<Pub_Pat_Info>> GetTempPatAsync();

        Task<List<Pub_Pat_Info>> GetByPIdAsync(string pId);

        Task<List<Pub_Pat_Info>> GetByCardIdAsync(string cardId);
    }
}
