Exemplo n.º 1
0
        public ActionResult CreatePatientFree()
        {
            try
            {
                vwCreatePatientFree obj = new vwCreatePatientFree();
                obj.SampleObj = new Sample();
                obj.SampleObj.DatetimeCapture = DateTime.Now;
                obj.SampleObj.DatetimeDelivery = DateTime.Now;
                obj.MBAdditionalServiceList = db.GetAdditionalServiceListActive();
                obj.MBAnalysisList = db.GetMBAnalysisTypeListActive();

                //   var itemsSex =

                List<SelectListItem> listSex = new List<SelectListItem>();
                listSex.Add(new SelectListItem { Text = "Неизвестно", Value = "1" });
                listSex.Add(new SelectListItem { Text = "Мужской", Value = "2" });
                listSex.Add(new SelectListItem { Text = "Женский", Value = "3" });
                var selectSex = new SelectList(listSex, "Value", "Text", 1);
                ViewData["selectSex"] = selectSex;

                var itemsClinicMaterials = db.GetClinicMaterialsList();
                List<SelectListItem> listClinicMaterial = new List<SelectListItem>();
                foreach (var item in itemsClinicMaterials)
                {
                    listClinicMaterial.Add(new SelectListItem { Text = item.Description + " - " + item.ClinicMaterialGroup.DescriptionRus, Value = item.ClinicMaterialID.ToString() });
                }
                var selectClinicMaterial = new SelectList(listClinicMaterial, "Value", "Text", 1);
                ViewData["selectClinicMaterial"] = selectClinicMaterial;

                var itemsDoctors = db.GetDoctorsList();
                List<SelectListItem> listDoctor = new List<SelectListItem>();
                foreach (var item in itemsDoctors)
                {
                    listDoctor.Add(new SelectListItem { Text = item.Lastname + " " + item.Initials, Value = item.DoctorID.ToString() });
                }
                var selectDoctor = new SelectList(listDoctor, "Value", "Text", 1);
                ViewData["selectDoctor"] = selectDoctor;

                var itemsClinics = db.GetClinicList();
                List<SelectListItem> listClinic = new List<SelectListItem>();
                foreach (var item in itemsClinics)
                {
                    listClinic.Add(new SelectListItem { Text = item.Description + " - " + item.ClinicGroup.Description, Value = item.ClinicID.ToString() });
                }
                var selectClinic = new SelectList(listClinic, "Value", "Text", 1);
                ViewData["selectClinic"] = selectClinic;

                var itemsPatientStatusTypes = db.GetPatientStatusTypeList();
                List<SelectListItem> listPatientStatusTypes = new List<SelectListItem>();
                foreach (var item in itemsPatientStatusTypes)
                {
                    listPatientStatusTypes.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.PatientStatusTypeID.ToString() });
                }
                var selectPatientStatusTypes = new SelectList(listPatientStatusTypes, "Value", "Text", 1);
                ViewData["selectPatientStatusTypes"] = selectPatientStatusTypes;

                return View(obj);
            }
            catch (DataException ex)
            {
                string strMessage = "Ошибка " + ex.Message + ". Получение формы для ввода пациента не удалось";
                Response.Write(strMessage);
                return null;
            }
        }
