Esempio n. 1
0
        public JsonResult UpdateInvoice(PatientInvoice pinvoice)
        {
            PatientInvoice onlyInvoice    = new PatientInvoice();
            PatientInvoice patientInvoice = new PatientInvoice();


            using (Repository <PatientInvoice> repository = new Repository <PatientInvoice>())
            {
                patientInvoice        = repository.Update(pinvoice);
                patientInvoice.UserId = GetLoggedinUserInfo().UserId;
                repository.Commit();
            }

            List <PatientService> patientServiceItems = pinvoice.PatientServices.ToList();

            foreach (PatientService item in patientServiceItems)
            {
                using (PatientServiceRepository patientservicerepository = new PatientServiceRepository())
                {
                    item.UserId = GetLoggedinUserInfo().UserId;
                    patientservicerepository.Update(item);
                    patientservicerepository.Commit();
                }
            }


            return(Json("Invoice update successfull", JsonRequestBehavior.AllowGet));
        }
 public IActionResult AddPatientInvoice([FromBody] PatientInvoice model)
 {
     if (model.DateCreated == null)
     {
         model.DateCreated = DateTime.Now;
     }
     model.SlipNumber = GenPSN();
     _repo.Add(model);
     return(new OkObjectResult(new { PatientInvoiceID = model.PatientInvoiceId }));
 }
Esempio n. 3
0
        public JsonResult SaveInvoice(PatientInvoice invoice, IList <PatientService> patientServices)
        {
            using (PatientInvoiceRepository repository = new PatientInvoiceRepository())
            {
                invoice.UserId = GetLoggedinUserInfo().UserId;
                invoice        = repository.Insert(invoice);
                repository.Commit();
                // CreatePatientService(invoice.Id, patientServices);
            }

            return(Json(invoice.Id, JsonRequestBehavior.AllowGet));
        }
        public IActionResult DeletePatientInvoice(long id)
        {
            PatientInvoice patientInvoice = _repo.Find(id);

            if (patientInvoice == null)
            {
                return(NotFound());
            }

            _repo.Delete(patientInvoice);
            return(Ok());
        }
 private void CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() == typeof(DataGridViewImageColumn))
     {
         int             rowIndex = e.RowIndex;
         DataGridViewRow row      = dgvData.Rows[rowIndex];
         PatientInvoice  p        = new PatientInvoice();
         p.PatientMedicineBillGuid = (Guid)(row.Cells[8].Value);
         p.PatientGuid             = (Guid)(row.Cells[7].Value);
         p.PatientName             = row.Cells[0].Value.ToString();
         p.Show();
     }
 }
