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); }
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); }
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); }
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); }
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 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))); }