Ejemplo n.º 1
0
        public ActionResult Post([FromBody] Form form)
        {
            if (this.ModelState.IsValid)
            {
                Postulant postulant = fnc.createPostulant(form);
                //Aca valida datos y guarda en db
                int     IdPostulantDb      = dbm.InsertPostulant(postulant);
                int     IdStudyform        = fnc.validateIdStudy(form);
                int     IdStudiesStateform = fnc.validateIdStudyState(form);
                Studies studies            = fnc.createStudies(form, IdPostulantDb, IdStudyform, IdStudiesStateform);
                dbm.InsertStudies(studies);

                var formString = JsonConvert.SerializeObject(form);
                var barray     = Encoding.UTF8.GetBytes(formString);

                Attached attached = new Attached {
                    Name           = "InitForm.txt",
                    Link           = barray,
                    IdTypeAttached = 1
                };

                dbm.InsertAttached(attached, IdPostulantDb);
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public Studies GetStudiesByName(string name)
        {
            using (var client = new SqlConnection(
                       "Data Source=db-mssql;Initial Catalog=s17428;Integrated Security=True"))
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection  = client;
                    cmd.CommandText = @"SELECT IdStudy, Name
                  FROM Studies AS studies
                  WHERE Name = @name";
                    cmd.Parameters.AddWithValue("name", name);

                    client.Open();
                    var reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        var studies = new Studies();
                        studies.IdStudy = Convert.ToInt32(reader["IdStudy"]);
                        studies.Name    = reader["Name"].ToString();
                        return(studies);
                    }

                    return(null);
                }
        }
Ejemplo n.º 3
0
        public ActionResult OnGet([FromRoute] long id)
        {
            Study = Studies.GetStudy(id);
            if (Study == null)
            {
                return(NotFound());
            }


            var studyIdentity     = Study.Id;
            var consentedSubjects = Subjects.GetConsentedSubjects(studyIdentity);

            Logger.LogDebug(
                "Found {count} consentedPeople - {consentedPeopleIds}",
                consentedSubjects.Length,
                consentedSubjects);

            if (!Search)
            {
                SearchGroups = GetDefinedSearchGroups();
                return(Page());
            }

            var mergedSearchGroups = GetSearchGroupsAndValues();

            SearchGroups = mergedSearchGroups;

            return(DoSearch());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load all user datas from the firebase db.
        /// </summary>
        /// <returns></returns>
        private async Task GetUserDataAsync()
        {
            try
            {
                var documents = await CrossCloudFirestore.Current
                                .Instance
                                .GetCollection(QStudy.CollectionPath)
                                .GetDocumentsAsync();

                IEnumerable <StudiesToParticipate> myModel = documents.ToObjects <StudiesToParticipate>();

                foreach (var study in myModel)
                {
                    if (!study.Team.Equals("System") && (!(study.EndDate < DateTime.Now) | (study.EndDate == DateTime.MinValue)))
                    {
                        if (CurrentUser.Instance.User.ActiveStudies.Contains(study.Id))
                        {
                            study.Paricipate = true;
                        }
                        Studies.Add(study);
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Ejemplo n.º 5
0
        IEnumerable <Studies> IDbService.GetStudies()
        {
            List <Studies> _studiesesList = new List <Studies>();

            using (_connection = new SqlConnection(connection_string))
                using (var command = new SqlCommand())
                {
                    _connection.Open();
                    command.Connection  = _connection;
                    command.CommandText = "Select * from Studies";


                    var dr = command.ExecuteReader();

                    while (dr.Read())
                    {
                        var studies = new Studies();
                        studies.Name    = dr["Name"].ToString();
                        studies.IdStudy = int.Parse(dr["IdStudy"].ToString());

                        _studiesesList.Add(studies);
                    }
                    dr.Close();
                    _studieses = _studiesesList;
                }
            return(_studieses);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("IdStudy,Name")] Studies studies)
        {
            if (id != studies.IdStudy)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studies);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudiesExists(studies.IdStudy))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studies));
        }
