예제 #1
0
        // GET: Admin/Medical/ViewPrescription
        public ActionResult ViewPrescription(string id = "")
        {
            try
            {
                int _id;
                MedicalPrescriptionInfo _prescription = null;

                if (!int.TryParse(id, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(View(_prescription));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(_id);

                    if (_prescription == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription not found.");

                        return(View(_prescription));
                    }
                }

                return(View(_prescription));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "ViewPrescription")));
            }
        }
예제 #2
0
        public ActionResult DownloadPrescription(string id = "")
        {
            try
            {
                int _id;
                MedicalPrescriptionInfo _prescription = null;

                if (!int.TryParse(id, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(_id);

                    if (_prescription == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription not found.");

                        return(RedirectToAction("Requests", "Medical"));
                    }
                }

                var prescriptionPath = Server.MapPath(_prescription.PrescriptionPath);
                return(File(prescriptionPath, MimeMapping.GetMimeMapping(prescriptionPath), _prescription.FileName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DownloadPrescription")));
            }
        }
예제 #3
0
        public ActionResult DownloadPrescriptions(string CheckoutId = "")
        {
            try
            {
                int id;
                var _prescriptionsList        = new List <MedicalPrescriptionInfo>();
                MedicalCheckoutInfo _checkout = null;
                var outputStream = new MemoryStream();

                if (!int.TryParse(CheckoutId, out id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalCheckoutRepository CheckoutRepo = new MedicalCheckoutRepository())
                {
                    _checkout = CheckoutRepo.GetMedicalCheckoutById(id);

                    if (_checkout == null || _checkout.EmployeeInfoId != CurrentUser.EmployeeInfoId)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

                        return(RedirectToAction("Details", "Medical"));
                    }
                }

                var _zipName = _checkout.PatientName + "_Prescriptions_" + _checkout.TreatmentDate.Value.ToString("dd-MM-yyyy");

                using (MedicalPrescriptionRepository PrescriptionRepo = new MedicalPrescriptionRepository())
                {
                    _prescriptionsList = PrescriptionRepo.GetMedicalPrescriptionsListByMedicalCheckoutId(id);

                    using (var zip = new ZipFile())
                    {
                        foreach (var item in _prescriptionsList)
                        {
                            zip.AddFile(Server.MapPath(item.PrescriptionPath), string.Empty).FileName = item.FileName;
                        }

                        zip.Save(outputStream);
                    }
                }

                outputStream.Position = 0;

                return(File(outputStream, "application/zip", _zipName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DownloadPrescriptions")));
            }
        }
예제 #4
0
        public ActionResult ApplyMedical(string id = "")
        {
            try
            {
                int _id;
                MedicalCheckoutInfo _medicalCheckout = null;

                if (!int.TryParse(id, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong please try again later.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    var _prescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(_id);

                    if (_prescriptions.Count() == 0)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Please upload prescription(s).");

                        return(RedirectToAction("Details", "Medical", new { id = _id }));
                    }
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _medicalCheckout = Repo.GetMedicalCheckoutById(_id);

                    if (_medicalCheckout == null || _medicalCheckout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _medicalCheckout.Status == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

                        return(RedirectToAction("Details", "Medical"));
                    }

                    _medicalCheckout.RequestDate      = DateTime.Now;
                    _medicalCheckout.IsCreatedByAdmin = false;
                    _medicalCheckout.Status           = "Pending";

                    Repo.UpdateMedicalCheckout(_medicalCheckout);

                    TempData["Msg"] = AlertMessageProvider.SuccessMessage("You have applied for medical successfully.");
                }

                return(RedirectToAction("Details", "Medical"));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "ApplyMedical")));
            }
        }
예제 #5
0
        public ActionResult DeletePrescription(string PrescriptionId)
        {
            try
            {
                int id;
                MedicalPrescriptionInfo _prescription = null;

                if (!int.TryParse(PrescriptionId, out id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(id);

                    if (_prescription == null || _prescription.EmployeeInfoId != CurrentUser.EmployeeInfoId || _prescription.CheckoutStatus == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription not found.");

                        return(RedirectToAction("Details", "Medical"));
                    }

                    string _prescriptionPath = Request.MapPath(_prescription.PrescriptionPath);

                    if (System.IO.File.Exists(_prescriptionPath))
                    {
                        System.IO.File.Delete(_prescriptionPath);

                        Repo.DeleteMedicalPrescription(_prescription.Id);
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription does not exist physically.");
                    }
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Prescription deleted successfully.");

                return(RedirectToAction("Apply", "Medical", new { id = _prescription.MedicalCheckoutId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DeletePrescription")));
            }
        }
예제 #6
0
        // GET: Employee/Medical/Apply
        public ActionResult Apply(string id = "")
        {
            try
            {
                int _id;
                MedicalCheckoutInfo _medicalCheckout = null;

                if (!int.TryParse(id, out _id))
                {
                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _medicalCheckout = Repo.GetMedicalCheckoutById(_id);
                }

                if (_medicalCheckout == null || _medicalCheckout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _medicalCheckout.Status == "Approved")
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _medicalCheckout.MedicalPrescriptions = new List <MedicalPrescriptionInfo>();

                    _medicalCheckout.MedicalPrescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(_id);
                }

                return(View(_medicalCheckout));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Apply")));
            }
        }
예제 #7
0
        // GET: Admin/Medical/RequestDetails
        public ActionResult RequestDetails(string id = "")
        {
            try
            {
                int _id;
                var _pendingRequestList = new List <MedicalCheckoutInfo>();

                if (!int.TryParse(id, out _id))
                {
                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _pendingRequestList = Repo.GetPendingMedicalCheckoutsListByEmployeeId(_id);
                }

                if (_pendingRequestList.Count() == 0)
                {
                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    foreach (var item in _pendingRequestList)
                    {
                        item.MedicalPrescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(item.Id);
                    }
                }

                return(View(_pendingRequestList));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "RequestDetails")));
            }
        }
예제 #8
0
        public ActionResult UploadPrescription(HttpPostedFileBase file, MedicalCheckoutInfo medicalCheckoutInfo)
        {
            try
            {
                int id;
                MedicalCheckoutInfo _medicalCheckout = null;
                var _prescription = new MedicalPrescriptionInfo();

                if (!int.TryParse(medicalCheckoutInfo.Id.ToString(), out id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong please try again later.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _medicalCheckout = Repo.GetMedicalCheckoutById(id);
                }

                if (_medicalCheckout == null || _medicalCheckout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _medicalCheckout.Status == "Approved")
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

                    return(RedirectToAction("Details", "Medical"));
                }

                if (string.IsNullOrEmpty(medicalCheckoutInfo.PrescriptionName))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription name is required.");

                    return(RedirectToAction("Details", "Medical"));
                }

                if (file != null)
                {
                    if (file.ContentType.Contains("image"))
                    {
                        if (file.ContentLength < 2 * 1024 * 1024)
                        {
                            if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg"))
                            {
                                _prescription.FileName          = medicalCheckoutInfo.PrescriptionName + Path.GetExtension(file.FileName);
                                _prescription.UploadDate        = DateTime.Now;
                                _prescription.MedicalCheckoutId = medicalCheckoutInfo.Id;

                                string _dirPath = Server.MapPath(Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions"));

                                bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath);

                                if (!_isDirectoryExists)
                                {
                                    System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions")));
                                }

                                Guid guid = Guid.NewGuid();
                                _prescription.PrescriptionPath = Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions/" + _medicalCheckout.EmployeeInfoId + "-" + guid + "-" + _prescription.FileName);

                                string _prescriptionPath = Server.MapPath(_prescription.PrescriptionPath);

                                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                                {
                                    file.SaveAs(_prescriptionPath);

                                    Repo.SaveMedicalPrescription(_prescription);
                                }
                            }
                            else
                            {
                                TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select 'jpeg, jpg' format only.");

                                return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id }));
                            }
                        }
                        else
                        {
                            TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller.");

                            return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id }));
                        }
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only.");

                        return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id }));
                    }
                }
                else
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select prescription.");

                    return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id }));
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Prescription uploaded successfully.");

                return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "UploadPrescription")));
            }
        }
