示例#1
0
        public ActionResult TreatmentToPatient(PatientTreatment model, int centerId)
        {
            Patient patient = _patientManager.GetAll().FirstOrDefault(m => m.Id == model.PatientId);

            patient.ServiceGiven = model.ServiceTime;


            try
            {
                if (ModelState.IsValid)
                {
                    _patientManager.Update(patient);
                    _patientTreatmentManager.Add(model);
                    ViewBag.message = "Patient treatment is given Sucessfully";
                }
            }
            catch (Exception ex)
            {
                ViewBag.message = ex.Message;
            }
            SelectList aList = new SelectList(_doctorManager.GetAll().ToList(), "Id", "Name");
            SelectList list  = new SelectList(_diseaseManager.GetAll().ToList(), "Id", "Name");
            Dictionary <int, string> doses = new Dictionary <int, string>()
            {
                { 1, "Before Meal" },
                { 2, "After Meal" }
            };

            ViewBag.doctors  = aList;
            ViewBag.diseases = list;
            SelectList anList = new SelectList(doses, "Key", "Value");

            ViewBag.doseList = anList;
            return(View(model));
        }
示例#2
0
        public ActionResult DeliverMedicineToPatient(DeliverMedicineViewModel model)
        {
            if (Session["CenterId"] == null)
            {
                ViewBag.message = "Center Id not found!! Please give Correct Center";
                return(View());
            }
            int              centerId         = (int)Session["CenterId"];
            MedicineStore    store            = (MedicineStore)_medicineStoreManager.GetAll().ToList().FirstOrDefault(m => m.CenterId == centerId);
            PatientTreatment patientTreatment = _patientTreatmentManager.GetById(model.Id);

            foreach (PatientDisease disease in patientTreatment.PatientDiseases)
            {
                StoreDetail storeDetail = store.StoreDetails.ToList().FirstOrDefault(m => m.MedicineId == disease.MedicineId);
                if (storeDetail == null)
                {
                    ViewBag.message = "Medicine Id " + disease.MedicineId + " no Found in this Center Store";
                    return(View());
                }
                storeDetail.Quantity = storeDetail.Quantity - disease.MedicineQuantity;
                if (storeDetail.Quantity < 0)
                {
                    ViewBag.message = "Medicine Id " + disease.MedicineId + " is out of Stock!!! Please Inform Head office for Medicine";
                    return(View());
                }
            }

            bool result = _medicineStoreManager.Update(store);

            if (result)
            {
                ViewBag.message = "Medicine Given Sucessfully to Patient";
            }
            SelectList aList = new SelectList(_patientTreatmentManager.GetAll().ToList(), "Id", "TreatmentCode");

            ViewBag.treatmentList = aList;
            return(View());
        }