Beispiel #1
0
        public EntityPatientInvoice GetChargesForCate(int charge)
        {
            EntityPatientInvoice cate = (from tbl in objData.tblChargeCategories
                                         where tbl.ChargesId.Equals(charge) &&
                                         tbl.IsDelete == false
                                         select new EntityPatientInvoice {
                Amount = tbl.Charges
            }).SingleOrDefault();

            return(cate);
        }
Beispiel #2
0
        public int GetBillNo(int Patient_ID)
        {
            EntityPatientInvoice entIn = new EntityPatientInvoice();

            entIn = (from tbl in objData.tblPatientInvoices
                     where tbl.PatientId.Equals(Patient_ID) && tbl.BillType != "Estimated"
                     select new EntityPatientInvoice {
                BillNo = tbl.BillNo
            }).FirstOrDefault();

            if (entIn != null)
            {
                return(entIn.BillNo);
            }
            else
            {
                return(0);
            }
        }
Beispiel #3
0
        public EntityPatientInvoice GetWardName(int PatID)
        {
            EntityPatientInvoice lst = (from tbl in objData.tblBedAllocationToPatients
                                        join tblbed in objData.tblBedMasters
                                        on tbl.BedId equals tblbed.BedId
                                        join tblR in objData.tblRoomMasters
                                        on tbl.RoomId equals tblR.RoomId
                                        join tblC in objData.tblRoomCategories
                                        on tblR.CategoryId equals tblC.PKId
                                        join tblP in objData.tblPatientAdmitDetails
                                        on tbl.PatientId equals tblP.AdmitId
                                        where tbl.PatientId.Equals(PatID) &&
                                        tbl.DischargeDate == null &&
                                        tblC.IsOT == false &&
                                        tblC.IsICU == false &&
                                        tbl.ShiftDate == null
                                        orderby tbl.BedAllocId ascending
                                        select new EntityPatientInvoice {
                Description = tblC.CategoryDesc
            }).FirstOrDefault();

            return(lst);
        }