Esempio n. 6
0
        private void CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;

            if (rowindex >= 0)
            {
                int columnindex = e.ColumnIndex;

                var value = dgvData.Rows[rowindex].Cells[columnindex].Value;

                if (e.RowIndex >= 0 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() == typeof(DataGridViewImageColumn))
                {
                    int             rowIndex = e.RowIndex;
                    DataGridViewRow row      = dgvData.Rows[rowIndex];
                    if (e.ColumnIndex == 15)
                    {
                        IndoorCaseReportForm p = new IndoorCaseReportForm();
                        p.PatientGuid = (Guid)(row.Cells[19].Value);
                        p.Show();
                    }
                    if (e.ColumnIndex == 14)
                    {
                        PatientInvoice p = new PatientInvoice();
                        p.PatientGuid = (Guid)(row.Cells[19].Value);
                        p.Show();
                    }
                    if (e.ColumnIndex == 16)
                    {
                        MLCReportForm p = new MLCReportForm();
                        p.PatientGuid = (Guid)(row.Cells[19].Value);
                        p.Show();
                    }
                    if (e.ColumnIndex == 17)
                    {
                        PatientDetailReportForm p = new PatientDetailReportForm();
                        p.PatientGuid = (Guid)(row.Cells[19].Value);
                        p.Show();
                    }
                    if (e.ColumnIndex == 18)
                    {
                        DischargeSummeryReport p = new DischargeSummeryReport();
                        p.PatientGuid = (Guid)(row.Cells[19].Value);
                        p.Show();
                    }
                }
            }
        }
        private string GenPSN()
        {
            try
            {
                PatientInvoice lastPatientInvoice = _repo.GetLast();
                string         value  = lastPatientInvoice.SlipNumber;
                string         number = Regex.Match(value, "[0-9]+$").Value;

                return(value.Substring(0, value.Length - number.Length) +
                       (long.Parse(number) + 1).ToString().PadLeft(number.Length, '0'));
            }
            catch (ArgumentNullException)
            {
                return("PSN0000000001");
            }
            catch (NullReferenceException)
            {
                return("PSN0000000001");
            }
        }
        public int Update(PatientInvoice patientInvoice)
        {
            UpdateCommand.Parameters["@ID"].Value            = patientInvoice.ID;
            UpdateCommand.Parameters["@InvoiceNo"].Value     = patientInvoice.InvoiceNo;
            UpdateCommand.Parameters["@PatientID"].Value     = patientInvoice.PatientID;
            UpdateCommand.Parameters["@PatientName"].Value   = patientInvoice.PatientName;
            UpdateCommand.Parameters["@DoctorID"].Value      = patientInvoice.DoctorID;
            UpdateCommand.Parameters["@DoctorName"].Value    = patientInvoice.DoctorName;
            UpdateCommand.Parameters["@CompanyID"].Value     = patientInvoice.CompanyID;
            UpdateCommand.Parameters["@CompanyName"].Value   = patientInvoice.CompanyName;
            UpdateCommand.Parameters["@PaymentModeID"].Value = patientInvoice.PaymentModeID;
            UpdateCommand.Parameters["@PaymentMode"].Value   = patientInvoice.PaymentMode;
            UpdateCommand.Parameters["@Total"].Value         = patientInvoice.Total;
            UpdateCommand.Parameters["@Discount"].Value      = patientInvoice.Discount;
            UpdateCommand.Parameters["@MOH"].Value           = patientInvoice.MOH;
            UpdateCommand.Parameters["@NetTotal"].Value      = patientInvoice.NetTotal;
            UpdateCommand.Parameters["@InvoiceDate"].Value   = patientInvoice.InvoiceDate;
            UpdateCommand.Parameters["@Username"].Value      = patientInvoice.Username;
            UpdateCommand.Parameters["@Status"].Value        = patientInvoice.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
Esempio n. 9
0
        public JsonResult CreateInvoice(PatientInvoice pinvoice)
        {
            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims             = identity.Claims;
            PatientInvoice      patientInvoice     = new PatientInvoice();
            PatientInvoice      onlyPatientInvoice = new PatientInvoice();

            // var userId = claims.Where(r => r.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value;

            using (Repository <PatientInvoice> repository = new Repository <PatientInvoice>())
            {
                // patientInvoice.UserId = Convert.ToInt32(userId);
                // patientInvoice.InvoiceStatusId = 1;
                if (pinvoice.Id == 0)
                {
                    List <PatientService> patientServiceItems = pinvoice.PatientServices.ToList();
                    pinvoice.PatientServices = null;
                    pinvoice.UserId          = patientInvoice.UserId;
                    patientInvoice           = repository.Insert(pinvoice);
                    repository.Commit();
                    foreach (PatientService item in patientServiceItems)
                    {
                        item.InvoiceID = pinvoice.Id;
                        item.UserId    = GetLoggedinUserInfo().UserId;

                        using (PatientServiceRepository patientservicerepository = new PatientServiceRepository())
                        {
                            patientservicerepository.Update(item);
                            patientservicerepository.Commit();
                        }
                    }
                }
                else
                {
                    List <PatientService> patientServiceItems = pinvoice.PatientServices.ToList();
                    pinvoice.PatientServices = null;

                    patientInvoice = repository.Update(pinvoice);
                    repository.Commit();

                    if (pinvoice.InvoiceStatusId == 2)
                    {
                        foreach (PatientService item in patientServiceItems)
                        {
                            item.InvoiceID = pinvoice.Id;
                            item.UserId    = GetLoggedinUserInfo().UserId;

                            item.Billed = true;

                            using (PatientServiceRepository patientservicerepository = new PatientServiceRepository())
                            {
                                patientservicerepository.Update(item);
                                patientservicerepository.Commit();
                            }
                        }
                    }
                }


                // repository.Commit();
            }

            //using (PatientServiceRepository repository = new PatientServiceRepository())
            //{

            //    foreach (PatientService patientervice in patientServices)
            //    {
            //        patientervice.InvoiceID = pinvoice.Id;
            //        repository.Update(patientervice);

            //    }
            //    repository.Commit();
            //}

            onlyPatientInvoice.Id              = patientInvoice.Id;
            onlyPatientInvoice.InvoiceDate     = patientInvoice.InvoiceDate;
            onlyPatientInvoice.DueDate         = patientInvoice.DueDate;
            onlyPatientInvoice.PatientID       = patientInvoice.PatientID;
            onlyPatientInvoice.TotalAmount     = patientInvoice.TotalAmount;
            onlyPatientInvoice.TotalDiscount   = patientInvoice.TotalDiscount;
            onlyPatientInvoice.InvoiceStatusId = patientInvoice.InvoiceStatusId;
            onlyPatientInvoice.InvoiceStatusId = patientInvoice.InvoiceStatusId;
            onlyPatientInvoice.LabStatusId     = patientInvoice.LabStatusId;
            onlyPatientInvoice.ItemDiscount    = patientInvoice.ItemDiscount;
            onlyPatientInvoice.UserId          = patientInvoice.UserId;

            return(Json(onlyPatientInvoice, JsonRequestBehavior.AllowGet));
        }
Esempio n. 10
0
        public JsonResult GetInvoicesByPatientId(long id, long statusid, string DateStart, string DateEnd, long?invoiceId = null)
        {
            List <PatientInvoice> onlypatientInvoices = new List <PatientInvoice>();
            List <PatientInvoice> patientInvoices;

            DateTime invoiceDateStart = DateTime.Parse("1/1/1980");
            DateTime invoiceDateEnd   = DateTime.Today;

            if (IsDate(DateEnd) && IsDate(DateStart))
            {
                invoiceDateStart = DateTime.Parse(DateStart);
                invoiceDateEnd   = DateTime.Parse(DateEnd);
            }


            using (PatientInvoiceRepository repository = new PatientInvoiceRepository())
            {
                /* ParameterExpression argParam = Expression.Parameter(typeof(PatientInvoice), "s");
                 * Expression patientProperty = Expression.Property(argParam, "PatientID");
                 * Expression statusProperty = Expression.Property(argParam, "InvoiceStatusId");
                 *
                 * var val1 = Expression.Constant(id);
                 * var val2 = Expression.Constant(statusid);
                 *
                 * Expression e1 = Expression.Equal(patientProperty, val1);
                 * Expression e2 = Expression.Equal(statusProperty, val2);
                 *
                 * BinaryExpression andExp;*/


                // var andExp = e1;

                //var lambda = Expression.Lambda<Func<PatientInvoice, bool>>(andExp, argParam);
                Expression <Func <PatientInvoice, bool> > lambda;


                if (id == 0)
                {
                    if (statusid == 0)
                    {
                        lambda = (x => x.Active == true && x.InvoiceDate >= invoiceDateStart && x.InvoiceDate <= invoiceDateEnd && (invoiceId == null ? x.Id > 0 : x.Id == invoiceId));
                    }
                    else
                    {
                        lambda = (x => x.InvoiceStatusId == statusid && x.Active == true && x.InvoiceDate >= invoiceDateStart && x.InvoiceDate <= invoiceDateEnd && (invoiceId == null ? x.Id > 0 : x.Id == invoiceId));
                    }
                }
                else
                {
                    if (statusid == 0)
                    {
                        lambda = (x => x.PatientID == id && x.Active == true && x.InvoiceDate >= invoiceDateStart && x.InvoiceDate <= invoiceDateEnd && (invoiceId == null ? x.Id > 0 : x.Id == invoiceId));
                    }
                    else
                    {
                        lambda = (x => x.PatientID == id && x.Active == true && x.InvoiceStatusId == statusid && x.InvoiceDate >= invoiceDateStart && x.InvoiceDate <= invoiceDateEnd && (invoiceId == null ? x.Id > 0 : x.Id == invoiceId));
                    }
                }


                patientInvoices = repository.GetByQuery(lambda).ToList();
                patientInvoices = patientInvoices.OrderByDescending(x => x.InvoiceDate).ToList();



                foreach (PatientInvoice pinvoice in patientInvoices)
                {
                    PatientInvoice onlyPatientInvoice = new PatientInvoice();
                    Patient        patient            = new Patient();
                    onlyPatientInvoice.Patient = patient;

                    onlyPatientInvoice.Id                = pinvoice.Id;
                    onlyPatientInvoice.InvoiceDate       = pinvoice.InvoiceDate;
                    onlyPatientInvoice.DueDate           = pinvoice.DueDate;
                    onlyPatientInvoice.PatientID         = pinvoice.PatientID;
                    onlyPatientInvoice.TotalAmount       = pinvoice.TotalAmount;
                    onlyPatientInvoice.TotalDiscount     = pinvoice.TotalDiscount;
                    onlyPatientInvoice.InvoiceStatusId   = pinvoice.InvoiceStatusId;
                    onlyPatientInvoice.ItemDiscount      = pinvoice.ItemDiscount;
                    onlyPatientInvoice.UserId            = pinvoice.UserId;
                    onlyPatientInvoice.LabStatusId       = pinvoice.LabStatusId;
                    onlyPatientInvoice.IsRefunded        = pinvoice.IsRefunded;
                    onlyPatientInvoice.Patient.FirstName = pinvoice.Patient.FirstName;
                    onlyPatientInvoice.Patient.LastName  = pinvoice.Patient.LastName;
                    onlyPatientInvoice.UserId            = GetLoggedinUserInfo().UserId;

                    foreach (InvoicePayment invoicepayment in pinvoice.InvoicePayments)
                    {
                        InvoicePayment invoicePayment = new InvoicePayment();

                        invoicePayment.Id = invoicepayment.Id;
                        invoicePayment.PatientInvoiceId = invoicepayment.PatientInvoiceId;
                        invoicePayment.Amount           = invoicepayment.Amount;
                        invoicePayment.PaymentID        = invoicepayment.PaymentID;
                        invoicePayment.UserId           = invoicepayment.UserId;
                        onlyPatientInvoice.InvoicePayments.Add(invoicePayment);
                    }

                    foreach (PatientService c in pinvoice.PatientServices)
                    {
                        PatientService patientstitem = new PatientService();
                        Item           item          = new Item();
                        ItemCategory   Category      = new ItemCategory();
                        patientstitem.Item = item;
                        patientstitem.Item.ItemCategory = Category;


                        patientstitem.Id                   = c.Id;
                        patientstitem.PatientID            = c.PatientID;
                        patientstitem.ItemId               = c.ItemId;
                        patientstitem.InvoiceID            = c.InvoiceID;
                        patientstitem.ReceiptId            = c.ReceiptId;
                        patientstitem.PatientAdmissionId   = c.PatientAdmissionId;
                        patientstitem.ServiceListPrice     = c.ServiceListPrice;
                        patientstitem.ServiceActualPrice   = c.ServiceActualPrice;
                        patientstitem.ServiceQuantity      = c.ServiceQuantity;
                        patientstitem.ServiceDate          = c.ServiceDate;
                        patientstitem.UserId               = c.UserId;
                        patientstitem.Discount             = c.Discount;
                        patientstitem.DiscountAfterInvoice = c.DiscountAfterInvoice;
                        patientstitem.Refund               = c.Refund;
                        patientstitem.RefundNote           = c.RefundNote;

                        patientstitem.Billed       = c.Billed;
                        patientstitem.LabStatusId  = c.LabStatusId;
                        patientstitem.ReferralFee  = c.ReferralFee;
                        patientstitem.DeliveryDate = c.DeliveryDate;
                        patientstitem.DeliveryTime = c.DeliveryTime;


                        patientstitem.Item.Name        = c.Item.Name;
                        patientstitem.Item.GenericName = c.Item.GenericName;

                        if (c.Item.ItemCategory != null)
                        {
                            patientstitem.Item.ItemCategory.Name = c.Item.ItemCategory.Name;
                        }

                        patientstitem.Item.ReferralAllowed = c.Item.ReferralAllowed;

                        patientstitem.ReferralFeePaid   = c.ReferralFeePaid;
                        patientstitem.ServiceProviderId = c.ServiceProviderId;
                        patientstitem.UserId            = GetLoggedinUserInfo().UserId;

                        onlyPatientInvoice.PatientServices.Add(patientstitem);
                    }

                    onlypatientInvoices.Add(onlyPatientInvoice);
                }

                if (onlypatientInvoices == null)
                {
                    return(Json(HttpNotFound(), JsonRequestBehavior.AllowGet));
                }

                return(Json(onlypatientInvoices, JsonRequestBehavior.AllowGet));
            }
        }
        private PatientInvoice DataTableToEntity(DataTable dt)
        {
            PatientInvoice patientInvoice = new PatientInvoice();

            if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0)
            {
                if (Null.IsNotNull(dt.Rows[0]))
                {
                    DataRow dr = dt.Rows[0];
                    if (Null.IsNotNull(dr["ID"]))
                    {
                        patientInvoice.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        patientInvoice.ID = 0;
                    }
                    if (Null.IsNotNull(dr["InvoiceNo"]))
                    {
                        patientInvoice.InvoiceNo = Convert.ToInt32(dr["InvoiceNo"]);
                    }
                    else
                    {
                        patientInvoice.InvoiceNo = 0;
                    }
                    if (Null.IsNotNull(dr["PatientID"]))
                    {
                        patientInvoice.PatientID = Convert.ToInt32(dr["PatientID"]);
                    }
                    else
                    {
                        patientInvoice.PatientID = 0;
                    }
                    if (Null.IsNotNull(dr["PatientName"]))
                    {
                        patientInvoice.PatientName = Convert.ToString(dr["PatientName"]);
                    }
                    else
                    {
                        patientInvoice.PatientName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["DoctorID"]))
                    {
                        patientInvoice.DoctorID = Convert.ToInt32(dr["DoctorID"]);
                    }
                    else
                    {
                        patientInvoice.DoctorID = 0;
                    }
                    if (Null.IsNotNull(dr["DoctorName"]))
                    {
                        patientInvoice.DoctorName = Convert.ToString(dr["DoctorName"]);
                    }
                    else
                    {
                        patientInvoice.DoctorName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["CompanyID"]))
                    {
                        patientInvoice.CompanyID = Convert.ToInt32(dr["CompanyID"]);
                    }
                    else
                    {
                        patientInvoice.CompanyID = 0;
                    }
                    if (Null.IsNotNull(dr["CompanyName"]))
                    {
                        patientInvoice.CompanyName = Convert.ToString(dr["CompanyName"]);
                    }
                    else
                    {
                        patientInvoice.CompanyName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["PaymentModeID"]))
                    {
                        patientInvoice.PaymentModeID = Convert.ToInt32(dr["PaymentModeID"]);
                    }
                    else
                    {
                        patientInvoice.PaymentModeID = 0;
                    }
                    if (Null.IsNotNull(dr["PaymentMode"]))
                    {
                        patientInvoice.PaymentMode = Convert.ToString(dr["PaymentMode"]);
                    }
                    else
                    {
                        patientInvoice.PaymentMode = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Total"]))
                    {
                        patientInvoice.Total = Convert.ToDecimal(dr["Total"]);
                    }
                    else
                    {
                        patientInvoice.Total = 0.00m;
                    }
                    if (Null.IsNotNull(dr["Discount"]))
                    {
                        patientInvoice.Discount = Convert.ToDecimal(dr["Discount"]);
                    }
                    else
                    {
                        patientInvoice.Discount = 0.00m;
                    }
                    if (Null.IsNotNull(dr["MOH"]))
                    {
                        patientInvoice.MOH = Convert.ToDecimal(dr["MOH"]);
                    }
                    else
                    {
                        patientInvoice.MOH = 0.00m;
                    }
                    if (Null.IsNotNull(dr["NetTotal"]))
                    {
                        patientInvoice.NetTotal = Convert.ToDecimal(dr["NetTotal"]);
                    }
                    else
                    {
                        patientInvoice.NetTotal = 0.00m;
                    }
                    if (Null.IsNotNull(dr["InvoiceDate"]))
                    {
                        patientInvoice.InvoiceDate = Convert.ToDateTime(dr["InvoiceDate"]);
                    }
                    else
                    {
                        patientInvoice.InvoiceDate = DateTime.Now;
                    }
                    if (Null.IsNotNull(dr["Username"]))
                    {
                        patientInvoice.Username = Convert.ToString(dr["Username"]);
                    }
                    else
                    {
                        patientInvoice.Username = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        patientInvoice.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        patientInvoice.Status = string.Empty;
                    }
                }
            }
            return(patientInvoice);
        }
 public IActionResult UpdatePatientInvoice([FromBody] PatientInvoice model)
 {
     _repo.Update(model);
     return(new OkObjectResult(new { PatientInvoiceID = model.PatientInvoiceId }));
 }