public ActionResult AddNewPatientExam(KcbDanhsachBenhnhan objPatientInfo, KcbLuotkham objLuotkham, KcbDangkyKcb objRegExam, int KieuKham) { try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { UpdatePatientInfo(objPatientInfo); SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham); if (sqlQueryPatientExam.GetRecordCount() > 0)//Nếu BN khác đã lấy mã này { objLuotkham.MaLuotkham = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM(); } objLuotkham.IsNew = true; objLuotkham.Save(); if (objLuotkham.TrangthaiNoitru >= 1) { SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema).Where( KcbLuotkham.Columns.MaLuotkham).IsNotEqualTo(objLuotkham.MaLuotkham) .And(KcbLuotkham.Columns.SoBenhAn).IsEqualTo(objLuotkham.SoBenhAn) .And(KcbLuotkham.Columns.TrangthaiNoitru).IsGreaterThanOrEqualTo(1); if (sqlQuery.GetRecordCount() > 0) { var query = new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(THU_VIEN_CHUNG.LaySoBenhAn()) .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham). Execute(); } } if (objRegExam != null) { objRegExam.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objRegExam.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); AddRegExam(objRegExam,objLuotkham, false, KieuKham); } scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { return ActionResult.Error; } }
private void SearchPatient() { try { ClearControl(); _malankham = ""; _objkcbdangky = null; ObjBenhnhan = null; ObjLuotkham = null; if (_dtIcdPhu != null) { _dtIcdPhu.Clear(); } if (_mDtAssignDetail != null) { _mDtAssignDetail.Clear(); } if (_mDtPresDetail != null) { _mDtPresDetail.Clear(); } _mDtDanhsachbenhnhanthamkham = _kcbThamkham.KcbLichsuKcbTimkiemBenhnhan(dtFromDate.Value, dtToDate.Value, Utility.DoTrim(txtmaluotkham.Text), Utility.Int32Dbnull(txtIdBenhnhan.Text, -1), Utility.DoTrim(txtTenBN.Text), Utility.DoTrim(txtTheBHYT.Text), Utility.Int32Dbnull(txtBacsikham.MyID, -1), _thamso); Utility.SetDataSourceForDataGridEx_Basic(grdList, _mDtDanhsachbenhnhanthamkham, true, true, "", KcbDanhsachBenhnhan.Columns.TenBenhnhan); if (_dtIcdPhu != null && !_dtIcdPhu.Columns.Contains(DmucBenh.Columns.MaBenh)) { _dtIcdPhu.Columns.Add(DmucBenh.Columns.MaBenh, typeof(string)); } if (_dtIcdPhu != null && !_dtIcdPhu.Columns.Contains(DmucBenh.Columns.TenBenh)) { _dtIcdPhu.Columns.Add(DmucBenh.Columns.TenBenh, typeof(string)); } grd_ICD.DataSource = _dtIcdPhu; grdList.MoveFirst(); } catch (Exception ex) { Utility.CatchException(ex); } }
public ActionResult ThemmoiBenhnhan(SysTrace mytrace, KcbDanhsachBenhnhan objKcbDanhsachBenhnhan, KcbLuotkham objLuotkham, KcbDangkyKcb objKcbDangkyKcb, KcbDangkySokham objSoKCB, int KieuKham, ref long id_kham, ref string Msg) { int v_IdBenhnhan = -1; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { objKcbDanhsachBenhnhan.IsNew = true; objKcbDanhsachBenhnhan.Save(); KcbLichsuDoituongKcb objLichsuKcb = new KcbLichsuDoituongKcb(); objLichsuKcb.IdBenhnhan = objKcbDanhsachBenhnhan.IdBenhnhan; objLichsuKcb.MaLuotkham = objLuotkham.MaLuotkham; objLichsuKcb.NgayHieuluc = objLuotkham.NgayTiepdon; objLichsuKcb.IdDoituongKcb = objLuotkham.IdDoituongKcb; objLichsuKcb.MaDoituongKcb = objLuotkham.MaDoituongKcb; objLichsuKcb.IdLoaidoituongKcb = objLuotkham.IdLoaidoituongKcb; objLichsuKcb.MatheBhyt = objLuotkham.MatheBhyt; objLichsuKcb.PtramBhyt = objLuotkham.PtramBhyt; objLichsuKcb.PtramBhytGoc = objLuotkham.PtramBhytGoc; objLichsuKcb.NgaybatdauBhyt = objLuotkham.NgaybatdauBhyt; objLichsuKcb.NgayketthucBhyt = objLuotkham.NgayketthucBhyt; objLichsuKcb.NoicapBhyt = objLuotkham.NoicapBhyt; objLichsuKcb.MaNoicapBhyt = objLuotkham.MaNoicapBhyt; objLichsuKcb.MaDoituongBhyt = objLuotkham.MaDoituongBhyt; objLichsuKcb.MaQuyenloi = objLuotkham.MaQuyenloi; objLichsuKcb.NoiDongtrusoKcbbd = objLuotkham.NoiDongtrusoKcbbd; objLichsuKcb.MaKcbbd = objLuotkham.MaKcbbd; objLichsuKcb.TrangthaiNoitru = 0; objLichsuKcb.DungTuyen = objLuotkham.DungTuyen; objLichsuKcb.Cmt = objLuotkham.Cmt; objLichsuKcb.IdRavien = -1; objLichsuKcb.IdBuong = -1; objLichsuKcb.IdGiuong = -1; objLichsuKcb.IdKhoanoitru = -1; objLichsuKcb.NguoiTao = globalVariables.UserName; objLichsuKcb.NgayTao = globalVariables.SysDate; objLichsuKcb.IsNew = true; objLichsuKcb.Save(); //Thêm lần khám objLuotkham.IdBenhnhan = objKcbDanhsachBenhnhan.IdBenhnhan; objLuotkham.SoBenhAn = string.Empty; objLuotkham.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; objLuotkham.SttKham = THU_VIEN_CHUNG.LaySTTKhamTheoDoituong(objLuotkham.IdDoituongKcb); objLuotkham.NgayTao = globalVariables.SysDate; objLuotkham.NguoiTao = globalVariables.UserName; objLuotkham.IsNew = true; objLuotkham.Save(); SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham); if (sqlQueryPatientExam.GetRecordCount() > 0) { string patientCode = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM((byte)(objKcbDanhsachBenhnhan.KieuBenhnhan==0?0:1)); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.MaLuotkham).EqualTo(patientCode) .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham).Execute(); new Update(KcbLichsuDoituongKcb.Schema) .Set(KcbLichsuDoituongKcb.Columns.MaLuotkham).EqualTo(patientCode) .Where(KcbLichsuDoituongKcb.Columns.IdLichsuDoituongKcb).IsEqualTo(objLichsuKcb.IdLichsuDoituongKcb).Execute(); objLuotkham.MaLuotkham = patientCode; } new Update(KcbDmucLuotkham.Schema) .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(2) .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(DateTime.Now) .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDmucLuotkham.Columns.Loai).IsEqualTo((byte)(objKcbDanhsachBenhnhan.KieuBenhnhan == 0 ? 0 : 1)) .And(KcbDmucLuotkham.Columns.TrangThai).IsLessThanOrEqualTo(1) .And(KcbDmucLuotkham.Columns.UsedBy).IsLessThanOrEqualTo(globalVariables.UserName) .Execute(); //.And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year)//Tạm bỏ tránh máy client cố tình điều chỉnh khác máy server ; if (objSoKCB != null) { //Kiểm tra xem có sổ KCB hay chưa objSoKCB.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objSoKCB.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); KcbDangkySokham _temp = new Select().From(KcbDangkySokham.Schema).Where(KcbDangkySokham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbDangkySokham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .ExecuteSingle<KcbDangkySokham>(); if (_temp == null) { objSoKCB.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; objSoKCB.NgayTao = globalVariables.SysDate; objSoKCB.NguoiTao = globalVariables.UserName; objSoKCB.IsNew = true; objSoKCB.Save(); } else { if (Utility.Int64Dbnull(_temp.IdThanhtoan, 0) > 0)//Ko làm gì cả { Msg = "Đã thu tiền sổ khám của Bệnh nhân nên không được phép xóa hoặc cập nhật lại"; } else//Update lại sổ KCB { _temp.DonGia = objSoKCB.DonGia; _temp.BnhanChitra = objSoKCB.BnhanChitra; _temp.BhytChitra = objSoKCB.BhytChitra; _temp.PtramBhyt = objSoKCB.PtramBhyt; _temp.PtramBhytGoc = objSoKCB.PtramBhytGoc; _temp.PhuThu = objSoKCB.PhuThu; _temp.TuTuc = objSoKCB.TuTuc; _temp.NguonThanhtoan = objSoKCB.NguonThanhtoan; _temp.IdLoaidoituongkcb = objSoKCB.IdLoaidoituongkcb; _temp.IdDoituongkcb = objSoKCB.IdDoituongkcb; _temp.MaDoituongkcb = objSoKCB.MaDoituongkcb; _temp.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; _temp.Noitru = objSoKCB.Noitru; _temp.IdGoi = objSoKCB.IdGoi; _temp.TrongGoi = objSoKCB.TrongGoi; _temp.IdNhanvien = objSoKCB.IdNhanvien; _temp.NgaySua = globalVariables.SysDate; _temp.NguoiSua = globalVariables.UserName; _temp.IsNew = false; _temp.MarkOld(); _temp.Save(); } } } else { new Delete().From(KcbDangkySokham.Schema).Where(KcbDangkySokham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbDangkySokham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDangkySokham.Columns.TrangthaiThanhtoan).IsEqualTo(0) .Execute(); } if (objKcbDangkyKcb != null)//Đôi lúc người dùng không chọn phòng khám { objKcbDangkyKcb.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objKcbDangkyKcb.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); objKcbDangkyKcb.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; id_kham = AddRegExam(objKcbDangkyKcb, objLuotkham, false, KieuKham); } mytrace.Desc = string.Format("Thêm mới Bệnh nhân ID={0}, Code={1}, Name={2}", objKcbDanhsachBenhnhan.IdBenhnhan.ToString(), objLuotkham.MaLuotkham, objKcbDanhsachBenhnhan.TenBenhnhan); mytrace.Lot = 0; mytrace.IsNew = true; mytrace.Save(); scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { log.Error("loi trong qua trinh cap nhap thong tin them moi thong tin benh nhan tiep don {0}", ex); return ActionResult.Error; } }
private KcbDangkyKcb CreateNewRegExam() { bool b_HasKham = false; var query = from phong in m_dataDataRegExam.AsEnumerable().Cast<DataRow>() where Utility.Int32Dbnull(phong[KcbDangkyKcb.Columns.IdDichvuKcb], -100) == Utility.Int32Dbnull(cboKieuKham.Value, -1) select phong; if (query.Count() > 0) { Utility.ShowMsg("Bệnh nhân đã đăng ký dịch vụ khám này. Đề nghị bạn xem lại"); b_HasKham = true; } else { b_HasKham = false; } if (!b_HasKham) { KcbDangkyKcb objRegExam = new KcbDangkyKcb(); DmucDichvukcb objDichvuKCB = DmucDichvukcb.FetchByID(Utility.Int32Dbnull(cboKieuKham.Value)); DmucKhoaphong objdepartment = new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.MaKhoaphongColumn).IsEqualTo(globalVariables.MA_KHOA_THIEN).ExecuteSingle<DmucKhoaphong>(); DmucDoituongkcb objDoituongKCB = new Select().From(DmucDoituongkcb.Schema).Where(DmucDoituongkcb.MaDoituongKcbColumn).IsEqualTo(MA_DTUONG).ExecuteSingle<DmucDoituongkcb>(); if (objDichvuKCB != null) { string MaLuotkham = Utility.sDbnull(grdList.GetValue(KcbLuotkham.Columns.MaLuotkham)); int Patient_ID = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.IdBenhnhan), -1); int dungtuyen = Utility.Int32Dbnull(grdList.GetValue(KcbLuotkham.Columns.DungTuyen), 0); objRegExam.IdDichvuKcb = Utility.Int16Dbnull(objDichvuKCB.IdDichvukcb, -1); objRegExam.IdKieukham = objDichvuKCB.IdKieukham; objRegExam.DonGia = Utility.DecimaltoDbnull(objDichvuKCB.DonGia, 0); objRegExam.NguoiTao = globalVariables.UserName; if (objdepartment != null) { objRegExam.IdKhoakcb = objdepartment.IdKhoaphong; objRegExam.MaPhongStt = objdepartment.MaPhongStt; } if (objDoituongKCB != null) { objRegExam.IdLoaidoituongkcb = objDoituongKCB.IdLoaidoituongKcb; objRegExam.MaDoituongkcb = objDoituongKCB.MaDoituongKcb; objRegExam.IdDoituongkcb = objDoituongKCB.IdDoituongKcb; } if (Utility.Int16Dbnull(objDichvuKCB.IdPhongkham, -1) > -1) objRegExam.IdPhongkham = Utility.Int16Dbnull(objDichvuKCB.IdPhongkham, -1); else objRegExam.IdPhongkham = Utility.Int16Dbnull(txtIDPkham.Text, -1); if (Utility.Int32Dbnull(objDichvuKCB.IdBacsy) > 0) objRegExam.IdBacsikham = Utility.Int16Dbnull(objDichvuKCB.IdBacsy); else { objRegExam.IdBacsikham = globalVariables.gv_intIDNhanvien; } objRegExam.PhuThu = THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb) ? (dungtuyen == 1 ? Utility.DecimaltoDbnull(objDichvuKCB.PhuthuDungtuyen) : Utility.DecimaltoDbnull(objDichvuKCB.PhuthuTraituyen)) : 0m; objRegExam.NgayDangky = globalVariables.SysDate; objRegExam.IdBenhnhan = Patient_ID; objRegExam.TrangthaiThanhtoan = 0; objRegExam.TrangthaiHuy = 0; objRegExam.Noitru = 0; objRegExam.TrangthaiIn = 0; objRegExam.TuTuc = Utility.ByteDbnull(objDichvuKCB.TuTuc, 0); objRegExam.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN; objRegExam.TenDichvuKcb = cboKieuKham.Text; objRegExam.NgayTiepdon = globalVariables.SysDate; objRegExam.MaLuotkham = MaLuotkham; if (THU_VIEN_CHUNG.IsNgoaiGio()) { objRegExam.KhamNgoaigio = 1; objRegExam.DonGia = Utility.DecimaltoDbnull(objDichvuKCB.DongiaNgoaigio, 0); objRegExam.PhuThu =Utility.Byte2Bool( objLuotkham.DungTuyen) ? Utility.DecimaltoDbnull(objDichvuKCB.PhuthuNgoaigio, 0) : Utility.DecimaltoDbnull(objDichvuKCB.PhuthuDungtuyen); } else { objRegExam.KhamNgoaigio = 0; } } else { objRegExam = null; } return objRegExam; } return null; }
public void THEM_PHI_DVU_KYC(KcbLuotkham objLuotkham, KcbDangkyKcb objregexam) { using (var scope = new TransactionScope()) { DmucPhikemtheoCollection lstPhikemtheo = new Select().From(DmucPhikemtheo.Schema).Where(DmucPhikemtheo.IdKhoakcbColumn).IsEqualTo(objregexam.IdKhoakcb).ExecuteAsCollection<DmucPhikemtheoCollection>(); if (lstPhikemtheo != null && lstPhikemtheo.Count > 0) { if (Utility.Int32Dbnull(lstPhikemtheo[0].IdPhikemtheo, -1) > 0) { SqlQuery sql = new Select().From(KcbDangkyKcb.Schema).Where(KcbDangkyKcb.Columns.MaLuotkham). IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDangkyKcb.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).And( KcbDangkyKcb.Columns.LaPhidichvukemtheo).IsEqualTo(1) .And(KcbDangkyKcb.Columns.IdCha).IsEqualTo(objregexam.IdKham); if (sql.GetRecordCount() > 0)//Chỉ được 1 lần phí dịch vụ kèm theo { return; } int IdDv = -1; //Mã ưu tiên của một số đối tượng BHYT ko cần trả phí dịch vụ kèm theo(hiện tại là có mã quyền lợi 1,2,3) string[] maUuTienKkb = globalVariables.gv_strMaUutien.Split(','); if (globalVariables.MA_KHOA_THIEN != "KYC") { if (THU_VIEN_CHUNG.IsNgoaiGio()) { IdDv = Utility.Int32Dbnull(lstPhikemtheo[0].IdPhikemtheongoaigio, -1); } else//Khám trong giờ cần xét đối tượng ưu tiên { //var query= from loz in Ma_UuTien. if (!maUuTienKkb.Contains(Utility.sDbnull(objLuotkham.MaQuyenloi, "0"))) { IdDv = Utility.Int32Dbnull(lstPhikemtheo[0].IdPhikemtheo, -1); } else { IdDv = -1; } } } else//Khám yêu cầu thì luôn bị tính phí dịch vụ kèm theo { IdDv = Utility.Int32Dbnull(lstPhikemtheo[0].IdPhikemtheo, -1); } DmucDichvuclsChitiet lServiceDetail = DmucDichvuclsChitiet.FetchByID(IdDv); long reg_id = objregexam.IdKham; if (lServiceDetail != null) { objregexam.DonGia = lServiceDetail.DonGia.Value; objregexam.PhuThu = 0; objregexam.BhytChitra = 0; objregexam.BnhanChitra = lServiceDetail.DonGia; objregexam.IdCha = reg_id; objregexam.TrangThai = 0; objregexam.SttKham = -1; objregexam.TenDichvuKcb = "Phí dịch vụ kèm theo"; objregexam.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN; objregexam.TuTuc = 0; objregexam.KhamNgoaigio = 0; objregexam.LaPhidichvukemtheo = 1; objregexam.IsNew = true; objregexam.Save(); } } } scope.Complete(); } }
/// <summary> /// /// </summary> /// <param name="objRegExam"></param> /// <param name="b_HasLoaded"></param> /// <returns></returns> public int AddRegExam(KcbDangkyKcb objRegExam, KcbLuotkham objLuotkham, bool b_HasLoaded, int KieuKham) { int v_RegId = -1; decimal BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m); try { using (var scope = new TransactionScope()) { objRegExam.SttKham = THU_VIEN_CHUNG.LaySothutuKCB(Utility.Int32Dbnull(objRegExam.IdPhongkham, -1)); objRegExam.PtramBhyt = objLuotkham.PtramBhyt; objRegExam.PtramBhytGoc = objLuotkham.PtramBhytGoc; if (!THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb)) objRegExam.TuTuc = 0; if (Utility.ByteDbnull(objRegExam.TuTuc, 0) == 1) { objRegExam.BhytChitra =0;// objRegExam.DonGia * Utility.DecimaltoDbnull(objLuotkham.PtramBhyt) / 100; objRegExam.BnhanChitra = objRegExam.DonGia; } else { decimal BHCT = 0m; if (objLuotkham.DungTuyen == 1) { BHCT = objRegExam.DonGia * Utility.DecimaltoDbnull(objLuotkham.PtramBhyt) / 100; } else { if (objLuotkham.TrangthaiNoitru <= 0) BHCT = objRegExam.DonGia * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100); else//Nội trú cần tính=đơn giá * % đầu thẻ * % tuyến BHCT = objRegExam.DonGia * (Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0) / 100) * (BHYT_PTRAM_TRAITUYENNOITRU / 100); } objRegExam.BhytChitra =BHCT;// objRegExam.DonGia * Utility.DecimaltoDbnull(objLuotkham.PtramBhyt) / 100; objRegExam.BnhanChitra = objRegExam.DonGia - objRegExam.BhytChitra; } objRegExam.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN; objRegExam.TrangThai = 0; objRegExam.IsNew = true; objRegExam.Save(); //Thêm bản ghi trong bảng phân buồng giường để tiện tính toán NoitruPhanbuonggiuong _newItem = new NoitruPhanbuonggiuong(); _newItem.IdBenhnhan = objRegExam.IdBenhnhan; _newItem.MaLuotkham = objRegExam.MaLuotkham; _newItem.IdKham = (int)objRegExam.IdKham; _newItem.IdKhoanoitru = objRegExam.IdKhoakcb.Value; _newItem.NgayVaokhoa = objRegExam.NgayDangky.Value; _newItem.IdBacsiChidinh = objRegExam.IdBacsikham; _newItem.NguoiTao = objRegExam.NguoiTao; _newItem.NgayTao = objRegExam.NgayDangky.Value; _newItem.NoiTru =0; _newItem.DuyetBhyt = 0; _newItem.TrongGoi =-1; _newItem.SoLuong = 1; _newItem.DonGia = objRegExam.DonGia; _newItem.PhuThu = objRegExam.PhuThu; _newItem.BnhanChitra = objRegExam.BnhanChitra; _newItem.BhytChitra = objRegExam.BhytChitra; _newItem.TenHienthi = objRegExam.TenDichvuKcb; _newItem.TuTuc = objRegExam.TuTuc; _newItem.TrangthaiXacnhan = 0; _newItem.GiaGoc = objRegExam.DonGia + objRegExam.PhuThu; _newItem.IdBuong = -1; _newItem.IdGiuong = -1; _newItem.IdChuyen = -1; _newItem.IdNhanvienPhangiuong = -1; _newItem.IsNew = true; _newItem.Save(); v_RegId = Utility.Int32Dbnull(objRegExam.IdKham); if (objRegExam.IdKham > 0) { KieuKham = Utility.Int32Dbnull(objRegExam.IdDichvuKcb); long _regid = objRegExam.IdKham; //Lấy phí kèm theo trong bảng Quan hệ kiểu khám và đẩy vào bảng T_RegExam //THEM_PHI_DVU_KYC(objLuotkham,objRegExam, KieuKham); //Lấy phí kèm theo trong bảng DmucPhikemtheoCollection //(cấu hình theo từng phòng khám thay vì theo từng kiểu khám) và đẩy vào bảng T_RegExam THEM_PHI_DVU_KYC(objLuotkham, objRegExam); //Lấy phí dịch vụ trong bảng Quan hệ kiểu khám và đẩy vào bảng CLS //THEM_PHI_DVU_KYC(objLuotkham, KieuKham); } scope.Complete(); } } catch (Exception ex) { log.Error(ex.Message); } return v_RegId; }
public static bool CapnhatTrangthaiTutuc(KcbDangkyKcb objDoituong, KcbLuotkham objLuotkham, bool noitru, byte tu_tuc, decimal PTramBHYT) { try { byte TrangthaiBhyt = 1; decimal BHYT_PTRAM_TRAITUYENNOITRU = Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_PTRAM_TRAITUYENNOITRU", "0", false), 0m); bool b_ExistPtramBHYT = false; objDoituong.TuTuc = tu_tuc; if (!THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb.Value))//Đối tượng DV { TrangthaiBhyt = (byte)0; objDoituong.TuTuc = 0; } else { TrangthaiBhyt = (byte)(globalVariables.gv_blnApdungChedoDuyetBHYT ? 0 : 1); } if (Utility.Int32Dbnull(objDoituong.TrangthaiHuy, -1) == -1) { objDoituong.TrangthaiHuy = 0; } objDoituong.PtramBhyt = PTramBHYT; objDoituong.PtramBhytGoc = objLuotkham.PtramBhytGoc; // objChidinhChitiet.LoaiChietkhau = 0; // objChidinhChitiet.TrangthaiBhyt = TrangthaiBhyt; //objChidinhChitiet.IdLoaichidinh = 0;//Chưa hiểu trường này-->Cần xem lại if (Utility.Int32Dbnull(objDoituong.TuTuc, 0) == 1) { objDoituong.BhytChitra = 0; objDoituong.BnhanChitra = Utility.DecimaltoDbnull(objDoituong.DonGia, 0); objDoituong.PtramBhyt = 0; } else { if (b_ExistPtramBHYT) { objDoituong.BhytChitra = Utility.DecimaltoDbnull(objDoituong.DonGia) * Utility.DecimaltoDbnull(objDoituong.PtramBhyt) / 100; objDoituong.BnhanChitra = Utility.DecimaltoDbnull(objDoituong.DonGia, 0) - Utility.DecimaltoDbnull(objDoituong.BhytChitra); } else//99% rơi vào nhánh này { PTramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt); decimal BHCT = 0m; if (objLuotkham.DungTuyen == 1)//BHYT đúng tuyến rơi vào nhánh này dù nội trú ngay ngoại trú { BHCT = Utility.DecimaltoDbnull(objDoituong.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100); } else//DV và BHYT trái tuyến { if (objLuotkham.TrangthaiNoitru <= 0 || !noitru)//Đối tượng ngoại trú hoặc Chỉ định ngoại trú-->Lấy phần trăm ngoại trú { BHCT = Utility.DecimaltoDbnull(objDoituong.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) / 100); } else//Nội trú cần tính=đơn giá * % đầu thẻ * % tuyến { BHCT = Utility.DecimaltoDbnull(objDoituong.DonGia, 0) * (Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0) / 100) * (BHYT_PTRAM_TRAITUYENNOITRU / 100); } } decimal BNCT = Utility.DecimaltoDbnull(objDoituong.DonGia, 0) - BHCT; objDoituong.BhytChitra = BHCT; objDoituong.BnhanChitra = BNCT; } } objDoituong.MarkOld(); objDoituong.IsNew = false; objDoituong.Save(); return(true); } catch (Exception ex) { Utility.CatchException(ex); return(false); } }
public void Insert(long IdBenhnhan, string MaLuotkham, string MadoituongGia, decimal DonGia, decimal?PtramBhytGoc, decimal?PtramBhyt, decimal?BhytChitra, decimal?BnhanChitra, DateTime?NgayDangky, DateTime?NgayTiepdon, decimal?PhuThu, short?IdPhongkham, short?IdBacsikham, byte TrangthaiThanhtoan, long?IdThanhtoan, DateTime?NgayThanhtoan, string NguoiThanhtoan, byte?TrangthaiIn, byte?TrangThai, byte?TrangthaiHuy, short?SttKham, short?IdDichvuKcb, string TenDichvuKcb, byte?Noitru, string MaKhoaThuchien, byte?TuTuc, byte?KhamNgoaigio, string MaPhongStt, long?IdCha, byte?LaPhidichvukemtheo, string MaDoituongkcb, short?IdDoituongkcb, byte?IdLoaidoituongkcb, short?IdKhoakcb, string NhomBaocao, string NguoiChuyen, DateTime?NgayChuyen, string LydoChuyen, byte?TrangthaiChuyen, int?IdKieukham, decimal?TileChietkhau, decimal?TienChietkhau, string KieuChietkhau, int?IdGoi, byte?TrongGoi, byte?NguonThanhtoan, string NguoiTao, DateTime?NgaySua, string NguoiSua, long?IdLichsuDoituongKcb, string MatheBhyt, string IpMaytao, string IpMaysua, string TenMaytao, string TenMaysua, byte?DachidinhCls, byte?DakeDonthuoc) { KcbDangkyKcb item = new KcbDangkyKcb(); item.IdBenhnhan = IdBenhnhan; item.MaLuotkham = MaLuotkham; item.MadoituongGia = MadoituongGia; item.DonGia = DonGia; item.PtramBhytGoc = PtramBhytGoc; item.PtramBhyt = PtramBhyt; item.BhytChitra = BhytChitra; item.BnhanChitra = BnhanChitra; item.NgayDangky = NgayDangky; item.NgayTiepdon = NgayTiepdon; item.PhuThu = PhuThu; item.IdPhongkham = IdPhongkham; item.IdBacsikham = IdBacsikham; item.TrangthaiThanhtoan = TrangthaiThanhtoan; item.IdThanhtoan = IdThanhtoan; item.NgayThanhtoan = NgayThanhtoan; item.NguoiThanhtoan = NguoiThanhtoan; item.TrangthaiIn = TrangthaiIn; item.TrangThai = TrangThai; item.TrangthaiHuy = TrangthaiHuy; item.SttKham = SttKham; item.IdDichvuKcb = IdDichvuKcb; item.TenDichvuKcb = TenDichvuKcb; item.Noitru = Noitru; item.MaKhoaThuchien = MaKhoaThuchien; item.TuTuc = TuTuc; item.KhamNgoaigio = KhamNgoaigio; item.MaPhongStt = MaPhongStt; item.IdCha = IdCha; item.LaPhidichvukemtheo = LaPhidichvukemtheo; item.MaDoituongkcb = MaDoituongkcb; item.IdDoituongkcb = IdDoituongkcb; item.IdLoaidoituongkcb = IdLoaidoituongkcb; item.IdKhoakcb = IdKhoakcb; item.NhomBaocao = NhomBaocao; item.NguoiChuyen = NguoiChuyen; item.NgayChuyen = NgayChuyen; item.LydoChuyen = LydoChuyen; item.TrangthaiChuyen = TrangthaiChuyen; item.IdKieukham = IdKieukham; item.TileChietkhau = TileChietkhau; item.TienChietkhau = TienChietkhau; item.KieuChietkhau = KieuChietkhau; item.IdGoi = IdGoi; item.TrongGoi = TrongGoi; item.NguonThanhtoan = NguonThanhtoan; item.NguoiTao = NguoiTao; item.NgaySua = NgaySua; item.NguoiSua = NguoiSua; item.IdLichsuDoituongKcb = IdLichsuDoituongKcb; item.MatheBhyt = MatheBhyt; item.IpMaytao = IpMaytao; item.IpMaysua = IpMaysua; item.TenMaytao = TenMaytao; item.TenMaysua = TenMaysua; item.DachidinhCls = DachidinhCls; item.DakeDonthuoc = DakeDonthuoc; item.Save(UserName); }
public bool Delete(object IdKham) { return(KcbDangkyKcb.Delete(IdKham) == 1); }
public bool Destroy(object IdKham) { return(KcbDangkyKcb.Destroy(IdKham) == 1); }
public static ActionResult Thembenhnhan(KcbDanhsachBenhnhan objdanhsachbenhnhan, KcbLuotkham objluotkham, KcbChidinhcl objchidinh, KcbDangkyKcb objDangkyKcb, KcbChidinhclsChitiet[] objchidinhchitiet, ref string errMsg) { Logger log = LogManager.GetCurrentClassLogger(); try { var option = new TransactionOptions { IsolationLevel = IsolationLevel.Snapshot, Timeout = TimeSpan.FromMinutes(5) }; using (var trans = new TransactionScope()) { using (var shs = new SharedDbConnectionScope()) { log.Trace("1.Bắt đầu thêm mới bệnh nhân " + objdanhsachbenhnhan.TenBenhnhan + ""); string PatientCode = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM( (byte)(Utility.Int16Dbnull(objdanhsachbenhnhan.KieuBenhnhan, 1))); // Them moi thong tin benh nhan SqlQuery objdbenhnhan = new Select().From(KcbDanhsachBenhnhan.Schema) .Where(KcbDanhsachBenhnhan.Columns.IdBenhnhan).IsEqualTo(objdanhsachbenhnhan.IdBenhnhan); if (objdbenhnhan.GetRecordCount() > 0) { objdanhsachbenhnhan.MarkOld(); objdanhsachbenhnhan.IsLoaded = true; } else { objdanhsachbenhnhan.IsNew = true; } objdanhsachbenhnhan.Save(); log.Trace("2. Đã thêm mới Bệnh nhân"); // them moi lan kham cho benh nhan objluotkham.MaLuotkham = Utility.sDbnull(PatientCode, ""); SqlQuery sqlPatientExam = new Select().From(KcbLuotkham.Schema).Where( KcbLuotkham.Columns.MaLuotkham) .IsEqualTo(objluotkham.MaLuotkham); if (sqlPatientExam.GetRecordCount() > 0) { objluotkham.MarkOld(); objluotkham.IsLoaded = true; } else { objluotkham.IsNew = true; objluotkham.MaLuotkham = PatientCode; objluotkham.IdBenhnhan = objdanhsachbenhnhan.IdBenhnhan; } objluotkham.Save(); log.Trace("3. Đã thêm mới Lượt khám Bệnh nhân"); DataTable dtCheck = SPs.SpKcbKiemtraTrungMaLuotkham(objluotkham.IdBenhnhan, objluotkham.MaLuotkham). GetDataSet().Tables[0]; if (dtCheck != null && dtCheck.Rows.Count > 0) { log.Trace("3.1 Đã phát hiện trùng mã Bệnh nhân-->Lấy lại mã mới"); string patientCode = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM( (byte)(Utility.Int16Dbnull(objdanhsachbenhnhan.KieuBenhnhan, 1))); SPs.SpKcbCapnhatLuotkhamMaluotkham(patientCode, objluotkham.MaLuotkham, objluotkham.IdBenhnhan).Execute(); log.Trace("3.2 Cập nhập mã lượt khám này được sử dụng rồi"); // SPs.SpKcbCapnhatMaluotkhamLichsudoituongKcb(patientCode, objLichsuKcb.IdLichsuDoituongKcb).Execute(); // log.Trace("3.2 Đã Cập nhật lại mã lượt khám mới"); objluotkham.MaLuotkham = patientCode; } SPs.SpKcbCapnhatDmucLuotkham(objluotkham.MaLuotkham, (byte)(Utility.Int16Dbnull(objdanhsachbenhnhan.KieuBenhnhan, 1)), 1, 2, globalVariables.UserName).Execute(); log.Trace("4. Đã đánh dấu mã lượt khám đã được sử dụng trong hệ thống"); // Them moi thong tin chi dinh cho benh nhan if (objDangkyKcb != null) { SqlQuery sqldangkykcb = new Select().From(KcbDangkyKcb.Schema).Where( KcbDangkyKcb.Columns.IdKham) .IsEqualTo(Utility.Int64Dbnull(objDangkyKcb.IdKham, -1)); if (sqldangkykcb.GetRecordCount() > 0) { objDangkyKcb.MarkOld(); objDangkyKcb.IsLoaded = true; } else { objDangkyKcb.IsNew = true; objDangkyKcb.MaLuotkham = PatientCode; objDangkyKcb.IdBenhnhan = objdanhsachbenhnhan.IdBenhnhan; } objDangkyKcb.Save(); } SqlQuery sqlAssignInfo = new Select().From(KcbChidinhcl.Schema) .Where(KcbChidinhcl.Columns.IdChidinh).IsEqualTo(objchidinh.IdChidinh); if (objDangkyKcb != null) { objchidinh.IdKham = objDangkyKcb.IdKham; } objchidinh.IdDoituongKcb = 3; objchidinh.MaDoituongKcb = "KSK"; objchidinh.IdLoaidoituongKcb = 2; if (sqlAssignInfo.GetRecordCount() > 0) { objchidinh.MarkOld(); objchidinh.IsLoaded = true; } else { objchidinh.IsNew = true; objchidinh.MaChidinh = THU_VIEN_CHUNG.SinhMaChidinhCLSKSK(); } objchidinh.IdBenhnhan = objluotkham.IdBenhnhan; objchidinh.MaLuotkham = objluotkham.MaLuotkham; objchidinh.NguoiSua = globalVariables.UserName; objchidinh.NgaySua = DateTime.Now; if (string.IsNullOrEmpty(objchidinh.MaKhoaChidinh)) { objchidinh.MaKhoaChidinh = Utility.sDbnull(objluotkham.MaKhoaThuchien); } objchidinh.Save(); log.Trace("5. Đã thêm mới phiếu chỉ định cho bệnh nhân"); if (Utility.Int32Dbnull(objchidinh.IdChidinh) > 0) { foreach (KcbChidinhclsChitiet objAssignDetail in objchidinhchitiet) { // Them chi tiet chi dinh cho benh nhan SqlQuery sqlAssignDetail = new Select().From(KcbChidinhclsChitiet.Schema) .Where(KcbChidinhclsChitiet.Columns.IdChitietchidinh).IsEqualTo( objAssignDetail.IdChitietchidinh); if (sqlAssignDetail.GetRecordCount() > 0) { objAssignDetail.MarkOld(); objAssignDetail.IsLoaded = true; } else { objAssignDetail.IsNew = true; } objAssignDetail.IdDoituongKcb = Utility.Int16Dbnull(objluotkham.IdDoituongKcb); objAssignDetail.MaLuotkham = objchidinh.MaLuotkham; objAssignDetail.IdBenhnhan = objchidinh.IdBenhnhan; objAssignDetail.IdKham = objchidinh.IdKham; objAssignDetail.IdChidinh = Utility.Int32Dbnull(objchidinh.IdChidinh); // objAssignDetail.IdKham = -1; objAssignDetail.IpMaytao = globalVariables.gv_strIPAddress; objAssignDetail.PtramBhyt = Utility.DecimaltoDbnull(objluotkham.PtramBhyt); objAssignDetail.IdBacsiThuchien = globalVariables.IdKhoaNhanvien; // objAssignDetail.IsNew = true; objAssignDetail.Save(); log.Info( "Them moi thong tin cua phieu chi dinh chi tiet voi ma phieu Assign_ID=" + objchidinh.IdChidinh); } log.Trace("6. Đã thêm mới chi tiết phiếu chỉ định cho bệnh nhân"); } else { log.Trace("7. Lỗi thêm bệnh nhân vào hệ thống"); return(ActionResult.Error); } } trans.Complete(); log.Trace("8. Thêm bệnh nhân có ID_Benhnhan " + objdanhsachbenhnhan.IdBenhnhan + " vào hệ thống thành công"); errMsg = @"Thêm mới thành công bệnh nhân"; return(ActionResult.Success); } } catch (Exception ex) { errMsg = "Lỗi thêm mới bệnh nhân : " + ex.Message; log.Error(ex.Message); return(ActionResult.Error); } }
/// <summary> /// hàm thực hiện việc update thông tin xác nhận gói /// </summary> /// <param name="objThongtinGoiDvuBnhan"></param> /// <returns></returns> public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam, KcbLuotkham objPatientExam) { try { using (var scope = new TransactionScope()) { using (var sh = new SharedDbConnectionScope()) { if (objDiagInfo != null) { log.Trace("1.1 Bat dau ket thuc benh nhan: " + objDiagInfo.MaLuotkham); if (objDiagInfo.IsNew) { // objDiagInfo.Save(); SPs.SpKcbThemmoiChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdKham, objDiagInfo.IdBenhnhan, objDiagInfo.MaLuotkham, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan, objDiagInfo.NguoiTao, objDiagInfo.NgayTao, objDiagInfo.IdKhoanoitru, objDiagInfo.IdBuonggiuong, objDiagInfo.IdBuong, objDiagInfo.IdGiuong , objDiagInfo.IdPhieudieutri, objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap , objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao, objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau , objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh, objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaytao, objDiagInfo.TenMaytao, objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1 , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5, objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1, objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet , objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt ).Execute(); } else { SPs.SpKcbCapnhatChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan, objDiagInfo.NguoiSua, objDiagInfo.NgaySua, objDiagInfo.IdPhieudieutri , objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap, objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao , objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau, objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh , objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaysua, objDiagInfo.TenMaysua, objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1 , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5, objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1, objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet, objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt).Execute(); } } log.Trace("1.2 Luu xong chan doan cua benh nhan: " + objDiagInfo.MaLuotkham); SqlQuery sqlQuery = new Select().From( KcbChandoanKetluan.Schema) .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan) .And(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objRegExam.IdKham).OrderAsc( KcbChandoanKetluan.Columns.NgayChandoan); KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>(); var query = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.Chandoan) where (y != "") select y).ToArray(); string cdchinh = string.Join(";", query); //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>(); var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.ChandoanKemtheo) where (y != "") select y).ToArray(); string cdphu = string.Join(";", querychandoanphu); var querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhchinh.MabenhChinh) where (y != "") select y).ToArray(); string mabenhchinh = string.Join(";", querybenhchinh); var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhphu.MabenhPhu) where (y != "") select y).ToArray(); string mabenhphu = string.Join(";", querybenhphu); SPs.KcbLuotkhamTrangthaiketthuckham(objPatientExam.IdBenhnhan, objPatientExam.MaLuotkham, objPatientExam.TrangthaiNgoaitru, objPatientExam.Noitru, mabenhchinh, mabenhphu, objPatientExam.KetLuan, objPatientExam.HuongDieutri, cdchinh , cdphu, objPatientExam.Locked, objPatientExam.SongayDieutri, objPatientExam.TrieuChung, globalVariables.UserName, globalVariables.SysDate, globalVariables.gv_strIPAddress, globalVariables.gv_strComputerName, objDiagInfo.IdBacsikham, objRegExam.TrangThai, objRegExam.IdKham).Execute(); log.Trace("1.3 Update thanh cong trang thai cua benh nhan: " + objDiagInfo.MaLuotkham); //new Update(KcbLuotkham.Schema) // .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh) // .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu) // .Set(KcbLuotkham.Columns.KetLuan).EqualTo(objPatientExam.KetLuan) // .Set(KcbLuotkham.Columns.HuongDieutri).EqualTo(objPatientExam.HuongDieutri) // .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh) // .Set(KcbLuotkham.Columns.SongayDieutri).EqualTo(objPatientExam.SongayDieutri) // .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu) // .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung) // .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName) // .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate) // .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked) // .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc) // .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc) // .Set(KcbLuotkham.Columns.TrangthaiNgoaitru).EqualTo(objPatientExam.TrangthaiNgoaitru) // .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) // .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute(); ////Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận ////SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham, //// Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1), //// Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute(); //if (objRegExam != null) //{ // new Update(KcbDangkyKcb.Schema) // .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate) // .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName) // .Set(KcbDangkyKcb.Columns.IpMaysua).EqualTo(globalVariables.gv_strIPAddress) // .Set(KcbDangkyKcb.Columns.TenMaysua).EqualTo(globalVariables.gv_strComputerName) // .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham) // .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai) // .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)). // Execute(); //} sh.Dispose(); } scope.Complete(); // Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1); return(ActionResult.Success); } } catch (Exception exception) { log.Error("Loi trong qua trinh ket thuc benh nhan", exception); return(ActionResult.Error); } }
/// <summary> /// hàm thực hiện việc tính phần trăm của bảo hiểm y tế /// </summary> /// <param name="objPatientExam"></param> /// <param name="objRegExam"></param> public static void TinhToanKhamPtramBHYT(KcbLuotkham objPatientExam, KcbDangkyKcb objRegExam) { decimal PTramBHYT = Utility.DecimaltoDbnull(objPatientExam.PtramBhyt, 0); objRegExam.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN; objRegExam.BhytChitra = Utility.DecimaltoDbnull(objRegExam.DonGia) * Utility.DecimaltoDbnull(PTramBHYT) / 100; objRegExam.BnhanChitra = Utility.DecimaltoDbnull(objRegExam.DonGia, 0) - Utility.DecimaltoDbnull(objRegExam.BhytChitra, 0); }
public ActionResult ThemmoiBenhnhan(KcbDanhsachBenhnhan objKcbDanhsachBenhnhan, KcbLuotkham objLuotkham, KcbDangkyKcb objKcbDangkyKcb, int KieuKham,ref long id_kham) { int v_IdBenhnhan = -1; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { objKcbDanhsachBenhnhan.IsNew = true; objKcbDanhsachBenhnhan.Save(); //Thêm lần khám objLuotkham.IdBenhnhan = objKcbDanhsachBenhnhan.IdBenhnhan; objLuotkham.SoBenhAn = string.Empty; objLuotkham.SttKham = THU_VIEN_CHUNG.LaySTTKhamTheoDoituong(objLuotkham.IdDoituongKcb); objLuotkham.NgayTao = globalVariables.SysDate; objLuotkham.NguoiTao = globalVariables.UserName; objLuotkham.IsNew = true; objLuotkham.Save(); SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham); if (sqlQueryPatientExam.GetRecordCount() > 0) { string patientCode = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM(); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.MaLuotkham).EqualTo(patientCode) .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham).Execute(); objLuotkham.MaLuotkham = patientCode; } new Update(KcbDmucLuotkham.Schema) .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(2) .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(DateTime.Now) .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDmucLuotkham.Columns.TrangThai).IsLessThanOrEqualTo(1) .And(KcbDmucLuotkham.Columns.UsedBy).IsLessThanOrEqualTo(globalVariables.UserName) .Execute(); //.And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year)//Tạm bỏ tránh máy client cố tình điều chỉnh khác máy server ; if (objKcbDangkyKcb != null)//Đôi lúc người dùng không chọn phòng khám { objKcbDangkyKcb.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objKcbDangkyKcb.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); id_kham = AddRegExam(objKcbDangkyKcb, objLuotkham, false, KieuKham); } scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { log.Error("loi trong qua trinh cap nhap thong tin them moi thong tin benh nhan tiep don {0}", ex); return ActionResult.Error; } }
/// <summary> /// Lấy về thông tin bệnh nhâ nội trú /// </summary> private void GetData() { try { Utility.SetMsg(lblMsg, "", false); if (!Utility.isValidGrid(grdList)) { return; } bool KHAMCHEO_CACKHOA = THU_VIEN_CHUNG.Laygiatrithamsohethong("KHAMCHEO_CACKHOA", "0", true) == "1"; // Utility.SetMsg(lblMsg, "", false); string PatientCode = Utility.sDbnull(grdList.GetValue(KcbLuotkham.Columns.MaLuotkham), ""); m_strMaLuotkham = PatientCode; if (!Utility.CheckLockObject(m_strMaLuotkham, "Thăm khám", "TK")) return; int Id_Benhnhan = 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(Id_Benhnhan).ExecuteSingle<KcbLuotkham>(); objBenhnhan = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan); isRoom = false; if (objLuotkham != null) { string ten_khoaphong = Utility.sDbnull(grdList.GetValue("ten_khoaphong"), ""); cmdChuyenPhong.Visible = objLuotkham.TrangthaiNoitru == 0; int hien_thi = Utility.Int32Dbnull(grdList.GetValue("hien_thi"), 0); if (hien_thi == 0) { Utility.ShowMsg("Bệnh nhân " + objBenhnhan.TenBenhnhan + " CHƯA NỘP TIỀN KHÁM trong khi thuộc đối tượng khám chữa bệnh CẦN THANH TOÁN TRƯỚC KHI VÀO PHÒNG KHÁM.\nYêu cầu Bệnh nhân đi NỘP TIỀN KHÁM TRƯỚC"); objLuotkham = null; objBenhnhan = null; m_strMaLuotkham = ""; return; } if (!KHAMCHEO_CACKHOA && globalVariables.MA_KHOA_THIEN != objLuotkham.MaKhoaThuchien) { Utility.ShowMsg("Bệnh nhân này được tiếp đón và chỉ định khám cho khoa " + ten_khoaphong + ". Trong khi máy bạn đang cấu hình khám chữa bệnh cho khoa " + globalVariablesPrivate.objKhoaphong.TenKhoaphong + "\nHệ thống không cho phép khám chéo giữa các khoa. Đề nghị liên hệ Bộ phận IT trong đơn vị để được trợ giúp"); objLuotkham = null; objBenhnhan = null; m_strMaLuotkham = ""; return; } ClearControl(); lblSongaydieutri.ForeColor = THU_VIEN_CHUNG.IsBaoHiem(objLuotkham.IdLoaidoituongKcb) ? lblKetluan.ForeColor : lblBenhphu.ForeColor; lblBenhchinh.ForeColor = lblSongaydieutri.ForeColor; lblBANoitru.Text = Utility.Int32Dbnull(objLuotkham.SoBenhAn, -1) <= 0 ? "" : "Số B.A Nội trú: " + objLuotkham.SoBenhAn; txt_idchidinhphongkham.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham)); objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text)); var objStaff = new Select().From(DmucNhanvien.Schema).Where(DmucNhanvien.UserNameColumn).IsEqualTo( Utility.sDbnull(objLuotkham.NguoiKetthuc, "")).ExecuteSingle<DmucNhanvien>(); string TenNhanvien = objLuotkham.NguoiKetthuc; if (objStaff != null) TenNhanvien = objStaff.TenNhanvien; pnlCLS.Enabled = true; pnlDonthuoc.Enabled = true; pnlVTTH.Enabled = true; if (objkcbdangky != null) { cmdUnlock.Visible = objLuotkham.TrangthaiNoitru == 0 && objLuotkham.Locked.ToString() == "1"; cmdUnlock.Enabled = cmdUnlock.Visible && (Utility.Coquyen("quyen_mokhoa_tatca") || objLuotkham.NguoiKetthuc == globalVariables.UserName); if (!cmdUnlock.Enabled) toolTip1.SetToolTip(cmdUnlock, "Bạn không có quyền mở khóa Bệnh nhân này. Đề nghị liên hệ " + TenNhanvien + "(" + objLuotkham.NguoiKetthuc + " - Là người khóa BN này) để được họ mở khóa. Hoặc liên hệ Quản trị hệ thống"); else toolTip1.SetToolTip(cmdUnlock, "Nhấn vào đây để mở khóa cho bệnh nhân đang chọn(Phím tắt Ctrl+U). Điều kiện là chỉ mở khóa đối với đối tượng Dịch vụ. Muốn mở khóa đối tượng BHYT thì cần liên lạc với bộ phận thanh toán hủy in phôi BHYT"); cmdNhapVien.Enabled = objkcbdangky.TrangThai == 1; cmdHuyNhapVien.Enabled = objLuotkham.TrangthaiNoitru >= 1; cmdNhapVien.Tag = objLuotkham.TrangthaiNoitru == 0 ? "0" : "1"; cmdNhapVien.Text = objLuotkham.TrangthaiNoitru == 0 ? "Nhập viện" : "Cập nhật"; DataTable m_dtThongTin = _KCB_THAMKHAM.LayThongtinBenhnhanKCB(objLuotkham.MaLuotkham, Utility.Int32Dbnull( objLuotkham.IdBenhnhan, -1), Utility.Int32Dbnull( txt_idchidinhphongkham.Text)); if (m_dtThongTin.Rows.Count > 0) { DataRow dr = m_dtThongTin.Rows[0]; if (dr != null) { dtInput_Date.Value = Convert.ToDateTime(dr[KcbLuotkham.Columns.NgayTiepdon]); txtExam_ID.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham)); txtGioitinh.Text = Utility.sDbnull(grdList.GetValue(KcbDanhsachBenhnhan.Columns.GioiTinh), ""); txt_idchidinhphongkham.Text = Utility.sDbnull(grdList.GetValue(KcbDangkyKcb.Columns.IdKham)); lblSOkham.Text = Utility.sDbnull(grdList.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 = m_strMaLuotkham; txtDiaChi.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiaChi], ""); txtDiachiBHYT.Text = Utility.sDbnull(dr[KcbDanhsachBenhnhan.Columns.DiachiBhyt], ""); txtTrieuChungBD._Text = Utility.sDbnull(dr[KcbLuotkham.Columns.TrieuChung], ""); 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")); txtTuoi.Text = Utility.sDbnull(Utility.Int32Dbnull(globalVariables.SysDate.Year) - objBenhnhan.NgaySinh.Value.Year); ThongBaoBenhAn(txtPatient_ID.Text); if (objkcbdangky != null) { // txtSTTKhamBenh.Text = Utility.sDbnull(objkcbdangky.SoKham); txtReg_ID.Text = Utility.sDbnull(objkcbdangky.IdKham); dtpCreatedDate.Value = Convert.ToDateTime(objkcbdangky.NgayDangky); txtDepartment_ID.Text = Utility.sDbnull(objkcbdangky.IdPhongkham); var _department = new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.IdKhoaphongColumn). IsEqualTo(objkcbdangky.IdPhongkham).ExecuteSingle<DmucKhoaphong>(); if (_department != null) { txtPhongkham.Text = Utility.sDbnull(_department.TenKhoaphong); } txtTenDvuKham.Text = Utility.sDbnull(objkcbdangky.TenDichvuKcb); txtNguoiTiepNhan.Text = Utility.sDbnull(objkcbdangky.NguoiTao); if (Utility.Int16Dbnull(objkcbdangky.IdBacsikham, -1) != -1) { txtBacsi.SetId(Utility.sDbnull(objkcbdangky.IdBacsikham, -1)); } else { txtBacsi.SetId(globalVariables.gv_intIDNhanvien); } chkDaThucHien.Checked = Utility.Int32Dbnull(objkcbdangky.TrangThai) == 1; } _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.SetCode(_KcbChandoanKetluan.HuongDieutri); txtHuongdieutri._Text = _KcbChandoanKetluan.HuongDieutri; txtSongaydieutri.Text = Utility.sDbnull(_KcbChandoanKetluan.SongayDieutri, "0"); txtHa.Text = Utility.sDbnull(_KcbChandoanKetluan.Huyetap); txtTrieuChungBD._Text = Utility.sDbnull(_KcbChandoanKetluan.TrieuchungBandau); 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); txtChieucao.Text = Utility.sDbnull(_KcbChandoanKetluan.Chieucao); txtNhanxet.Text = Utility.sDbnull(_KcbChandoanKetluan.NhanXet); if (!string.IsNullOrEmpty(Utility.sDbnull(_KcbChandoanKetluan.Nhommau)) && Utility.sDbnull(_KcbChandoanKetluan.Nhommau) != "-1") txtNhommau._Text = Utility.sDbnull(_KcbChandoanKetluan.Nhommau); 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; dt_ICD_PHU.Clear(); if (!string.IsNullOrEmpty(dataString)) { string[] rows = dataString.Split(','); foreach (string row in rows) { if (!string.IsNullOrEmpty(row)) { DataRow newDr = dt_ICD_PHU.NewRow(); newDr[DmucBenh.Columns.MaBenh] = row; newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row); dt_ICD_PHU.Rows.Add(newDr); dt_ICD_PHU.AcceptChanges(); } } grd_ICD.DataSource = dt_ICD_PHU; } } Laythongtinchidinhngoaitru(); } } //cmdKETTHUC.Visible = objLuotkham.Locked == 0 && objkcbdangky.TrangThai > 0; cmdInTTDieuTri.Visible = cmdInphieuhen.Visible = objkcbdangky.TrangThai != 0 && objLuotkham.TrangthaiNoitru == 0; cboChonBenhAn.Visible = objkcbdangky.TrangThai != 0 && THU_VIEN_CHUNG.Laygiatrithamsohethong("BENH_AN", "0", true) == "1" && objLuotkham.TrangthaiNoitru == 0; lblBenhan.Visible = cboChonBenhAn.Visible; // cmdBenhAnNgoaiTru.Visible = objkcbdangky.TrangThai != 0; cmdKETTHUC.Enabled = true; } else { ClearControl(); cmdKETTHUC.Enabled = false; } } } catch (Exception ex) { Utility.ShowMsg("Lỗi:" + ex.Message); } finally { ModifyCommmands(); KiemTraDaInPhoiBHYT(); getResult(); } }
public ActionResult ThemmoiLuotkham(KcbDanhsachBenhnhan objKcbDanhsachBenhnhan, KcbLuotkham objLuotkham, KcbDangkyKcb objKcbDangkyKcb, int KieuKham) { try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { UpdatePatientInfo(objKcbDanhsachBenhnhan); SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham); if (sqlQueryPatientExam.GetRecordCount() > 0)//Nếu BN khác đã lấy mã này { objLuotkham.MaLuotkham = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM(); } objLuotkham.IsNew = true; objLuotkham.Save(); new Update(KcbDmucLuotkham.Schema) .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(2) .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(DateTime.Now) .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDmucLuotkham.Columns.TrangThai).IsLessThanOrEqualTo(1) .And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year) .And(KcbDmucLuotkham.Columns.UsedBy).IsLessThanOrEqualTo(globalVariables.UserName) .Execute(); ; if (objKcbDangkyKcb != null) { objKcbDangkyKcb.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objKcbDangkyKcb.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); AddRegExam(objKcbDangkyKcb,objLuotkham, false, KieuKham); } scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { return ActionResult.Error; } }
private void SearchPatient() { try { ClearControl(); m_strMaLuotkham = ""; objkcbdangky = null; objBenhnhan = null; objLuotkham = null; if (dt_ICD_PHU != null) dt_ICD_PHU.Clear(); if (m_dtAssignDetail != null) m_dtAssignDetail.Clear(); if (m_dtPresDetail != null) m_dtPresDetail.Clear(); DateTime dt_FormDate = dtFromDate.Value; DateTime dt_ToDate = dtToDate.Value; int Status = -1; int SoKham = -1; if (!string.IsNullOrEmpty(txtSoKham.Text)) { SoKham = Utility.Int32Dbnull(txtSoKham.Text, -1); Status = -1; } else { Status = radChuaKham.Checked ? 0 : 1; } m_dtDanhsachbenhnhanthamkham = _KCB_THAMKHAM.LayDSachBnhanThamkham( !chkByDate.Checked ? globalVariables.SysDate.AddDays(-7) : dt_FormDate, !chkByDate.Checked ? globalVariables.SysDate : dt_ToDate, txtTenBN.Text, Status, SoKham, Utility.Int32Dbnull(cboPhongKhamNgoaiTru.SelectedValue, -1), globalVariables.MA_KHOA_THIEN); if (!m_dtDanhsachbenhnhanthamkham.Columns.Contains("MAUSAC")) m_dtDanhsachbenhnhanthamkham.Columns.Add("MAUSAC", typeof (int)); Utility.SetDataSourceForDataGridEx_Basic(grdList, m_dtDanhsachbenhnhanthamkham, true, true, "", KcbDangkyKcb.Columns.SttKham); //"locked=0", ""); if (!dt_ICD_PHU.Columns.Contains(DmucBenh.Columns.MaBenh)) { dt_ICD_PHU.Columns.Add(DmucBenh.Columns.MaBenh, typeof (string)); } if (!dt_ICD_PHU.Columns.Contains(DmucBenh.Columns.TenBenh)) { dt_ICD_PHU.Columns.Add(DmucBenh.Columns.TenBenh, typeof (string)); } grd_ICD.DataSource = dt_ICD_PHU; cmdUnlock.Visible = false; ModifyCommmands(); } catch (Exception ex) { Utility.CatchException(ex); } }
/// <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 txtPatient_Code_KeyDown(object sender, KeyEventArgs e) { try { var dtPatient = new DataTable(); if (e.KeyCode == Keys.Enter) { Utility.FreeLockObject(m_strMaLuotkham); string _patient_Code = Utility.AutoFullPatientCode(txtPatient_Code.Text); ClearControl(); txtPatient_Code.Text = _patient_Code; if (grdList.RowCount > 0 && PropertyLib._ThamKhamProperties.Timtrenluoi) { DataRow[] arrData_tempt = null; arrData_tempt = m_dtDanhsachbenhnhanthamkham.Select(KcbLuotkham.Columns.MaLuotkham + "='" + _patient_Code + "'"); if (arrData_tempt.Length > 0) { string _status = radChuaKham.Checked ? "0" : "1"; string regStatus = Utility.sDbnull(arrData_tempt[0][KcbDangkyKcb.Columns.TrangThai], "0"); if (_status != regStatus) { if (regStatus == "1") radDaKham.Checked = true; else radChuaKham.Checked = true; } Utility.GotoNewRowJanus(grdList, KcbLuotkham.Columns.MaLuotkham, _patient_Code); if (Utility.isValidGrid(grdList)) grdList_DoubleClick(grdList, new EventArgs()); return; } } dtPatient = _KCB_THAMKHAM.TimkiemBenhnhan(txtPatient_Code.Text, Utility.Int32Dbnull(cboPhongKhamNgoaiTru.SelectedValue, -1), 0, 0); DataRow[] arrPatients = dtPatient.Select(KcbLuotkham.Columns.MaLuotkham + "='" + _patient_Code + "'"); if (arrPatients.GetLength(0) <= 0) { if (dtPatient.Rows.Count > 1) { var frm = new frm_DSACH_BN_TKIEM(); frm.MaLuotkham = txtPatient_Code.Text; frm.dtPatient = dtPatient; frm.ShowDialog(); if (!frm.has_Cancel) { txtPatient_Code.Text = frm.MaLuotkham; } } } else { txtPatient_Code.Text = _patient_Code; } DataTable dt_Patient = _KCB_THAMKHAM.TimkiemThongtinBenhnhansaukhigoMaBN (txtPatient_Code.Text, Utility.Int32Dbnull(cboPhongKhamNgoaiTru.SelectedValue, -1), globalVariables.MA_KHOA_THIEN); grdList.DataSource = null; grdList.DataSource = dt_Patient; if (dt_Patient.Rows.Count > 0) { grdList.MoveToRowIndex(0); grdList.CurrentRow.BeginEdit(); grdList.CurrentRow.Cells["MAUSAC"].Value = 1; grdList.CurrentRow.EndEdit(); if (dt_ICD_PHU != null) dt_ICD_PHU.Rows.Clear(); GetData(); txtPatient_Code.SelectAll(); } else { string sPatientTemp = txtPatient_Code.Text; m_strMaLuotkham = ""; objLuotkham = null; objkcbdangky = null; objBenhnhan = null; ClearControl(); txtPatient_Code.Text = sPatientTemp; txtPatient_Code.SelectAll(); //Utility.SetMsg(lblMsg, "Không tìm thấy bệnh nhân có mã lần khám đang chọn",true); } txtMach.SelectAll(); } } catch (Exception) { Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin bệnh nhân"); } finally { ModifyCommmands(); } }
public ActionResult UpdateLanKham(KcbDanhsachBenhnhan objPatientInfo, KcbLuotkham objLuotkham, KcbDangkyKcb objRegExam, int KieuKham, decimal PtramBhytCu, decimal PtramBhytgoc ) { ActionResult _ActionResult = ActionResult.Success; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { SqlQuery query = new Select().From(KcbLuotkham.Schema).Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo( objLuotkham.MaLuotkham).And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo( objLuotkham.IdBenhnhan); KcbLuotkham objExam = query.ExecuteSingle<KcbLuotkham>(); UpdatePatientInfo(objPatientInfo); //decimal PtramBHYT = THU_VIEN_CHUNG.TinhPtramBHYT(objLuotkham); //if (PtramBHYT != Utility.DecimaltoDbnull(objLuotkham.PtramBhyt)) //{ // objLuotkham.PtramBhyt = PtramBHYT; //} objLuotkham.MarkOld(); objLuotkham.IsNew = false; objLuotkham.Save(); //int recordExam = new Update(KcbLuotkham.Schema) // .Set(KcbLuotkham.Columns.NguoiLienhe).EqualTo(objLuotkham.NguoiLienhe) // .Set(KcbLuotkham.Columns.TrangthaiCapcuu).EqualTo(objLuotkham.TrangthaiCapcuu) // .Set(KcbLuotkham.Columns.LuongCoban).EqualTo(objLuotkham.LuongCoban) // .Set(KcbLuotkham.Columns.TthaiChuyendi).EqualTo(objLuotkham.TthaiChuyendi) // .Set(KcbLuotkham.Columns.DienthoaiLienhe).EqualTo(objLuotkham.DienthoaiLienhe) // .Set(KcbLuotkham.Columns.DiachiLienhe).EqualTo(objLuotkham.DiachiLienhe) // .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objLuotkham.TrieuChung) // .Set(KcbLuotkham.Columns.MatheBhyt).EqualTo(objLuotkham.MatheBhyt) // .Set(KcbLuotkham.Columns.MaNoicapBhyt).EqualTo(objLuotkham.MaNoicapBhyt) // .Set(KcbLuotkham.Columns.MaQuyenloi).EqualTo(objLuotkham.MaQuyenloi) // .Set(KcbLuotkham.Columns.NgaybatdauBhyt).EqualTo(objLuotkham.NgaybatdauBhyt) // .Set(KcbLuotkham.Columns.NgayketthucBhyt).EqualTo(objLuotkham.NgayketthucBhyt) // .Set(KcbLuotkham.Columns.NoicapBhyt).EqualTo(objLuotkham.NoicapBhyt) // .Set(KcbLuotkham.Columns.IdDoituongKcb).EqualTo(objLuotkham.IdDoituongKcb) // .Set(KcbLuotkham.Columns.IdLoaidoituongKcb).EqualTo(objLuotkham.IdLoaidoituongKcb) // .Set(KcbLuotkham.Columns.TrangthaiNgoaitru).EqualTo(objLuotkham.TrangthaiNgoaitru) // .Set(KcbLuotkham.Columns.MaKcbbd).EqualTo(objLuotkham.MaKcbbd) // .Set(KcbLuotkham.Columns.NoiDongtrusoKcbbd).EqualTo(objLuotkham.NoiDongtrusoKcbbd) // .Set(KcbLuotkham.Columns.MaDoituongBhyt).EqualTo(objLuotkham.MaDoituongBhyt) // .Set(KcbLuotkham.Columns.IdKhoatiepnhan).EqualTo(objLuotkham.IdKhoatiepnhan) // .Set(KcbLuotkham.Columns.DungTuyen).EqualTo(objLuotkham.DungTuyen) // .Set(KcbLuotkham.Columns.NgayTiepdon).EqualTo(objLuotkham.NgayTiepdon) // .Set(KcbLuotkham.Columns.MaDoituongKcb).EqualTo(objLuotkham.MaDoituongKcb) // .Set(KcbLuotkham.Columns.MaKhoaThuchien).EqualTo(objLuotkham.MaKhoaThuchien) // .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName) // .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate) // .Set(KcbLuotkham.Columns.PtramBhyt).EqualTo(objLuotkham.PtramBhyt) // .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(objLuotkham.SoBenhAn) // .Set(KcbLuotkham.Columns.DiaChi).EqualTo(objLuotkham.DiaChi) // .Set(KcbLuotkham.Columns.DiachiBhyt).EqualTo(objLuotkham.DiachiBhyt) // .Set(KcbLuotkham.Columns.Cmt).EqualTo(objLuotkham.Cmt) // .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) // .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) // .Execute(); //Kiểm tra nếu % bị thay đổi thì cập nhật lại tất cả các bảng if (PtramBhytCu != Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) || PtramBhytgoc != Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0)) _ActionResult= THU_VIEN_CHUNG.UpdatePtramBHYT(objLuotkham, -1); if (_ActionResult == ActionResult.Cancel)//Báo không cho phép thay đổi phần trăm BHYT do đã có dịch vụ đã thanh toán { return _ActionResult; } if (objRegExam != null) { objRegExam.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objRegExam.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); AddRegExam(objRegExam,objLuotkham, false, KieuKham); } scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { log.Error("Loi trong qua trinh update thong tin benh nhan {0}", ex); return ActionResult.Error; } }
private void SearchPatient() { try { ClearControl(); malankham = ""; objkcbdangky = null; objBenhnhan = null; objLuotkham = null; if (dt_ICD_PHU != null) dt_ICD_PHU.Clear(); if (m_dtAssignDetail != null) m_dtAssignDetail.Clear(); if (m_dtPresDetail != null) m_dtPresDetail.Clear(); DateTime dt_FormDate = dtFromDate.Value; DateTime dt_ToDate = dtToDate.Value; m_dtDanhsachbenhnhanthamkham = _KCB_THAMKHAM.KcbLichsuKcbTimkiemBenhnhan(!chkByDate.Checked ? "01/01/1900" : dt_FormDate.ToString("dd/MM/yyyy"), !chkByDate.Checked ? "01/01/1900" : dt_ToDate.ToString("dd/MM/yyyy"), Utility.DoTrim(txtmaluotkham.Text), Utility.Int32Dbnull(txtIdBenhnhan.Text,-1), Utility.DoTrim(txtTenBN.Text),Utility.DoTrim(txtTheBHYT.Text),Utility.Int32Dbnull(txtBacsikham.MyID,-1)); Utility.SetDataSourceForDataGridEx_Basic(grdList, m_dtDanhsachbenhnhanthamkham, true, true, "", KcbDanhsachBenhnhan.Columns.TenBenhnhan); if (!dt_ICD_PHU.Columns.Contains(DmucBenh.Columns.MaBenh)) { dt_ICD_PHU.Columns.Add(DmucBenh.Columns.MaBenh, typeof(string)); } if (!dt_ICD_PHU.Columns.Contains(DmucBenh.Columns.TenBenh)) { dt_ICD_PHU.Columns.Add(DmucBenh.Columns.TenBenh, typeof(string)); } grd_ICD.DataSource = dt_ICD_PHU; grdList.MoveFirst(); } catch(Exception ex) { Utility.CatchException(ex); } }
public ActionResult InsertRegExam(KcbDangkyKcb objRegExam,KcbLuotkham objLuotkham, ref int v_RegId, int KieuKham) { bool b_HasLoaded = false; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { v_RegId = AddRegExam(objRegExam,objLuotkham,b_HasLoaded, KieuKham); } scope.Complete(); return ActionResult.Success; } } catch (Exception ex) { log.Error(ex.ToString); return ActionResult.Error; } }
/// <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 Patient_ID = 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(Patient_ID).ExecuteSingle<KcbLuotkham>(); objBenhnhan = KcbDanhsachBenhnhan.FetchByID(objLuotkham.IdBenhnhan); isRoom = false; if (objLuotkham != null) { ClearControl(); txt_idchidinhphongkham.Text = Utility.sDbnull(grdRegExam.GetValue(KcbDangkyKcb.Columns.IdKham)); objkcbdangky = KcbDangkyKcb.FetchByID(Utility.Int32Dbnull(txt_idchidinhphongkham.Text)); DmucNhanvien objStaff = new Select().From(DmucNhanvien.Schema).Where(DmucNhanvien.UserNameColumn).IsEqualTo(Utility.sDbnull(objLuotkham.NguoiKetthuc, "")).ExecuteSingle<DmucNhanvien>(); string TenNhanvien = objLuotkham.NguoiKetthuc; if (objStaff != null) TenNhanvien = objStaff.TenNhanvien; if (objkcbdangky != null) { DataTable m_dtThongTin = _KCB_THAMKHAM.LayThongtinBenhnhanKCB(objLuotkham.MaLuotkham, Utility.Int32Dbnull(objLuotkham.IdBenhnhan, -1), Utility.Int32Dbnull(txt_idchidinhphongkham.Text)); if (m_dtThongTin.Rows.Count > 0) { DataRow dr = m_dtThongTin.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")); Exam_ID = 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")); 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); DmucKhoaphong _department = new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.IdKhoaphongColumn).IsEqualTo(objkcbdangky.IdPhongkham).ExecuteSingle<DmucKhoaphong>(); if (_department != null) { txtPhongkham.Text = Utility.sDbnull(_department.TenKhoaphong); } 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) { } } _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); 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; dt_ICD_PHU.Clear(); if (!string.IsNullOrEmpty(dataString)) { string[] rows = dataString.Split(','); foreach (string row in rows) { if (!string.IsNullOrEmpty(row)) { DataRow newDr = dt_ICD_PHU.NewRow(); newDr[DmucBenh.Columns.MaBenh] = row; newDr[DmucBenh.Columns.TenBenh] = GetTenBenh(row); dt_ICD_PHU.Rows.Add(newDr); dt_ICD_PHU.AcceptChanges(); } } grd_ICD.DataSource = dt_ICD_PHU; } } GetDataChiDinh(); } } } else { ClearControl(); } } } catch { } finally { KiemTraDaInPhoiBHYT(); getResult(); } }
public ActionResult ThemLankhamMoi(KcbDanhsachBenhnhan objPatientInfo, KcbLuotkham objLuotkham, KcbDangkyKcb objRegExam, int KieuKham,ref long id_kham) { int v_IdBenhnhan = -1; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { objPatientInfo.IsNew = true; objPatientInfo.Save(); //Thêm lần khám objLuotkham.IdBenhnhan = objPatientInfo.IdBenhnhan; objLuotkham.SoBenhAn = string.Empty; //Tạm bỏ đoạn này //decimal PtramBHYT = THU_VIEN_CHUNG.TinhPtramBHYT(objLuotkham); //if (PtramBHYT != Utility.DecimaltoDbnull(objLuotkham.PtramBhyt)) //{ // log.Info(string.Format("voi benh nhan :{0} va MaLuotkham:{1} ", objPatientInfo.TenBenhnhan, objLuotkham.MaLuotkham)); // log.Info( // string.Format( // "truong hop phan tram tinh toan sai void ptramBHYT:{0} va truyen tu ngoai vao :{1} ", // PtramBHYT, objLuotkham.PtramBhyt)); // objLuotkham.PtramBhyt = PtramBHYT; //} objLuotkham.SttKham = THU_VIEN_CHUNG.LaySTTKhamTheoDoituong(objLuotkham.IdDoituongKcb); objLuotkham.NgayTao = globalVariables.SysDate; objLuotkham.NguoiTao = globalVariables.UserName; objLuotkham.IsNew = true; objLuotkham.Save(); SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham); if (sqlQueryPatientExam.GetRecordCount() > 0) { string patientCode = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM(); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.MaLuotkham).EqualTo(patientCode) .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham).Execute(); objLuotkham.MaLuotkham = patientCode; } //Đoạn này Rem lại vì ko có ý nghĩa ngoại trú //if (objLuotkham.TrangThai >= 1) //{ // SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema).Where( // KcbLuotkham.Columns.MaLuotkham).IsNotEqualTo(objLuotkham.MaLuotkham) // .And(KcbLuotkham.Columns.SoBenhAn).IsEqualTo(objLuotkham.SoBenhAn) // .And(KcbLuotkham.Columns.TrangThai).IsGreaterThanOrEqualTo(1); // if (sqlQuery.GetRecordCount() > 0) // { // new Update(KcbLuotkham.Schema) // .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(THU_VIEN_CHUNG.LaySoBenhAn()) // .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham). // Execute(); // } //} if (objRegExam != null)//Đôi lúc người dùng không chọn phòng khám { objRegExam.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objRegExam.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); id_kham = AddRegExam(objRegExam, objLuotkham, false, KieuKham); } scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { log.Error("loi trong qua trinh cap nhap thong tin them moi thong tin benh nhan tiep don {0}", ex); return ActionResult.Error; } }
/// <summary> /// hàm thực hiện việc update thông tin xác nhận gói /// </summary> /// <param name="objThongtinGoiDvuBnhan"></param> /// <returns></returns> public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam, KcbLuotkham objPatientExam) { try { using (var scope = new TransactionScope()) { using (var sh = new SharedDbConnectionScope()) { if (objDiagInfo.IsNew) { objDiagInfo.Save(); } else { objDiagInfo.MarkOld(); objDiagInfo.Save(); } SqlQuery sqlQuery = new Select().From( KcbChandoanKetluan.Schema) .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).OrderAsc( KcbChandoanKetluan.Columns.NgayChandoan); KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>(); var query = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.Chandoan) where (y != "") select y).ToArray(); string cdchinh = string.Join(";", query); //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>(); var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.ChandoanKemtheo) where (y != "") select y).ToArray(); string cdphu = string.Join(";", querychandoanphu); var querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhchinh.MabenhChinh) where (y != "") select y).ToArray(); string mabenhchinh = string.Join(";", querybenhchinh); var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhphu.MabenhPhu) where (y != "") select y).ToArray(); string mabenhphu = string.Join(";", querybenhphu); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh) .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu) .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh) .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu) .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung) .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate) .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked) .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc) .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc) .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute(); //Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận //SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham, // Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1), // Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute(); if (objRegExam != null) { new Update(KcbDangkyKcb.Schema) .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate) .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName) //.Set(KcbDangkyKcb.Columns.IpMacSua).EqualTo(BusinessHelper.GetMACAddress()) //.Set(KcbDangkyKcb.Columns.IpMaySua).EqualTo(BusinessHelper.GetIP4Address()) .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham) .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai) .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)). Execute(); } } scope.Complete(); // Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1); return(ActionResult.Success); } } catch (Exception exception) { log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception); return(ActionResult.Error); } }
public void Insert(long IdBenhnhan,string MaLuotkham,string MadoituongGia,decimal DonGia,decimal? PtramBhytGoc,decimal? PtramBhyt,decimal? BhytChitra,decimal? BnhanChitra,DateTime? NgayDangky,DateTime? NgayTiepdon,decimal? PhuThu,short? IdPhongkham,short? IdBacsikham,byte TrangthaiThanhtoan,int? IdThanhtoan,DateTime? NgayThanhtoan,string NguoiThanhtoan,byte? TrangthaiIn,byte? TrangThai,byte? TrangthaiHuy,short? SttKham,short? IdDichvuKcb,string TenDichvuKcb,byte? Noitru,string MaKhoaThuchien,byte? TuTuc,byte? KhamNgoaigio,string MaPhongStt,long? IdCha,byte? LaPhidichvukemtheo,string MaDoituongkcb,short? IdDoituongkcb,byte? IdLoaidoituongkcb,short? IdKhoakcb,string NhomBaocao,string NguoiChuyen,DateTime? NgayChuyen,string LydoChuyen,byte? TrangthaiChuyen,int? IdKieukham,decimal? TileChietkhau,decimal? TienChietkhau,string KieuChietkhau,int? IdGoi,byte? TrongGoi,string NguoiTao,DateTime? NgaySua,string NguoiSua,string IpMaytao,string IpMaysua,string TenMaytao,string TenMaysua) { KcbDangkyKcb item = new KcbDangkyKcb(); item.IdBenhnhan = IdBenhnhan; item.MaLuotkham = MaLuotkham; item.MadoituongGia = MadoituongGia; item.DonGia = DonGia; item.PtramBhytGoc = PtramBhytGoc; item.PtramBhyt = PtramBhyt; item.BhytChitra = BhytChitra; item.BnhanChitra = BnhanChitra; item.NgayDangky = NgayDangky; item.NgayTiepdon = NgayTiepdon; item.PhuThu = PhuThu; item.IdPhongkham = IdPhongkham; item.IdBacsikham = IdBacsikham; item.TrangthaiThanhtoan = TrangthaiThanhtoan; item.IdThanhtoan = IdThanhtoan; item.NgayThanhtoan = NgayThanhtoan; item.NguoiThanhtoan = NguoiThanhtoan; item.TrangthaiIn = TrangthaiIn; item.TrangThai = TrangThai; item.TrangthaiHuy = TrangthaiHuy; item.SttKham = SttKham; item.IdDichvuKcb = IdDichvuKcb; item.TenDichvuKcb = TenDichvuKcb; item.Noitru = Noitru; item.MaKhoaThuchien = MaKhoaThuchien; item.TuTuc = TuTuc; item.KhamNgoaigio = KhamNgoaigio; item.MaPhongStt = MaPhongStt; item.IdCha = IdCha; item.LaPhidichvukemtheo = LaPhidichvukemtheo; item.MaDoituongkcb = MaDoituongkcb; item.IdDoituongkcb = IdDoituongkcb; item.IdLoaidoituongkcb = IdLoaidoituongkcb; item.IdKhoakcb = IdKhoakcb; item.NhomBaocao = NhomBaocao; item.NguoiChuyen = NguoiChuyen; item.NgayChuyen = NgayChuyen; item.LydoChuyen = LydoChuyen; item.TrangthaiChuyen = TrangthaiChuyen; item.IdKieukham = IdKieukham; item.TileChietkhau = TileChietkhau; item.TienChietkhau = TienChietkhau; item.KieuChietkhau = KieuChietkhau; item.IdGoi = IdGoi; item.TrongGoi = TrongGoi; item.NguoiTao = NguoiTao; item.NgaySua = NgaySua; item.NguoiSua = NguoiSua; item.IpMaytao = IpMaytao; item.IpMaysua = IpMaysua; item.TenMaytao = TenMaytao; item.TenMaysua = TenMaysua; item.Save(UserName); }
/// <summary> /// hàm thực hiện việc update thông tin xác nhận gói /// </summary> /// <param name="objThongtinGoiDvuBnhan"></param> /// <returns></returns> public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam, KcbLuotkham objPatientExam) { try { using (var scope = new TransactionScope()) { using (var sh = new SharedDbConnectionScope()) { if (objDiagInfo.IsNew) { objDiagInfo.Save(); } else { objDiagInfo.MarkOld(); objDiagInfo.Save(); } SqlQuery sqlQuery = new Select().From( KcbChandoanKetluan.Schema) .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).OrderAsc( KcbChandoanKetluan.Columns.NgayChandoan); KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>(); var query = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.Chandoan) where (y != "") select y).ToArray(); string cdchinh = string.Join(";", query); //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>(); var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(chandoan.ChandoanKemtheo) where (y != "") select y).ToArray(); string cdphu = string.Join(";", querychandoanphu); var querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhchinh.MabenhChinh) where (y != "") select y).ToArray(); string mabenhchinh = string.Join(";", querybenhchinh); var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable() let y = Utility.sDbnull(benhphu.MabenhPhu) where (y != "") select y).ToArray(); string mabenhphu = string.Join(";", querybenhphu); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh) .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu) .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh) .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu) .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung) .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate) .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked) .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc) .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc) .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham) .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute(); //Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận //SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham, // Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1), // Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute(); if (objRegExam != null) { new Update(KcbDangkyKcb.Schema) .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate) .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(KcbDangkyKcb.Columns.IpMaysua).EqualTo(globalVariables.gv_strIPAddress) .Set(KcbDangkyKcb.Columns.TenMaysua).EqualTo(globalVariables.gv_strComputerName) .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham) .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai) .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)). Execute(); } } scope.Complete(); // Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1); return ActionResult.Success; } } catch (Exception exception) { log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception); return ActionResult.Error; } }
private KcbDangkyKcb CreateNewRegExam() { bool b_HasKham = false; EnumerableRowCollection<DataRow> query = from phong in m_dataDataRegExam.AsEnumerable().Cast<DataRow>() where Utility.Int32Dbnull(phong[KcbDangkyKcb.Columns.IdDichvuKcb], -100) == Utility.Int32Dbnull(cboKieuKham.Value, -1) select phong; if (query.Count() > 0) { Utility.ShowMsg("Bệnh nhân đã đăng ký dịch vụ khám này. Đề nghị bạn xem lại"); b_HasKham = true; } else { b_HasKham = false; } if (!b_HasKham) { var objRegExam = new KcbDangkyKcb(); DmucDichvukcb objDichvuKCB = DmucDichvukcb.FetchByID(Utility.Int32Dbnull(cboKieuKham.Value)); objDoituongKCB = new Select().From(DmucDoituongkcb.Schema).Where(DmucDoituongkcb.MaDoituongKcbColumn).IsEqualTo(_MaDoituongKcb).ExecuteSingle<DmucDoituongkcb>(); DmucKhoaphong objdepartment = new Select().From(DmucKhoaphong.Schema).Where(DmucKhoaphong.IdKhoaphongColumn).IsEqualTo(Utility.Int16Dbnull(txtIDPkham.Text, -1)).ExecuteSingle<DmucKhoaphong>(); if (objDichvuKCB != null) { objRegExam.IdDichvuKcb = Utility.Int16Dbnull(objDichvuKCB.IdDichvukcb, -1); objRegExam.IdKieukham = objDichvuKCB.IdKieukham; objRegExam.NhomBaocao = objDichvuKCB.NhomBaocao; objRegExam.DonGia = Utility.DecimaltoDbnull(objDichvuKCB.DonGia, 0); objRegExam.NguoiTao = globalVariables.UserName; objRegExam.LaPhidichvukemtheo = 0; objRegExam.IdCha = -1; if (objdepartment != null) { objRegExam.IdKhoakcb = objdepartment.IdKhoaphong; objRegExam.MaPhongStt = objdepartment.MaPhongStt; } if (objDoituongKCB != null) { objRegExam.IdLoaidoituongkcb = objDoituongKCB.IdLoaidoituongKcb; objRegExam.MaDoituongkcb = objDoituongKCB.MaDoituongKcb; objRegExam.IdDoituongkcb = objDoituongKCB.IdDoituongKcb; } if (Utility.Int16Dbnull(objDichvuKCB.IdPhongkham, -1) > -1) objRegExam.IdPhongkham = Utility.Int16Dbnull(objDichvuKCB.IdPhongkham, -1); else objRegExam.IdPhongkham = Utility.Int16Dbnull(txtIDPkham.Text, -1); if (Utility.Int32Dbnull(objDichvuKCB.IdBacsy) > 0) objRegExam.IdBacsikham = Utility.Int16Dbnull(objDichvuKCB.IdBacsy); else { objRegExam.IdBacsikham = globalVariables.gv_intIDNhanvien; } objRegExam.PhuThu = !chkTraiTuyen.Checked ? Utility.DecimaltoDbnull(objDichvuKCB.PhuthuDungtuyen) : Utility.DecimaltoDbnull(objDichvuKCB.PhuthuTraituyen); objRegExam.NgayDangky = globalVariables.SysDate; objRegExam.IdBenhnhan = Utility.Int32Dbnull(txtMaBN.Text, -1); objRegExam.TrangthaiThanhtoan = 0; objRegExam.TrangthaiHuy = 0; objRegExam.Noitru = 0; objRegExam.TrangthaiIn = 0; objRegExam.IpMaytao = globalVariables.gv_strIPAddress; objRegExam.TenMaytao = globalVariables.gv_strComputerName; objRegExam.TuTuc =Utility.ByteDbnull( objDichvuKCB.TuTuc,0); if (pnlBHYT.Enabled && chkTraiTuyen.Checked && THU_VIEN_CHUNG.Laygiatrithamsohethong("BHYT_TRAITUYENNGOAITRU_GIADICHVU", false) == "1") objRegExam.TuTuc = 1; objRegExam.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN; objRegExam.TenDichvuKcb = cboKieuKham.Text; objRegExam.NgayTiepdon = globalVariables.SysDate; objRegExam.MaLuotkham = Utility.sDbnull(txtMaLankham.Text, ""); //Bỏ đi do sinh lại ở mục business if (THU_VIEN_CHUNG.IsNgoaiGio()) { objRegExam.KhamNgoaigio = 1; objRegExam.DonGia = Utility.DecimaltoDbnull(objDichvuKCB.DongiaNgoaigio, 0); objRegExam.PhuThu = chkTraiTuyen.Checked ? Utility.DecimaltoDbnull(objDichvuKCB.PhuthuNgoaigio, 0) : Utility.DecimaltoDbnull(objDichvuKCB.PhuthuDungtuyen); } else { objRegExam.KhamNgoaigio = 0; } } else { objRegExam = null; } return objRegExam; } return null; }
public ActionResult UpdateLanKham(SysTrace mytrace, KcbDanhsachBenhnhan objKcbDanhsachBenhnhan, KcbLuotkham objLuotkham, KcbDangkyKcb objKcbDangkyKcb, KcbDangkySokham objSoKCB, int KieuKham, decimal PtramBhytCu, decimal PtramBhytgoc, ref string Msg) { ActionResult _ActionResult = ActionResult.Success; try { using (var scope = new TransactionScope()) { using (var dbscope = new SharedDbConnectionScope()) { UpdatePatientInfo(objKcbDanhsachBenhnhan); long IdLichsuDoituongKcb = KcbLayIdDoituongKCBHientai(objLuotkham.IdBenhnhan, objLuotkham.MaLuotkham); KcbLichsuDoituongKcb objLichsuKcb = null; if (IdLichsuDoituongKcb > 0) { objLichsuKcb = KcbLichsuDoituongKcb.FetchByID(IdLichsuDoituongKcb); objLichsuKcb.MarkOld(); objLichsuKcb.IsNew = false; } else { objLichsuKcb = new KcbLichsuDoituongKcb(); objLichsuKcb.IsNew = true; } if (objLichsuKcb == null) { Msg = "NULL-->Không lấy được thông tin lịch sử đối tượng KCB của Bệnh nhân"; return ActionResult.Error; } objLichsuKcb.IdBenhnhan = objLuotkham.IdBenhnhan; objLichsuKcb.MaLuotkham = objLuotkham.MaLuotkham; objLichsuKcb.NgayHieuluc = objLuotkham.NgayTiepdon; objLichsuKcb.IdDoituongKcb = objLuotkham.IdDoituongKcb; objLichsuKcb.MaDoituongKcb = objLuotkham.MaDoituongKcb; objLichsuKcb.IdLoaidoituongKcb = objLuotkham.IdLoaidoituongKcb; objLichsuKcb.MatheBhyt = objLuotkham.MatheBhyt; objLichsuKcb.PtramBhyt = objLuotkham.PtramBhyt; objLichsuKcb.PtramBhytGoc = objLuotkham.PtramBhytGoc; objLichsuKcb.NgaybatdauBhyt = objLuotkham.NgaybatdauBhyt; objLichsuKcb.NgayketthucBhyt = objLuotkham.NgayketthucBhyt; objLichsuKcb.NoicapBhyt = objLuotkham.NoicapBhyt; objLichsuKcb.MaNoicapBhyt = objLuotkham.MaNoicapBhyt; objLichsuKcb.MaDoituongBhyt = objLuotkham.MaDoituongBhyt; objLichsuKcb.MaQuyenloi = objLuotkham.MaQuyenloi; objLichsuKcb.NoiDongtrusoKcbbd = objLuotkham.NoiDongtrusoKcbbd; objLichsuKcb.MaKcbbd = objLuotkham.MaKcbbd; objLichsuKcb.TrangthaiNoitru = 0; objLichsuKcb.DungTuyen = objLuotkham.DungTuyen; objLichsuKcb.Cmt = objLuotkham.Cmt; objLichsuKcb.IdRavien = -1; objLichsuKcb.IdBuong = -1; objLichsuKcb.IdGiuong = -1; objLichsuKcb.IdKhoanoitru = -1; objLichsuKcb.NguoiTao = globalVariables.UserName; objLichsuKcb.NgayTao = globalVariables.SysDate; objLichsuKcb.Save(); objLuotkham.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; objLuotkham.MarkOld(); objLuotkham.IsNew = false; objLuotkham.Save(); if (objSoKCB != null) { //Kiểm tra xem có sổ KCB hay chưa objSoKCB.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objSoKCB.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); KcbDangkySokham _temp = new Select().From(KcbDangkySokham.Schema).Where(KcbDangkySokham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbDangkySokham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .ExecuteSingle<KcbDangkySokham>(); if (_temp == null) { objSoKCB.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; objSoKCB.NgayTao = globalVariables.SysDate; objSoKCB.NguoiTao = globalVariables.UserName; objSoKCB.IsNew = true; objSoKCB.Save(); } else { if (Utility.Int64Dbnull(_temp.IdThanhtoan, 0) > 0)//Ko làm gì cả { Msg = "Đã thu tiền sổ khám của Bệnh nhân nên không được phép xóa hoặc cập nhật lại"; } else//Update lại sổ KCB { _temp.DonGia = objSoKCB.DonGia; _temp.BnhanChitra = objSoKCB.BnhanChitra; _temp.BhytChitra = objSoKCB.BhytChitra; _temp.PtramBhyt = objSoKCB.PtramBhyt; _temp.PtramBhytGoc = objSoKCB.PtramBhytGoc; _temp.PhuThu = objSoKCB.PhuThu; _temp.TuTuc = objSoKCB.TuTuc; _temp.NguonThanhtoan = objSoKCB.NguonThanhtoan; _temp.IdLoaidoituongkcb = objSoKCB.IdLoaidoituongkcb; _temp.IdDoituongkcb = objSoKCB.IdDoituongkcb; _temp.MaDoituongkcb = objSoKCB.MaDoituongkcb; _temp.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; _temp.Noitru = objSoKCB.Noitru; _temp.IdGoi = objSoKCB.IdGoi; _temp.TrongGoi = objSoKCB.TrongGoi; _temp.IdNhanvien = objSoKCB.IdNhanvien; _temp.NgaySua = globalVariables.SysDate; _temp.NguoiSua = globalVariables.UserName; _temp.IsNew = false; _temp.MarkOld(); _temp.Save(); } } } else { new Delete().From(KcbDangkySokham.Schema).Where(KcbDangkySokham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(KcbDangkySokham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbDangkySokham.Columns.TrangthaiThanhtoan).IsEqualTo(0) .Execute(); } //Kiểm tra nếu % bị thay đổi thì cập nhật lại tất cả các bảng if (PtramBhytCu != Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0) || PtramBhytgoc != Utility.DecimaltoDbnull(objLuotkham.PtramBhytGoc, 0)) _ActionResult = THU_VIEN_CHUNG.UpdatePtramBHYT(objLuotkham, -1); if (_ActionResult == ActionResult.Cancel)//Báo không cho phép thay đổi phần trăm BHYT do đã có dịch vụ đã thanh toán { return _ActionResult; } if (objKcbDangkyKcb != null) { objKcbDangkyKcb.IdLichsuDoituongKcb = objLichsuKcb.IdLichsuDoituongKcb; objKcbDangkyKcb.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham); objKcbDangkyKcb.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan); AddRegExam(objKcbDangkyKcb, objLuotkham, false, KieuKham); } mytrace.Desc = string.Format("Cập nhật Bệnh nhân ID={0}, Code={1}, Name={2}", objKcbDanhsachBenhnhan.IdBenhnhan.ToString(), objLuotkham.MaLuotkham, objKcbDanhsachBenhnhan.TenBenhnhan); mytrace.Lot = 0; mytrace.IsNew = true; mytrace.Save(); scope.Complete(); return ActionResult.Success; } } } catch (Exception ex) { log.Error("Loi trong qua trinh update thong tin benh nhan {0}", ex); return ActionResult.Error; } }