Beispiel #1
0
        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");
                }
            }
        }
Beispiel #2
0
 public void DataGrid_Loaded(string id, string fn, string ln)
 {
     SelectedFirstName = fn;
     PatientsList.Add(new PatientModel {
         IDPatient = id, FirstName = fn, LastName = ln
     });
 }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            string photoFileName = null;
            string notesFileName = null;

            if (PatientView.Photo != null)
            {
                photoFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(PatientView.Photo.FileName);
                var imagePath = Path.Combine(_environment.WebRootPath, "images", photoFileName);

                using (var fileStream = new FileStream(imagePath, FileMode.Create))
                {
                    await PatientView.Photo.CopyToAsync(fileStream);
                }
            }

            if (PatientView.Notes != null)
            {
                notesFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(PatientView.Notes.FileName);
                var notesPath = Path.Combine(_environment.WebRootPath, "files", notesFileName);

                using (var fileStream = new FileStream(notesPath, FileMode.Create))
                {
                    await PatientView.Notes.CopyToAsync(fileStream);
                }
            }

            var speciesName = PatientView.Species.ToLowerInvariant();
            var species     = _speciesList.SearchBy(speciesName);

            if (species == null)
            {
                _speciesList.Add(
                    new Models.DbModels.Species
                {
                    Name = speciesName
                });

                species = _speciesList.SearchBy(speciesName);
            }

            var patient = new Patient
            {
                Name      = PatientView.Name,
                Species   = species,
                Age       = PatientView.Age,
                PhotoPath = photoFileName,
                NotesPath = notesFileName
            };

            _patientsList.Add(patient);

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
 public async void SavePatient(LocalPatient addedPatient)
 {
     if (!string.IsNullOrEmpty(SearchedItem))
     {
         Search(SearchedItem);
     }
     AddPatientControlVisibility = Visibility.Collapsed;
     PatientsList.Add(addedPatient);
     //SelectedPatient = addedPatient;
 }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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);*/
        }
Beispiel #7
0
        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");
            }
        }
Beispiel #8
0
        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);
            }
        }