using ASHermed.SinoInterface.Api.ContractModel;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.IRepository;
using ASHermed.SinoInterface.Repository.MySql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASHermed.SinoInterface.Api.MySqlRepository
{
    public class OutMapDocPatRepository : BaseRepositoryToASHermed_SinoInterface<Out_Map_Doc_Pat>, IOutMapDocPatRepository
    {
        public Out_Map_Doc_Pat SelectByDocIdWithPatId(int doctorUserId, int userID)
        {
            var selectSql = new StringBuilder();
            var parms = new Dictionary<string, object>();
            selectSql.Append(@"select *
                                        from out_map_doc_pat
                                        where `STATUS` = 1
                                          and DOCTOR_ID = @DOCTOR_ID
                                          and PAT_ID = @PAT_ID");
            parms.Add("@DOCTOR_ID", doctorUserId);
            parms.Add("@PAT_ID", userID);
            var result = Query<Out_Map_Doc_Pat>(selectSql.ToString(), parms);
            return result?.FirstOrDefault();
        }

        public int InsertOutMapDocPat(Out_Map_Doc_Pat ent)
        {
            StringBuilder selectSql = new StringBuilder();
            selectSql.Append(@"INSERT INTO `Out_Map_Doc_Pat` (
								`ID`,
								`DOCTOR_ID`,
								`PAT_ID`,
								`IS_STAR`,
								`IS_TOPPING`,
								`STATUS`,
								`CREATE_TIME`,
								`UPDATE_TIME`,
                                `REMARK`,
								`REMARKS`,
								`DESCRIPTION`)
								VALUES
									(@ID,@DOCTOR_ID,@PAT_ID,@IS_STAR,@IS_TOPPING,@STATUS,@CREATE_TIME,@UPDATE_TIME,@REMARK,@REMARKS,@DESCRIPTION);");
            return Execute(selectSql.ToString(), ent);
        }


    }
}