Exemplo n.º 2
0
        public ActionResult CreatePatientFree(vwCreatePatientFree obj, string[] selectedMBAnalysis, string[] selectedAdditionalServices)
        {
            try
            {

                if ((ModelState.IsValidField("2")) && (ModelState.IsValidField("3")) && (ModelState.IsValidField("4")) && (ModelState.IsValidField("9")) && (ModelState.IsValidField("10"))
                    && (selectedAdditionalServices != null) && (selectedMBAnalysis != null))
                {
                    //Insert Patient

                    int resPatientID = db.AddPatientNewForDiagnosis(obj.PatientObj);
                    obj.SampleObj.PatientID = resPatientID;
                    var resClinicContract = db.GetClinicContractId(25, obj.SampleObj.ClinicID);
                    obj.SampleObj.ClinicContractID = resClinicContract.ClinicContractID;
                    //Insert Sample
                    int resSampleID = db.AddSampleNewForDiagnosisFree(obj.SampleObj);
                    //insert MBAnalysis
                    foreach (var item in selectedMBAnalysis)
                    {
                        db.AddMBAnalysisToSample(resSampleID, int.Parse(item.ToString()));
                    }
                    //insert AdditionalServices
                    foreach (var item in selectedAdditionalServices)
                    {
                        db.AddAdditionalServiceToSample(resSampleID, int.Parse(item.ToString()));
                    }
                    string strMessage = "Образец успешно добавлен в систему. Образцу, принятому от пацента " +
                        obj.PatientObj.Lastname + " " + obj.PatientObj.Initials +
                        " присвоен номер " + resSampleID.ToString();
                    return RedirectToAction("PatientListFree", new { message = strMessage, queue = 1 });
                }
                else
                {
                    List<SelectListItem> listSex = new List<SelectListItem>();
                    listSex.Add(new SelectListItem { Text = "Неизвестно", Value = "1" });
                    listSex.Add(new SelectListItem { Text = "Мужской", Value = "2" });
                    listSex.Add(new SelectListItem { Text = "Женский", Value = "3" });
                    var selectSex = new SelectList(listSex, "Value", "Text", 1);
                    ViewData["selectSex"] = selectSex;

                    var itemsClinicMaterials = db.GetClinicMaterialsList();
                    List<SelectListItem> listClinicMaterial = new List<SelectListItem>();
                    foreach (var item in itemsClinicMaterials)
                    {
                        listClinicMaterial.Add(new SelectListItem { Text = item.Description + " - " + item.ClinicMaterialGroup.DescriptionRus, Value = item.ClinicMaterialID.ToString() });
                    }
                    var selectClinicMaterial = new SelectList(listClinicMaterial, "Value", "Text", 1);
                    ViewData["selectClinicMaterial"] = selectClinicMaterial;

                    var itemsDoctors = db.GetDoctorsList();
                    List<SelectListItem> listDoctor = new List<SelectListItem>();
                    foreach (var item in itemsDoctors)
                    {
                        listDoctor.Add(new SelectListItem { Text = item.Lastname + " " + item.Initials, Value = item.DoctorID.ToString() });
                    }
                    var selectDoctor = new SelectList(listDoctor, "Value", "Text", 1);
                    ViewData["selectDoctor"] = selectDoctor;

                    var itemsClinics = db.GetClinicList();
                    List<SelectListItem> listClinic = new List<SelectListItem>();
                    foreach (var item in itemsClinics)
                    {
                        listClinic.Add(new SelectListItem { Text = item.Description + " - " + item.ClinicGroup.Description, Value = item.ClinicID.ToString() });
                    }
                    var selectClinic = new SelectList(listClinic, "Value", "Text", 1);
                    ViewData["selectClinic"] = selectClinic;

                    var itemsPatientStatusTypes = db.GetPatientStatusTypeList();
                    List<SelectListItem> listPatientStatusTypes = new List<SelectListItem>();
                    foreach (var item in itemsPatientStatusTypes)
                    {
                        listPatientStatusTypes.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.PatientStatusTypeID.ToString() });
                    }
                    var selectPatientStatusTypes = new SelectList(listPatientStatusTypes, "Value", "Text", 1);
                    ViewData["selectPatientStatusTypes"] = selectPatientStatusTypes;

                    obj.MBAdditionalServiceList = db.GetAdditionalServiceListActive();
                    obj.MBAnalysisList = db.GetMBAnalysisTypeListActive();

                    ModelState.AddModelError("", "Невозможно сохранить изменения. Проверьте правильность заполнения всех полей.");
                }
            }
            catch (DataException ex)
            {
                ModelState.AddModelError("", ex.Message.ToString() + " | " + ex.GetType().ToString() + " | " + "Невозможно сохранить изменения. Проверьте правильность заполнения всех полей.");
            }

            return View(obj);
        }