private void FindPatientIDbyMaLanKham(string malankham)
 {
     try
     {
         QueryCommand cmd = KcbDanhsachBenhnhan.CreateQuery().BuildCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandSql =
             "Select id_benhnhan,ten_benhnhan,gioi_tinh from kcb_danhsach_benhnhan p where exists(select 1 from kcb_luotkham where id_benhnhan=P.id_benhnhan and ma_luotkham like '%" +
             malankham + "%')";
         DataTable temdt = DataService.GetDataSet(cmd).Tables[0];
         if (temdt.Rows.Count <= 0) return;
         if (temdt.Rows.Count == 1)
         {
             AutoFindLastExamandFetchIntoControls(temdt.Rows[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), string.Empty);
         }
         else //Show dialog for select
         {
             var _ChonBN = new frm_CHON_BENHNHAN();
             _ChonBN.temdt = temdt;
             _ChonBN.ShowDialog();
             if (!_ChonBN.mv_bCancel)
             {
                 AutoFindLastExamandFetchIntoControls(_ChonBN.Patient_ID, string.Empty);
             }
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("FindPatient().Exception-->" + ex.Message);
     }
 }
 private void FindPatientIDbyCMT(string CMT)
 {
     try
     {
         DataTable temdt = SPs.KcbTimkiembenhnhantheosocmt(CMT).GetDataSet().Tables[0];
         if (temdt.Rows.Count <= 0) return;
         if (temdt.Rows.Count == 1)
         {
             AutoFindLastExamandFetchIntoControls(temdt.Rows[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), string.Empty);
         }
         else //Show dialog for select
         {
             DataRow[] arrDr = temdt.Select(KcbDanhsachBenhnhan.Columns.Cmt+ "='" + CMT + "'");
             if (arrDr.Length == 1)
                 AutoFindLastExamandFetchIntoControls(arrDr[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), string.Empty);
             else
             {
                 var _ChonBN = new frm_CHON_BENHNHAN();
                 _ChonBN.temdt = temdt;
                 _ChonBN.ShowDialog();
                 if (!_ChonBN.mv_bCancel)
                 {
                     AutoFindLastExamandFetchIntoControls(_ChonBN.Patient_ID, string.Empty);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("FindPatient().Exception-->" + ex.Message);
     }
 }
        private void FindPatient(string patient_ID)
        {
            try
            {
                QueryCommand cmd = KcbDanhsachBenhnhan.CreateQuery().BuildCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandSql =
                    "Select id_benhnhan,ten_benhnhan,gioi_tinh from kcb_danhsach_benhnhan where id_benhnhan like '%" +
                    patient_ID + "%'";

                DataTable temdt = DataService.GetDataSet(cmd).Tables[0];
                if (temdt.Rows.Count == 1)
                {
                    AutoFindLastExamandFetchIntoControls(temdt.Rows[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), string.Empty);
                }
                else //Show dialog for select
                {
                    DataRow[] arrDr = temdt.Select("id_benhnhan=" + patient_ID);
                    if (arrDr.Length == 1)
                        AutoFindLastExamandFetchIntoControls(arrDr[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), string.Empty);
                    else
                    {
                        var _ChonBN = new frm_CHON_BENHNHAN();
                        _ChonBN.temdt = temdt;
                        _ChonBN.ShowDialog();
                        if (!_ChonBN.mv_bCancel)
                        {
                            AutoFindLastExamandFetchIntoControls(_ChonBN.Patient_ID, string.Empty);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("FindPatient().Exception-->" + ex.Message);
            }
        }
        private void FindPatientIDbyBHYT(string Insurance_Num)
        {
            try
            {

                DataTable temdt = SPs.KcbTimkiembenhnhantheomathebhyt(Insurance_Num).GetDataSet().Tables[0];
                if (temdt.Rows.Count <= 0) return;
                if (temdt.Rows.Count == 1)
                {
                    //AutoFindLastExamandFetchIntoControls(temdt.Rows[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), Insurance_Num);
                }
                else //Show dialog for select
                {
                    DataRow[] arrDr = temdt.Select(KcbLuotkham.Columns.MatheBhyt + "='" + Insurance_Num + "'");
                    if (arrDr.Length == 1)
                    {
                        //AutoFindLastExamandFetchIntoControls(arrDr[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan].ToString(), Insurance_Num);
                    }
                    else
                    {
                        var _ChonBN = new frm_CHON_BENHNHAN();
                        _ChonBN.temdt = temdt;
                        _ChonBN.ShowDialog();
                        if (!_ChonBN.mv_bCancel)
                        {
                            //AutoFindLastExamandFetchIntoControls(_ChonBN.Patient_ID, Insurance_Num);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("FindPatient().Exception-->" + ex.Message);
            }
        }