예제 #1
0
 public void Update(PhieuSangLoc PhieuSangLoc)
 {
     if (!string.IsNullOrEmpty(PhieuSangLoc.MaDVCS))
     {
         PhieuSangLoc.MaTrungTam = this.donViCoSoRepository.GetMaTrungTamByMaDonViCS(PhieuSangLoc.MaDVCS);
     }
     PhieuSangLocRepository.Update(PhieuSangLoc);
 }
예제 #2
0
 public static void UpdatePhieuSangLoc(this PhieuSangLoc phieusangloc, PhieuSangLocViewModel phieusanglocVm)
 {
     phieusangloc.RowIDPhieu         = phieusanglocVm.RowIDPhieu;
     phieusangloc.IDPhieu            = phieusanglocVm.IDPhieu;
     phieusangloc.NgayTaoPhieu       = phieusanglocVm.NgayTaoPhieu;
     phieusangloc.IDNhanVienTaoPhieu = phieusanglocVm.IDNhanVienTaoPhieu;
     phieusangloc.IDCoSo             = phieusanglocVm.IDCoSo;
     if (phieusanglocVm.NgayGioLayMau != null && phieusanglocVm.NgayGioLayMauTime != null)
     {
         DateTime NgayGioLayMau     = DateTime.ParseExact(phieusanglocVm.NgayGioLayMau, "dd/MM/yyyy", CultureInfo.InvariantCulture);
         DateTime NgayGioLayMauTime = Convert.ToDateTime(phieusanglocVm.NgayGioLayMauTime);
         phieusangloc.NgayGioLayMau = new DateTime(NgayGioLayMau.Year, NgayGioLayMau.Month, NgayGioLayMau.Day, NgayGioLayMauTime.Hour, NgayGioLayMauTime.Minute, NgayGioLayMauTime.Second);
     }
     phieusangloc.IDViTriLayMau      = phieusanglocVm.IDViTriLayMau;
     phieusangloc.IDNhanVienLayMau   = phieusanglocVm.IDNhanVienLayMau;
     phieusangloc.isLayMauLan2       = phieusanglocVm.isLayMauLan2;
     phieusangloc.IDPhieuLan1        = phieusanglocVm.IDPhieuLan1;
     phieusangloc.TinhTrangLucLayMau = phieusanglocVm.TinhTrangLucLayMau;
     phieusangloc.SLTruyenMau        = phieusanglocVm.SLTruyenMau;
     if (!string.IsNullOrEmpty(phieusanglocVm.NgayTruyenMau))
     {
         DateTime NgayTruyenMau = DateTime.ParseExact(phieusanglocVm.NgayTruyenMau.Substring(0, 16), "dd/MM/yyyy HH:mm", mFomatter);
         phieusangloc.NgayTruyenMau = NgayTruyenMau;
     }
     phieusangloc.CheDoDinhDuong    = phieusanglocVm.CheDoDinhDuong;
     phieusangloc.TrangThaiPhieu    = phieusanglocVm.TrangThaiPhieu;
     phieusangloc.TrangThaiMau      = phieusanglocVm.TrangThaiMau;
     phieusangloc.isKhongDat        = phieusanglocVm.isKhongDat;
     phieusangloc.NgayNhanMau       = phieusanglocVm.NgayNhanMau;
     phieusangloc.MaXetNghiem       = phieusanglocVm.MaXetNghiem;
     phieusangloc.Para              = phieusanglocVm.Para;
     phieusangloc.isTruoc24h        = phieusanglocVm.isTruoc24h;
     phieusangloc.isSinhNon         = phieusanglocVm.isSinhNon;
     phieusangloc.isNheCan          = phieusanglocVm.isNheCan;
     phieusangloc.isGuiMauTre       = phieusanglocVm.isGuiMauTre;
     phieusangloc.IDChuongTrinh     = phieusanglocVm.IDChuongTrinh;
     phieusangloc.MaGoiXN           = phieusanglocVm.MaGoiXN;
     phieusangloc.TenNhanVienLayMau = phieusanglocVm.TenNhanVienLayMau;
     phieusangloc.SDTNhanVienLayMau = phieusanglocVm.SDTNhanVienLayMau;
     phieusangloc.NoiLayMau         = phieusanglocVm.NoiLayMau;
     phieusangloc.isHuyMau          = phieusanglocVm.isHuyMau;
     phieusangloc.LyDoKhongDat      = phieusanglocVm.LyDoKhongDat;
     phieusangloc.isDongBo          = phieusanglocVm.isDongBo;
     phieusangloc.isXoa             = phieusanglocVm.isXoa;
     phieusangloc.DiaChiLayMau      = phieusanglocVm.DiaChiLayMau;
     phieusangloc.isXNLan2          = phieusanglocVm.isXNLan2;
     phieusangloc.IDNhanVienXoa     = phieusanglocVm.IDNhanVienXoa;
     phieusangloc.NgayGioXoa        = phieusanglocVm.NgayGioXoa;
     phieusangloc.MaDVCS            = phieusanglocVm.MaDVCS;
 }
        public HttpResponseMessage addupFromApp(HttpRequestMessage request)
        {
            HttpContent           requestContent = Request.Content;
            string                jsonContent    = requestContent.ReadAsStringAsync().Result;
            PhieuSangLocViewModel phieuSangLocVm = JsonConvert.DeserializeObject <PhieuSangLocViewModel>(jsonContent);

            var userName = HttpContext.Current.GetOwinContext().Authentication.User.Identity.Name;
            var user     = userManager.FindByNameAsync(userName).Result;

            if (phieuSangLocVm.MaTrungTam != user.LevelCode && !phieuSangLocVm.IDPhieu.Contains(user.LevelCode))
            {
                return(request.CreateResponse(HttpStatusCode.ExpectationFailed, "Phiếu " + phieuSangLocVm.IDPhieu + "không thuộc trung tâm " + user.LevelCode));
            }

            HttpResponseMessage response = null;

            var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu);

            if (phieuDB == null)
            {
                var newPhieu = new PhieuSangLoc();
                newPhieu.UpdatePhieuSangLoc(phieuSangLocVm);

                var lvcode = user.LevelCode;
                newPhieu.IDNhanVienTaoPhieu = user.Id;
                var newPatient = new Patient();
                newPatient.UpdatePatient(phieuSangLocVm);
                newPhieu.MaBenhNhan   = lvcode[1] + lvcode[2] + Guid.NewGuid().ToString();
                newPatient.MaBenhNhan = newPhieu.MaBenhNhan;
                phieuSangLocService.Add(newPhieu);
                patientService.Add(newPatient);
                phieuSangLocService.Save();
                response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm);
            }
            else
            {
                phieuDB.UpdatePhieuSangLoc(phieuSangLocVm);
                var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan);
                patientDB.UpdatePatient(phieuSangLocVm);

                this.phieuSangLocService.Update(phieuDB);
                this.patientService.Update(patientDB);
                donViCoSoService.Save();

                response = request.CreateResponse(HttpStatusCode.OK);
            }
            return(response);
        }
