예제 #1
0
        public bool Create(List <OPDHistoryUpdateModel> model)
        {
            try
            {
                bool isSaved = false;
                using (var db = new HMSEntities())
                {
                    foreach (OPDHistoryUpdateModel item in model)
                    {
                        OPDHistoryUpdate entity = new OPDHistoryUpdate();

                        entity.OPDHistoryId  = item.OPDHistoryId;
                        entity.UpdatedBy     = UserDetailSession.Id;
                        entity.UpdatedField  = item.UpdatedField;
                        entity.UpdatedValue  = item.UpdatedValue;
                        entity.PreviousValue = item.PreviousValue;
                        entity.CreatedOn     = DateTime.Now;

                        db.OPDHistoryUpdates.Add(entity);
                    }


                    db.SaveChanges();

                    isSaved = true;
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public List <OPDHistoryModel> GetGenericReport(Expression <Func <OPDHistory, bool> > predicate)
        {
            try
            {
                List <OPDHistoryModel> list = new List <OPDHistoryModel>();

                using (var db = new HMSEntities())
                {
                    var data = db.OPDHistories.Where(predicate).OrderBy(t => t.InTime).ToList();
                    foreach (OPDHistory t in data)
                    {
                        OPDHistoryModel model = new OPDHistoryModel();
                        model.Id                  = t.Id;
                        model.PatientId           = t.PatientId;
                        model.PatientName         = t.PatientDetail != null ? t.PatientDetail.FullName : "";
                        model.CasePaperNumber     = t.PatientDetail != null ? t.PatientDetail.CasePaperNumber : "";
                        model.Sequence            = t.Sequence;
                        model.InTime              = t.InTime;
                        model.OutTime             = t.OutTime;
                        model.IsCharity           = t.IsCharity;
                        model.IsLabCharity        = t.IsLabCharity;
                        model.ECGAmount           = t.ECGAmount;
                        model.ConsultingDoctorId  = t.ConsultingDoctorId;
                        model.DoctorNames         = t.DoctorDetail.FullName;
                        model.IsECG               = t.IsECG.HasValue ? t.IsECG : false;
                        model.IsXRAY              = t.IsXRAY.HasValue ? t.IsXRAY : false;
                        model.XRAYAmount          = t.XRAYAmount;
                        model.NumberofXRAY        = t.NumberofXRAY.HasValue ? t.NumberofXRAY : 0;
                        model.ThirdPartyLabId     = t.ThirdPartyLabId;
                        model.ThirdPartyLabAmoumt = t.ThirdPartyLabAmoumt;
                        model.StatusId            = t.StatusId;
                        model.StatusName          = t.Status != null ? t.Status.Name : "";
                        model.Amount              = t.Amount;
                        model.PaidAmount          = t.PaidAmount;
                        model.DueAmount           = t.DueAmount;
                        model.TotalAmount         = t.TotalAmount;
                        model.LabTestingAmount    = t.LabTestingAmount;
                        model.ReceivedBy          = t.ReceivedBy;
                        model.Diagnose            = t.Diagnose;
                        model.Madicines           = t.Madicines;
                        model.CreatedBy           = t.CreatedBy;
                        model.ModifiedBy          = t.ModifiedBy;
                        model.OPDHistoryUpdates   = new List <OPDHistoryUpdateModel>();
                        model.OPDHistoryUpdates.AddRange(OPDHistoryUpdate.GetPayingPatient(model.Id.Value));
                        model.TPLabs = new List <LookupModel>();
                        model.TPLabs.AddRange(TPLabPatientMapping.GetLabByOPD(model.Id.Value));
                        list.Add(model);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        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;
            }
        }