Beispiel #1
0
        private void BindData()
        {
            SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                                .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(txtMaLanKham.Text);

            if (sqlQuery.GetRecordCount() > 0)
            {
                objLuotkham = sqlQuery.ExecuteSingle <KcbLuotkham>();
                if (objLuotkham != null)
                {
                    txtMaLanKham.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                    txtSoBHYT.Text    = Utility.sDbnull(objLuotkham.MatheBhyt);
                    DmucKhoaphong objDmucKhoaphong = DmucKhoaphong.FetchByID(objLuotkham.IdKhoanoitru);
                    if (objDmucKhoaphong != null)
                    {
                        txtDepartmentName.Tag  = Utility.sDbnull(objDmucKhoaphong.IdKhoaphong);
                        txtDepartment_ID.Text  = Utility.sDbnull(objDmucKhoaphong.IdKhoaphong);
                        txtDepartmentName.Text = Utility.sDbnull(objDmucKhoaphong.TenKhoaphong);
                    }

                    KcbDanhsachBenhnhan objPatientInfo = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan);
                    if (objPatientInfo != null)
                    {
                        txtPatient_Name.Text = Utility.sDbnull(objPatientInfo.TenBenhnhan);
                        txtPatient_ID.Text   = Utility.sDbnull(objLuotkham.IdBenhnhan);
                        txtNamSinh.Text      = Utility.sDbnull(objPatientInfo.NamSinh);
                        txtTuoi.Text         = Utility.sDbnull(DateTime.Now.Year - objPatientInfo.NamSinh);
                        txtPatientSex.Text   = objPatientInfo.GioiTinh;// Utility.Int32Dbnull(objPatientInfo.PatientSex) == 0 ? "Nam" : "Nữ";
                    }
                    objPhanbuonggiuong = NoitruPhanbuonggiuong.FetchByID(objLuotkham.IdRavien);
                    dtNgayvao.Value    = objPhanbuonggiuong.NgayVaokhoa;
                    if (objPhanbuonggiuong != null)
                    {
                        txtPatientDept_ID.Text = Utility.sDbnull(objPhanbuonggiuong.Id);
                        NoitruDmucBuong objRoom = NoitruDmucBuong.FetchByID(objPhanbuonggiuong.IdBuong);
                        if (objRoom != null)
                        {
                            txtSoPhong.Text = Utility.sDbnull(objRoom.TenBuong);
                            txtSoPhong.Tag  = Utility.sDbnull(objPhanbuonggiuong.IdBuong);
                        }
                        NoitruDmucGiuongbenh objNoitruDmucGiuongbenh = NoitruDmucGiuongbenh.FetchByID(objPhanbuonggiuong.IdGiuong);
                        if (objNoitruDmucGiuongbenh != null)
                        {
                            txtSoGiuong.Text = Utility.sDbnull(objNoitruDmucGiuongbenh.TenGiuong);
                            txtSoGiuong.Tag  = Utility.sDbnull(objPhanbuonggiuong.IdGiuong);
                        }
                    }
                }
            }
            ModifyCommand();
        }
        /// <summary>
        ///     Lấy về thông tin bệnh nhâ nội trú
        /// </summary>
        private void GetData()
        {
            try
            {
                // Utility.SetMsg(lblMsg, "", false);
                string patientCode = Utility.sDbnull(grdLuotkham.GetValue(KcbLuotkham.Columns.MaLuotkham), "");
                _malankham = patientCode;
                int patientId = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.IdBenhnhan), -1);
                ObjLuotkham = new Select().From(KcbLuotkham.Schema)
                              .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(patientCode)
                              .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(patientId).ExecuteSingle <KcbLuotkham>();

                ObjBenhnhan = KcbDanhsachBenhnhan.FetchByID(ObjLuotkham.IdBenhnhan);

                if (ObjLuotkham != null)
                {
                    ClearControl();
                    txt_idchidinhphongkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                    _objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                    if (_objkcbdangky != null)
                    {
                        DataTable mDtThongTin = _kcbThamkham.LayThongtinBenhnhanKCB(ObjLuotkham.MaLuotkham,
                                                                                    Utility.Int32Dbnull(ObjLuotkham.IdBenhnhan,
                                                                                                        -1),
                                                                                    Utility.Int32Dbnull(txt_idchidinhphongkham.Text));
                        if (mDtThongTin.Rows.Count > 0)
                        {
                            DataRow dr = mDtThongTin.Rows[0];
                            if (dr != null)
                            {
                                dtInput_Date.Value = Convert.ToDateTime(dr[KcbLuotkham.Columns.NgayTiepdon]);
                                txtExam_ID.Text    = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));

                                txtKhoaDieuTri.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_khoanoitru"));
                                txtBuong.Text       = Utility.sDbnull(grdLuotkham.GetValue("ten_buong"));
                                txtGiuong.Text      = Utility.sDbnull(grdLuotkham.GetValue("ten_giuong"));

                                txtTrangthaiNgoaitru.Text =
                                    Utility.sDbnull(grdLuotkham.GetValue("trangthai_ngoaitru")) == "0"
                                        ? "Đang khám"
                                        : "Đã khám xong";
                                txtTrangthaiNoitru.Text = Utility.sDbnull(grdLuotkham.GetValue("ten_trangthai_noitru"));

                                Utility.Int32Dbnull(txtExam_ID.Text, -1);
                                txtGioitinh.Text =
                                    Utility.sDbnull(grdList.GetValue(KcbDanhsachBenhnhan.Columns.GioiTinh), "");
                                txt_idchidinhphongkham.Text =
                                    Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham));
                                lblSOkham.Text       = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.SttKham));
                                txtPatient_Name.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.TenBenhnhan], "");
                                txtPatient_ID.Text   = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.IdBenhnhan], "");
                                txtPatient_Code.Text = Utility.sDbnull(dr[KcbLuotkham.Columns.MaLuotkham], "");
                                barcode.Data         = _malankham;
                                txtDiaChi.Text       = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiaChi], "");
                                txtDiachiBHYT.Text   = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiachiBhyt], "");

                                txtObjectType_Name.Text = Utility.sDbnull(dr[DmucDoituongkcb.Columns.TenDoituongKcb], "");
                                txtSoBHYT.Text          = Utility.sDbnull(dr[KcbLuotkham.Columns.MatheBhyt], "");
                                txtBHTT.Text            = Utility.sDbnull(dr[KcbLuotkham.Columns.PtramBhyt], "0");
                                txtNgheNghiep.Text      = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.NgheNghiep], "");
                                txtHanTheBHYT.Text      = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt], "");
                                dtpNgayhethanBHYT.Text  = Utility.sDbnull(dr[KcbLuotkham.Columns.NgayketthucBhyt],
                                                                          globalVariables.SysDate.ToString("dd/MM/yyyy"));
                                var sqlbenhan =
                                    new Select().From(KcbBenhAn.Schema)
                                    .Where(KcbBenhAn.Columns.IdBnhan)
                                    .IsEqualTo(ObjLuotkham.IdBenhnhan)
                                    .ExecuteSingle <KcbBenhAn>();
                                txtSoBa.Text = sqlbenhan != null?string.Format("{0}-{1}", sqlbenhan.LoaiBa, sqlbenhan.SoBenhAn) : "";

                                if (ObjBenhnhan.NgaySinh != null)
                                {
                                    txtTuoi.Text = Utility.sDbnull(Utility.Int32Dbnull(globalVariables.SysDate.Year) -
                                                                   ObjBenhnhan.NgaySinh.Value.Year);
                                }
                                //ThongBaoBenhAn(txtPatient_ID.Text);

                                if (_objkcbdangky != null)
                                {
                                    txtReg_ID.Text        = Utility.sDbnull(_objkcbdangky.IdKham);
                                    dtpCreatedDate.Value  = Convert.ToDateTime(_objkcbdangky.NgayDangky);
                                    txtDepartment_ID.Text = Utility.sDbnull(_objkcbdangky.IdPhongkham);
                                    var department = (from p in globalVariables.gv_dtDmucPhongban.AsEnumerable()
                                                      where p[DmucKhoaphong.Columns.IdKhoaphong].Equals(_objkcbdangky.IdPhongkham)
                                                      select p).FirstOrDefault();
                                    if (department != null)
                                    {
                                        txtPhongkham.Text = Utility.sDbnull(department["ten_khoaphong"], "");
                                    }
                                    txtTenDvuKham.Text    = Utility.sDbnull(_objkcbdangky.TenDichvuKcb);
                                    txtNguoiTiepNhan.Text = Utility.sDbnull(_objkcbdangky.NguoiTao);
                                    try
                                    {
                                        cboDoctorAssign.SelectedIndex =
                                            Utility.GetSelectedIndex(cboDoctorAssign,
                                                                     Utility.sDbnull(
                                                                         _objkcbdangky.IdBacsikham, -1));
                                    }
                                    catch (Exception exception)
                                    {
                                        if (globalVariables.IsAdmin)
                                        {
                                            Utility.ShowMsg(exception.ToString());
                                        }
                                    }
                                }
                                _kcbChandoanKetluan = new Select().From(KcbChandoanKetluan.Schema)
                                                      .Where(KcbChandoanKetluan.Columns.IdKham)
                                                      .IsEqualTo(_objkcbdangky.IdKham)
                                                      .ExecuteSingle
                                                      <KcbChandoanKetluan>();
                                if (_kcbChandoanKetluan != null)
                                {
                                    txtKet_Luan._Text     = Utility.sDbnull(_kcbChandoanKetluan.Ketluan);
                                    txtHuongdieutri._Text = _kcbChandoanKetluan.HuongDieutri;
                                    nmrSongayDT.Value     = Utility.DecimaltoDbnull(_kcbChandoanKetluan.SongayDieutri, 0);
                                    txtHa.Text            = Utility.sDbnull(_kcbChandoanKetluan.Huyetap);
                                    txtMach.Text          = Utility.sDbnull(_kcbChandoanKetluan.Mach);
                                    txtNhipTim.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhiptim);
                                    txtNhipTho.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhiptho);
                                    txtNhietDo.Text       = Utility.sDbnull(_kcbChandoanKetluan.Nhietdo);
                                    txtCannang.Text       = Utility.sDbnull(_kcbChandoanKetluan.Cannang);
                                    txtSoNgayHen.Text     = Utility.sDbnull(_kcbChandoanKetluan.SoNgayhen);
                                    txtChieucao.Text      = Utility.sDbnull(_kcbChandoanKetluan.Chieucao);
                                    if (!string.IsNullOrEmpty(Utility.sDbnull(_kcbChandoanKetluan.Nhommau)) &&
                                        Utility.sDbnull(_kcbChandoanKetluan.Nhommau) != "-1")
                                    {
                                        txtNhommau._Text = Utility.sDbnull(_kcbChandoanKetluan.Nhommau);
                                    }


                                    AllowTextChanged        = true;
                                    _isLike                 = false;
                                    txtChanDoan._Text       = Utility.sDbnull(_kcbChandoanKetluan.Chandoan);
                                    txtChanDoanKemTheo.Text = Utility.sDbnull(_kcbChandoanKetluan.ChandoanKemtheo);
                                    txtMaBenhChinh.Text     = Utility.sDbnull(_kcbChandoanKetluan.MabenhChinh);
                                    string dataString = Utility.sDbnull(_kcbChandoanKetluan.MabenhPhu, "");
                                    _isLike          = true;
                                    AllowTextChanged = false;
                                    _dtIcdPhu.Clear();
                                    if (!string.IsNullOrEmpty(dataString))
                                    {
                                        string[] rows = dataString.Split(',');
                                        foreach (string row in rows)
                                        {
                                            if (!string.IsNullOrEmpty(row))
                                            {
                                                DataRow newDr = _dtIcdPhu.NewRow();
                                                newDr[DmucBenh.Columns.MaBenh]  = row;
                                                newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row);
                                                _dtIcdPhu.Rows.Add(newDr);
                                                _dtIcdPhu.AcceptChanges();
                                            }
                                        }
                                        grd_ICD.DataSource = _dtIcdPhu;
                                    }
                                }

                                GetDataChiDinh();
                            }
                        }
                    }
                    else
                    {
                        ClearControl();
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi: " + ex.Message);
            }
            finally
            {
                KiemTraDaInPhoiBhyt();
            }
        }
        private void BindData()
        {
            SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                                .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(txtMaLanKham.Text);

            if (sqlQuery.GetRecordCount() > 0)
            {
                _objPatientExam = sqlQuery.ExecuteSingle <KcbLuotkham>();
                if (_objPatientExam != null)
                {
                    if (ObjPhanbuonggiuong == null)
                    {
                        ObjPhanbuonggiuong = NoitruPhanbuonggiuong.FetchByID(Utility.Int32Dbnull(_objPatientExam.IdRavien, 0));
                    }
                    txtMaLanKham.Text = Utility.sDbnull(_objPatientExam.MaLuotkham);
                    txtSoBHYT.Text    = string.Format("{0}-{1}{2}", Utility.sDbnull(_objPatientExam.MatheBhyt),
                                                      Utility.sDbnull(_objPatientExam.MaNoicapBhyt), Utility.sDbnull(_objPatientExam.MaKcbbd));
                    txtphantramhuong.Text = Utility.sDbnull(_objPatientExam.PtramBhyt);
                    DmucKhoaphong objLDepartment = DmucKhoaphong.FetchByID(_objPatientExam.IdKhoanoitru);
                    if (objLDepartment != null)
                    {
                        txtDepartment_ID.Text  = Utility.sDbnull(objLDepartment.IdKhoaphong);
                        txtDepartmentName.Tag  = Utility.sDbnull(objLDepartment.IdKhoaphong);
                        txtDepartmentName.Text = Utility.sDbnull(objLDepartment.TenKhoaphong);
                        txtKhoadieutri.Text    = txtDepartmentName.Text;
                    }
                    KcbDanhsachBenhnhan objPatientInfo = KcbDanhsachBenhnhan.FetchByID(_objPatientExam.IdBenhnhan);
                    if (objPatientInfo != null)
                    {
                        txtPatient_Name.Text = Utility.sDbnull(objPatientInfo.TenBenhnhan);
                        txtPatient_ID.Text   = Utility.sDbnull(_objPatientExam.IdBenhnhan);
                        txtNamSinh.Text      = Utility.sDbnull(objPatientInfo.NamSinh);
                        txtTuoi.Text         = Utility.sDbnull(DateTime.Now.Year - objPatientInfo.NamSinh);
                        txtPatientSex.Text   = objPatientInfo.GioiTinh;
                        // Utility.Int32Dbnull(objPatientInfo.) == 0 ? "Nam" : "Nữ";
                    }
                    if (ObjPhanbuonggiuong != null)
                    {
                        txtPatientDept_ID.Text = Utility.sDbnull(ObjPhanbuonggiuong.Id);
                        txtsoluongghep.Text    = Utility.sDbnull(ObjPhanbuonggiuong.SoLuongGhep);
                        chkGhepgiuong.Checked  = Utility.Byte2Bool(ObjPhanbuonggiuong.IsGhepGiuong);
                    }
                    DataTable dtGia = new dmucgiagiuong_busrule().dsGetList("-1").Tables[0];
                    dtGia.DefaultView.Sort = NoitruGiabuonggiuong.Columns.SttHthi + "," +
                                             NoitruGiabuonggiuong.Columns.TenGia;
                    txtGia.Init(dtGia,
                                new List <string>
                    {
                        NoitruGiabuonggiuong.Columns.IdGia,
                        NoitruGiabuonggiuong.Columns.MaGia,
                        NoitruGiabuonggiuong.Columns.TenGia
                    });
                    cboGia.DataSource    = dtGia;
                    cboGia.DataMember    = NoitruGiabuonggiuong.Columns.IdGia;
                    cboGia.ValueMember   = NoitruGiabuonggiuong.Columns.IdGia;
                    cboGia.DisplayMember = NoitruGiabuonggiuong.Columns.TenGia;
                    _mDtDataRoom         = THU_VIEN_CHUNG.NoitruTimkiembuongTheokhoa(Utility.Int32Dbnull(txtDepartment_ID.Text));

                    Utility.SetDataSourceForDataGridEx_Basic(grdBuong, _mDtDataRoom, true, true, "1=1",
                                                             "sluong_giuong_trong desc,ten_buong");
                    txtRoom_code.Init(_mDtDataRoom,
                                      new List <string>
                    {
                        NoitruDmucBuong.Columns.IdBuong,
                        NoitruDmucBuong.Columns.MaBuong,
                        NoitruDmucBuong.Columns.TenBuong
                    });
                    if (grdBuong.DataSource != null)
                    {
                        grdBuong.MoveFirst();
                    }
                }
                else
                {
                    string tempt = txtMaLanKham.Text;
                    ClearControl();
                    if (_mDtDataRoom != null)
                    {
                        _mDtDataRoom.Clear();
                    }
                    if (_mDtDatabed != null)
                    {
                        if (_mDtDataRoom != null)
                        {
                            _mDtDataRoom.Clear();
                        }
                    }
                    txtMaLanKham.Text = tempt;
                    txtMaLanKham.SelectAll();
                    txtMaLanKham.Focus();
                }
            }
        }
        private void BindData()
        {
            SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                                .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(txtMaLanKham.Text);

            if (sqlQuery.GetRecordCount() > 0)
            {
                objLuotkham = sqlQuery.ExecuteSingle <KcbLuotkham>();
                if (objLuotkham != null)
                {
                    txtMaLanKham.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                    txtSoBHYT.Text    = Utility.sDbnull(objLuotkham.MatheBhyt);
                    DmucKhoaphong objLDepartment = DmucKhoaphong.FetchByID(objLuotkham.IdKhoanoitru);
                    if (objLDepartment != null)
                    {
                        txtDepartment_ID.Text  = Utility.sDbnull(objLDepartment.IdKhoaphong);
                        txtDepartmentName.Tag  = Utility.sDbnull(objLDepartment.IdKhoaphong);
                        txtDepartmentName.Text = Utility.sDbnull(objLDepartment.TenKhoaphong);
                    }
                    KcbDanhsachBenhnhan objPatientInfo = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan);
                    if (objPatientInfo != null)
                    {
                        txtPatient_Name.Text = Utility.sDbnull(objPatientInfo.TenBenhnhan);
                        txtPatient_ID.Text   = Utility.sDbnull(objLuotkham.IdBenhnhan);
                        txtNamSinh.Text      = Utility.sDbnull(objPatientInfo.NamSinh);
                        txtTuoi.Text         = Utility.sDbnull(DateTime.Now.Year - objPatientInfo.NamSinh);
                        txtPatientSex.Text   = objPatientInfo.GioiTinh;                                        // Utility.Int32Dbnull(objPatientInfo.) == 0 ? "Nam" : "Nữ";
                    }
                    NoitruPhanbuonggiuong objPhanbuonggiuong = NoitruPhanbuonggiuong.FetchByID(IDBuonggiuong); // noitru_nhapvien.LaythongtinBuonggiuongHtai(objLuotkham);
                    if (objPhanbuonggiuong != null)
                    {
                        dtNgayvao.Value        = objPhanbuonggiuong.NgayVaokhoa;
                        txtPatientDept_ID.Text = Utility.sDbnull(objPhanbuonggiuong.Id);
                        NoitruDmucBuong objRoom = NoitruDmucBuong.FetchByID(objPhanbuonggiuong.IdBuong);
                        if (objRoom != null)
                        {
                            txtSoPhong.Text = Utility.sDbnull(objRoom.TenBuong);
                            txtSoPhong.Tag  = Utility.sDbnull(objPhanbuonggiuong.IdBuong);
                        }
                        NoitruDmucGiuongbenh objNoitruDmucGiuongbenh = NoitruDmucGiuongbenh.FetchByID(objPhanbuonggiuong.IdGiuong);
                        if (objNoitruDmucGiuongbenh != null)
                        {
                            txtSoGiuong.Text = Utility.sDbnull(objNoitruDmucGiuongbenh.TenGiuong);
                            txtSoGiuong.Tag  = Utility.sDbnull(objPhanbuonggiuong.IdGiuong);
                        }
                    }

                    DataTable dtGia = new dmucgiagiuong_busrule().dsGetList("-1").Tables[0];
                    dtGia.DefaultView.Sort = NoitruGiabuonggiuong.Columns.SttHthi + "," + NoitruGiabuonggiuong.Columns.TenGia;
                    txtGia.Init(dtGia,
                                new List <string>()
                    {
                        NoitruGiabuonggiuong.Columns.IdGia,
                        NoitruGiabuonggiuong.Columns.MaGia,
                        NoitruGiabuonggiuong.Columns.TenGia
                    });
                    cboGia.DataSource    = dtGia;
                    cboGia.DataMember    = NoitruGiabuonggiuong.Columns.IdGia;
                    cboGia.ValueMember   = NoitruGiabuonggiuong.Columns.IdGia;
                    cboGia.DisplayMember = NoitruGiabuonggiuong.Columns.TenGia;

                    m_dtDataRoom = THU_VIEN_CHUNG.NoitruTimkiembuongTheokhoa(Utility.Int32Dbnull(txtDepartment_ID.Text));
                    Utility.SetDataSourceForDataGridEx_Basic(grdBuong, m_dtDataRoom, true, true, "1=1", "sluong_giuong_trong desc,ten_buong");
                    txtRoom_code.Init(m_dtDataRoom, new List <string>()
                    {
                        NoitruDmucBuong.Columns.IdBuong, NoitruDmucBuong.Columns.MaBuong, NoitruDmucBuong.Columns.TenBuong
                    });
                    if (grdBuong.DataSource != null)
                    {
                        grdBuong.MoveFirst();
                    }
                }
                else
                {
                    string tempt = txtMaLanKham.Text;
                    ClearControl();
                    if (m_dtDataRoom != null)
                    {
                        m_dtDataRoom.Clear();
                    }
                    if (m_dtDatabed != null)
                    {
                        m_dtDataRoom.Clear();
                    }
                    txtMaLanKham.Text = tempt;
                    txtMaLanKham.SelectAll();
                    txtMaLanKham.Focus();
                }
            }
        }