예제 #9
0
        // GET: Employee/Medical/Details
        public ActionResult Details()
        {
            try
            {
                var _employeeInfo    = new EmployeeInfo();
                var _medicalCheckout = new MedicalCheckoutInfo();
                _medicalCheckout.AvailedMedicalsList = new List <MedicalCheckoutInfo>();
                _medicalCheckout.PendingMedicalsList = new List <MedicalCheckoutInfo>();
                _medicalCheckout.MedicalAllowance    = new MedicalAllowanceInfo();
                var    _incompleteMedicalChekouts = new List <MedicalCheckoutInfo>();
                string _medicalYear = DateTime.Now.Year.ToString();

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    TempData["FamilyMembersList"] = new SelectList(Repo.GetAllFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId), "Id", "Name");
                }

                using (var transaction = new System.Transactions.TransactionScope())
                {
                    using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                    {
                        ViewBag.MedicalYear = new SelectList(Repo.GetMedicalYearsList(CurrentUser.EmployeeInfoId));

                        _incompleteMedicalChekouts = Repo.GetIncompleteMedicalCheckoutsListByEmployeeId(CurrentUser.EmployeeInfoId);

                        if (_incompleteMedicalChekouts.Count() > 0)
                        {
                            using (MedicalPrescriptionRepository PrescriptionRepo = new MedicalPrescriptionRepository())
                            {
                                foreach (var checkout in _incompleteMedicalChekouts)
                                {
                                    var _prescriptionsList = PrescriptionRepo.GetMedicalPrescriptionsListByMedicalCheckoutId(checkout.Id);

                                    foreach (var prescription in _prescriptionsList)
                                    {
                                        string fullPath = Request.MapPath(prescription.PrescriptionPath);

                                        if (System.IO.File.Exists(fullPath))
                                        {
                                            System.IO.File.Delete(fullPath);
                                        }

                                        PrescriptionRepo.DeleteMedicalPrescription(prescription.Id);
                                    }

                                    Repo.DeleteMedicalCheckout(checkout.Id);
                                }
                            }
                        }

                        _medicalCheckout.PendingMedicalsList = Repo.GetPendingMedicalCheckoutsListByEmployeeId(CurrentUser.EmployeeInfoId);
                        _medicalCheckout.AvailedMedicalsList = Repo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(CurrentUser.EmployeeInfoId, _medicalYear);
                    }

                    transaction.Complete();
                }

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _employeeInfo = Repo.GetEmployeeInfoById(CurrentUser.EmployeeInfoId);
                }

                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    if (_employeeInfo.MaritalStatus == "Single")
                    {
                        _medicalCheckout.MedicalAllowance = Repo.GetMedicalAllowanceByCategory("Single");
                    }
                    else
                    {
                        _medicalCheckout.MedicalAllowance = Repo.GetMedicalAllowanceByCategory("Married");
                    }
                }

                return(View(_medicalCheckout));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Details")));
            }
        }