private void OnPatientDeleted(int id) { double deletedRevenue = 0; double deletedProfit = 0; double time = 0; int interventionsNb = 0; foreach (var localIntervention in SelectedPatient.Interventions) { deletedRevenue += localIntervention.Revenue; deletedProfit += localIntervention.Percent; interventionsNb++; time += localIntervention.DateHourDetail.Duration.TotalMinutes; } Parent.OnChangeTotalInfo(new TotalsIfo { TotalHours = new TimeSpan(-(long)time), TotalInverventions = -interventionsNb, TotalRevenue = -deletedRevenue, TotalProfit = -deletedProfit, TotalPatients = -1 }); PatientsList.Remove(SelectedPatient); SelectedPatient = PatientsList.FirstOrDefault(); }
public void DataGrid_Loaded(string id, string fn, string ln) { SelectedFirstName = fn; PatientsList.Add(new PatientModel { IDPatient = id, FirstName = fn, LastName = ln }); }
public void SetInterventionToEdit() { TotalInfoSelectedEl = new TotalsIfo() { TotalHours = -SelectedInterventionDetails.LocalIntervention.DateHourDetail.Duration, TotalInverventions = -1, TotalRevenue = -SelectedInterventionDetails.LocalIntervention.Revenue, TotalProfit = -SelectedInterventionDetails.LocalIntervention.Percent }; SelectedArea = SelectedInterventionDetails.LocalIntervention.Area != null?Areas.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.Area.Id) : null; if (SelectedInterventionDetails.LocalIntervention.Location != null) { SelectedLocation = LocalLocations.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.Location.Id); } if (SelectedInterventionDetails.LocalIntervention.Material != null && Materials != null) { SelectedMaterial = Materials.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.Material.Id); } SelectedPatient = PatientsList.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.PatientId); SelectedWork = SelectedInterventionDetails.LocalIntervention.Lucrare != null?Works.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.Lucrare.Id) : new LocalWork(); Durata = SelectedInterventionDetails.Durata.TotalMinutes.ToString(); Date = SelectedInterventionDetails.LocalIntervention.DateHourDetail.Date; StartingHour = SelectedInterventionDetails.LocalIntervention.DateHourDetail.StartHour; Revenue = SelectedInterventionDetails.LocalIntervention.Revenue; Id = SelectedInterventionDetails.LocalIntervention.Id; LocalIntervention = SelectedInterventionDetails.LocalIntervention; Observation = SelectedInterventionDetails.Observations; IsInEditMode = true; WasPayedByDental = SelectedInterventionDetails.WasPayedByDental; SelectedTechnician = Technicians.FirstOrDefault(item => item.Id == SelectedInterventionDetails.LocalIntervention.TechnicianId); MaterialCost = SelectedInterventionDetails.MaterialCost; }
public async Task <IActionResult> ResetView() { PatientsList queriedPatients = await FhirService.GetObservationValues(AppContext.MonitorPatients); AppContext.MonitorPatients = queriedPatients; return(Json("Success")); }
public async void AddNewPatient(string PatientName) { int spaceOcc = PatientName.IndexOf(" "); var patient = new LocalPatient() { Name = spaceOcc > 0 ? PatientName.Substring(spaceOcc + 1, PatientName.Length - spaceOcc - 1) : PatientName, Surname = spaceOcc > 0 ? PatientName.Substring(0, spaceOcc) : "", AllName = PatientName, Brush = BackgroundColors.BackgroundFilled, }; if (!PatientsList.Any(item => item.Surname.Trim() == patient.Surname.Trim() && item.Name.Trim() == patient.Name.Trim())) { patient.Name = patient.Name.TrimEnd(); patient.Surname = patient.Surname.TrimEnd(); patient.AllName = patient.Surname + " " + patient.Name; SelectedPatient = patient; try { SelectedPatient.Id = await DatabaseHandler.Instance.AddPatient(SelectedPatient, LocalCache.Instance.CurrentUser.Id); PatientsList.Add(SelectedPatient); eventAggregator.GetEvent <PatientAddedEvent>().Publish(SelectedPatient); LocalCache.Instance.PatientsRepository.Patients.Add(SelectedPatient); } catch (Exception ex) { MessageBox.Show("Eroare la salvare pacient"); } } }
private void UpdatePatientList_Click(object sender, EventArgs e) { RefreshPatients(); PatientsList.Update(); PatientsList.Columns[0].Width = 42; PatientsList.Columns[1].Width = 232; }
public EditModel(PatientsList patientsList, SpeciesList speciesList, IHostingEnvironment environment) { _patientsList = patientsList; _speciesList = speciesList; _environment = environment; }
private void DoctorForm_Load(object sender, EventArgs e) { DoctorName.Text = user.FullName; _container = new EntityModelContainer(); RefreshPatients(); PatientsList.Update(); }
private void DoctorForm_Activated(object sender, EventArgs e) { RefreshPatients(); PatientsList.Update(); PatientsList.Columns[0].Width = 42; PatientsList.Columns[1].Width = 232; }
public void Add(PatientsList list) { foreach (var i in list.Patients) { var child = new TreeViewModel(); child.Title = "Patient"; // Level2 node name child.Add(i); Children.Add(child); } }
public async void SavePatient(LocalPatient addedPatient) { if (!string.IsNullOrEmpty(SearchedItem)) { Search(SearchedItem); } AddPatientControlVisibility = Visibility.Collapsed; PatientsList.Add(addedPatient); //SelectedPatient = addedPatient; }
private void Search(string searchedWord) { searchedWord = searchedWord.ToLower(); int wordLength = searchedWord.Length; // CurrentPatients = new ObservableCollection<PatientViewModel>(PatientsList.Where(item => item.Name.ToLower().Contains(searchedWord))); CurrentPatients = new ObservableCollection <LocalPatient>(PatientsList.Where(item => (item.Name != null && item.Name.Length >= wordLength && item.Name.ToLower().Substring(0, wordLength) == searchedWord) || item.Surname != null && item.Surname.Length >= wordLength && item.Surname.ToLower().Substring(0, wordLength) == searchedWord)); SelectedPatient = CurrentPatients.FirstOrDefault(); }
private void FilterItem(string filter) { PatientsList.BeginRefresh(); if (string.IsNullOrEmpty(filter)) { PatientsList.ItemsSource = patientItems; } else { PatientsList.ItemsSource = patientItems.Where(p => p.FirstName.ToLower().Contains(filter.ToLower()) || p.LastName.ToLower().Contains(filter.ToLower())); } PatientsList.EndRefresh(); }
void RefreshPatients() { _container = new EntityModelContainer(); Doctor refreshUser = _container.DoctorSet.Find(user.UserCode); user = refreshUser; if (AllPatientsSearch.Checked) { PatientsList.DataSource = (from patient in user.Patient.AsParallel() select new { Код = patient.UserCode, ФИО = patient.FullName, Дата_рождения = patient.BirthDate.ToShortDateString() }).ToList(); } else { if (NameSearch.Checked) { PatientsList.DataSource = (from patient in user.Patient.AsParallel() where patient.FullName.IndexOf(PatientNameSearch.Text) != -1 select new { Код = patient.UserCode, ФИО = patient.FullName, Дата_рождения = patient.BirthDate.ToShortDateString() }).ToList(); } else { PatientsList.DataSource = (from patient in user.Patient.AsParallel() where patient.UserCode == int.Parse(PatientCodeSearch.Text) select new { Код = patient.UserCode, ФИО = patient.FullName, Дата_рождения = patient.BirthDate.ToShortDateString() }).ToList(); } } PatientsList.Update(); }
public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddDbContext <VetClinicContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VetClinicContext"))); var optionsBuilder = new DbContextOptionsBuilder <VetClinicContext>(); optionsBuilder.UseSqlServer(Configuration.GetConnectionString("VetClinicContext")); var context = new VetClinicContext(optionsBuilder.Options); var patientList = new PatientsList(context); var speciesList = new SpeciesList(context); services.AddSingleton <PatientsList>(patientList); services.AddSingleton <SpeciesList>(speciesList); }
private void OnPatientAdded(object patient) { var patientSelected = (LocalPatient)patient; PatientsList.Add(patientSelected); CurrentPatients = PatientsList; SelectedPatient = patientSelected; eventAggregator.GetEvent <TotalsModifiedEvent>().Publish(new TotalsIfo { TotalHours = new TimeSpan(0), TotalInverventions = 0, TotalRevenue = 0, TotalProfit = 0, TotalPatients = 1 }); LocalCache.Instance.PatientsRepository.Patients.Add(patientSelected); LocalCache.Instance.PatientsRepository.SetBirthDays(); Parent.InterventionsGeneralDetailsViewModel.InitNames(); }
private void OnPatientNameChanged(object patient) { var patientToEdit = (LocalPatient)patient; var editedPatient = PatientsList.FirstOrDefault(item => item.Id == patientToEdit.Id); editedPatient.AllName = patientToEdit.AllName; var currentDate = DateTime.Now; // if (currentDate.Day == ((LocalPatient)patient).BirthDate.Day && currentDate.Month == ((LocalPatient)patient).BirthDate.Month) { var poEdit = LocalCache.Instance.PatientsRepository.Patients.FirstOrDefault(item => item.Id == editedPatient.Id); poEdit = patientToEdit; // LocalCache.Instance.PatientsRepository.BirthDays.Add(ed); LocalCache.Instance.PatientsRepository.SetBirthDays(); Parent.InterventionsGeneralDetailsViewModel.InitNames(); } //PatientsList.Add(editedPatient); }
private void LoadData() { var list1 = new PatientsList(); list1.Patients.Add(new Patient { ID = 44, Name = "Ben Garsia", Year = 1985 }); list1.Patients.Add(new Patient { ID = 22, Name = "Melisa Mayer", Year = 1968 }); list1.Patients.Add(new Patient { ID = 33, Name = "Morgan Smith", Year = 1979 }); var root = new TreeViewModel(); root.Add(list1); Tree.Add(root); }
/// <summary> /// Helper method that takes Primary Key and set all fields with value /// </summary> /// <param name="PK">int PrimaryKey of Doctors</param> /// <returns>Doctors object</returns> public void FromPrimaryKey(int PK) { if (PK < 1) { throw new ArgumentNullException("docID"); } Doctors obj = new Doctors { docID = PK }; DataSet ds = obj.Select(); if (ds.Tables[0].Rows.Count > 0) { obj = new Doctors(ds.Tables[0].Rows[0]); } obj.Clone(this); }
public async Task <ActionResult> UpdateMonitor(List <string> ListId) { AppContext.MonitorPatients.IsLoading = true; PatientsList newMonitorList = new PatientsList(); PatientsList queryPatients = new PatientsList(); // Only add Patients haven't queried observations to avoid repeated query // One patient only needs to query once at the first time it is selected foreach (Patient patient in AppContext.Patients) { if (ListId.Contains(patient.Id)) { patient.Selected = true; if (!patient.HasObservations) { queryPatients.AddPatient(patient); } else { newMonitorList.AddPatient(patient); } } else { patient.Selected = false; } } // query list of patients haven't queried Cholesterol PatientsList queriedPatients = await FhirService.GetObservationValues(queryPatients); foreach (Patient patient in queriedPatients) { newMonitorList.AddPatient(patient); } AppContext.MonitorPatients = newMonitorList; return(View("Monitor")); }
public void LoadPatientsList() { PatientsList.Clear(); DBHandler conn = new DBHandler(); conn.InitializeConnection(); List <Patient> patients = conn.GetAllPatients(); conn.CloseConnection(); for (int i = 0; i < patients.Count; i++) { PatientsList.Add(patients.ElementAt(i)); } /* var a = new Patient("Jan", "Kowalski", 18, "93827193821", 1); * var b = new Patient("Adam", "Adamski", 19, "93827193822", 1); * var c = new Patient("Tomasz", "Nowak", 20, "93827193823", 1); * PatientsList.Add(a); * PatientsList.Add(b); * PatientsList.Add(c);*/ }
//Submit Add Form protected void AddPatientButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; String btnId = btn.ID; if (btnId.Equals("AddPatientButton")) { if (IsValid) { System.Threading.Thread.Sleep(3000); var name = NameTextBox.Text; var gender = GenderRadioButtonList1.SelectedItem.Value; var genderId = long.Parse(gender); var dob = Convert.ToDateTime(DOBTextBox.Text); var address = AddressTextBox.Text; var patient = new Patient() { patientName = name, genderId = genderId, dob = dob, address = address }; _dataContext.Patients.InsertOnSubmit(patient); _dataContext.SubmitChanges(); PatientsList.DataBind(); ResetInputField(); //Use For checking Data //Debug.WriteLine("name: " + name); //Debug.WriteLine("gender: " + gender); //Debug.WriteLine("dob: " + dob); //Debug.WriteLine("address: " + address); } else if (btnId.Equals("ResetPatientButton")) { ResetInputField(); } } }
public List <Patiants> getPatiants() { PatientsList dm = new PatientsList(); ListDictionary Params = new ListDictionary(); // Params.Add("@dt", dt); DataSet ds = dm.getPatiants(Params); List <Patiants> l = new List <Patiants>(); Patiants p; foreach (DataRow item in ds.Tables[0].Rows) { // f.FollowUp = BLCtrl.getString(item, "FollowUp", ""); p = new Patiants(); p.Id = BLCtrl.getString(item, "Id", " "); p.FirstName = BLCtrl.getString(item, "FirstName", " "); p.LastName = BLCtrl.getString(item, "LastName", " "); p.Doctor = BLCtrl.getString(item, "Doctor", " "); l.Add(p); } return(l); }
public TimeSpan TimeStuck(Patient patient) { var p = PatientsList.FirstOrDefault(x => x.Id == patient.Id); var index = PatientsList.IndexOf(p); if (index == -1) { return(TimeSpan.Zero); } if (index == 0) { return(TimeSpan.Zero); } TimeSpan duration; for (var i = 0; i < index; i++) { duration += PatientsList[i].Duration; } return(duration); //patient.VisitTime.Subtract(DateTime.Now) <= duration; }
/// <summary> /// Get Data for ML Task /// </summary> /// <returns>a list of patients contain observation data for ML task</returns> public static async Task <PatientsList> GetData() { int count = 0; bool stop = false; PatientsList data = new PatientsList(); try { var PatientQuery = new SearchParams() .OrderBy("birthdate") .LimitTo(LIMIT_ENTRY); Bundle PatientResult = await Client.SearchAsync <Hl7.Fhir.Model.Patient>(PatientQuery); // paging to search for all patient until reaching NUMBER_OF_DATA_RECORD value while (PatientResult != null) { if (stop) { break; } foreach (var Entry in PatientResult.Entry) { Hl7.Fhir.Model.Patient fhirPatient = (Hl7.Fhir.Model.Patient)Entry.Resource; PatientMapper mapper = new PatientMapper(); Models.Patient patient = mapper.Map(fhirPatient); if (!AppContext.AnalysisData.Contains(patient) && !data.Contains(patient)) { var CholesterolQuery = new SearchParams() .Where("patient=" + patient.Id) .Where("code=2093-3") .OrderBy("-date") .LimitTo(1); // Only GetData for patient that has Cholesterol value Bundle CholesterolResult = await Client.SearchAsync <Hl7.Fhir.Model.Observation>(CholesterolQuery); if (CholesterolResult.Entry.Count > 0) { data.AddPatient(await GetDataForAnalysis(patient)); count++; } } // Stop if count reachs NUMBER_OF_DATA_RECORD if (count == NUMBER_OF_DATA_RECORD) { stop = true; break; } } PatientResult = Client.Continue(PatientResult, PageDirection.Next); } } catch (FhirOperationException FhirException) { System.Diagnostics.Debug.WriteLine("Fhir error message: " + FhirException.Message); } catch (Exception GeneralException) { System.Diagnostics.Debug.WriteLine("General error message: " + GeneralException.Message); } return(data); }
/// <summary> /// Get Observation values of a patients list (Total Cholesterol, Blood Pressure) /// </summary> /// <param name="patients"> given list of patients </param> /// <returns> list of patients that contain Cholesterol and Blood Pressure values </returns> public static async Task <PatientsList> GetObservationValues(PatientsList patients) { PatientsList MonitoredPatientList = new PatientsList(); foreach (Models.Patient MonitoredPatient in patients) { try { Models.Patient patient = MonitoredPatient; patient.Observations = new List <Models.Observation>(); patient.HasObservations = true; // sort by date, limit to 1 so only take the newest Cholesterol observation var ObservationQuery = new SearchParams() .Where("patient=" + MonitoredPatient.Id) .Where("code=" + CHOLESTEROL_CODE) .OrderBy("-date") .LimitTo(1); Bundle ObservationResult = await Client.SearchAsync <Hl7.Fhir.Model.Observation>(ObservationQuery); if (ObservationResult.Entry.Count > 0) { // Map the FHIR Observation object to App's Observation object Hl7.Fhir.Model.Observation fhirObservation = (Hl7.Fhir.Model.Observation)ObservationResult.Entry[0].Resource; ObservationMapper mapper = new ObservationMapper(); Models.Observation cholesterolObservation = mapper.Map(fhirObservation); patient.Observations.Add(cholesterolObservation); } // sort by date, limit to 5 so only take the lastest Blood Pressure observation ObservationQuery = new SearchParams() .Where("patient=" + MonitoredPatient.Id) .Where("code=" + BLOOD_PRESSURE_CODE) .OrderBy("-date") .LimitTo(5); ObservationResult = await Client.SearchAsync <Hl7.Fhir.Model.Observation>(ObservationQuery); for (int i = 0; i < ObservationResult.Entry.Count; i++) { // Map the FHIR Observation object to App's Observation object Hl7.Fhir.Model.Observation fhirObservation = (Hl7.Fhir.Model.Observation)ObservationResult.Entry[i].Resource; ComponentObservationMapper mapper = new ComponentObservationMapper(); Models.Observation diastolicObservation = mapper.Map(fhirObservation.Component[0]); diastolicObservation.Id = fhirObservation.Id; Models.Observation systolicObservation = mapper.Map(fhirObservation.Component[1]); systolicObservation.Id = fhirObservation.Id; if (fhirObservation.Issued != null) { diastolicObservation.Issued = ((DateTimeOffset)fhirObservation.Issued).DateTime; systolicObservation.Issued = ((DateTimeOffset)fhirObservation.Issued).DateTime; } else { diastolicObservation.Issued = null; systolicObservation.Issued = null; } patient.Observations.Add(diastolicObservation); patient.Observations.Add(systolicObservation); } MonitoredPatientList.AddPatient(patient); } catch (FhirOperationException FhirException) { System.Diagnostics.Debug.WriteLine("Fhir error message: " + FhirException.Message); } catch (Exception GeneralException) { System.Diagnostics.Debug.WriteLine("General error message: " + GeneralException.Message); } } return(MonitoredPatientList); }
public void DataGrid_Loaded() { DBClass.openConnection(); //) CAST(DateOfBirth AS date), convert(Date, DateOfBirth, 23) DBClass.sql = "select distinct IDPatient, FirstName, LastName, convert(VARCHAR, DateOfBirth, 23) , " + "Street, ZIP, City, therapists.LastNameTherapist, patients.IDTherapist, Phone, Email " + "from patients, therapists, therapistSpecialization where therapists.LastNameTherapist = " + "(select LastNameTherapist from therapists where IDTherapist = patients.IDTherapist)"; DBClass.cmd.CommandType = CommandType.Text; DBClass.cmd.CommandText = DBClass.sql; DBClass.da = new SqlDataAdapter(DBClass.cmd); DBClass.dt = new DataTable(); DBClass.da.Fill(DBClass.dt); // wyciągamy dane int i = 0; int j = 0; //Console.WriteLine("Przy bazie" + data[3]); PatientsList.Clear(); using (SqlDataReader reader = DBClass.cmd.ExecuteReader()) { while (reader.Read()) { for (j = 0; j <= reader.FieldCount - 1; j++) // Looping throw colums { data[j] = reader.GetValue(j).ToString(); } if (data[7] == null) { data[7] = ""; } //Console.WriteLine("Przy bazie" + data[3]); PatientsList.Add(new PatientModel { IDPatient = (data[0]), FirstName = data[1], LastName = data[2], DateOfBirth = data[3], Street = data[4], ZIP = data[5], City = data[6], IDTherapist = data[7], NameTherapist = (data[8]), Phone = data[9], Email = data[10] }); //Console.WriteLine("IDTherapist - " + data[7] + data[8]); } } //cmd.CommandText = "update projekt set ocena_projekt = @ocenaProjekt " + // "where(select ID_Studenta from Student where STU_nazwisko = @nazwiskoS) = ID_studenta and " + // "(select ID_prowadzacego from Prowadzacy where nazwisko_pro = 'Wodecki') = Pro_ID_prowadzacego and " + // "(select ID_projektu from Projekty where temat = @temat) = ID_projektu;"; DBClass.closeConnection(); //int i = 0; //int j = 0; //var con = new SQLiteConnection("Data Source=Prolog;Version=3;New=False;Compress=True;"); try { //String con = "Server=localhost;Database=Prolog;User Id=prolog;password=prolog"; //String con = "Server=DELL-ADI\\SQLEXPRESS; uid=prolog; pwd=prolog; database=Prolog;"; ////String con = " server = 194.181.228.20; uid = edenland_prolog; pwd = adikos; database = edenland_prolog;"; //MySqlConnection Connection = new MySqlConnection(con); //string CommandText = "select * from patients"; //MySqlDataAdapter ApapterSQL = new MySqlDataAdapter(); //ApapterSQL.SelectCommand = new MySqlCommand(CommandText, Connection); //MySqlCommandBuilder builder = new MySqlCommandBuilder(ApapterSQL); //Connection.Open(); //DataTable dane = new DataTable(); //ApapterSQL.Fill(dane); ////ReservationFromWebList.ItemsSource = dane.DefaultView; //ApapterSQL.Update(dane); //con.Open(); //SQLiteCommand sqlCmd = con.CreateCommand(); //sqlCmd.CommandText = "SELECT * FROM patients "; //using (SQLiteDataReader rdr = sqlCmd.ExecuteReader()) //{ // while (rdr.Read()) // Reading Rows // { // for (j = 0; j <= rdr.FieldCount - 1; j++) // Looping throw colums // { // data[j] = rdr.GetValue(j).ToString(); // } // PatientsList.Add(new PatientModel { IDPatient = (data[0]), FirstName = data[1], LastName = data[2] }); // i++; // } //} //Connection.Close(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
public void Save() { if (SelectedPatient != null && SelectedPatient.NewlyAdded) { PatientsList.Add(SelectedPatient); SelectedPatient.NewlyAdded = false; } try { bool shouldDisplayMessage; double cost = MaterialCost.HasValue ? MaterialCost.Value : 0; var itemsNotSelected = GetNotAddedInformation(out shouldDisplayMessage); if (shouldDisplayMessage) { MessageBox.Show("Inainte de a salva adaugati :" + itemsNotSelected); return; } var duration = TimeSpan.FromMinutes(Convert.ToDouble(Durata)); EndTIme = StartingHour.Add(duration); double percentage = SelectedPercentage != null ? SelectedPercentage.Percentage / 100 : (SelectedWork != null && SelectedWork.Percent != 0 ? SelectedWork.Percent / 100 : 1); var intervention = new LocalIntervention() { Id = Id, Area = SelectedArea != null ? (SelectedArea.SettingTOarea()) : null, Location = SelectedLocation != null?SelectedLocation.SettingToLocation() : null, DateHourDetail = new LocalDateHourDetail() { Date = Date, StartHour = StartingHour, Mili = Convert.ToInt64(DateTime.Now.TimeOfDay.TotalMilliseconds), EndingHour = EndTIme, Duration = duration }, Lucrare = SelectedWork, PatientName = SelectedPatient.AllName, Material = SelectedMaterial, Observation = Observation, Revenue = Revenue.HasValue ? Revenue.Value : 0, PatientId = SelectedPatient.Id, Percent = Convert.ToDouble((Revenue - cost) * percentage), WasPayedByDental = WasPayedByDental, TechnicianId = SelectedTechnician != null ? SelectedTechnician.Id : (int?)null, MaterialCost = MaterialCost, Technician = SelectedTechnician }; ChangeTotalInfo(intervention, IsInEditMode); intervention.Id = DatabaseHandler.Instance.AddIntervention(intervention, LocalCache.Instance.CurrentUser.Id); if (IsInEditMode) { LocalIntervention = intervention; } else { LocalCache.Instance.AddIntervention(intervention); var patient = LocalCache.Instance.PatientsRepository.Patients.FirstOrDefault(item => item.Id == SelectedPatient.Id); if (patient != null) { patient.Interventions.Add(intervention); } } SetNewIntervenionDetails(intervention); IsPatientComboFocused = false; IsPatientComboFocused = true; InitData(); } catch (Exception ex) { MessageBox.Show("A intervenit o eroare la salvare."); Log.Error("Error inserting intervention --> Save"); } }
public DetailsModel(PatientsList patientsList) { _patientsList = patientsList; }
/// <summary> /// Write list of patients data to csv file /// </summary> /// <param name="data"> given patientslist data </param> public static void WriteToCsv(PatientsList data) { List <PatientData> outputPatients = new List <PatientData>(); foreach (Patient patient in data) { Single[] attributes = new Single[PatientData.NUMBER_OF_FEATURES]; Observation CholesterolObservation = patient.GetObservationByCodeText(TOTAL_CHOLESTEROL); if (CholesterolObservation == null) { continue; } if (CholesterolObservation.MeasurementResult.Value == null) { continue; } double cholesterol = (double)CholesterolObservation.MeasurementResult.Value; bool label = (cholesterol > HIGH_CHOLESTEROL_THRESHOLD); int NaNCount = 0; // get value of each feature and add to attributes array for (int i = 0; i < PatientData.NUMBER_OF_FEATURES; i++) { attributes[i] = Single.NaN; Observation observation = patient.GetObservationByCodeText(PatientData.attributes[i]); if (observation != null) { if (observation.MeasurementResult.Value != null) { attributes[i] = (Single)observation.MeasurementResult.Value; } else { NaNCount++; } } else { NaNCount++; } } if (NaNCount > 0) { continue; } // create a PatientData object with label and features PatientData newData = new PatientData { HighCholesterol = label, Features = attributes }; outputPatients.Add(newData); } // if csv file exists, append data to the csv file // otherwises, write headers and the data to new csv file if (!File.Exists(DATA_FILE_ROOT)) { File.WriteAllText(DATA_FILE_ROOT, string.Concat( string.Join(",", PatientData.Headers()) + "\n", string.Join("\n", outputPatients.Select(p => p.ToString()).ToArray()))); } else { File.AppendAllText(DATA_FILE_ROOT, "\n" + string.Join("\n", outputPatients.Select(p => p.ToString()).ToArray())); } }