public PatientRevenueReportResponseModel GetPatientRevenueReport(PatientRevenueReportResponseModel model) { if (model.FromDate == null || model.ToDate == null) { throw new Exception("Please enter proper date range"); } model.Hdls = hdlRegistrationRepository.GetAll().ToList()?.FindAll(x => x.RegistrationCategoryId == 2 && x.RegistrationTypeId != 3); model.Occupations = fieldOptionsRepository.GetAll().ToList()?.FindAll(x => x.FieldId == 2); var bills = patientBillRepository.GetAll().ToList()?.FindAll(x => x.BillDate >= model.FromDate && x.BillDate <= model.ToDate); if (bills != null) { model.RevenueItems = new List <PatientRevenueModelDto>(); foreach (var bill in bills) { var item = new PatientRevenueModelDto(); item.BillId = bill.Id; item.BillNo = (int)bill.BillNo; var discount = (float)bill.Discount; var gst = (float)bill.Gst; item.TotalAmount = (float)bill.TotalCharges - ConvertPercentToValue((float)bill.TotalCharges, discount) + ConvertPercentToValue((float)bill.TotalCharges, gst); item.AmountPaid = (float)bill.AmountPaid; item.Balance = (float)(item.TotalAmount - (float)bill.AmountPaid); item.Balance = (float)Math.Round(item.Balance, 2); item.IsPaid = bill.AmountPaid >= item.TotalAmount; var patient = patientRepository.Get(bill.PatientId); if (patient != null) { item.PatientCode = patient.PatientCode; item.PatientName = patient.FirstName + " " + patient.LastName; item.PatientId = patient.Id; item.HdlId = (int)patient.ReferredBy; item.Occupation = patient.Occupation; } model.RevenueItems.Add(item); } } return(model); }
public ActionResult GetPatientRevenueReport(PatientRevenueReportResponseModel requestModel) { try { var resposeModel = financeService.GetPatientRevenueReport(requestModel); if (resposeModel != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, resposeModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No bills found", "Something went wrong!")))); } } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", e.Message)))); } }
public async Task <PatientRevenueReportResponseModel> GetPatientRevenueResponseModel(PatientRevenueReportResponseModel model) { var url = URLBuilder.GetURL(Controllers.FINANCE, EndPoint.FINANCE_PATIENT_REVENUE_REPORT); return(await requestProvider.PostAsync(url, model)); }