예제 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sampleid"></param>
 /// <returns></returns>
 public static SampleInformation getDetailSamples(string sampleid)
 {
     var dataContext = new PEStDataContext();
     SampleInformation result;
     try
     {
         result = (from a in dataContext.SampleData
                   join s in dataContext.PatientData on a.fkPatiendId equals s.PatientId
                   where a.SampleStates.StateName != "gesperrt" &&
                         a.SampleStates.StateName != "verworfen" && a.SampleId == sampleid
                   select new SampleInformation{
                          sampleID = a.SampleId,
                          patientID = s.PatientId,
                          isAccounted = a.IsAccounted,
                          analysisName = a.fkAnalysisName,
                          sampleState = a.fkSampleStates,
                          sampleType = a.Analyses.fkSampleType,
                          patientName = s.Lastname,
                          patientFirstname = s.Firstname,
                          comment = a.Comment,
                          resultE = a.Result
                   }).First();
     }
     catch (Exception) { return null; }
     return result;
 }
예제 #2
0
 /// <summary>
 /// Function to geht all available Roles which are in the database
 /// </summary>
 /// <returns></returns>
 public static List<RoleInformation> getAllRoles()
 {
     var dataContext = new PEStDataContext();
     List<RoleInformation> result = (from a in dataContext.Roles
                                          select new RoleInformation
                                          {
                                             roleName = a.RoleName
                                          }).ToList();
     return result;
 }
예제 #3
0
        /// <summary>
        /// Function to get all Hospitals which are in the database
        /// </summary>
        /// <returns></returns>
        public static List<HospitalInformation> getAllHospitals()
        {
            var dataContext = new PEStDataContext();
            List<HospitalInformation> result = (from a in dataContext.Hospitals
                                                     select new HospitalInformation
                                                     {
                                                         hospitalID = a.HospitalId,
                                                         hospitalName = a.HospitalName
                                                     }).ToList();

            return result;
        }
예제 #4
0
        /// <summary>
        /// Function to get all Users who are in the database
        /// </summary>
        /// <returns></returns>
        public static IQueryable<UserInformation> getAllUsers()
        {
            var dataContext = new PEStDataContext();
            IQueryable<UserInformation> result = from a in dataContext.Users
                                                    join s in dataContext.Hospitals on a.fkHospitalId equals s.HospitalId
                                                    select new UserInformation
                                                    {
                                                        username = a.Username,
                                                        hospitalName = s.HospitalName,
                                                        role = a.fkRoleName,
                                                        email = a.Email
                                                    };

            return result;
        }
예제 #5
0
        public IQueryable<PatientInformation> getAllPatients(int HospitalID)
        {
            var dataContext = new PEStDataContext();
            IQueryable<PatientInformation> result = from a in dataContext.PatientData
                                                    join s in dataContext.SampleData on a.fkHospitalId equals HospitalID                                                    where a.fkHospitalId == HospitalID
                                                    select new PatientInformation
                                                    {
                                                        firstname = a.Firstname,
                                                        name = a.Lastname,
                                                        patientID = a.PatientId,
                                                        status = s.fkSampleStates,
                                                        untersuchung = s.fkAnalysisName
                                                    };

                return result;
        }
예제 #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sampleid"></param>
 /// <returns></returns>
 public static AdminSampleInformation getDeleteSample(string sampleid)
 {
     var dataContext = new PEStDataContext();
     AdminSampleInformation result;
     try
     {
         result = (from a in dataContext.SampleData
                   where a.SampleId.Equals(sampleid) &&
                         ((a.fkSampleStates.Equals("gesperrt") && a.IsAccounted == 1) || a.fkSampleStates.Equals("verworfen"))
                   select new AdminSampleInformation
                   {
                       sampleID = a.SampleId,
                       sampleState = a.fkSampleStates,
                   }).First();
     }
     catch (Exception) { return null; }
     return result;
 }