Ejemplo n.º 7
0
        public Studies GetStudies(String studies)
        {
            using (var conection = new SqlConnection(_connection))
                using (var command = new SqlCommand())
                {
                    command.Connection  = conection;
                    command.CommandText = @"SELECT idstudy, Name FROM Studies WHERE Name = @name";
                    command.Parameters.AddWithValue("name", studies);

                    conection.Open();
                    try
                    {
                        var dr = command.ExecuteReader();
                        dr.Read();
                        var _study = new Studies
                        {
                            IdStudy = int.Parse(dr["idstudy"].ToString()),
                            Name    = dr["name"].ToString()
                        };
                        return(_study);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
        }
Ejemplo n.º 8
0
        public IActionResult GetStudent(string IndexNumber)
        {
            Student       student;
            Enrollment    enrollment = new Enrollment();
            Studies       studies    = new Studies();
            List <Object> query      = new List <object>();

            using (SqlConnection conn = new SqlConnection(Conncetion))
                using (SqlCommand command = new SqlCommand()){
                    command.Connection  = conn;
                    command.CommandText = "select Student.idEnrollment, semester, name, startdate from Enrollment inner join student on Enrollment.IdEnrollment = Student.IdEnrollment inner join Studies on Enrollment.idStudy = Studies.idStudy where Student.IndexNumber = @index";

                    command.Parameters.AddWithValue("index", IndexNumber);

                    conn.Open();
                    var sqlReader = command.ExecuteReader();
                    if (sqlReader.Read())
                    {
                        enrollment.IdEnrollment = Int32.Parse(sqlReader["IdEnrollment"].ToString());
                        enrollment.Semester     = Int32.Parse(sqlReader["Semester"].ToString());
                        studies.Name            = sqlReader["Name"].ToString();
                        enrollment.Startdate    = sqlReader["StartDate"].ToString();

                        query.Add(enrollment.IdEnrollment);
                        query.Add(enrollment.Semester);
                        query.Add(studies.Name);
                        query.Add(enrollment.Startdate);
                        return(Ok(query));
                    }
                    sqlReader.Close();
                    return(NotFound());
                }
        }
Ejemplo n.º 9
0
            /// <inheritdoc />
            public WhenRecordingConsent_ForANonExistantStudy()
            {
                var nonExistentStudyId = -Study.Id;

                A.CallTo(() => Studies.GetStudy(nonExistentStudyId)).Returns(null);

                RecordConsent(A.Dummy <IIdentifierValueDto>(), A.Dummy <DateTime>(), studyId: nonExistentStudyId);
            }
Ejemplo n.º 10
0
 /// <summary>
 /// Finds the spatial registration objects for this patient that satisfy a predicate
 /// </summary>
 /// <param name="predicate">A predicate for the search</param>
 /// <returns>All of the patient spatial registration objects that satisfy the predicate or null if the
 /// predicate was null or no patient spatial registration object satisfies the predicate</returns>
 /// <example>This example shows how to find spatial registration objects for a patient that transform to or
 /// from a specific frame of reference:
 /// <code>
 /// using ProKnow;
 /// using System.Threading.Tasks;
 ///
 /// var pk = new ProKnowApi("https://example.proknow.com", "./credentials.json");
 /// var patientItem = await pk.Patients.CreateAsync("Clinical");
 /// var frameOfReferenceUid = "1.2.246.352.221.5093062159960566210763150553104377477";
 /// var sroSummaries = patientItem.FindSros(s => s.TargetFrameOfReferenceUid == frameOfReferenceUid ||
 ///     s.SourceTargetFrameOfReferenceUid == frameOfReferenceUid);
 /// </code>
 /// </example>
 /// <example>This example shows how to find all spatial registration objects for a patient:
 /// <code>
 /// using ProKnow;
 /// using System.Threading.Tasks;
 ///
 /// var pk = new ProKnowApi("https://example.proknow.com", "./credentials.json");
 /// var patientItem = await pk.Patients.CreateAsync("Clinical");
 /// var sroSummaries = patientItem.FindSros(s => true);
 /// </code>
 /// </example>
 public IList <SroSummary> FindSros(Func <SroSummary, bool> predicate)
 {
     if (predicate == null)
     {
         return(new List <SroSummary>());
     }
     return(Studies.SelectMany(study => study.Sros.Where(sro => predicate(sro))).ToList());
 }
Ejemplo n.º 11
0
        public IActionResult PromoteStudents(PromoteStudentsRequest request)
        {
            Studies study = (from st in dbContext.Studies
                             where st.Name == request.Studies
                             select st).First();

            Enrollment thisEnrollment = (from en in dbContext.Enrollment
                                         where en.Semester == request.Semester
                                         where en.IdStudy == study.IdStudy
                                         select en).First();

            Enrollment nextEnrollment = (from en in dbContext.Enrollment
                                         where en.Semester == request.Semester + 1
                                         where en.IdStudy == study.IdStudy
                                         select en).FirstOrDefault();

            if (nextEnrollment == null)
            {
                Enrollment lastEnrollment = (from enrollments in dbContext.Enrollment
                                             orderby enrollments.IdEnrollment descending
                                             select enrollments).FirstOrDefault();

                int idEnrollment;

                if (lastEnrollment == null)
                {
                    idEnrollment = 1;
                }
                else
                {
                    idEnrollment = lastEnrollment.IdEnrollment + 1;
                }

                nextEnrollment = new Enrollment
                {
                    IdStudy      = study.IdStudy,
                    Semester     = request.Semester + 1,
                    IdEnrollment = idEnrollment,
                    StartDate    = DateTime.Now
                };

                dbContext.Add(nextEnrollment);
            }

            var students = (from st in dbContext.Student
                            where st.IdEnrollment == thisEnrollment.IdEnrollment
                            select st);

            foreach (Student st in students)
            {
                st.IdEnrollment = nextEnrollment.IdEnrollment;
                dbContext.Add(st);
            }

            dbContext.SaveChanges();

            return(Created("/enrollments/", request));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> EnrollStudent(EnrollStudentRequest request)
        {
            if (ModelState.IsValid == false)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);

                return(BadRequest(allErrors));
            }

            Studies studies = await Context.Studies.FirstOrDefaultAsync(stud => stud.Name == request.Studies);

            if (studies == null)
            {
                return(NotFound("Studia nie istnieją"));
            }

            Enrollment enrollment = await Context.Enrollment.FirstOrDefaultAsync(en => en.IdStudy == studies.IdStudy && en.Semester == 1);

            if (enrollment == null)
            {
                enrollment = new Enrollment {
                    Semester = 1, IdStudy = studies.IdStudy, StartDate = DateTime.Now
                };
                Context.Add(enrollment);
            }

            Student student = await Context.Student.FirstOrDefaultAsync(s => s.IndexNumber == request.IndexNumber);

            if (studies != null)
            {
                return(BadRequest("Student o takim indeksie już istnieje w bazie danych."));
            }
            student = new Student
            {
                IndexNumber  = request.IndexNumber,
                FirstName    = request.FirstName,
                LastName     = request.LastName,
                BirthDate    = request.Birthdate,
                IdEnrollment = enrollment.IdEnrollment
            };
            Context.Add(student);

            if (await Context.SaveChangesAsync() == 0)
            {
                return(StatusCode(500, "Błąd podczas zapisu danych do bazy."));
            }
            EnrollStudentResponse result = new EnrollStudentResponse
            {
                IndexNumber = student.IndexNumber,
                FirstName   = student.FirstName,
                LastName    = student.LastName,
                Semester    = enrollment.Semester,
                StartDate   = enrollment.StartDate,
            };

            return(StatusCode(201, result));
        }
 private Enrollment PrepareNewEnrollment(Studies studies)
 {
     _sqlCommand.CommandText = InsertFirstSemesterEnrollmentForStudiesQuery;
     _sqlCommand.Parameters.AddWithValue("EnrollmentDate", _enrollmentDate);
     if (_sqlCommand.ExecuteNonQuery() == 0)
     {
         throw new SqlInsertException("Błąd podczas tworzenia nowego wpisu w tablicy \"Enrollment\"!");
     }
     return(InsertedEnrollment(studies.Name));
 }
Ejemplo n.º 14
0
        public void FilterAndJoin()
        {
            //filter subjects by arms
            if (Arms.Any())
            {
                Subjects = Subjects.FindAll(s => Arms.Select(a => a.Id).Contains(s.StudyArmId)).ToList();
            }

            Debug.WriteLine(Subjects.Count, " AFTER ARMS");

            //filter subjects by studies
            if (Studies.Any())
            {
                Subjects = Subjects.FindAll(subj => Studies.Select(st => st.Id).Contains(subj.StudyId)).ToList();
            }
            Debug.WriteLine(Subjects.Count, " AFTER Studies");

            //filter subjects by subCharacteristics
            if (SubjChars.Any())
            {
                Subjects = Subjects.FindAll(s => SubjChars.Select(sc => sc.SubjectId).Contains(s.Id)).ToList();
            }
            Debug.WriteLine(Subjects.Count, " AFTER SubjChars");

            //filter by visits
            //TODO

            //TODO : WILL RETRIEVE SUBJECTS THAT HAVE SAME UNIQUE IDS ACROSS PROJECTS  (i.e. need to load observations to Mongo with
            //TODO: DB subjectId
            //filter observations for filtered subjects
            Observations = Observations?.FindAll(o => Subjects.Select(s => s.UniqueSubjectId).Contains(o.USubjId));

            //filter subjects by selected observations
            if (Observations.Any() && ObservationsFiltered)
            {
                Subjects = Subjects.FindAll(s => Observations.Select(o => o.USubjId).Contains(s.UniqueSubjectId));
            }
            Debug.WriteLine(Subjects.Count, " AFTER syncing with observations");

            //FILTER SAMPLES BY SELECTED AND FILTERED SAMPLE CHARACTERISTICS
            if (SampleCharacteristics.Any())
            {
                Samples = Samples.FindAll(s => SampleCharacteristics.Select(sc => sc.SampleId).Contains(s.Id)).ToList();
            }

            //TODO: TEMP FILTERING BY COLLECTION STUDY DAY


            //SYNCHRONIZE SAMPLES AND SUBJECTS
            if (Samples.Any())
            {
                Samples  = Samples.FindAll(s => Subjects.Select(sc => sc.Id).Contains(s.SubjectId)).ToList();
                Subjects = Subjects.FindAll(sb => Samples.Select(sp => sp.SubjectId).Contains(sb.Id)).ToList();
            }
        }
Ejemplo n.º 15
0
        private (StudyIdentity studyIdentity, IActionResult actionResult) GetStudy(long studyId)
        {
            var study = Studies.GetStudy(studyId);

            if (study != null)
            {
                return(study.Id, null);
            }
            Logger.LogWarning("Study#{studyId} not found", studyId);
            return(study.Id, NotFound());
        }
Ejemplo n.º 16
0
        private void AddStudy()
        {
            Study s = new Study();

            s.Practice = DesktopApplication.CurrentPratice;
            ((Patient)Item).Studies.Add(s);
            StudyViewModel vm = new StudyViewModel(s);

            Studies.Add(vm);
            SelectedStudy = vm;
        }
Ejemplo n.º 17
0
 public Student(string fname, string lname, string sname, string mode, string idx, string bd, string email, string mname, string faname)
 {
     this.fname       = fname;
     this.lname       = lname;
     this.indexNumber = idx;
     this.birthdate   = bd;
     this.email       = email;
     this.motherName  = mname;
     this.fatherName  = faname;
     studies          = new Studies(sname, mode);
 }
Ejemplo n.º 18
0
        //STUDIES
        public void InsertStudies(Studies studies)
        {
            var sql = "INSERT INTO Studies (IdStudy, Institution, Career, IdPostulant, Year, IdStudiesState) VALUES (@IdStudy, @Institution, @Career, @IdPostulant, @Year, @IdStudiesState)";

            using (var conn = new SqlConnection(connStr))
            {
                conn.Open();
                conn.Execute(sql, studies);
                conn.Close();
            }
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Create([Bind("IdStudy,Name")] Studies studies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studies));
        }
