Exemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            // Tạo mã bệnh án
            BenhAn b = new BenhAn();

            b = a.GetLastID();
            long s = -1;

            if (b != null)
            {
                s = long.Parse(b.MaBenhAn.Substring(2));
            }
            s++;
            string kq = "BA" + s;

            while (kq.Length < 13)
            {
                kq = kq.Insert(2, "0");
            }
            //-----------------------------------------
            BenhAn ba = GetFormBenhAn();

            ba.MaBenhAn = kq;
            a.Add(ba);
            LoadGridView();
        }
Exemplo n.º 2
0
        public static BenhAn ShowBenhAn(string maba)
        {
            string        query = "SELECT * FROM current.dmbenhan WHERE maba=@maba";
            NpgsqlCommand cmd   = new NpgsqlCommand(query, conn);
            BenhAn        ba    = new BenhAn();

            try

            {
                conn.Open();
                cmd.Parameters.Add("@maba", NpgsqlDbType.Varchar).Value = maba;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ba = new BenhAn(reader.GetString(0), reader.GetString(1), reader.GetDateTime(2).ToShortDateString());
                }
                conn.Close();
            }
            catch (Exception e)
            {
                conn.Close();
                Console.WriteLine(e.Message);
            }
            return(ba);
        }
Exemplo n.º 3
0
        public string ThongTinBenhAn(string id)
        {
            BenhAn ba = BenhAnProcessor.ThongTinBenhAn(id);

            if (ba.Maba == null)
            {
                return("NULL");
            }
            return(JsonConvert.SerializeObject(ba));
        }
Exemplo n.º 4
0
        private BenhAn GetFormBenhAn()
        {
            BenhAn ba = new BenhAn();

            ba.MaBenhAn    = txtMabenhan.Text;
            ba.NgayKham    = DateTime.Parse(dtNgaykham.Text);
            ba.TrieuChung  = txtTrieuchung.Text;
            ba.KetLuan     = txtketluan.Text;
            ba.NgayTaiKham = DateTime.Parse(dtNgaytaikham.Text);
            ba.MaNhanVien  = cbbBacSy.SelectedValue.ToString();
            ba.ManBenhNhan = cbbMaBN.SelectedValue.ToString();
            return(ba);
        }
