public DataTable GetPatientDataForUpdate(int PatientID) { DataTable dt = new DataTable(); using (var db = new HMISDBContext()) { var conn = (SqlConnection)db.Database.GetDbConnection(); try { DataSet ds = new DataSet(); SqlCommand sqlComm = new SqlCommand("GetPatientList", conn); sqlComm.Parameters.AddWithValue("@PatientID", PatientID); sqlComm.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = sqlComm; da.Fill(ds); dt = ds.Tables[0]; return(dt); } catch (Exception ex) { throw; } finally { conn.Close(); } } }
public PaginationResult <HealthFacilityListModel> GetHospitalList(PaginationViewModel model) { try { using (var db = new HMISDBContext()) { var HospitalList = (from HF in db.HealthFacilityDetails select new HealthFacilityListModel { id = HF.Id, HFMISCode = HF.HFMISCode, DivisionName = HF.DivisionName, DistrictName = HF.DistrictName, TehsilName = HF.TehsilName, HospitalName = HF.FullName }).ToList().AsQueryable(); var TotalCount = HospitalList.Count(); HospitalList = HospitalList.OrderByDescending(x => x.id).Skip((model.Page - 1) * (model.PageSize)).Take(model.PageSize); var res = HospitalList.OrderByDescending(a => a.id).ToList(); return(new PaginationResult <HealthFacilityListModel> { Data = res, RecordsTotal = TotalCount }); } } catch (Exception ex) { throw ex; } }
public int SaveHospital(HealthFacilityModel model) { using (var db = new HMISDBContext()) { var trans = db.Database.BeginTransaction(); try { if (model != null && !string.IsNullOrEmpty(model.HFMISCode)) { var HealthFacility = db.HealthFacilityDetails.Where(a => a.HFMISCode == model.HFMISCode).FirstOrDefault(); if (string.IsNullOrEmpty(HealthFacility.HFMISCode)) { var UpdatedHealthFacility = this._mapper.Map <HealthFacilityModel, HealthFacilityDetail>(model, HealthFacility); db.Entry(UpdatedHealthFacility).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } } else { var NewHF = this._mapper.Map <HealthFacilityDetail>(model); NewHF.HFMISCode = NewHF.DivisionCode + NewHF.DistrictCode + NewHF.TehsilCode; db.HealthFacilityDetails.AddAsync(NewHF); } db.SaveChanges(); trans.Commit(); return(1); } catch (Exception ex) { trans.Rollback(); return(-1); } } }
public DataTable GetAllPatientList(PaginationViewModel paginatedDTO, string CNIC = "") { DataTable dt = new DataTable(); using (var db = new HMISDBContext()) { var conn = (SqlConnection)db.Database.GetDbConnection(); try { DataSet ds = new DataSet(); SqlCommand sqlComm = new SqlCommand("GetPatientList", conn); sqlComm.Parameters.AddWithValue("@vCNIC", CNIC); sqlComm.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = sqlComm; da.Fill(ds); dt = ds.Tables[0]; return(dt); } catch (Exception ex) { throw; } finally { conn.Close(); } } }
public List <DDLModel> GetProvince() { try { using (var db = new HMISDBContext()) { return(null);// db.TblLocation.Where(x => x.Type == "Province").OrderBy(x => x.Name).Select(x => new DDLModel { Id = x.Id, Code = x.Code, Name = x.Name }).ToList(); } } catch (Exception ex) { throw ex; } }
public List <DDLModel> GetAllRoles() { try { using (var db = new HMISDBContext()) { return(null);// db.AspNetRoles.Select(x => new DDLRolesModel { Id = x.Id, Name = x.Name }).ToList(); } } catch (Exception ex) { throw ex; } }
public List <DDLModel> GetHealthfacilities(string tehsilCode = "", string HealthFacilityCode = "") { try { using (var db = new HMISDBContext()) { return(db.HealthFacilityDetails.Where(a => a.TehsilCode == (string.IsNullOrEmpty(tehsilCode) ? a.TehsilCode : tehsilCode) && a.Id.ToString() == (string.IsNullOrEmpty(HealthFacilityCode) ? a.Id.ToString() : HealthFacilityCode)).Select(x => new DDLModel { Code = x.HFMISCode, Name = x.FullName }).Distinct().ToList()); } } catch (Exception ex) { throw ex; } }
public List <DDLModel> GetDistrict(string divisionCode) { try { using (var db = new HMISDBContext()) { return(db.HealthFacilityDetails.Where(a => a.DivisionCode == divisionCode).OrderBy(x => x.DistrictName).Select(x => new DDLModel { Code = x.DistrictCode, Name = x.DistrictName }).Distinct().ToList()); } } catch (Exception ex) { throw ex; } }
public List <DDLModel> GetDesignationList() { try { using (var db = new HMISDBContext()) { return(db.Designations.Select(x => new DDLModel { Id = x.Id, Name = x.Name }).ToList()); } } catch (Exception ex) { throw ex; } }
public List <DDLModel> GetMaritalStatusList() { try { using (var db = new HMISDBContext()) { return(db.HealthFacilityDetails.Select(x => new DDLModel { Id = x.Id, Name = x.Name }).ToList()); } } catch (Exception ex) { throw ex; } }
public HealthFacilityListModel GetHealthFacilitiesData(string HealthFacilityCode = "") { try { using (var db = new HMISDBContext()) { return(db.HealthFacilityDetails.Where(a => a.HFMISCode == HealthFacilityCode).Select(x => new HealthFacilityListModel { id = x.Id, divisionCode = x.DivisionCode, districtCode = x.DistrictCode, tehsilCode = x.TehsilCode }).FirstOrDefault()); } } catch (Exception ex) { throw ex; } }
public object DeleteHealthFacility(string HFMISCode) { try { using (var db = new HMISDBContext()) { var HealthFacility = db.HealthFacilityDetails.Where(a => a.HFMISCode == HFMISCode).FirstOrDefault(); if (HealthFacility != null && HealthFacility.HFMISCode == HFMISCode) { db.HealthFacilityDetails.Remove(HealthFacility); db.SaveChanges(); } } return(true); } catch (Exception) { throw; } }
public int SavePatient(PatientRegistrationDTO model) { int Result = 0; using (var db = new HMISDBContext()) { var trans = db.Database.BeginTransaction(); try { if (model != null && !string.IsNullOrEmpty(model.CNIC)) { var PatientData = db.PatientRegistrations.Where(a => a.ID == model.id).FirstOrDefault(); if (PatientData != null) { var UpdatedHealthFacility = this._mapper.Map <PatientRegistrationDTO, PatientRegistration>(model, PatientData); db.Entry(UpdatedHealthFacility).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } else { var CurrentDate = DateTime.Now; var NewPatient = this._mapper.Map <PatientRegistration>(model); db.PatientRegistrations.AddAsync(NewPatient); } } else { Result = -1; } db.SaveChanges(); trans.Commit(); Result = 1; } catch (Exception ex) { trans.Rollback(); Result = -1; } return(Result); } }
public PaginationResult <AspNetUser> GetAllUsers(PaginationViewModel model) { try { using (var db = new HMISDBContext()) { IQueryable <AspNetUser> UserList; UserList = db.AspNetUsers.AsQueryable(); var TotalCount = UserList.Count(); UserList = UserList.OrderByDescending(x => x.Id).Skip((model.Page - 1) * (model.PageSize)).Take(model.PageSize); var res = UserList.ToList(); return(new PaginationResult <AspNetUser> { Data = res, RecordsTotal = TotalCount }); } } catch (Exception ex) { throw ex; } }
public String GetLastMRNO() { String LastMRNO = ""; try { using (var db = new HMISDBContext()) { var Data = db.PatientRegistrations.Where(a => a.CreatedOn.Date == DateTime.Now.Date).OrderByDescending(a => a.ID).FirstOrDefault(); if (Data != null) { LastMRNO = Data.MRNO; } ; } } catch (Exception ex) { throw ex; } return(LastMRNO); }
public int AddPatientVitals(PatientVitalsDTO model) { int Result = 0; using (var db = new HMISDBContext()) { var trans = db.Database.BeginTransaction(); try { var CurrentDate = DateTime.Now; var PatientVital = this._mapper.Map <PatientVital>(model); db.PatientVitals.AddAsync(PatientVital); db.SaveChanges(); trans.Commit(); Result = 1; } catch (Exception ex) { trans.Rollback(); Result = -1; } return(Result); } }
public HealthFacilityModel GetHealthFacilityData(string HFMISCode) { try { using (var db = new HMISDBContext()) { HealthFacilityModel HealthFacility; HealthFacility = db.HealthFacilityDetails.Where(a => a.HFMISCode == HFMISCode).Select(x => new HealthFacilityModel { id = x.Id, HFMISCode = x.DivisionCode + x.DistrictCode + x.TehsilCode, DivisionCode = x.DivisionCode, DistrictCode = x.DistrictCode, TehsilCode = x.TehsilCode, HospitalName = x.FullName }).FirstOrDefault(); return(HealthFacility); } } catch (Exception ex) { throw ex; } }