Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(PatientBillViewModel model)
        {
            db.Database.ExecuteSqlCommand("sp_DeletePatientBill @ID", new SqlParameter("@ID", model.ID)); //trigger it

            var tblPatientBill2 = (from o in db.tblPatientBillDetails
                                   join p in db.tblPatientBills on o.PatientBillID equals p.ID
                                   where o.ID == model.ID && p.is_active == true
                                   select p).FirstOrDefault();

            var tblPatientBill = (from o in db.tblPatientBillDetails
                                  join p in db.tblPatientBills on o.PatientBillID equals p.ID
                                  where o.ID == model.ID && p.is_active == true
                                  select p)
                                 .ToList();

            if (tblPatientBill.Count != 0)
            {
                var lst = db.tblPatientBillDetails
                          .Where(x => x.PatientBillID == tblPatientBill2.ID && x.is_active == true)
                          .ToList();

                foreach (var patientBill in tblPatientBill)
                {
                    patientBill.Amount = lst.Where(b => b.PatientBillID == tblPatientBill2.ID && b.is_active == true).Select(c => c.Amount).Sum();
                    if (patientBill.Amount == 0)
                    {
                        patientBill.is_active = false;
                    }
                }
                db.SaveChanges();
            }
            return(RedirectToAction("BillListings"));
        }
Ejemplo n.º 2
0
        public ActionResult EditPatient(int id)
        {
            HMS_DBEntity db = new HMS_DBEntity();
            List <tblPatientBillDetail> list = db.tblPatientBillDetails.ToList();

            PatientBillViewModel model = new PatientBillViewModel();

            if (id > 0)
            {
                tblPatientBillDetail detail = db.tblPatientBillDetails.SingleOrDefault(x => x.ID == id && x.is_active == true);
                model.ID            = detail.ID;
                model.PatientBillID = detail.PatientBillID;
                model.Amount        = detail.Amount;
                model.Description   = detail.Description;
            }
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(PatientBillViewModel model)
        {
            string     username = "";
            HttpCookie cookie   = HttpContext.Request.Cookies["AdminCookies"];

            if (cookie != null)
            {
                username = Convert.ToString(cookie.Values["UserName"]);
            }
            if (model.ID > 0)
            {
                //update
                tblPatientBillDetail emp = db.tblPatientBillDetails.SingleOrDefault(x => x.ID == model.ID && x.is_active == true);
                emp.PatientBillID = model.PatientBillID;
                emp.Amount        = model.Amount;
                emp.CreatedAt     = DateTime.UtcNow;
                emp.CreatedBy     = username;
                emp.Description   = model.Description;
                db.SaveChanges();

                var tblPatientBill2 = db.tblPatientBills.FirstOrDefault(x => x.ID == emp.PatientBillID && x.is_active == true);
                var tblPatientBill  = db.tblPatientBills.Where(x => x.ID == emp.PatientBillID && x.is_active == true).ToList();

                if (tblPatientBill.Count != 0)
                {
                    var lst = db.tblPatientBillDetails
                              .Where(x => x.PatientBillID == tblPatientBill2.ID && x.is_active == true)
                              .ToList();

                    foreach (var patientBill in tblPatientBill)
                    {
                        patientBill.Amount = lst.Where(b => b.PatientBillID == tblPatientBill2.ID).Select(c => c.Amount).Sum();
                    }
                    db.SaveChanges();
                }
                return(Redirect("/EditBill?id=" + emp.PatientBillID));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public ActionResult PatientBill(int patientId)
        {
            List <Treatment>  treatments  = _billingManagementService.GetTreatmentsForPatient(patientId);
            List <Test>       tests       = _billingManagementService.GetTestsForPatient(patientId);
            List <Medication> medications = _billingManagementService.GetMedicationsForPatient(patientId);
            Dictionary <string, Tuple <double, int, double> > treatmentDict  = new Dictionary <string, Tuple <double, int, double> >();
            Dictionary <string, Tuple <double, int, double> > testDict       = new Dictionary <string, Tuple <double, int, double> >();
            Dictionary <string, Tuple <double, int, double> > medicationDict = new Dictionary <string, Tuple <double, int, double> >();
            int count = 0;

            foreach (Treatment treatment in treatments)
            {
                if (!String.IsNullOrEmpty(treatment.TreatmentType))
                {
                    if (treatmentDict.ContainsKey(treatment.TreatmentType))
                    {
                        count = treatmentDict[treatment.TreatmentType].Item2 + 1;
                        Tuple <double, int, double> treatmentTuple = new Tuple <double, int, double>(treatment.Rate, count, treatment.Rate * count);
                        treatmentDict[treatment.TreatmentType] = treatmentTuple;
                    }
                    else
                    {
                        Tuple <double, int, double> treatmentTuple = new Tuple <double, int, double>(treatment.Rate, 1, treatment.Rate);
                        treatmentDict.Add(treatment.TreatmentType, treatmentTuple);
                    }
                }
            }

            count = 0;
            foreach (Test test in tests)
            {
                if (!String.IsNullOrEmpty(test.Type))
                {
                    if (testDict.ContainsKey(test.Type))
                    {
                        count = testDict[test.Type].Item2 + 1;
                        Tuple <double, int, double> testTuple = new Tuple <double, int, double>(test.Rate, count, test.Rate * count);
                        testDict[test.Type] = testTuple;
                    }
                    else
                    {
                        Tuple <double, int, double> testTuple = new Tuple <double, int, double>(test.Rate, 1, test.Rate);
                        testDict.Add(test.Type, testTuple);
                    }
                }
            }

            count = 0;
            foreach (Medication medication in medications)
            {
                if (!String.IsNullOrEmpty(medication.Name))
                {
                    if (medicationDict.ContainsKey(medication.Name))
                    {
                        count = medicationDict[medication.Name].Item2 + 1;
                        Tuple <double, int, double> medicationTuple = new Tuple <double, int, double>(medication.Rate, count, medication.Rate * count);
                        medicationDict[medication.Name] = medicationTuple;
                    }
                    else
                    {
                        Tuple <double, int, double> medicationTuple = new Tuple <double, int, double>(medication.Rate, 1, medication.Rate);
                        medicationDict.Add(medication.Name, medicationTuple);
                    }
                }
            }


            // CALCULATE BILL AMOUNT
            int    numVisits = _billingManagementService.GetNumberOfVisitationsForPatient(patientId);
            double Amount    = (numVisits * 100)
                               + testDict.Sum(ix => ix.Value.Item3)
                               + treatmentDict.Sum(ix => ix.Value.Item3)
                               + medicationDict.Sum(ix => ix.Value.Item3);

            PatientBillViewModel patientBillViewModel = new PatientBillViewModel
            {
                Patient             = _patientRepository.GetPatient(patientId),
                NumberOfVisitations = numVisits,
                VisitationCost      = 100 * numVisits,
                TestDict            = testDict,
                TreatmentDict       = treatmentDict,
                MedicationDict      = medicationDict,
                BillAmount          = Amount
            };

            return(View(patientBillViewModel));
        }
 public PatientBillView()
 {
     InitializeComponent();
     _viewModel  = DIContainer.Resolve <PatientBillViewModel>();
     DataContext = _viewModel;
 }