Exemplo n.º 5
0
        public object CapNhatBenhAn(FormCollection collec)
        {
            try
            {
                if (Session["ThanhVien"] != null)
                {
                    if (collec["ModelbenhAn"] != null)
                    {
                        DuAnYTeEntities entity = new DuAnYTeEntities();
                        BenhAn          benhAn = JsonConvert.DeserializeObject <BenhAn>(collec["ModelbenhAn"]);
                        benhAn.id_ThanhVien_SoHuu = (Session["ThanhVien"] as ThanhVien).id;
                        BenhAn benhAnTim = entity.BenhAns.FirstOrDefault(ba => ba.id == benhAn.id);
                        if (benhAnTim == null)
                        {
                            return(false);
                        }
                        if (benhAnTim.id_ThanhVien_SoHuu != (Session["ThanhVien"] as ThanhVien).id)
                        {
                            return(false);
                        }
                        if (collec["dsloai"] != null)
                        {
                            List <BenhAn_LoaiXetNghiem> DanhSachBenhAnLoaiXetNghiem = JsonConvert.DeserializeObject <List <BenhAn_LoaiXetNghiem> >(collec["dsloai"]);

                            DanhSachBenhAnLoaiXetNghiem = HealthyService.CapNhatBenhAn_LoaiXetNghiem(benhAnTim, DanhSachBenhAnLoaiXetNghiem);
                        }
                        if (Request.Files.Count > 0)
                        {
                            List <int> dsTapTin = (List <int>)FilesService.SaveFile(Request.Files);
                            if (HealthFilesService.CapNhatBenhAnTapTin(benhAnTim, dsTapTin))
                            {
                                return(true);
                            }
                            else
                            {
                                return(new { KetQua = true, NoiDung = "Không Lưu Được Tập Tin!" });
                            }
                        }
                        return(true);
                    }
                    return(false);
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void SetFormBenhAn()
        {
            BenhAn ba = new BenhAn();

            if (gridView1.SelectedRowsCount > 0)
            {
                ba = (BenhAn)gridView1.GetRow(gridView1.GetSelectedRows()[0]);
                this.txtMabenhan.Text       = ba.MaBenhAn;
                this.dtNgaykham.Text        = ba.NgayKham.ToShortDateString();
                this.txtTrieuchung.Text     = ba.TrieuChung;
                this.txtketluan.Text        = ba.KetLuan;
                this.dtNgaytaikham.Text     = ba.NgayTaiKham.ToShortDateString();
                this.cbbBacSy.SelectedValue = ba.MaNhanVien;
            }
        }
Exemplo n.º 7
0
 public ActionResult MyHealViewToUpdate(int id)
 {
     if (Session["ThanhVien"] != null)
     {
         //ViewBag.idThanhVien = (Session["ThanhVien"] as ThanhVien).id;
         //HealthyService.LayBenhAnTheoIdThanhVienVaIdBenhAn(1, id);
         BenhAn benhan = HealthyService.LayBenhAnTheoIdThanhVienVaIdBenhAn((Session["ThanhVien"] as ThanhVien).id, id);
         var    temp   = from iten in benhan.BenhAn_TapTin.ToList()
                         where iten.TrangThai != false
                         select iten;
         benhan.BenhAn_TapTin = temp.ToList();
         return(View(benhan));
     }
     return(RedirectToAction("Index", "Home"));
 }
Exemplo n.º 8
0
        public static string AddBenhAn(BenhAn ba)
        {
            string        query = "INSERT INTO current.dmbenhan VALUES(@maba,@mabn,@ngaylap)";
            NpgsqlCommand cmd   = new NpgsqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@maba", NpgsqlDbType.Varchar).Value = ba.Maba;
                cmd.Parameters.Add("@mabn", NpgsqlDbType.Varchar).Value = ba.Mabn;
                cmd.Parameters.Add("@ngaylap", NpgsqlDbType.Date).Value = ba.Ngaylap;
                cmd.ExecuteNonQuery();
                conn.Close();
                return(tb.add_successed);
            }
            catch (Exception e)
            {
                conn.Close();
                return(e.Message);
            }
        }
Exemplo n.º 9
0
        public static string UpdateBenhAn(BenhAn ba)
        {
            string        query = "UPDATE current.dmbenhan SET mabn=@mabn,ngaylap=@ngaylap WHERE maba=@maba";
            NpgsqlCommand cmd   = new NpgsqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@maba", NpgsqlDbType.Varchar).Value = ba.Maba;
                cmd.Parameters.Add("@mabn", NpgsqlDbType.Varchar).Value = ba.Mabn;
                cmd.Parameters.Add("@ngaylap", NpgsqlDbType.Date).Value = ba.Ngaylap;
                cmd.ExecuteNonQuery();
                conn.Close();
                return(tb.update_successed);
            }
            catch (Exception e)
            {
                conn.Close();
                return(e.Message);
            }
        }
Exemplo n.º 10
0
 public static string ThemBenhAn(BenhAn ba)
 {
     return(BenhAnRepository.AddBenhAn(ba));
 }
Exemplo n.º 11
0
 public List <BenhAn_LoaiXetNghiem> CapNhatBenhAn_LoaiXetNghiem(BenhAn benhAn, List <BenhAn_LoaiXetNghiem> DanhSachBenhAnLoaiXetNghiem)
 {
     return(BenhAnLoaiXetNghiemService.CapNhatLoaiXetNghiemChoBenhAn(benhAn, DanhSachBenhAnLoaiXetNghiem));
 }
Exemplo n.º 12
0
 public string SuaBenhAn([FromBody] BenhAn ba)
 {
     return(BenhAnProcessor.SuaBenhAn(ba));
 }
Exemplo n.º 13
0
 public string ThemBenhAn([FromBody] BenhAn ba)
 {
     return(BenhAnProcessor.ThemBenhAn(ba));
 }
Exemplo n.º 14
0
 //Service.SinhHoaMau_TapTin_Service SinhHoaMauTapTinService = new SinhHoaMau_TapTin_Service();
 //Service.NuocTieu_TapTin_Servive NuocTieuTapTinServive = new NuocTieu_TapTin_Servive();
 //Service.SieuAm_TapTin_Service SieuAmTapTinService = new SieuAm_TapTin_Service();
 public bool CapNhatBenhAnTapTin(BenhAn benhAn, List <int> DSFile)
 {
     return(BenhAnTapTinService.CapNhatBenhAnTapTin(benhAn, DSFile));
 }
Exemplo n.º 15
0
        public object MyHealViewToUpdate(FormCollection collec)
        {
            try
            {
                if (Session["ThanhVien"] != null)
                {
                    if (collec["ModelbenhAn"] != null)
                    {
                        BenhAn benhAn = JsonConvert.DeserializeObject <BenhAn>(collec["ModelbenhAn"]);
                        benhAn.id_ThanhVien_SoHuu = (Session["ThanhVien"] as ThanhVien).id;
                        //benhAn.id_ThanhVien_SoHuu = 1;
                        //benhAn = HealthyService.CapNhatBenhAn(benhAn);
                        if (collec["dsloai"] != null)
                        {
                            List <BenhAn_LoaiXetNghiem> DanhSachBenhAnLoaiXetNghiem = JsonConvert.DeserializeObject <List <BenhAn_LoaiXetNghiem> >(collec["dsloai"]);
                            benhAn.id = int.Parse(collec["idBenhAn"]);
                            //int idBenhAn =int.Parse( collec["idBenhAn"]);
                            HealthyService.UpdateBenhAn_LoaiXetNghiem(benhAn.id_ThanhVien_SoHuu, benhAn, DanhSachBenhAnLoaiXetNghiem);
                            //DanhSachBenhAnLoaiXetNghiem = HealthyService.CapNhatBenhAn_LoaiXetNghiem(benhAn, DanhSachBenhAnLoaiXetNghiem);
                        }
                        if (Request.Files.Count > 0)
                        {
                            List <int> dsTapTin = (List <int>)FilesService.SaveFile(Request.Files);
                            return(HealthFilesService.CapNhatBenhAnTapTin(benhAn, dsTapTin));
                        }
                        return(true);
                    }
                    return(false);
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }



            //ModelbenhAn.id_ThanhVien_SoHuu = 1;
            //Service.BenhAn_Service BenhAnService = new Service.BenhAn_Service();
            //for (int i = 0; i < 2; i++)
            //{
            //    BenhAn_LoaiXetNghiem m = new BenhAn_LoaiXetNghiem();
            //    m.id_LoaiXetNghiem = i+1;
            //    m.GiaTri = (i + 10).ToString();
            //    m.DonVi = "mmol/l";
            //    dsloai.Add(m);
            //}
            //return (BenhAnService.CapNhatBenhAnChoBenhNhan(benhAn)!=null);

            //if(Session["ThanhVien"]!=null)
            //{
            //    List<int> ds = new List<int>();
            //    if (Request.Files.Count > 0)
            //    {

            //         ds=(List < int >) FilesService.SaveFile(Request.Files);
            //    }
            //    int idHuyetHoc= HealthyService.CapNhatHuyetHoc(HuyetHocModel, ((ThanhVien)Session["ThanhVien"]).id);
            //    if(ds.Count>0)
            //    {
            //        return HealthFilesService.CapNhatTapTinHuyetHoc(idHuyetHoc, ds);
            //    }
            //    return true;
            //}
        }
Exemplo n.º 16
0
 public BenhAn CapNhatBenhAn(BenhAn benhAn)
 {
     return(BenhAnService.CapNhatBenhAnChoBenhNhan(benhAn));
 }
Exemplo n.º 17
0
        public static string AddDienBienToDB(DienBien dienbien)
        {
            //validate
            BenhAn ba = BenhAnRepository.ShowBenhAn(dienbien.Maba);

            if (ba.Maba == null)
            {
                return("Bệnh án ko tồn tại");
            }
            //BenhNhan bn =BenhNhanRepository.ShowBenhNhanFromDB(dienbien.Mabn);
            //  NhanVien nv = NhanVienRepository.ShowNhanVienFromDB(dienbien.Manv);
            ICD icdchinh = ICDRepository.ShowICD(dienbien.Maicd);

            if (icdchinh.maicd == null)
            {
                return("Mã icd không tồn tại");
            }


            var tenicd = icdchinh.tenviet;
            var icdphu = new ICD();

            if (dienbien.Maicdp != "")
            {
                icdphu = ICDRepository.ShowICD(dienbien.Maicdp);
            }
            var tenicdp = dienbien.Tenicdp;


            //Cấu trúc connection
            //var connectionstring = "Server=127.0.0.1;Port=5432;User Id=postgres;Password=123456;Database=svthuctap;";
            //check benh an ton tai
            //Câu lệnh SQL thêm vào Database
            string query = "INSERT INTO current.dienbien VALUES(@Iddienbien,@mabn,@maba,@makhoa,@magiuong,@manv,@maicd,@tenicd,@maicdp,@tenicdp)";


            //Tạo kết nối tới PostgreSQL
            NpgsqlConnection conn = new NpgsqlConnection(connectstring);

            //Try thêm dữ liệu
            try
            {
                conn.Open();
                NpgsqlCommand cmd = new NpgsqlCommand(query, conn);
                cmd.Parameters.Add("@Iddienbien", NpgsqlDbType.Varchar).Value = dienbien.Iddienbien;
                cmd.Parameters.Add("@mabn", NpgsqlDbType.Varchar).Value       = dienbien.Mabn;
                cmd.Parameters.Add("@maba", NpgsqlDbType.Varchar).Value       = dienbien.Maba;
                cmd.Parameters.Add("@makhoa", NpgsqlDbType.Varchar).Value     = dienbien.Makhoa;
                cmd.Parameters.Add("@magiuong", NpgsqlDbType.Varchar).Value   = dienbien.Magiuong;
                cmd.Parameters.Add("@manv", NpgsqlDbType.Varchar).Value       = dienbien.Manv;
                cmd.Parameters.Add("@maicd", NpgsqlDbType.Varchar).Value      = dienbien.Maicd;
                cmd.Parameters.Add("@tenicd", NpgsqlDbType.Varchar).Value     = dienbien.Tenicd;
                cmd.Parameters.Add("@maicdp", NpgsqlDbType.Varchar).Value     = dienbien.Maicdp;
                cmd.Parameters.Add("@Tenicdp", NpgsqlDbType.Varchar).Value    = dienbien.Tenicdp;

                cmd.ExecuteNonQuery();
                conn.Close();

                return("Thêm thành công!");
            }
            // Bắt trường hợp lỗi
            catch (Exception e)
            {
                conn.Close();
                return(e.Message);
            }
        }
Exemplo n.º 18
0
 public static string SuaBenhAn(BenhAn ba)
 {
     return(BenhAnRepository.UpdateBenhAn(ba));
 }
Exemplo n.º 19
0
 public bool UpdateBenhAn_LoaiXetNghiem(int idThanhVien, BenhAn benhAn, List <BenhAn_LoaiXetNghiem> dsLoaiXetNghiem)
 {
     return(BenhAnService.UpdateBenhAn_LoaiXetNghiem(idThanhVien, benhAn, dsLoaiXetNghiem));
 }