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; } }