public async Task RemoveTest() { var fake = Mock.Of <ITherapiesRepo>(); var therapiesService = new TherapiesService(fake); var therapy = new Therapy() { Therapy_Name = "Module 3" }; await therapiesService.Delete(therapy); }
public MedicalRecord UpdateTherapy(Therapy therapy, MedicalRecord medicalRecord) { MedicalRecord medicalRecordToUpdate = medicalRecordRepository.GetObject(medicalRecord.IdRecord); if (!medicalRecordToUpdate.Therapies.Any(entity => entity.Medication.MedId == therapy.Medication.MedId)) { medicalRecordToUpdate.Therapies.Add(therapy); } return(medicalRecordRepository.Update(medicalRecordToUpdate)); }
public async Task <IActionResult> Create([Bind("TherapyID,TherapyName,Price")] Therapy therapy) { if (ModelState.IsValid) { _context.Add(therapy); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(therapy)); }
public ActionResult Edit([Bind(Include = "Id,DateFrom,DateTo,Diagnose,PatientId,DrugId")] Therapy therapy2) { if (ModelState.IsValid) { db.Entry(therapy2).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = therapy2.PatientId })); } ViewBag.PatientId = new SelectList(db.Patients, "Id", "NameSurName", therapy2.PatientId); return(View(therapy2)); }
public Therapy Save(Therapy entity) { if (AuthorizedUsers["Save"].SingleOrDefault(x => x == Role) != null) { return(TherapyController.Save(entity)); } else { return(null); } }
public async Task UpdateTest() { var fake = Mock.Of <ITherapiesRepo>(); var therapiesService = new TherapiesService(fake); var therapy = new Therapy() { Therapy_Name = "Module 2" }; await therapiesService.Update(therapy); }
public async Task AddTest() { var fake = Mock.Of <ITherapiesRepo>(); var therapiesService = new TherapiesService(fake); var therapy = new Therapy() { Therapy_Name = "Module 1" }; await therapiesService.AddAndSave(therapy); }
public void RegisterGameSession(ref GameSession _session) { gameSession = _session; gameSession.NextTherapySession(); a.text = $"<sprite name=\"{gameSession.GetActiveTherapy().relationship.partnerA.displayName}\">"; b.text = $"<sprite name=\"{gameSession.GetActiveTherapy().relationship.partnerB.displayName}\">"; act = gameSession.GetActiveTherapy(); pa = act.relationship.partnerA.stats; pb = act.relationship.partnerB.stats; act.NextSession(); }
public Model.Doctor.Therapy NewTherapy(Model.Doctor.Therapy therapy) { List <Therapy> therapyList = ReadFromFile(); Therapy searchTherapy = GetTherapy(therapy.Id); if (searchTherapy != null) { return(null); } therapyList.Add(therapy); WriteInFile(therapyList); return(therapy); }
public void RemoveTerapija(Therapy oldTherapy) { if (oldTherapy == null) { return; } if (this.terapija != null) { if (this.terapija.Contains(oldTherapy)) { this.terapija.Remove(oldTherapy); } } }
private void submitClick(object sender, RoutedEventArgs e) { //sacuvaj terapiju Therapy therapy = new Therapy(); therapy.PatientId = Appointments.interv.PatientId; therapy.MedicationName = ((Medication)dropMedications.SelectedItem).Name; therapy.Dose = Convert.ToInt32(dose.Text); therapyController.AddTherapy(therapy); AddExamination add = new AddExamination(); add.Show(); this.Close(); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Therapy therapy2 = db.Therapies.Find(id); if (therapy2 == null) { return(HttpNotFound()); } return(View(therapy2)); }
public void AddTerapija(Therapy newTherapy) { if (newTherapy == null) { return; } if (this.terapija == null) { this.terapija = new System.Collections.Generic.List <Therapy>(); } if (!this.terapija.Contains(newTherapy)) { this.terapija.Add(newTherapy); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Therapy therapy2 = db.Therapies.Find(id); if (therapy2 == null) { return(HttpNotFound()); } ViewBag.PatientId = new SelectList(db.Patients, "Id", "NameSurName", therapy2.PatientId); ViewBag.PatientName = db.Patients.Find(therapy2.PatientId).NameSurName; ViewBag.Drugs = db.Drugs.ToList(); return(View(therapy2)); }
// GET: Therapy2/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Therapy therapy2 = db.Therapies.Include(sss => sss.Patient).Single(p => p.Id == id); var drug = db.Drugs.Find(therapy2.DrugId); ViewBag.drug = drug.Name; ViewBag.drugId = drug.Id; if (therapy2 == null) { return(HttpNotFound()); } return(View(therapy2)); }
public static TherapyDTO ToTherapyDTO(this Therapy therapy) { TherapyMemento memento = therapy.GetMemento(); return(new TherapyDTO() { Id = memento.Id, DailyDose = memento.DailyDose, Diagnosis = memento.Diagnosis, DoctorName = memento.DoctorName, DoctorSurname = memento.DoctorSurname, DrugName = memento.DrugName, IdDrug = memento.DrugId, EndDate = memento.EndDate, StartDate = memento.StartDate, ExaminationId = memento.ExaminationId }); }
public async Task ValidPutTherapyCorrectlyUpdatesData() { var oldAbbreviation = _testTherapies[0].Abbreviation; var newAbbreviation = ModelFakes.TherapyFake.Generate().Abbreviation; _testTherapies[0].Abbreviation = newAbbreviation; await _testController.PutTherapy(_testTherapies[0].Adl, _testTherapies[0]); var response = await _testController.GetTherapy(_testTherapies[0].Adl); var responseResult = response.Result as OkObjectResult; Therapy therapy = (Therapy)responseResult.Value; therapy.Abbreviation.Should().NotBe(oldAbbreviation); therapy.Abbreviation.Should().Be(newAbbreviation); therapy.Should().Be(_testTherapies[0]); }
public override void OnInspectorGUI() { Therapy myScript = (Therapy)target; if (GUILayout.Button("Initialize")) { myScript.Initialize(); } if (GUILayout.Button("Next Session")) { if (!myScript.NextSession()) { Debug.Log("reached last Session"); } } DrawDefaultInspector(); }
public async Task <Therapy> UpdateTherapy(string adl, Therapy therapy) { if (therapy.Adl != adl) { throw new TherapyAdlsDoNotMatchException(); } if (!await TherapyExistsByAdl(therapy.Adl)) { throw new TherapyDoesNotExistException(); } if (!await TherapyMainExists(therapy.Type)) { throw new TherapyMainDoesNotExistException(); } var local = await _context.Therapy.FindAsync(adl); if (local == null) { throw new TherapyDoesNotExistException(); } UpdateNonNullAndNonEmptyFields(local, therapy); _context.Entry(local).State = EntityState.Modified; //_context.Entry(therapy).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(therapy); }
public bool DeleteTherapy(int idTherapy) { List <Therapy> therapyList = ReadFromFile(); Therapy therapyForDelete = null; foreach (Therapy t in therapyList) { if (t.Id == idTherapy) { therapyForDelete = t; break; } } if (therapyForDelete == null) { return(false); } therapyList.Remove(therapyForDelete); WriteInFile(therapyList); return(true); }
public ObservableCollection <Therapy> ViewTherapies(int patientId) { ObservableCollection <Therapy> therapyList = new ObservableCollection <Therapy>(); String[] foundRecordTher; String[] linesTher = File.ReadAllLines("C:/Users/Andjela Paunovic/Desktop/HCI_wpf_Andjela_Paunovic/HCI_wpf_Andjela_Paunovic/CSV/therapies.csv"); for (int i = 1; i < linesTher.Length; i++) { Therapy therapy = new Therapy(); foundRecordTher = linesTher[i].Split(','); if (Convert.ToInt32(foundRecordTher[0]) == patientId) { Therapy mappedTherapy = mapTherapyData(foundRecordTher, therapy); therapyList.Add(mappedTherapy); } } return(therapyList); }
protected void SaveTherapy_Click(object sender, EventArgs e) { try { DAL.DBTherapyConnection dBTherapy = new DAL.DBTherapyConnection(); Therapy therapy = new Therapy(); therapy.date = Convert.ToDateTime(NewTherapyDate.Text); therapy.Time = TimeSpan.Parse(NewTherapyEndTime.Text); therapy.description = NewTherapyDescriptionTB.Text; therapy.Location = Location.Text ?? ""; therapy.CostsInEuro = Convert.ToDecimal(Costs.Text ?? "0", CultureInfo.InvariantCulture); Desease desease = new Desease(); desease.ID = Convert.ToInt32(NewDesease.SelectedValue); Medication medication = new Medication(); medication.ID = Convert.ToInt32(NewMedicationDDL.SelectedValue); if (dBTherapy.IsTherapyAllowed(LoggedInUser, therapy, NewTherapyClient.SelectedValue)) { bool result = dBTherapy.Save(LoggedInUser, therapy, medication, desease, NewTherapyClient.SelectedValue); if (result) { lbl.Text = "Behandeling is succesvol opgeslagen"; } else { lbl.Text = "Er is iets fout gegaan"; } } else { lbl.Text = "De behandelaar of de cliënt heeft al een behandeling gepland in het ingevuld tijdsbestek"; } } catch (Exception ex) { lbl.Text = "Er is iets fout gegaan"; } }
public Boolean RemoveTherapy(Therapy therapy) { String path = "C:/Users/Andjela Paunovic/Desktop/projekat2/project/zdravoCorporationBackend/HCI_wpf_Andjela_Paunovic/HCI_wpf_Andjela_Paunovic/CSV/therapies.csv"; List <String> lines = new List <String>(); using (StreamReader reader = new StreamReader(path)) { String line; while ((line = reader.ReadLine()) != null) { if (line.Contains(",")) { String[] split = line.Split(','); if (split[0].Equals(Convert.ToString(therapy.PatientId)) && split[1] == therapy.MedicationName) { split[0] = "099"; split[1] = "099"; split[2] = "099"; line = String.Join(",", split); } } lines.Add(line); } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (String line in lines) { writer.WriteLine(line); } } return(true); }
public void Initialize() { var options = new DbContextOptionsBuilder <CoreDbContext>() .UseInMemoryDatabase(databaseName: "TherapyDatabase") .Options; _testTherapyMains = new List <TherapyMain>(); _testTherapies = new List <Therapy>(); _testAdls = new List <string>(); _testTypes = new List <string>(); _testContext = new CoreDbContext(options); _testContext.Database.EnsureDeleted(); for (var i = 0; i < 10; i++) { var newTherapyMain = ModelFakes.TherapyMainFake.Generate(); _testTypes.Add(newTherapyMain.Type); _testContext.Add(newTherapyMain); _testContext.SaveChanges(); _testTherapyMains.Add(ObjectExtensions.Copy(newTherapyMain)); var newTherapy = ModelFakes.TherapyFake.Generate(); newTherapy.Type = newTherapyMain.Type; _testAdls.Add(newTherapy.Adl); _testContext.Add(newTherapy); _testContext.SaveChanges(); _testTherapies.Add(ObjectExtensions.Copy(newTherapy)); } _nonActiveTherapy = ModelFakes.TherapyFake.Generate(); _nonActiveTherapy.Type = _testTherapyMains[0].Type; _nonActiveTherapy.Active = false; _testContext.Add(_nonActiveTherapy); _testContext.SaveChanges(); _testService = new TherapyService(_testContext); _testController = new TherapyController(_testService); }
public bool Save(User user, Therapy therapy, Medication medication, Desease desease, string BSNNumber) { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("insert into therapies (therapies.ID,therapies.Description,therapies.MedicationID,therapies.DeseaseID,therapies.TherapistID,therapies.Date,therapies.Time,therapies.DateEnd,therapies.BSNNumber,therapies.Costs,therapies.Location,therapies.Accepted) values(0,@description,@medicationID,@deseaseID,@therapistID,@date,@endtime,@dateend,@bsnnumber,@costs,@location,0)", con)) { try { con.Open(); cmd.Parameters.AddWithValue("@bsnnumber", BSNNumber); cmd.Parameters.AddWithValue("@description", therapy.description); cmd.Parameters.AddWithValue("@medicationID", medication.ID); cmd.Parameters.AddWithValue("@deseaseID", desease.ID); cmd.Parameters.AddWithValue("@therapistID", user.ID); cmd.Parameters.AddWithValue("@date", therapy.date); cmd.Parameters.AddWithValue("@endtime", therapy.Time); cmd.Parameters.AddWithValue("@dateend", therapy.date + therapy.Time); cmd.Parameters.AddWithValue("@costs", MySqlDbType.Decimal).Value = therapy.CostsInEuro; cmd.Parameters.AddWithValue("@location", therapy.Location); var result = cmd.ExecuteScalar(); if (result != null) { } } catch (Exception ex) { if (con.State != System.Data.ConnectionState.Closed) { con.Close(); } throw new Exception(ex.Message); } if (con.State != System.Data.ConnectionState.Closed) { con.Close(); } } return(true); }
private void DeleteTherapy_Click(object sender, RoutedEventArgs e) { if (selectedTherapy == null) { ErrorMessage.Visibility = Visibility.Visible; Error.Text = ERROR_DELETE; return; } ModelHCI.MedicalRecordHCI record = Informations.currentRecord; var recordToUpdate = record.MedicalRecord; Therapy therapyToDelete = null; foreach (Therapy therapy in recordToUpdate.Therapies) { Medication med = medicationController.GetMedication(therapy.Medication.MedId); if (med.Med.Equals(selectedTherapy.medication.medication.Med)) { therapyToDelete = therapy; } } if (therapyToDelete != null) { recordToUpdate.Therapies.Remove(therapyToDelete); } var recordUpdate = medicalRecordController.GetMedicalRecord(recordToUpdate.IdRecord); if (therapyToDelete != null) { recordUpdate.Therapies.Remove(therapyToDelete); } Informations.currentRecord.MedicalRecord = medicalRecordController.UpdateRecord(recordToUpdate); setListBoxes(); }
public ActionResult Create([Bind(Include = "Id,DateFrom,DateTo,Diagnose,PatientId,DrugId")] Therapy therapy2) { if (ModelState.IsValid) { db.Therapies.Add(therapy2); string diagnose = Request.Form["Diagnose"]; int pacient = int.Parse(Request.Form["PatientId"]); var patient = db.Patients.Find(pacient); var historyofdeseases = patient.HistoryOfDiseases.ToString(); var added = historyofdeseases + " " + diagnose; patient.HistoryOfDiseases = added; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PatientId = new SelectList(db.Patients, "Id", "NameSurName", therapy2.PatientId); return(View(therapy2)); }
public Therapy EditTherapy(Therapy therapy) { return(therapyRepository.SetTherapy(therapy)); }
public Therapy AddTherapy(Therapy therapy) { return(therapyRepository.NewTherapy(therapy)); }
public Boolean AddTherapy(Therapy therapy) { return(therapyService.AddTherapy(therapy)); }