Beispiel #4
0
        public int UpdateOPDRefund(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lst)
        {
            int i = 0;

            try
            {
                tblPatientInvoice objTest = (from tbl in objData.tblPatientInvoices
                                             where tbl.IsDelete == false &&
                                             tbl.BillNo == entInvoice.BillNo
                                             select tbl).FirstOrDefault();
                if (objTest != null)
                {
                    objTest.Amount         = 0;
                    objTest.NetAmount      = 0;
                    objTest.ReceivedAmount = 0;
                    objTest.RefundAmount   = entInvoice.NetAmount;
                    objTest.TotalAdvance   = 0;

                    tblCustomerTransaction objCust = (from tbl in objData.tblCustomerTransactions
                                                      where tbl.IsDelete == false &&
                                                      tbl.TransactionDocNo == entInvoice.BillNo &&
                                                      tbl.TransactionType == "Invoice"
                                                      select tbl).FirstOrDefault();


                    if (objCust != null)
                    {
                        objCust.PayAmount  = 0;
                        objCust.BillAmount = 0;
                    }

                    foreach (EntityInvoiceDetails item in lst)
                    {
                        if (item.BillSRNo > 0)
                        {
                            tblPatientInvoiceDetail cnt = (from tbl in objData.tblPatientInvoiceDetails
                                                           where tbl.BillNo == item.BillNo &&
                                                           tbl.BillSRNo == item.BillSRNo &&
                                                           tbl.IsDelete == false
                                                           select tbl).FirstOrDefault();
                            if (cnt != null)
                            {
                                cnt.BillNo         = entInvoice.BillNo;
                                cnt.ChargePerDay   = 0;
                                cnt.NetAmount      = 0;
                                cnt.Amount         = 0;
                                cnt.OtherChargesId = item.OtherChargesId;
                                cnt.IsDelete       = item.IsDelete;
                            }
                            objData.SubmitChanges();
                        }
                    }
                    objData.SubmitChanges();
                }
                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return(i);
        }
Beispiel #5
0
        public int UpdateInvoice(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lst)
        {
            int i = 0;

            try
            {
                tblPatientInvoice objTest = (from tbl in objData.tblPatientInvoices
                                             where tbl.IsDelete == false &&
                                             tbl.BillNo == entInvoice.BillNo
                                             select tbl).FirstOrDefault();
                if (objTest != null)
                {
                    objTest.Amount         = entInvoice.Amount;
                    objTest.BillType       = entInvoice.BillType;
                    objTest.NetAmount      = entInvoice.NetAmount;
                    objTest.TotalAdvance   = entInvoice.TotalAdvance;
                    objTest.BalanceAmount  = entInvoice.BalanceAmount;
                    objTest.ReceivedAmount = entInvoice.ReceivedAmount;
                    objTest.RefundAmount   = entInvoice.RefundAmount;
                    objTest.FixedDiscount  = entInvoice.FixedDiscount;
                    objTest.PreparedByName = entInvoice.PreparedByName;
                    //objTest.Service = entInvoice.Service;
                    //objTest.Vat = entInvoice.Vat;
                    if (entInvoice.BillType != "Estimated")
                    {
                        int TransactionId = GetTransactionId();
                        if (entInvoice.IsCash)
                        {
                            tblCustomerTransaction objDebit = new tblCustomerTransaction()
                            {
                                TransactionId    = TransactionId,
                                IsCash           = true,
                                TransactionDocNo = entInvoice.BillNo,
                                TransactionType  = "Invoice",
                                BillAmount       = entInvoice.NetAmount,
                                PayAmount        = entInvoice.NetAmount,
                                Discount         = entInvoice.FixedDiscount,
                                PatientId        = entInvoice.PatientId,
                                PreparedByName   = entInvoice.PreparedByName,
                                IsDelete         = false,
                                ReceiptDate      = entInvoice.BillDate,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        }
                        else
                        {
                            tblCustomerTransaction objDebit = new tblCustomerTransaction()
                            {
                                TransactionId    = TransactionId,
                                IsCash           = false,
                                TransactionDocNo = entInvoice.BillNo,
                                TransactionType  = "Invoice",
                                BillAmount       = entInvoice.NetAmount,
                                Discount         = entInvoice.FixedDiscount,
                                PatientId        = entInvoice.PatientId,
                                PreparedByName   = entInvoice.PreparedByName,
                                IsDelete         = false,
                                ReceiptDate      = entInvoice.BillDate,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                            //objData.SubmitChanges();
                        }
                    }
                    else
                    {
                        List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                                 where tbl.IsDelete == false &&
                                                                 tbl.TransactionDocNo == entInvoice.BillNo &&
                                                                 tbl.TransactionType == "Invoice"
                                                                 select tbl).ToList();
                        if (objCust != null)
                        {
                            if (objCust.Count == 1)
                            {
                                if (entInvoice.IsCash)
                                {
                                    tblCustomerTransaction objC = new tblCustomerTransaction()
                                    {
                                        PayAmount        = entInvoice.NetAmount,
                                        BillAmount       = entInvoice.NetAmount,
                                        Discount         = entInvoice.FixedDiscount,
                                        ReceiptDate      = entInvoice.BillDate,
                                        IsCash           = entInvoice.IsCash,
                                        IsDelete         = false,
                                        TransactionDocNo = entInvoice.BillNo,
                                        TransactionId    = objCust[0].TransactionId,
                                        TransactionType  = "Invoice",
                                        PatientId        = entInvoice.PatientId,
                                        PreparedByName   = entInvoice.PreparedByName,
                                    };
                                    objData.tblCustomerTransactions.InsertOnSubmit(objC);
                                    foreach (tblCustomerTransaction item in objCust)
                                    {
                                        item.BillAmount  = entInvoice.NetAmount;
                                        item.ReceiptDate = entInvoice.BillDate;
                                        item.IsCash      = entInvoice.IsCash;
                                        if (item.IsCash == false)
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.IsDelete = true;
                                            }
                                        }
                                        else
                                        {
                                            item.PayAmount = 0;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (tblCustomerTransaction item in objCust)
                                    {
                                        item.BillAmount  = entInvoice.NetAmount;
                                        item.ReceiptDate = entInvoice.BillDate;
                                        item.IsCash      = entInvoice.IsCash;
                                        if (item.IsCash == false)
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.IsDelete = true;
                                            }
                                        }
                                        else
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.PayAmount = entInvoice.NetAmount;
                                            }
                                            else
                                            {
                                                item.PayAmount = 0;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                foreach (tblCustomerTransaction item in objCust)
                                {
                                    item.BillAmount  = entInvoice.NetAmount;
                                    item.ReceiptDate = entInvoice.BillDate;
                                    item.IsCash      = entInvoice.IsCash;
                                    if (item.IsCash == false)
                                    {
                                        if (item.PayAmount > 0)
                                        {
                                            item.IsDelete = true;
                                        }
                                    }
                                    else
                                    {
                                        if (item.PayAmount > 0)
                                        {
                                            item.PayAmount = entInvoice.NetAmount;
                                        }
                                        else
                                        {
                                            item.PayAmount = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    foreach (EntityInvoiceDetails item in lst)
                    {
                        if (item.BillSRNo > 0)
                        {
                            tblPatientInvoiceDetail cnt = (from tbl in objData.tblPatientInvoiceDetails
                                                           where tbl.BillNo == item.BillNo &&
                                                           tbl.BillSRNo == item.BillSRNo &&
                                                           tbl.IsDelete == false
                                                           select tbl).FirstOrDefault();
                            if (cnt != null)
                            {
                                cnt.BillNo         = entInvoice.BillNo;
                                cnt.Quantity       = item.Quantity;
                                cnt.NoOfDays       = item.NoOfDays;
                                cnt.Remarks        = item.Remarks;
                                cnt.Amount         = item.Amount;
                                cnt.ChargePerDay   = item.PerDayCharge;
                                cnt.OtherChargesId = item.OtherChargesId;
                                cnt.IsDelete       = item.IsDelete;
                            }
                        }
                        else
                        {
                            tblPatientInvoiceDetail objNewAdded = new tblPatientInvoiceDetail()
                            {
                                BillNo         = entInvoice.BillNo,
                                BedAllocId     = item.BedAllocId,
                                OTAllocId      = item.OTBedAllocId,
                                DocAllocId     = item.DocAllocationId,
                                OtherChargesId = item.OtherChargesId,
                                Amount         = item.Amount,
                                ChargePerDay   = item.PerDayCharge,
                                NetAmount      = item.NetAmount,
                                Remarks        = item.Remarks,
                                NoOfDays       = item.NoOfDays,
                                Quantity       = item.Quantity,
                                IsDelete       = false
                            };
                            objData.tblPatientInvoiceDetails.InsertOnSubmit(objNewAdded);
                            if (entInvoice.BillType == "Original")
                            {
                                if (objNewAdded.BedAllocId > 0)
                                {
                                    int p = new BedStatusBLL().DischargePatient(entInvoice.PatientId, entInvoice.BillDate);
                                }
                            }
                        }
                    }

                    tblPatientAdmitDetail admit = (from tbl in objData.tblPatientAdmitDetails
                                                   where tbl.IsDelete == false &&
                                                   tbl.AdmitId == entInvoice.PatientId
                                                   select tbl).FirstOrDefault();
                    if (entInvoice.BillType == "Estimated")
                    {
                        if (admit != null)
                        {
                            admit.IsDischarge = false;
                        }
                    }

                    if (entInvoice.BillType == "Original")
                    {
                        if (admit != null)
                        {
                            admit.IsDischarge = true;
                        }
                    }

                    objData.SubmitChanges();
                }
                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return(i);
        }
Beispiel #6
0
        public int InsertInvoice(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lstInvoice, bool IsCash)
        {
            try
            {
                int?BillNo = 0;
                objData.STP_InsertInvoice(Convert.ToDateTime(entInvoice.BillDate),
                                          ref BillNo, Convert.ToString(entInvoice.BillType), Convert.ToInt32(entInvoice.PatientId), Convert.ToString(entInvoice.PreparedByName),
                                          Convert.ToDecimal(entInvoice.Amount), Convert.ToDecimal(entInvoice.Discount),
                                          //Convert.ToDecimal(entInvoice.Vat), Convert.ToDecimal(entInvoice.Service),
                                          Convert.ToDecimal(entInvoice.NetAmount), Convert.ToDecimal(entInvoice.TotalAdvance),
                                          Convert.ToDecimal(entInvoice.BalanceAmount), Convert.ToDecimal(entInvoice.ReceivedAmount),
                                          Convert.ToDecimal(entInvoice.RefundAmount),
                                          true, Convert.ToDecimal(entInvoice.FixedDiscount));
                foreach (EntityInvoiceDetails entInvoiceDetails in lstInvoice)
                {
                    tblPatientInvoiceDetail obj = new tblPatientInvoiceDetail()
                    {
                        BillNo         = BillNo,
                        BedAllocId     = entInvoiceDetails.BedAllocId,
                        OTAllocId      = entInvoiceDetails.OTBedAllocId,
                        DocAllocId     = entInvoiceDetails.DocAllocationId,
                        OtherChargesId = entInvoiceDetails.OtherChargesId,
                        Amount         = entInvoiceDetails.Amount,
                        NetAmount      = entInvoice.NetAmount,
                        ChargePerDay   = entInvoiceDetails.PerDayCharge,
                        Remarks        = entInvoiceDetails.Remarks,
                        NoOfDays       = entInvoiceDetails.NoOfDays,
                        Quantity       = entInvoiceDetails.Quantity,
                        IsDelete       = false
                    };
                    objData.tblPatientInvoiceDetails.InsertOnSubmit(obj);
                    if (entInvoice.BillType == "Original")
                    {
                        if (entInvoiceDetails.BedAllocId > 0)
                        {
                            int i = new BedStatusBLL().DischargePatient(entInvoice.PatientId, entInvoice.BillDate);
                        }
                    }
                }
                //int i = new BedStatusBLL().DischargePatient(entInvoiceDetails.PatientID, entInvoice.BillDate);
                if (entInvoice.BillType != "Estimated")
                {
                    int TransactionId = GetTransactionId();
                    if (IsCash)
                    {
                        tblCustomerTransaction objDebit = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = true,
                            TransactionDocNo = BillNo,
                            TransactionType  = "Invoice",
                            BillAmount       = entInvoice.NetAmount,
                            PayAmount        = entInvoice.NetAmount,
                            Discount         = entInvoice.FixedDiscount,
                            PatientId        = entInvoice.PatientId,
                            PreparedByName   = entInvoice.PreparedByName,
                            IsDelete         = false,
                            ReceiptDate      = entInvoice.BillDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        //objData.SubmitChanges();
                        //tblCustomerTransaction objCrReceipt = new tblCustomerTransaction()
                        //{
                        //    TransactionId = TransactionId,
                        //    IsCash = true,
                        //    TransactionDocNo = BillNo,
                        //    TransactionType = "Invoice",
                        //    PayAmount = entInvoice.NetAmount,
                        //    BillAmount=0,
                        //    PatientId = entInvoice.PatientId,
                        //    IsDelete = false,
                        //    ReceiptDate = entInvoice.BillDate,
                        //};
                        //objData.tblCustomerTransactions.InsertOnSubmit(objCrReceipt);
                        //objData.SubmitChanges();
                    }
                    else
                    {
                        tblCustomerTransaction objDebit = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            TransactionDocNo = BillNo,
                            TransactionType  = "Invoice",
                            BillAmount       = entInvoice.NetAmount,
                            Discount         = entInvoice.FixedDiscount,
                            PatientId        = entInvoice.PatientId,
                            PreparedByName   = entInvoice.PreparedByName,
                            IsDelete         = false,
                            ReceiptDate      = entInvoice.BillDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        //objData.SubmitChanges();
                    }
                }

                tblPatientAdmitDetail admit = (from tbl in objData.tblPatientAdmitDetails
                                               where tbl.IsDelete == false &&
                                               tbl.IsDischarge == false &&
                                               tbl.AdmitId == entInvoice.PatientId
                                               select tbl).FirstOrDefault();
                if (entInvoice.BillType == "Estimated")
                {
                    if (admit != null)
                    {
                        admit.IsDischarge = false;
                    }
                }

                if (entInvoice.BillType == "Original")
                {
                    if (admit != null)
                    {
                        admit.IsDischarge = true;
                    }
                    //if (admit != null && entInvoice.PatientType == "OPD")
                    //{
                    //    admit.IsDischarge = false;

                    //}
                }
                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }