private void UpdateTPOPDAmount(Guid id) { using (var db = new HMSEntities()) { decimal?amount = db.TPLabPatientMappings.Where(t => t.OPDHistoryId == id).Sum(t => t.Amount.Value); if (amount != null) { OPDHistory e = db.OPDHistories.Find(id); e.ThirdPartyLabAmoumt = amount; db.SaveChanges(); } } }
public bool UpdateStatus(List <OPDHistoryModel> m, string status) { using (var db = new HMSEntities()) { foreach (OPDHistoryModel mod in m) { OPDHistory entity = db.OPDHistories.Find(mod.Id); entity.StatusId = Status.GetIdByName(status); } db.SaveChanges(); return(true); } //return false; }
public OPDHistoryModel GetById(Guid id) { try { OPDHistoryModel model = new OPDHistoryModel(); using (var db = new HMSEntities()) { OPDHistory entity = db.OPDHistories.Find(id); if (entity != null) { model.Id = entity.Id; model.PatientId = entity.PatientId; model.PatientName = entity.PatientDetail != null ? entity.PatientDetail.FullName : ""; model.CasePaperNumber = entity.PatientDetail != null ? entity.PatientDetail.CasePaperNumber : ""; model.Sequence = entity.Sequence; model.InTime = entity.InTime; model.OutTime = entity.OutTime; model.IsCharity = entity.IsCharity; model.IsLabCharity = entity.IsLabCharity; model.IsECG = entity.IsECG.HasValue ? entity.IsECG : false; model.IsXRAY = entity.IsXRAY.HasValue ? entity.IsXRAY : false; model.StatusId = entity.StatusId; model.StatusName = entity.Status != null ? entity.Status.Name : ""; model.Amount = entity.Amount; model.PaidAmount = entity.PaidAmount; model.DueAmount = entity.DueAmount; model.TotalAmount = entity.TotalAmount; model.LabTestingAmount = entity.LabTestingAmount; model.ECGAmount = entity.ECGAmount; model.XRAYAmount = entity.XRAYAmount; model.NumberofXRAY = entity.NumberofXRAY.HasValue ? entity.NumberofXRAY : 0; model.ReceivedBy = entity.ReceivedBy; model.ConsultingDoctorId = entity.ConsultingDoctorId; model.ThirdPartyLabId = entity.ThirdPartyLabId; model.ThirdPartyLabAmoumt = entity.ThirdPartyLabAmoumt; model.Diagnose = entity.Diagnose; model.Madicines = entity.Madicines; model.CreatedBy = entity.CreatedBy; model.ModifiedBy = entity.ModifiedBy; model.PatientDetails = PatientDetail.SetModel(entity.PatientDetail); } } return(model); } catch (Exception ex) { throw ex; } }
public bool CreateOPD(PatientDetailModel model) { try { bool isSaved = false; using (var db = new HMSEntities()) { bool isExpire = UpdateCasePaperDate(model); OPDHistoryModel historyEntity = new OPDHistoryModel(); historyEntity.PatientId = model.Id; historyEntity.InTime = DateTime.Now; historyEntity.IsCharity = false; historyEntity.IsLabCharity = false; historyEntity.IsECG = false; historyEntity.IsXRAY = false; historyEntity.CasePaperNumber = model.CasePaperNumber; //historyEntity.Amount = isExpire ? OPDRate.GetRatesByType("New").Rate : OPDRate.GetRatesByType("FollowUP").Rate; //historyEntity.DueAmount = isExpire ? OPDRate.GetRatesByType("New").Rate : OPDRate.GetRatesByType("FollowUP").Rate; historyEntity.ECGAmount = 0.00M; historyEntity.XRAYAmount = 0.00M; historyEntity.ThirdPartyLabAmoumt = 0.00M; historyEntity.ConsultingDoctorId = new DoctorDetail().GetName("SIR"); historyEntity.TotalAmount = historyEntity.PaidAmount = historyEntity.LabTestingAmount = Convert.ToDecimal(0.00); historyEntity.PatientDetails = new PatientDetailModel(); historyEntity.PatientDetails = model; historyEntity.NumberofXRAY = 0; isSaved = new OPDHistory().Create(historyEntity, isExpire ? 0 : 1); } return(isSaved); } catch (Exception ex) { throw ex; } }
public bool Create(PatientDetailModel model) { try { bool isSaved = false; if (!IsExist(model)) { using (var db = new HMSEntities()) { PatientDetail entity = new PatientDetail(); entity.FullName = model.FullName; entity.Address = model.Address; entity.CasePaperNumber = model.CasePaperNumber; entity.Gender = model.Gender; entity.PhoneNumber = model.PhoneNumber; entity.MobileNumber = model.MobileNumber; entity.Age = model.Age; entity.IsAdmitted = model.IsAdmitted; entity.AdmittedDate = model.AdmittedDate; entity.IsDischarged = model.IsDischarged.HasValue ? model.IsDischarged : false; entity.DischargedDate = model.DischargedDate; entity.RefferedDoctor = model.RefferedDoctor; entity.CasePaperIssuedDate = model.CasePaperIssuedDate; entity.CasePaperExpiryDate = model.CasePaperIssuedDate.HasValue ? model.CasePaperIssuedDate.Value.AddMonths(2) : model.CasePaperExpiryDate; entity.WardNumberId = model.WardNumberId; entity.RoomNumber = model.RoomNumber; entity.RoomTypeId = model.RoomTypeId; entity.DepartmentId = model.DepartmentId; entity.AadharCard = model.AadharCard; entity.PanCard = model.PanCard; entity.IsActive = true; entity.IsDeleted = false; entity.CreatedOn = DateTime.Now; entity.CreatedBy = UserDetailSession.Id; entity.ModifiedOn = DateTime.Now; db.PatientDetails.Add(entity); db.SaveChanges(); if (!entity.IsDischarged.Value) { if (model.OPDHistory != null) { OPDHistory historyEntity = new OPDHistory(); model.OPDHistory.PatientId = entity.Id; model.OPDHistory.CasePaperNumber = model.CasePaperNumber; model.OPDHistory.ECGAmount = (model.OPDHistory.IsECG.Value) ? OPDRate.GetRatesByType("ECG").Rate : 0.00M; model.OPDHistory.XRAYAmount = model.OPDHistory.XRAYAmount; int isFollowUp = 0; if (model.IsOldPatient && model.CasePaperIssuedDate.Value.Date < DateTime.Now.Date) { isFollowUp = 1; } isSaved = historyEntity.Create(model.OPDHistory, isFollowUp); } } else { isSaved = CreateIPDHistory(entity.Id, model.IPDBillAmount); } } } return(isSaved); } catch (Exception ex) { throw ex; } }
public bool Update(OPDHistoryModel model) { try { bool isSaved = false; List <OPDHistoryUpdateModel> listUpdateModel = new List <OPDHistoryUpdateModel>(); using (var db = new HMSEntities()) { OPDHistory entity = db.OPDHistories.Find(model.Id); listUpdateModel = OPDHistoryModifications(entity, model); entity.PatientId = model.PatientId; entity.InTime = model.InTime; entity.OutTime = model.OutTime; entity.IsCharity = model.IsCharity; entity.IsLabCharity = model.IsLabCharity; entity.IsECG = model.IsECG.HasValue ? model.IsECG : false; entity.IsXRAY = model.IsXRAY.HasValue ? model.IsXRAY : false; entity.ConsultingDoctorId = model.ConsultingDoctorId; entity.StatusId = model.StatusId; entity.Amount = model.Amount; entity.PaidAmount = model.PaidAmount; entity.DueAmount = model.DueAmount; entity.TotalAmount = model.TotalAmount; entity.LabTestingAmount = model.LabTestingAmount; entity.ECGAmount = model.ECGAmount.HasValue ? model.ECGAmount : 0.00M; entity.XRAYAmount = model.XRAYAmount.HasValue ? model.XRAYAmount : 0.00M; entity.NumberofXRAY = model.NumberofXRAY.HasValue ? model.NumberofXRAY : 0; entity.ThirdPartyLabId = model.ThirdPartyLabId; entity.ThirdPartyLabAmoumt = model.ThirdPartyLabAmoumt.HasValue ? model.ThirdPartyLabAmoumt : 0.00M; string status = Status.GetNameById(model.StatusId); if (status == OPD_STATUS.Done.ToString()) { entity.ReceivedBy = UserDetailSession.Id; } else { entity.ReceivedBy = model.ReceivedBy; } entity.Diagnose = model.Diagnose; entity.Madicines = model.Madicines; entity.ModifiedBy = UserDetailSession.Id; db.SaveChanges(); OPDHistoryUpdate opdHistoryUpdate = new OPDHistoryUpdate(); opdHistoryUpdate.Create(listUpdateModel); if (status == OPD_STATUS.Done.ToString()) { BillHistoryModel billModel = new BillHistoryModel(); billModel.PatientId = model.PatientId.Value; billModel.OPDHistoryId = model.Id.Value; new BillHistory().Create(billModel); } isSaved = true; } return(isSaved); } catch (Exception ex) { throw ex; } }
public bool Create(OPDHistoryModel model, int isFollowUp = 0) { try { bool isSaved = false; if (!IsExist(model.CasePaperNumber)) { using (var db = new HMSEntities()) { OPDHistory entity = new OPDHistory(); entity.PatientId = model.PatientId; entity.Sequence = getLastSerial(); entity.InTime = model.InTime; entity.OutTime = model.OutTime; entity.IsCharity = model.IsCharity.HasValue ? model.IsCharity : false; entity.IsLabCharity = model.IsLabCharity; entity.ConsultingDoctorId = model.ConsultingDoctorId; entity.IsECG = model.IsECG.HasValue ? model.IsECG : false; entity.IsXRAY = model.IsXRAY.HasValue ? model.IsXRAY : false; entity.StatusId = Status.GetStatus(t => t.Name == OPD_STATUS.Waiting.ToString()).FirstOrDefault().Id; entity.IsFollowUp = isFollowUp; if (!entity.IsCharity.Value) { if (isFollowUp == 0) { entity.Amount = OPDRate.GetRatesByType("New").Rate; } else if (isFollowUp == 1) { entity.Amount = OPDRate.GetRatesByType("FollowUP").Rate; } } else { entity.Amount = 0.00M; entity.LabTestingAmount = 0.00M; entity.XRAYAmount = 0.00M; entity.ECGAmount = 0.00M; } model.PayingAmount = entity.Amount; entity.PaidAmount = entity.Amount; entity.DueAmount = model.ECGAmount + model.XRAYAmount; //model.DueAmount != null ? model.DueAmount : Convert.ToDecimal(0.00); entity.TotalAmount = entity.Amount + model.ECGAmount + model.XRAYAmount; entity.LabTestingAmount = model.LabTestingAmount != null ? model.LabTestingAmount : Convert.ToDecimal(0.00); entity.ECGAmount = model.ECGAmount.HasValue ? model.ECGAmount : 0.00M; entity.XRAYAmount = model.XRAYAmount.HasValue ? model.XRAYAmount : 0.00M; entity.NumberofXRAY = model.NumberofXRAY.HasValue ? model.NumberofXRAY : 0; entity.ThirdPartyLabId = model.ThirdPartyLabId; entity.ThirdPartyLabAmoumt = model.ThirdPartyLabAmoumt.HasValue ? model.ThirdPartyLabAmoumt : 0.00M; entity.ReceivedBy = model.ReceivedBy; entity.Diagnose = model.Diagnose; entity.Madicines = model.Madicines; entity.CreatedBy = UserDetailSession.Id; db.OPDHistories.Add(entity); db.SaveChanges(); model.Id = entity.Id; List <OPDHistoryUpdateModel> listUpdateModel = new List <OPDHistoryUpdateModel>(); listUpdateModel = OPDHistoryModifications(model); OPDHistoryUpdate opdHistoryUpdate = new OPDHistoryUpdate(); opdHistoryUpdate.Create(listUpdateModel); isSaved = true; } } return(isSaved); } catch (Exception ex) { throw ex; } }