Example #1
0
        public ActionResult VerExamen(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Alumno alumno = db.Alumnos.Find(id);

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

            var      examenes = db.Examenes.Where(a => a.AlumnoId == id);
            ExamenVM examenVM = new ExamenVM();

            examenVM.Alumno = alumno.Nombre + alumno.Apellido;
            var cintos = db.Cinturones.ToList();

            foreach (Examen examen in examenes)
            {
                examen.CinturonActual  = cintos.First(d => d.Id == examen.CinturonActualId);
                examen.CinturonProximo = cintos.First(d => d.Id == examen.CinturonProximoId);
                examenVM.Examenes.Add(examen);
            }
            return(View("VerExamen", examenVM));
        }
        public ActionResult ENREGISTREREXAMEN(ExamenVM EVM, String[] IdsExamenAPrescrire)
        {
            using (IDAL dal = new Dal())
            {
                if (dal.VerifierAccesParUtilisateurIdParPrivilegePeut(HttpContext.User.Identity.Name, "ENREGISTRER_EXAMEN"))
                {
                    if (ModelState.IsValid)
                    {
                        List <String> ListeIdsExamenAPrescrire = new List <string>();


                        if (IdsExamenAPrescrire != null)
                        {
                            foreach (var ExamId in IdsExamenAPrescrire)
                            {
                                if (ExamId != "false")
                                {
                                    ListeIdsExamenAPrescrire.Add(ExamId);
                                }
                            }
                        }

                        EXAMEN exam = new EXAMEN();

                        exam.Dossier     = dal.ObtenirDossierParId(EVM.DossierId);
                        exam.Utilisateur = dal.ObtenirUtilisateurParId(EVM.MedecinId);
                        exam.Service     = dal.ObtenirServiceParId(EVM.ServiceId);
                        exam.ExamenType  = dal.ObtenirExamenTypeParId(EVM.ExamenTypeId);
                        exam.DateExamen  = EVM.DateExamen;
                        exam.Description = EVM.Description;

                        if (ListeIdsExamenAPrescrire != null)
                        {
                            exam.ExamenID = dal.EnregistrerExamen(exam);

                            if (exam.ExamenID != null)
                            {
                                foreach (var ExamId in ListeIdsExamenAPrescrire)
                                {
                                    EXAMENMEDICAL examMedical = dal.ObtenirExamenMedicalParId(ExamId);
                                    if (examMedical != null)
                                    {
                                        EXAMENDETAILS ExamDetails = new EXAMENDETAILS();
                                        ExamDetails.Examen        = dal.ObtenirExamenParId(exam.ExamenID);
                                        ExamDetails.ExamenMedical = examMedical;

                                        dal.EnregistrerExamenDetails(ExamDetails);
                                    }
                                }
                            }
                        }

                        return(RedirectToAction("CONSULTERLISTEEXAMENS"));
                    }
                    return(RedirectToAction("ENREGISTREREXAMEN"));
                }
                else
                {
                    ViewBag.ErrorMessage = dal.getErrorMessageFailedAuthorization();
                    return(View("Error"));
                }
            }
        }
        public ActionResult ENREGISTREREXAMEN(String Id)
        {
            using (IDAL dal = new Dal())
            {
                if (dal.VerifierAccesParUtilisateurIdParPrivilegePeut(HttpContext.User.Identity.Name, "ENREGISTRER_EXAMEN"))
                {
                    DIAGNOSTIC Diagnostic = dal.ObtenirDiagnosticParId(CRYPTAGE.StringHelpers.Encrypt(Id));

                    if (Diagnostic != null)
                    {
                        DOSSIER Dossier = dal.ObtenirDossierParId(Diagnostic.Dossier.DossierID);

                        if (Dossier != null)
                        {
                            UTILISATEUR Medecin = dal.ObtenirUtilisateurParId(HttpContext.User.Identity.Name);
                            if (Medecin != null)
                            {
                                ExamenVM EVM = new ExamenVM();
                                EVM.DiagnosticId = Diagnostic.DiagnosticId;
                                EVM.Medecin      = CRYPTAGE.StringHelpers.Decrypt(Medecin.Personne.Nom) + " " + CRYPTAGE.StringHelpers.Decrypt(Medecin.Personne.Prenom);
                                EVM.Patient      = CRYPTAGE.StringHelpers.Decrypt(Dossier.Patient.Nom) + " " + CRYPTAGE.StringHelpers.Decrypt(Dossier.Patient.Prenom);
                                EVM.DossierId    = Dossier.DossierID;
                                EVM.CodeDossier  = CRYPTAGE.StringHelpers.Decrypt(Dossier.Code);
                                EVM.MedecinId    = Medecin.UtilisateurID;

                                List <EXAMENMEDICAL>   TempListeExamenMedical = dal.ObtenirTousLesExamenMedicaux();
                                List <ExamenMedicalVM> ListeExamenMedicalVM   = new List <ExamenMedicalVM>();
                                ExamenMedicalVM        examMedicalVM;

                                foreach (var examMedical in TempListeExamenMedical)
                                {
                                    examMedicalVM = new ExamenMedicalVM();
                                    ListeExamenMedicalVM.Add(dal.ConvertirExamenMedicalExamenMedicalVM(examMedical));
                                }

                                EVM.Examens = ListeExamenMedicalVM;

                                ViewBag.ListeExamenType = dal.ObtenirTousLesExamenTypes();
                                ViewBag.ListeService    = dal.ObtenirTousLesServices();

                                return(View("FormulaireAjoutExamen", EVM));
                            }
                            else
                            {
                                ViewBag.ErrorMessage = "Veuillez séléctionner un Médecin svp.";
                                return(View("Error"));
                            }
                        }
                        else
                        {
                            ViewBag.ErrorMessage = "Veuillez séléctionner un Dossier Patient svp.";
                            return(View("Error"));
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Veuillez séléctionner un Diagnostic ayant declenché cet examen médical svp.";
                        return(View("Error"));
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = dal.getErrorMessageFailedAuthorization();
                    return(View("Error"));
                }
            }
        }