public SaveObjectiveFunctionsViewModel(string objectiveFunctionsJson, string defaultDirectoryPath) { DefaultDirectoryPath = defaultDirectoryPath; var objectiveFunctionsJObject = JObject.Parse(objectiveFunctionsJson); var objectiveFunctionArguments = (JArray)objectiveFunctionsJObject["Arguments"]; ObjectiveFunctions.Clear(); foreach (var a in objectiveFunctionArguments) { var jObject = JObject.Parse(a.ToString()); ObjectiveFunctions.Add(new Models.ObjectiveFunction(jObject)); } var prescriptionsJArray = (JArray)objectiveFunctionsJObject["Prescriptions"]; var PrescriptionsAll = prescriptionsJArray.ToObject <List <Models.Prescription> >(); Prescriptions.Clear(); foreach (var p in PrescriptionsAll) { if (ObjectiveFunctions.Where(o => (o.PlanLabel == p.PlanLabel)).Count() > 0) { Prescriptions.Add(p); } } OkCommand = new DelegateCommand(() => { CanExecute = true; }); CancelCommand = new DelegateCommand(() => { CanExecute = false; }); SaveFileCommand = new DelegateCommand(SaveFile); }
public IActionResult GetPerscription(int id) { using (SqlConnection con = new SqlConnection("Data Source = db-mssql; Initial Catalog=s18793; Integrated Security=True")) using (SqlCommand com = new SqlCommand()) { try { var list = new List <Prescriptions>(); var lista = new List <PrescriptionsMedicament>(); com.Connection = con; com.Parameters.AddWithValue("IdPrescription", id); com.CommandText = "Select * from Prescription where IdPrescription =@id"; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { var per = new Prescriptions(); per.IdPerscription = (int)dr["IdPrescription"]; per.Date = DateTime.Parse(dr["Date"].ToString()); per.DueTime = DateTime.Parse(dr["DueDate"].ToString()); per.IdPatient = (int)dr["IdPatient"]; per.IdDoctor = (int)dr["IdDoctor"]; list.Add(per); } com.ExecuteNonQuery(); com.CommandText = "Select * from Prescription_Medicament where IdPrescription= @id"; com.Parameters.AddWithValue("idPerc", id); while (dr.Read()) { var permed = new PrescriptionsMedicament(); var listaMed = new List <Medicament>(); permed.IdPerscription = (int)dr["IdPrescription"];; permed.IdMedicament = (int)dr["IdMedicament"]; permed.Dose = (int)dr["Dose"]; permed.Details = (dr["Details"].ToString()); lista.Add(permed); } return(Ok(list + "\n" + lista)); } catch (SqlException sql) { return(BadRequest("Nie prawidłowy parametr/nie podano parametru")); } } }
public LoadObjectiveFunctionsViewModel() { List <Models.PlanLabel> planLabels0 = new List <Models.PlanLabel>(); planLabels0.Add(new Models.PlanLabel("1-1-1", 4600)); planLabels0[0].LabelInObjectiveFunction = PlanLabelNone; planLabels0.Add(new Models.PlanLabel("1-1-2", 2600)); planLabels0[1].LabelInObjectiveFunction = PlanLabelNone; PlanLabels = new ObservableCollection <Models.PlanLabel>(planLabels0); List <Models.Roi> rois0 = new List <Models.Roi>(); rois0.Add(new Models.Roi("PTV1")); rois0.Add(new Models.Roi("CTV")); rois0.Add(new Models.Roi("Rectum")); rois0.Add(new Models.Roi("Bladder")); Rois = new ObservableCollection <Models.Roi>(rois0); foreach (var r in Rois) { r.NameInObjectiveFunction = RoiNameNone; } RoiNamesInObjectiveFunctions.Add(RoiNameNone); PlanLabelsInObjectiveFuntions.Add(PlanLabelNone); Prescriptions.Add(new Models.Prescription { PlanLabel = "test", PrescribedDose = 300, PrescribedDoseInObjectiveFunction = 400 }); OkCommand = new DelegateCommand(() => { CanExecute = true; SetObjectiveFunctionArguments(); }); CancelCommand = new DelegateCommand(() => { CanExecute = false; }); ChooseFileCommand = new DelegateCommand(ChooseFile); }
private void AddObservation() { ServiceObservation.ServiceObservationClient client = new ServiceObservation.ServiceObservationClient(); ServiceObservation.Observation obs = new ServiceObservation.Observation(); obs.BloodPressure = BloodPressure; obs.Comment = Comment; obs.Prescription = Prescriptions.ToArray(); obs.Weight = Weight; obs.Pictures = ConverttobyteArray().ToArray(); obs.Date = Date; try { client.AddObservation(Patient.Id, obs); View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.NewObservation view = new colle_tMedecine.View.NewObservation(); ViewModel.NewObservationViewModel vm = new colle_tMedecine.ViewModel.NewObservationViewModel(Patient); view.DataContext = vm; mainwindow.contentcontrol.Content = view; } catch { View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.NewObservation view = new colle_tMedecine.View.NewObservation(); ViewModel.NewObservationViewModel vm = new colle_tMedecine.ViewModel.NewObservationViewModel(Patient); view.DataContext = vm; mainwindow.contentcontrol.Content = view; } }
private Prescription AddPrescriptionEntities1() { var doctor = new Doctor() { //IdDoctor = 1, FirstName = "Arnold", LastName = "Brzeczukiewicz", Email = "*****@*****.**" }; var patient = new Patient() { //IdPatient = 1, FirstName = "Larry", LastName = "Brandenberg", BirthDate = new DateTime() }; var prescription = new Prescription() { //IdPrescription = 1, Date = new DateTime(), DueDate = new DateTime(), Doctor = doctor, Patient = patient }; Patients.Add(patient); Doctors.Add(doctor); Prescriptions.Add(prescription); return(prescription); }
private Prescription AddPrescriptionEntities2() { var doctor = new Doctor() { //IdDoctor = 2, FirstName = "Ferdynand", LastName = "Roche", Email = "*****@*****.**" }; var patient = new Patient() { //IdPatient = 2, FirstName = "Lawrenze", LastName = "Muller", BirthDate = new DateTime() }; var prescription = new Prescription() { //IdPrescription = 1, Date = new DateTime(), DueDate = new DateTime(), Doctor = doctor, Patient = patient }; Patients.Add(patient); Doctors.Add(doctor); Prescriptions.Add(prescription); return(prescription); }
public async Task <IActionResult> PutPrescriptions([FromRoute] int id, [FromBody] Prescriptions prescriptions) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prescriptions.PrescriptionId) { return(BadRequest()); } _context.Entry(prescriptions).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrescriptionsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,AppointmentId,InventoryId,Quantity,Dosage,Notes,IssuedAt,IsPublic")] Prescriptions prescriptions) { if (id != prescriptions.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(prescriptions); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrescriptionsExists(prescriptions.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", prescriptions.AppointmentId); ViewData["InventoryId"] = new SelectList(_context.Inventories, "Id", "BrandName", prescriptions.InventoryId); return(View(prescriptions)); }
public IActionResult getPrescriptions(int id) { try { var prescList = new List<Prescriptions>(); var prescMedList = new List<PrescriptionMedicament>(); using (SqlConnection client = new SqlConnection("Data Source=db-mssql;Initial Catalog=s18840;Integrated Security=True")) using (var com = new SqlCommand()) { com.Connection = client; com.Parameters.AddWithValue("IdPrescription", id); com.CommandText = "Select * from Prescription where IdPrescription = @id"; client.Open(); var reader = com.ExecuteReader(); while (reader.Read()) { var presc = new Prescriptions(); presc.IdPrescription = (int)reader["IdPrescription"]; presc.Date = DateTime.Parse(reader["Date"].ToString()); presc.DueTime = DateTime.Parse(reader["DueDate"].ToString()); presc.IdPatient = (int)reader["IdPatient"]; presc.IdDoctor = (int)reader["IdPatient"]; prescList.Add(presc); //com.ExecuteNonQuery(); } com.ExecuteNonQuery(); com.Parameters.AddWithValue("IdPrescription2", id); com.CommandText = "Select * from Prescription_Medicament where IdPrescription = @id"; while (reader.Read()) { var prescMed = new PrescriptionMedicament(); var medList = new List<Medicament>(); prescMed.IdPrescription = (int)reader["IdPrescription"]; prescMed.IdMedicament = (int)reader["IdMedicament"]; prescMed.Dose = (int)reader["Dose"]; prescMed.Details = reader["Details"].ToString(); prescMedList.Add(prescMed); } return Ok(prescList + " " + prescMedList); } }catch(SqlException ex) { return BadRequest("Blad"); } }
public async Task <IActionResult> PostPrescriptions([FromBody] Prescriptions prescriptions) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Prescriptions.Add(prescriptions); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPrescriptions", new { id = prescriptions.PrescriptionId }, prescriptions)); }
public async Task <IActionResult> Create([Bind("Id,AppointmentId,InventoryId,Quantity,Dosage,Notes,IssuedAt,IsPublic")] Prescriptions prescriptions) { if (ModelState.IsValid) { _context.Add(prescriptions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", prescriptions.AppointmentId); ViewData["InventoryId"] = new SelectList(_context.Inventories, "Id", "BrandName", prescriptions.InventoryId); return(View(prescriptions)); }
public SaveObjectiveFunctionsViewModel() { Prescriptions.Add(new Models.Prescription { PlanLabel = "1-1-1", PrescribedDose = 4600 }); Prescriptions.Add(new Models.Prescription { PlanLabel = "1-1-2", PrescribedDose = 2600 }); Prescriptions.Add(new Models.Prescription { PlanLabel = "Combined dose", PrescribedDose = 7200 }); OkCommand = new DelegateCommand(() => { CanExecute = true; }); CancelCommand = new DelegateCommand(() => { CanExecute = false; }); SaveFileCommand = new DelegateCommand(SaveFile); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Prescriptions = await _context.Prescriptions.FindAsync(id); if (Prescriptions != null) { _context.Prescriptions.Remove(Prescriptions); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Prescriptions = await _context.Prescriptions .Include(p => p.Appointment) .Include(p => p.Inventory).FirstOrDefaultAsync(m => m.Id == id); if (Prescriptions == null) { return(NotFound()); } return(Page()); }
/// <summary> /// Removes the prescription group. /// </summary> /// <param name="selectedItems">The prescription group</param> public async void DeletePrescriptionGroup(object selectedItems) { try { PrescriptionGroup group = selectedItems as PrescriptionGroup; var count = group.Prescriptions.Count; await imsSvc.DeletePrescriptionGroupAsync(group.Prescriptions); AllPrescriptions.Remove(group); Prescriptions.Remove(group); } catch (Exception e) { MessengerInstance.Send(new ExceptionDialogMessage(e)); } }
public IActionResult GetPerscription(int id) { using (SqlConnection con = new SqlConnection("Data Source = db-mssql; Initial Catalog=s18830; Integrated Security=True")) com.Connection = con; using (SqlCommand com = new SqlCommand()) { try { var list = new List<Prescriptions>(); var lista = new List<PrescriptionsMedicament>(); com.Parameters.AddWithValue("IdPrescription", id); com.CommandText = "select Name Type,Date ,DueDate , Description ,Dose , IdPatient,IdDoctor from Prescription_Medicament JOIN Prescription on Prescription.IdPrescription = Prescription_Medicament.IdPrescription JOIN Medicament on Medicament.IdMedicament = Prescription_Medicament.IdMedicament where IdPrescription =@id"; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()){ var recepta = new Prescriptions(); recepta.IdPerscription = (int)dr["IdPrescription"]; recepta.Date = DateTime.Parse(dr["Date"].ToString()); recepta.DueTime = DateTime.Parse(dr["DueDate"].ToString()); recepta.IdPatient = (int)dr["IdPatient"]; recepta.IdDoctor = (int)dr["IdDoctor"]; var permed = new PrescriptionsMedicament(); var listaMed = new List<Medicament>(); permed.IdPerscription = (int)dr["IdPrescription"]; ; permed.IdMedicament = (int)dr["IdMedicament"]; listaMed.Dose = (int)dr["Dose"]; listaMed.Details = (dr["Details"].ToString()); lista.Add(permed); list.Add(recepta); } return Ok(list + "\n" + lista); } catch (SqlException sql) { return BadRequest("Wysłano nieprawidłowe zapytanie"); } } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Prescriptions = await _context.Prescriptions .Include(p => p.Appointment) .Include(p => p.Inventory).FirstOrDefaultAsync(m => m.Id == id); if (Prescriptions == null) { return(NotFound()); } ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id"); ViewData["InventoryId"] = new SelectList(_context.Inventories, "Id", "BrandName"); return(Page()); }
public ActionResult AddPrescription(AddPrescriptionViewModel model) { var db = new ApplicationDbContext(); if (!ModelState.IsValid) { model.Types = db.PrescriptionTypes.ToList(); return(View(model)); } var p = new Prescriptions { PrescriptionName = model.PrescriptionName, PrescriptionTypeID = model.PrescriptionTypeID }; db.Prescriptions.Add(p); db.SaveChanges(); return(RedirectToAction("Index", new { message = PrescriptionMessageId.AddPrescriptionSuccess })); }
public async Task GetPrescriptions() { IsRefreshing = true; var docs = await DatabaseInstance.Database.GetDoctors(); var myaddress = AccountManager.Instance().GetAddress(); var webclient = WebClient.WebAPI; List <Prescription> prescriptions; try { prescriptions = await webclient.GetPrescriptions(myaddress); } catch { IsRefreshing = false; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsRefreshing))); return; } var query = prescriptions.Join(docs, prescription => prescription.DoctorId, doc => doc.Address, (doc, prescription) => (Projection)doc); Prescriptions.Clear(); foreach (var item in query) { var proj = new Projection(); proj = (Projection)item; proj.BuyCommand = buy; proj.DoctorName = docs.First(x => x.Address == item.DoctorId).Name; Prescriptions.Add(proj); } IsRefreshing = false; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsRefreshing))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Prescriptions))); }
private void CreateObsMethod() { if (Prescriptions == null || Prescriptions.Equals("") || BloodPressure.Equals("0") || Weight.Equals("0")) { MaterialMessageBox.ShowError("Remplir les champs obligatoire de l'observation (poids, pression sanguine, prescription"); return; } Model.Observation obs = new Model.Observation() { bloodPressure = _bloodPressure, comment = Comment, date = Date, pictures = Pictures.ToArray(), prescription = Prescriptions.Split('\n'), weight = _weight }; int patientId = lastWindow.SelectedPatient.id; Observations.CreateObservation(patientId, obs); lastWindow.SelectedPatient.observations.Add(obs); lastWindow.SelectedObservation = obs; CloseWindow(); }
/// <summary> /// Removes the prescription. /// </summary> /// <param name="selectedItem"></param> public async void DeletePrescription(object selectedItem) { try { Prescription item = selectedItem as Prescription; await imsSvc.DeletePrescriptionAsync(item); var group = AllPrescriptions.Single(grp => grp.TimeStamp == item.Schedule); if (group.Prescriptions.Count > 1) { AllPrescriptions.Single(grp => grp.TimeStamp == item.Schedule).Prescriptions.Remove(item); Prescriptions.Single(grp => grp.TimeStamp == item.Schedule).Prescriptions.Remove(item); } else { AllPrescriptions.Remove(group); Prescriptions.Remove(group); } } catch (Exception e) { MessengerInstance.Send(new ExceptionDialogMessage(e)); } }
public PrescriptionsViewModel(IUnityContainer container, IRegionManager regionManage, IEventAggregator eventAggregator, Prescriptions view) : base(view) { Container = container; RegionManager = regionManage; EventAggregator = eventAggregator; }
private void SetObjectiveFunctionArguments() { foreach (var r in Rois) { if (!r.InUse || r.NameInObjectiveFunction == RoiNameNone) { continue; } var query = ObjectiveFunctions.Where(o => (o.InUse && o.RoiName == r.NameInObjectiveFunction)); if (query.Count() == 0) { continue; } foreach (var o in query) { var planLabelQuery = PlanLabels.Where(p => p.LabelInObjectiveFunction == o.PlanLabel); string newLabel = string.Empty; if (planLabelQuery.Count() > 0) { var newPlanLabel = planLabelQuery.First(); bool inUse = newPlanLabel.InUse; if (!inUse) { continue; } newLabel = newPlanLabel.Label; if (planLabelQuery.Count() >= 2) { Message = $"Multiple plans are assigned to {o.PlanLabel}. Use {newLabel}."; } o.SetPlanLabelInArguments(newLabel); } else if (!(o.PlanLabel == PlanLabelCombinedDose)) { continue; } o.UpdateWeightInArguments(); o.SetRoiNameInArguments(r.Name); if (o.PlanLabel == PlanLabelCombinedDose) { if (!DoesUseCombinedDose) { continue; } newLabel = PlanLabelCombinedDose; } var prescriptionQuery = Prescriptions.Where(p => p.PlanLabel == o.PlanLabel); double scale = 0; if (prescriptionQuery.Count() == 0) { scale = 1.0; Message = $"Prescription does not exist for new: {newLabel} and original: {o.PlanLabel}"; } else { var prescription = prescriptionQuery.First(); var originalPrescribedDose = prescription.PrescribedDoseInObjectiveFunction; var prescribedDose = prescription.PrescribedDose; if (DoesRescaleDose) { if (originalPrescribedDose == 0) { Message = $"No rescale because the original prescribed dose = 0"; scale = 1.0; } else { scale = prescribedDose / originalPrescribedDose; } } } var functionType = o.Arguments["FunctionType"].ToObject <string>(); if (functionType == "DoseFallOff") { var highDoseLevel = scale * o.Arguments["HighDoseLevel"].ToObject <double>(); var lowDoseLevel = scale * o.Arguments["LowDoseLevel"].ToObject <double>(); o.Arguments["HighDoseLevel"] = highDoseLevel; o.Arguments["LowDoseLevel"] = lowDoseLevel; } else if (functionType == "UniformDose" || functionType == "MaxDose" || functionType == "MinDose" || functionType == "MaxEud" || functionType == "MinEud" || functionType == "MaxDvh" || functionType == "MinDvh") { var doseLevel = scale * o.Arguments["DoseLevel"].ToObject <double>(); o.Arguments["DoseLevel"] = doseLevel; } r.ObjectiveFunctionArguments.Add(o.Arguments.ToString()); } } }