Пример #1
0
        public ActionResult Print(string id)
        {
            var intId = 0;

            int.TryParse(id, out intId);
            PrintPrescriptionModels viewModel = null;

            try
            {
                IDiagnosisRepository diagnosisRepository = new DiagnosisRepository();
                DTODiagnosis         dtoDiagnosis        = diagnosisRepository.GetDTODiagnosisById(intId);
                ViewData["PatientTel"] = dtoDiagnosis.Patient_Tel;
                IEnumerable <vMedicineDiagnosis> medicineRecords = objPrescription.GetPrescriptionDiagnosis(intId);
                if (dtoDiagnosis == null)
                {
                    return(RedirectToAction("Error404", "Error"));
                }
                viewModel = new PrintPrescriptionModels
                {
                    dtoDiagnosis    = dtoDiagnosis,
                    medicineRecords = medicineRecords
                };
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            return(View("Print", "_LayoutPrint", viewModel));
        }
Пример #2
0
        public ActionResult Edit(string id)
        {
            var itemAdd = new PrescriptionAdd();
            IDiagnosisRepository    diagnosisRepository = new DiagnosisRepository();
            IMedicineTypeRepository objMedicineType     = new MedicineTypeRepository();
            PrescriptionModels      viewModel           = null;

            try
            {
                int intId = 0;
                int.TryParse(id, out intId);
                IEnumerable <MedicineType> medicineTypeRecords = objMedicineType.Get();

                IEnumerable <Usage> usageRecords = objMedicineType.GetUsage();

                DTODiagnosis dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(intId);
                IEnumerable <vMedicineDiagnosis> medicineRecords = objPrescription.GetPrescriptionDiagnosis(intId);

                IMedicineTypeRepository medicineTypeRepository = new MedicineTypeRepository();
                var usageSelectBox = medicineTypeRepository.GetUsageSelectBox();
                ViewData["usageSelectBox"] = usageSelectBox;

                viewModel = new PrescriptionModels
                {
                    validAdd            = itemAdd,
                    checkPost           = false,
                    dtoDiagnosis        = dtoDiagnosis,
                    medicineTypeRecords = medicineTypeRecords,
                    medicineRecords     = medicineRecords,
                    usageRecords        = usageRecords,
                };
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            return(View(viewModel));
        }
Пример #3
0
        public ActionResult Edit(MyClinic.Infrastructure.PrescriptionAdd itemAdd)
        {
            this.GetUserProfile();
            bool checkError = true;
            PrescriptionModels               viewModel           = null;
            DTODiagnosis                     dtoDiagnosis        = null;
            IEnumerable <MedicineType>       medicineTypeRecords = null;
            IEnumerable <vMedicineDiagnosis> medicineRecords     = null;
            string diffString = "";

            try
            {
                IMedicineTypeRepository objMedicineType     = new MedicineTypeRepository();
                IDiagnosisRepository    diagnosisRepository = new DiagnosisRepository();
                dtoDiagnosis    = diagnosisRepository.GetDTODiagnosisById(itemAdd.DiagnosisId);
                medicineRecords = objPrescription.GetPrescriptionDiagnosis(itemAdd.DiagnosisId);
                if (ModelState.IsValid)
                {
                    var intTotal = 0;
                    if (itemAdd.MedicineId != null)
                    {
                        intTotal = itemAdd.MedicineId.Count();
                    }

                    foreach (var record in medicineRecords)
                    {
                        bool blnFound = false;
                        for (int intIndex = 0; intIndex < intTotal; intIndex++)
                        {
                            var intId = 0;
                            if (int.TryParse(itemAdd.Id[intIndex], out intId))
                            {
                                if (intId == record.Id)
                                {
                                    blnFound = true;
                                    Prescription itemOld = new Prescription();
                                    itemOld.DiagnosisId = record.DiagnosisId;
                                    itemOld.Id          = record.Id;
                                    itemOld.MedicineId  = record.MedicineId;
                                    itemOld.Qty         = record.Qty;
                                    //itemOld.MedicineType = record.MedicineType;
                                    itemOld.Morning = record.Morning;
                                    itemOld.Noon    = record.Noon;
                                    itemOld.Night   = record.Night;
                                    itemOld.Remark  = record.Remark;
                                    itemOld.UsageId = record.UsageId;

                                    Prescription itemNew = new Prescription();
                                    int          itemId  = 0;
                                    int.TryParse(itemAdd.Id[intIndex], out itemId);
                                    itemNew.DiagnosisId = record.DiagnosisId;
                                    itemNew.Id          = itemId;
                                    int MedicineId = 0;
                                    int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId);
                                    itemNew.MedicineId = MedicineId;
                                    itemNew.Qty        = itemAdd.Qty[intIndex];
                                    //itemNew.MedicineType = itemAdd.MedicineType[intIndex];
                                    itemNew.Morning = itemAdd.Morning[intIndex];
                                    itemNew.Noon    = itemAdd.Noon[intIndex];
                                    itemNew.Night   = itemAdd.Night[intIndex];
                                    itemNew.Remark  = itemAdd.Remark[intIndex];
                                    itemNew.UsageId = int.Parse(itemAdd.UsageId[intIndex]);
                                    itemNew.Status  = record.Status;
                                    diffString      = diffString + itemOld.EnumeratePropertyDifferencesInString(itemNew);
                                    objPrescription.Update(itemNew);
                                }
                            }
                        }
                        if (blnFound == false)
                        {
                            objPrescription.Delete(record.Id);
                        }
                    }
                    for (int intIndex = 0; intIndex < intTotal; intIndex++)
                    {
                        int itemId = 0;
                        int.TryParse(itemAdd.Id[intIndex], out itemId);
                        if (itemId == 0)
                        {
                            Prescription itemGet = new Prescription();
                            itemGet.DiagnosisId = itemAdd.DiagnosisId;
                            int MedicineId = 0;
                            int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId);
                            itemGet.MedicineId = MedicineId;
                            itemGet.Qty        = itemAdd.Qty[intIndex];
                            //itemGet.MedicineType = itemAdd.MedicineType[intIndex];
                            itemGet.Morning = itemAdd.Morning[intIndex];
                            itemGet.Noon    = itemAdd.Noon[intIndex];
                            itemGet.Night   = itemAdd.Night[intIndex];
                            itemGet.Remark  = itemAdd.Remark[intIndex];
                            itemGet.UsageId = int.Parse(itemAdd.UsageId[intIndex]);
                            itemGet.Status  = (int)MyClinic.Core.Enums.RecordStatus.Active;
                            objPrescription.Add(itemGet);
                        }
                    }

                    /*For Add New Record to LogTable*/
                    logTran.UserId      = this.objProfile.UserId;
                    logTran.ProcessType = "Edit Prescription";
                    logTran.Description = "Edit Prescription value as follow: " + diffString;
                    logTran.LogDate     = DateTime.Now;
                    logRepository.Add(logTran);
                    return(RedirectToAction("Detail", "Prescription", new { id = itemAdd.DiagnosisId }));

                    checkError = false;
                }
                medicineTypeRecords = objMedicineType.Get();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            if (checkError == true)
            {
                viewModel = new PrescriptionModels
                {
                    validAdd            = itemAdd,
                    checkPost           = true,
                    checkError          = checkError,
                    dtoDiagnosis        = dtoDiagnosis,
                    medicineTypeRecords = medicineTypeRecords,
                    medicineRecords     = medicineRecords
                };
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Index", "Diagnosis"));
            }
        }
Пример #4
0
        public ActionResult Add(MyClinic.Infrastructure.PrescriptionAdd itemAdd)
        {
            Prescription itemGet             = new Prescription();
            var          objSessionDiagnosis = Session["diagnosis"] as MyClinic.Infrastructure.Diagnosis;

            this.GetUserProfile();
            bool checkError = true;
            PrescriptionModels         viewModel           = null;
            DTODiagnosis               dtoDiagnosis        = null;
            IEnumerable <MedicineType> medicineTypeRecords = null;

            try
            {
                IMedicineTypeRepository objMedicineType     = new MedicineTypeRepository();
                IDiagnosisRepository    diagnosisRepository = new DiagnosisRepository();
                dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(itemAdd.DiagnosisId);

                /*For Add Diagnosis to Table */
                diagnosisRepository.Add(objSessionDiagnosis);
                itemGet.DiagnosisId = objSessionDiagnosis.Id;
                //Save Image
                SaveUploadImge(Session.SessionID, objSessionDiagnosis.Id);
                if (ModelState.IsValid)
                {
                    var intTotal = 0;
                    if (itemAdd.MedicineId != null)
                    {
                        intTotal = itemAdd.MedicineId.Count();
                    }
                    for (int intIndex = 0; intIndex < intTotal; intIndex++)
                    {
                        int MedicineId = 0;
                        int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId);
                        itemGet.MedicineId = MedicineId;
                        itemGet.Qty        = itemAdd.Qty[intIndex];
                        //itemGet.MedicineType       = itemAdd.MedicineType[intIndex];
                        itemGet.Morning = itemAdd.Morning[intIndex];
                        itemGet.Noon    = itemAdd.Noon[intIndex];
                        itemGet.Night   = itemAdd.Night[intIndex];
                        itemGet.Remark  = itemAdd.Remark[intIndex];
                        itemGet.UsageId = int.Parse(itemAdd.UsageId[intIndex]);
                        itemGet.Status  = (int)MyClinic.Core.Enums.RecordStatus.Active;

                        objPrescription.Add(itemGet);
                    }

                    Session["diagnosis"] = null;
                    /*For Add New Record to LogTable*/
                    logTran.UserId      = this.objProfile.UserId;
                    logTran.ProcessType = "Add Prescription";
                    logTran.Description = "Add Prescription";
                    logTran.LogDate     = DateTime.Now;
                    logRepository.Add(logTran);

                    /*this.GetUserProfile();
                     * var test = this.objProfile;*/
                    return(RedirectToAction("Detail", "Prescription", new { id = itemGet.DiagnosisId }));
                    //checkError = false;
                }
                medicineTypeRecords = objMedicineType.Get();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            if (checkError == true)
            {
                viewModel = new PrescriptionModels
                {
                    validAdd            = itemAdd,
                    checkPost           = true,
                    checkError          = checkError,
                    dtoDiagnosis        = dtoDiagnosis,
                    medicineTypeRecords = medicineTypeRecords
                };
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Index", "User"));
            }
        }