public int AddTherapy(string date, string objetive, string description, string patient_id, string therapy_id) { TherapySession therapySession = new TherapySession(); TherapySessionDAO therapySessionDao = new TherapySessionDAO(); therapySession.Date = date; therapySession.Objective = objetive; therapySession.Description = description; therapySession.Patient_id = patient_id; therapySession.Therapist_id = therapy_id; //game.Level(); int result = therapySessionDao.InsertTherapySessions(therapySession); if (result == -1) { return(result); } else { Debug.Log("error"); } return(0); }
public async Task <IActionResult> Edit(int id, [Bind("TherapySessionId,Date,Note,ClientId")] TherapySession therapySession) { if (id != therapySession.TherapySessionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(therapySession); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TherapySessionExists(therapySession.TherapySessionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "ClientId", "FirstInitial", therapySession.ClientId); return(View(therapySession)); }
public void Login() { GameObject input = GameObject.Find("Input ID Text"); string id = input.GetComponent <Text>().text; patient = PatientDAO.ConsultPatient(id); therapist = TherapistDAO.ConsultTherapist("123"); if (patient != null && therapist != null) { therapySession = new TherapySession(therapist.Id_num, patient.Id_num); bool insertion = TherapySessionDAO.InsertTherapySession(therapySession); } }
public async Task <IActionResult> Create([Bind("TherapySessionId,Date,Note,ClientId")] TherapySession therapySession) { //ModelState.Remove("ClientId"); if (ModelState.IsValid) { _context.Add(therapySession); await _context.SaveChangesAsync(); return(Redirect($"/Clients/Details/{therapySession.ClientId}")); } ViewData["ClientId"] = new SelectList(_context.Clients, "ClientId", "FirstInitial", therapySession.ClientId); ViewData["GoalId"] = new SelectList(_context.Goals, "GoalId", "Description"); return(View(therapySession)); }
public async Task <TherapySession> GetOrCreateIfNotExistsAsync(ISessionDetails details) { var sessionSpecification = TherapySessionSpecification.ByDetailsOrderDesc(details); var therapySession = await _therapySessionRepository.GetSingleOrDefaultAsync(sessionSpecification); if (therapySession != null) { return(therapySession); } var timeSlotSpecification = TimeSlotSpecification.ByDetailsOrderByDateDesc(details); var timeSlot = await _timeSlotRepository.GetFirstOrDefaultAsync(timeSlotSpecification); Check.NotNull(timeSlot, nameof(timeSlot)); therapySession = new TherapySession(details.DateTime, timeSlot); _therapySessionRepository.Add(therapySession); _logger.LogInformation($"Created therapySession with Id = {therapySession.Id}"); return(therapySession); }
public int InsertTherapySessions(TherapySession therapy) { bool exito = false; if (DBConnection.dbconn != null) { NpgsqlCommand dbcmd = DBConnection.dbconn.CreateCommand(); try { string save_sql = "INSERT INTO start_therapysession VALUES (NEXTVAL ('start_therapysession_id_seq'), '" + therapy.Date + "','" + therapy.Objective + "','" + therapy.Description + "','" + therapy.Patient_id + "','" + therapy.Therapist_id + "');"; Debug.Log(save_sql); dbcmd.CommandText = save_sql; dbcmd.ExecuteNonQuery(); exito = true; } catch (NpgsqlException ex) { Debug.Log(ex.Message); } // clean up dbcmd.Dispose(); dbcmd = null; } else { Debug.Log("Database connection not established"); } return(-1); }
public static bool InsertTherapySession(TherapySession therapy) { bool exito = false; if (DBConnection.dbconn != null) { NpgsqlCommand dbcmd = DBConnection.dbconn.CreateCommand(); Debug.Log("Patient id:" + therapy.Patient_id); try { string sql = string.Format("INSERT INTO start_therapysession (date, objective, description, patient_id, therapist_id) VALUES ('{0}', '{1}', '{2}', (SELECT id FROM patient_patient WHERE id_num = '{3}'), (SELECT user_ptr_id FROM therapist_therapist, auth_user WHERE therapist_therapist.user_ptr_id = auth_user.id and auth_user.username = '******'));", therapy.Date, therapy.Objective, therapy.Description, therapy.Patient_id, therapy.Therapist_id); dbcmd.CommandText = sql; dbcmd.ExecuteNonQuery(); //Debug.Log(""); exito = true; } catch (NpgsqlException ex) { Debug.Log(ex.Message); } // clean up dbcmd.Dispose(); dbcmd = null; } else { Debug.Log("Database connection not established"); } return(exito); }
// Use this for initialization void Start() { var ts = new TherapySession("23123", "sdfsdsaddsad"); Debug.Log(ts.Date); }
public void UpdateSeriesSessionBasis(TherapySession session) { if (session == null) { return; } foreach (var series in Series) { series.Values.Clear(); } var allData = session.GetEmotionDataList(); if (allData.Count == 0) { return; } int chunkSize = allData.Count < 50 ? 1 : allData.Count / 50; double sumAnger = 0; double sumContempt = 0; double sumDisgust = 0; double sumFear = 0; double sumHappiness = 0; double sumNeutral = 0; double sumSadness = 0; double sumSurprise = 0; int counter = 0; for (int i = 0; i < allData.Count; i++) { if (counter >= chunkSize) { Series.ElementAt(0).Values.Add(sumAnger / chunkSize); Series.ElementAt(1).Values.Add(sumContempt / chunkSize); Series.ElementAt(2).Values.Add(sumDisgust / chunkSize); Series.ElementAt(3).Values.Add(sumFear / chunkSize); Series.ElementAt(4).Values.Add(sumHappiness / chunkSize); Series.ElementAt(5).Values.Add(sumNeutral / chunkSize); Series.ElementAt(6).Values.Add(sumSadness / chunkSize); Series.ElementAt(7).Values.Add(sumSurprise / chunkSize); sumAnger = 0; sumContempt = 0; sumDisgust = 0; sumFear = 0; sumHappiness = 0; sumNeutral = 0; sumSadness = 0; sumSurprise = 0; counter = 0; } sumAnger += allData.ElementAt(i).Anger; sumContempt += allData.ElementAt(i).Contempt; sumDisgust += allData.ElementAt(i).Disgust; sumFear += allData.ElementAt(i).Fear; sumHappiness += allData.ElementAt(i).Happiness; sumNeutral += allData.ElementAt(i).Neutral; sumSadness += allData.ElementAt(i).Sadness; sumSurprise += allData.ElementAt(i).Surprise; counter++; } if (counter > 0) { Series.ElementAt(0).Values.Add(sumAnger / chunkSize); Series.ElementAt(1).Values.Add(sumContempt / chunkSize); Series.ElementAt(2).Values.Add(sumDisgust / chunkSize); Series.ElementAt(3).Values.Add(sumFear / chunkSize); Series.ElementAt(4).Values.Add(sumHappiness / chunkSize); Series.ElementAt(5).Values.Add(sumNeutral / chunkSize); Series.ElementAt(6).Values.Add(sumSadness / chunkSize); Series.ElementAt(7).Values.Add(sumSurprise / chunkSize); } }