public ActionResult DoctorClinecPaymnet()
        {
            try
            {
                int clinecID = getUserCurrentClinecID();
                int doctorID = getDoctorIDbyUserID();

                DateTime date = DateTime.Now;
                // day start
                DateTime from = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0);
                // day end
                DateTime to = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59, 999);

                PatientBillInfoWrap        billInfo;
                List <PatientBillInfoWrap> patientBillInfoWrap       = new List <PatientBillInfoWrap>();
                DoctorPatientBillInfoWrap  doctorPatientBillInfoWrap = new DoctorPatientBillInfoWrap();


                IEnumerable <PatientMiniData> patientList = patientRepository.getPatientListForDoctor(clinecID, doctorID, from, to);

                if (patientList == null)
                {
                    return(HttpNotFound());
                }

                foreach (PatientMiniData item in patientList)
                {
                    billInfo             = patientPaymentBL.patientTotalCost(item.PatientID, clinecID, from, to);
                    billInfo.patientID   = item.PatientID;
                    billInfo.patientName = item.Name;
                    patientBillInfoWrap.Add(billInfo);
                }

                patientBillInfoWrap.TrimExcess();

                billInfo = new PatientBillInfoWrap();

                billInfo.TotalCost         = patientBillInfoWrap.Sum(x => x.TotalCost);
                billInfo.Remain            = patientBillInfoWrap.Sum(x => x.Remain);
                billInfo.materialCost      = patientBillInfoWrap.Sum(x => x.materialCost);
                billInfo.customMatrialCost = patientBillInfoWrap.Sum(x => x.customMatrialCost);
                billInfo.opperationCost    = patientBillInfoWrap.Sum(x => x.opperationCost);
                billInfo.treatmentCost     = patientBillInfoWrap.Sum(x => x.treatmentCost);
                billInfo.PatientPayment    = patientBillInfoWrap.Sum(x => x.PatientPayment);


                doctorPatientBillInfoWrap.patientPaymentInfoList  = patientBillInfoWrap;
                doctorPatientBillInfoWrap.TotalPatientPaymentInfo = billInfo;

                return(View(doctorPatientBillInfoWrap));
            }
            catch (Exception)
            {
                return(HttpNotFound());
            }
        }
Exemple #2
0
        public PatientBillInfoWrap patientTotalCost(int patientID, int clinecID, DateTime from, DateTime to)
        {
            decimal?TotalCost = 0;

            decimal treatmentCost     = 0;
            decimal?opperationCost    = 0;
            decimal?materialCost      = 0;
            decimal?customMatrialCost = 0;
            decimal?patientPayment    = 0;
            decimal?remain            = 0;

            CustomMatrialRepository customMatrialRepository = new CustomMatrialRepository();

            customMatrialCost = customMatrialRepository.getPatientCusmotMatrialCostTotal(patientID, clinecID, from, to);

            TreatmentRepository     treatmentRepository  = new TreatmentRepository();
            IEnumerable <Treatment> patientTreatmentList = treatmentRepository.getPatientTreatmentList(patientID, clinecID, from, to);

            foreach (Treatment treatment in patientTreatmentList)
            {
                treatmentCost  += treatment.TeratmentCost;
                opperationCost += treatment.OpperationCost;

                IEnumerable <MaterialTreatment> matrialTreatmentList = treatment.MaterialTreatments;

                foreach (MaterialTreatment matrialTreatment in matrialTreatmentList)
                {
                    materialCost += matrialTreatment.MaterialCost * (int)matrialTreatment.Quantity;
                }
            }

            if (opperationCost == null)
            {
                opperationCost = 0;
            }

            if (materialCost == null)
            {
                materialCost = 0;
            }

            if (customMatrialCost == null)
            {
                customMatrialCost = 0;
            }

            TotalCost = treatmentCost + opperationCost + materialCost;// +customMatrialCost;

            patientPayment = patientTotalPayment(patientID, clinecID, from, to);

            if (patientPayment == null)
            {
                patientPayment = 0;
            }

            remain = TotalCost - patientPayment;

            PatientBillInfoWrap billInfo = new PatientBillInfoWrap {
                customMatrialCost = customMatrialCost, materialCost = materialCost, opperationCost = opperationCost, treatmentCost = treatmentCost, TotalCost = TotalCost, PatientPayment = patientPayment, Remain = remain
            };

            return(billInfo);
        }
        public ActionResult DoctorPayment()
        {
            PatientBillInfoWrap billInfo = patientPaymentBL.patientTotalCost(getCurrentPatientID(), getUserCurrentClinecID());

            return(View(billInfo));
        }