Ejemplo n.º 20
0
 public Student(string firstName, string name, string studiesName, string studiesMode, string index, DateTime dateOfBirth, string email, string mothersFName, string fathersFName)
 {
     this.firstName    = firstName;
     this.name         = name;
     study             = new Studies(studiesName, studiesMode);
     this.index        = index;
     this.dateOfBirth  = dateOfBirth;
     this.email        = email;
     this.mothersFName = mothersFName;
     this.fathersFName = fathersFName;
 }
Ejemplo n.º 21
0
        public void GenerateNames()
        {
            Studies = Studies.OrderBy(s => s.ID).ToList();
            int i = 1;

            foreach (DICOMStudy s in Studies)
            {
                StudyDictionary.Add(s.ID, string.Format("{0}_{1}", "Study", i));
                i++;
            }
        }
Ejemplo n.º 22
0
        public IActionResult upgradeStudent([FromBody] Studies studie)
        {
            if (studie.Studiess == null || studie.Semester == null)
            {
                return(BadRequest());
            }

            ObjectResult ob = new ObjectResult(new SqlServerDbService().PromoteStudents(studie.Semester, studie.Studiess));

            ob.StatusCode = 201;
            return(ob);
        }
        private Enrollment GetEnrollmentForNewStudent(Studies studies)
        {
            _sqlCommand.CommandText = FirstSemesterEnrollmentForStudiesQuery;
            using var sqlDataReader = _sqlCommand.ExecuteReader();
            if (sqlDataReader.Read())
            {
                return(SqlDataReaderToEnrollment(sqlDataReader, _enrollRequest.Studies));
            }

            sqlDataReader.Close();
            return(PrepareNewEnrollment(studies));
        }