예제 #7
0
        public string newSample(string analyses, int patient = -1)
        {
            if (checkUserPermission("Klinikpersonal"))
            {
                List<FormValidatorError> error = (new NewSampleFormValidator(patient, analyses)).validate();
                if (error.Count != 0)
                {
                    return (new AjaxResponse(AjaxStatus.invalidData, error)).ToString();
                }
                else
                {
                    String Username = (string)Session["Username"];
                    dbe = new PEStDataContext();

                    try
                    {
                    //get hospitalID
                    var checkID = from e in dbe.PatientData
                                  where e.PatientId == patient
                                  select e.fkHospitalId;

                    //check if patient ID is valid to the hospital
                    if (checkID.First() == (int)Session["hospital"])
                    {

                        try
                        {
                            NewSampleCommandPaket newSamp = new NewSampleCommandPaket(Username, analyses, patient);
                            ResultPaket result = CommunicationManager.sendCommand(newSamp);
                            if (result.Type == ResultType.success)
                            {
                                return (new AjaxResponse(AjaxStatus.success, ((NewSampleSuccessResultPaket)result).SampleID)).ToString();
                            }
                            else
                            {
                                return (new AjaxResponse(AjaxStatus.error, ((Pakets.ResultPakets.FailureResultPaket)result).ErrorText)).ToString();
                            }
                        }
                        catch (Exception e)
                        {
                            return new AjaxResponse(AjaxStatus.error, "Ausnahme: "+e.Message).ToString();
                        }
                    }
                    else
                    {
                        return new AjaxResponse(AjaxStatus.error, "Patient nicht in diesem Krankenhaus vorhanden").ToString();
                    }
                }
                catch (InvalidOperationException e)
                {
                    return new AjaxResponse(AjaxStatus.error, "Ausnahme: Keinen Patienten mit dieser Kennnummer gefunden!\n "+e.Message).ToString();
                }

                }

            }
            else
            {
                 return new AjaxResponse(AjaxStatus.permissiondenied).ToString();
            }
        }
예제 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult newSample()
        {
            if (checkUserPermission("Klinikpersonal"))
            {
                this.initViewBag();

                List<string> sampleT = new List<string>();
                List<string> analysis = new List<string>();
                List<string> patient = new List<string>();

                //create Entity to get databaseaccess
                dbe = new PEStDataContext();

                //put the list of sampleTypes in a ViewData to the View
                var sample =
                       from s in dbe.SampleType
                       select s;

                int id = (int)Session["hospital"];
                var patie =
                       from d in dbe.PatientData
                       where d.fkHospitalId == id
                       select d;

                var anal =
                       from a in dbe.Analyses
                       select a;

                ViewData["Patient"] = patie.ToList();

                return View(anal);
            }
            else
            {
                return RedirectToAction("PermissionDenied", "Error");
            }
        }
예제 #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public IQueryable<SampleInformation> getSamples()
 {
     var dataContext = new PEStDataContext();
     IQueryable<SampleInformation> result = from a in dataContext.SampleData
                                            join s in dataContext.PatientData on a.fkPatiendId equals s.PatientId
                                            where a.SampleStates.StateName != "gesperrt" &&
                                                  a.SampleStates.StateName != "verworfen"
                                            select new SampleInformation{sampleID = a.SampleId,
                                                                         patientID = s.PatientId,
                                                                         isAccounted = a.IsAccounted,
                                                                         analysisName = a.fkAnalysisName,
                                                                         sampleState = a.fkSampleStates,
                                                                         sampleType = a.Analyses.fkSampleType,
                                                                         patientName = s.Lastname,
                                                                         patientFirstname = s.Firstname
                                                                         };
     return result;
 }
예제 #10
0
        public string createUser(string newUsr, string passphrase1, string passphrase2, 
                                       string email, string hosp, string role)
        {
            if (this.checkUserPermission("Administrator"))
            {
                dbe = new PEStDataContext();

                List<FormValidatorError> error = (new NewUserFormValidator(newUsr, email, passphrase1,
                                                    passphrase2, hosp, role)).validate();

                if (error.Count != 0)
                {
                    return (new AjaxResponse(AjaxStatus.invalidData, error)).ToString();
                }else
                {
                     var result = from a in dbe.Hospitals
                             where a.HospitalName == hosp
                             select a;
                    try
                    {
                        int hospId = result.First().HospitalId;

                        Pakets.ResultPaket res = CommunicationManager.sendCommand(new NewUserCommandPaket((string)Session["username"],
                                                            newUsr, SessionManagerController.GetMD5Hash(newUsr)+SessionManagerController.GetMD5Hash(passphrase1), role, hospId, email));
                        if(res.Type == ResultType.success)
                        {
                            return (new AjaxResponse(AjaxStatus.success)).ToString();
                        }else{
                            return (new AjaxResponse(AjaxStatus.error, "Server: "+((Pakets.ResultPakets.FailureResultPaket)res).ErrorText)).ToString();
                        }
                    }
                    catch (Exception e)
                    {
                        return new AjaxResponse(AjaxStatus.error, "Ausnahme: "+e.Message).ToString();
                    }
                }
            }
            else
            {
                   return new AjaxResponse(AjaxStatus.permissiondenied).ToString();
            }
        }