예제 #4
0
 public void Add(PhieuSangLoc PhieuSangLoc)
 {
     PhieuSangLoc.TrangThaiPhieu = false;
     PhieuSangLoc.isKhongDat     = false;
     PhieuSangLoc.isDongBo       = false;
     PhieuSangLoc.isXoa          = false;
     PhieuSangLoc.isXNLan2       = false;
     PhieuSangLoc.IDNhanVienXoa  = string.Empty;
     PhieuSangLoc.NgayGioXoa     = null;
     PhieuSangLoc.NgayTaoPhieu   = DateTime.Now;
     if (!string.IsNullOrEmpty(PhieuSangLoc.MaDVCS))
     {
         PhieuSangLoc.MaTrungTam = this.donViCoSoRepository.GetMaTrungTamByMaDonViCS(PhieuSangLoc.MaDVCS);
     }
     this.PhieuSangLocRepository.Add(PhieuSangLoc);
 }
        public HttpResponseMessage Create(HttpRequestMessage request, PhieuSangLocViewModel phieuSangLocVm)
        {
            var userName = HttpContext.Current.GetOwinContext().Authentication.User.Identity.Name;
            var user     = userManager.FindByNameAsync(userName).Result;

            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu);
                    if (phieuDB != null)
                    {
                        phieuDB.UpdatePhieuSangLoc(phieuSangLocVm);
                        var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan);
                        patientDB.UpdatePatient(phieuSangLocVm);

                        this.phieuSangLocService.Update(phieuDB);
                        this.patientService.Update(patientDB);
                        donViCoSoService.Save();

                        response = request.CreateResponse(HttpStatusCode.OK);
                    }
                    else
                    {
                        var newPhieu = new PhieuSangLoc();
                        newPhieu.UpdatePhieuSangLoc(phieuSangLocVm);
                        var lvcode = user.LevelCode;
                        newPhieu.IDNhanVienTaoPhieu = user.Id;
                        var newPatient = new Patient();
                        newPatient.UpdatePatient(phieuSangLocVm);
                        newPhieu.MaBenhNhan = lvcode[1] + lvcode[2] + Guid.NewGuid().ToString();
                        newPatient.MaBenhNhan = newPhieu.MaBenhNhan;
                        phieuSangLocService.Add(newPhieu);
                        patientService.Add(newPatient);
                        phieuSangLocService.Save();
                        response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm);
                    }
                }

                return response;
            }));
        }
        public HttpResponseMessage GetPhieuSangLoc(HttpRequestMessage request, string maKhachHang)
        {
            Patient      patient = patientService.GetByMaKH(maKhachHang);
            PhieuSangLoc psl     = phieuSangLocService.GetByMaBenhNhan(patient.MaBenhNhan);

            var responseData = Mapper.Map <PhieuSangLoc, PhieuSangLocViewModel>(psl);

            responseData = Mapper.Map <Patient, PhieuSangLocViewModel>(patient, responseData);

            IFormatProvider mFomatter = new System.Globalization.CultureInfo("en-US", true);

            if (!string.IsNullOrEmpty(responseData.NgayGioLayMau))
            {
                string   NgayGioLayMau     = responseData.NgayGioLayMau.Substring(0, 10);
                DateTime NgayGioLayMauTime = DateTime.ParseExact(responseData.NgayGioLayMau, "dd/MM/yyyy HH:mm:ss", mFomatter);
                responseData.NgayGioLayMau     = NgayGioLayMau;
                responseData.NgayGioLayMauTime = NgayGioLayMauTime;
            }
            if (!string.IsNullOrEmpty(responseData.NgayGioSinh))
            {
                string   NgayGioSinh     = responseData.NgayGioSinh.Substring(0, 10);
                DateTime NgayGioSinhTime = DateTime.ParseExact(responseData.NgayGioSinh, "dd/MM/yyyy HH:mm:ss", mFomatter);
                responseData.NgayGioSinh     = NgayGioSinh;
                responseData.NgayGioSinhTime = NgayGioSinhTime;
            }
            if (!string.IsNullOrEmpty(responseData.MotherBirthday))
            {
                responseData.MotherBirthday = responseData.MotherBirthday.Substring(0, 10);
            }
            if (!string.IsNullOrEmpty(responseData.FatherBirthday))
            {
                responseData.FatherBirthday = responseData.FatherBirthday.Substring(0, 10);
            }
            var response = request.CreateResponse(HttpStatusCode.OK, responseData);

            return(response);
        }