Ejemplo n.º 24
0
 //POST api/Management/Study
 public ActionResult InsertStudies([FromBody] Studies studies)
 {
     if (this.ModelState.IsValid)
     {
         dbm.InsertStudies(studies);
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 25
0
        public ActionResult Studies(int id, StudiesInformationViewModel studiesViewModel)
        {
            if (ModelState.IsValid)
            {
                Studies studie = new Studies
                {
                    School          = studiesViewModel.School,
                    Idstudylevel    = studiesViewModel.Idstudylevel,
                    Obtainedtitle   = studiesViewModel.Obtainedtitle,
                    Idacademicstate = studiesViewModel.Idacademicstate,
                    Startdate       = studiesViewModel.Startdate,
                    Enddate         = studiesViewModel.Enddate,
                    Idperiodicity   = studiesViewModel.Idperiodicity,
                    Idcandidate     = HttpContext.Session.GetInt32("IdCandidate")
                };

                if (id > 0)
                {
                    studie.Idstudies = id;
                    db.Studies.Update(studie);
                }
                else
                {
                    db.Studies.Add(studie);
                }

                db.SaveChanges();

                var uploads  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\uploads");
                var fileName = Path.GetFileName(studiesViewModel.File.FileName);
                var filePath = Path.Combine(uploads, fileName);
                using (FileStream file = new FileStream(filePath, FileMode.Create))
                {
                    studiesViewModel.File.CopyTo(file);
                    file.Close();
                }

                Document document = new Document
                {
                    Idcandidate    = HttpContext.Session.GetInt32("IdCandidate"),
                    Url            = $"\\uploads\\{fileName}",
                    Iddocumenttype = (int)DocumentTypeEnum.CertificadoEstudio,
                };

                db.Document.Add(document);
                db.SaveChanges();

                return(RedirectToAction("StudyList"));
            }

            return(View(studiesViewModel));
        }
Ejemplo n.º 26
0
        public IEnumerable <Studies> UpdateStudies(Studies studies)
        {
            var sql = "UPDATE Studies SET IdStudy = @IdStudy, Institution = @Institution, Career = @Career, IdStudiesState = @IdStudiesState Where Id = @Id";

            using (var conn = new SqlConnection(connStr))
            {
                conn.Open();
                conn.Execute(sql, studies);
                conn.Close();
            }

            return(this.GetStudies(studies.IdPostulant));
        }
Ejemplo n.º 27
0
        public Studies createStudies(Form form, int IdPostulantDb, int IdStudyform, int IdStudiesStateform)
        {
            Studies studies = new Studies
            {
                IdStudy        = IdStudyform,
                Institution    = form.Institution,
                Career         = form.Career,
                IdPostulant    = IdPostulantDb,
                IdStudiesState = IdStudiesStateform
            };

            return(studies);
        }
Ejemplo n.º 28
0
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     if (typeof(Studies).IsInstanceOfType(obj))
     {
         Studies nStud = (Studies)obj;
         return(nStud.name == this.name);
     }
     return(false);
 }
Ejemplo n.º 29
0
 //PUT api/Management/Study/Modif
 public IEnumerable <Studies> UpdateStudies([FromBody] Studies studies)
 {
     if (studies.Id != 0)
     {
         return(dbm.UpdateStudies(studies));
     }
     else
     {
         IEnumerable <Studies> study = null;
         study.Append(studies);
         return(study);
     }
 }
Ejemplo n.º 30
0
        public Studies createStudiesget(Studiesget studyget, int IdStudyform, int IdStudiesStateform)
        {
            Studies studies = new Studies
            {
                IdStudy        = IdStudyform,
                Institution    = studyget.Institution,
                Career         = studyget.Career,
                IdPostulant    = studyget.IdPostulant,
                Year           = studyget.Year,
                IdStudiesState = IdStudiesStateform
            };

            return(studies);
        }