예제 #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sampleid"></param>
 /// <returns></returns>
 public static AdminSampleInformation getDetailSamples(string sampleid)
 {
     var dataContext = new PEStDataContext();
     AdminSampleInformation result;
     try
     {
         result = (from a in dataContext.SampleData
                   join s in dataContext.PatientData on a.fkPatiendId equals s.PatientId
                   where a.SampleId.Equals(sampleid) && (a.fkSampleStates.Equals("gesperrt") || a.fkSampleStates.Equals("verworfen"))
                   select new AdminSampleInformation
                   {
                       sampleID = a.SampleId,
                       patientID = s.PatientId,
                       isAccounted = a.IsAccounted,
                       analysisName = a.fkAnalysisName,
                       sampleState = a.fkSampleStates,
                       sampleType = a.Analyses.fkSampleType,
                       patientName = s.Lastname,
                       patientFirstname = s.Firstname,
                       comment = a.Comment,
                       result = a.Result,
                       hospital = s.Hospitals.HospitalName
                   }).First();
     }
     catch (Exception) { return null; }
     return result;
 }
예제 #12
0
 public static List<AdminSampleInformation> getInformation(string status)
 {
     var dataContext = new PEStDataContext();
     List<AdminSampleInformation> result = (from i in dataContext.SampleData
                                            join p in dataContext.PatientData on i.fkPatiendId equals p.PatientId
                                            where i.fkSampleStates.Equals(status)
                                            select new AdminSampleInformation
                                            {
                                                sampleID = i.SampleId,
                                                patientID = p.PatientId,
                                                isAccounted = i.IsAccounted,
                                                analysisName = i.Analyses.AnalysisName,
                                                sampleState = i.fkSampleStates,
                                                sampleType = i.Analyses.fkSampleType,
                                                patientName = p.Lastname,
                                                patientFirstname = p.Firstname,
                                                hospital = p.Hospitals.HospitalName
                                            }
                                           ).ToList();
     return result;
 }
예제 #13
0
        /// <summary>
        /// Check Userlogin. Are Password, Username correct? 
        /// Return value depend on the role
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Passphrase"></param>
        /// <param name="Role"></param>
        /// <returns>String - Value of Role</returns>
        protected ActionResult checkUserLogin(String Username, String Passphrase)
        {
            try
            {
                dbe = new PEStDataContext();
                string DB_Role = null;
                int DB_Hospital = 0;
                string DB_Hospital_Name = null;
                string DB_Username =  null;
                string DB_Passphrase = null;
                string MD5_Passphrase = null;
                string MD5_Username = GetMD5Hash(Username);

                //create sql statement to get the UserData
                var user =
                    from c in dbe.Users
                    where c.Username == Username
                    select c ;

                //check if there is a valid username in the DB
                //if not, than show error page
                if (user.Count()!=0)
                {
                    DB_Role = (user).ToList().First().fkRoleName.ToString();
                    DB_Username = (user).ToList().First().Username.ToString();
                    DB_Passphrase = (user).ToList().First().Passphrase.ToString();
                    DB_Hospital = (user).ToList().First().fkHospitalId;

                    //create sql statement to get the hospitaldata
                    var hosp =
                        from d in dbe.Hospitals
                        where d.HospitalId == DB_Hospital
                        select d;

                    //hospital name is:
                    DB_Hospital_Name = (hosp).ToList().First().HospitalName.ToString();

                    //create MD5 Hash to check PW
                    MD5_Passphrase = GetMD5Hash(Passphrase);

                    string MD5checkString = MD5_Username + MD5_Passphrase;

                    //check userdata
                    if (Username == DB_Username && MD5checkString == DB_Passphrase)
                    {
                        Session["username"] = Username;
                        Session["hospital"] = DB_Hospital;
                        Session["hospital_name"] = DB_Hospital_Name;

                        //Check the role
                        if (DB_Role == "Klinikpersonal")
                        {
                            //set the Loginsession and redirect to klinik Index
                            Session["Login"] = "******";
                            //return "klinik";
                            return RedirectToAction("../Klinik");
                        }
                        else if (DB_Role == "Laborant")
                        {
                            //set the Loginsession and redirect to Labor Index
                            Session["Login"] = "******";
                            //return "laborant";
                            return RedirectToAction("../Labor");
                        }
                        else
                        {
                            //set the Loginsession and redirect to Admin Index
                            Session["Login"] = "******";
                            //return "admin";
                            return RedirectToAction("../Admin");
                        }
                    }
                    else
                    {
                        //if user entered wrong password,
                        //go to the Error Index and show the Problem
                        return RedirectToAction("Index", new { errorMsg = "Benutzername oder Passwort falsch!" });
                    }
                }
                else
                {

                    return RedirectToAction("Index", new { errorMsg = "Benutzername oder Passwort falsch!" });
                }
            }
            catch (Exception)
            {
                return RedirectToAction("Index", new { errorMsg = "Benutzername oder Passwort falsch!" });
            }
        }