Ejemplo n.º 1
0
 private void buttonUpdateTestRecord_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (datepickerTestDate.SelectedDate == null)
         {
             MessageBox.Show("Вы не ввели дату сдачи анализа!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Warning);
             return;
         }
         MedicalTest test = ((IDataContextProvider <MedicalTest>)containerTestControl.Children[0]).ProvideDataContext();
         test.PatientID   = CurrentPatient.ID;
         test.Treatment   = textboxTreatment.Text;
         test.Date        = datepickerTestDate.SelectedDate ?? DateTime.Now.Date;
         test.Attachments = attachments_.ToList();
         PatientDB.Instance.AddAnalysis(ref test, test_type);
         MessageBox.Show("Результаты анализов сохранены!", "", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (SQLiteException exception)
     {
         string message = String.Format("Обнаружена проблема при работе с базой данных!\n{0}", exception.Message);
         MessageBox.Show(message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (Exception exception)
     {
         string message = String.Format("Обнаружена проблема при работе программы!\n{0}", exception.Message);
         MessageBox.Show(message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 2
0
        public static void CreateTestReport(Patient patient, MedicalTest test, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            Type test_type = test.GetType();

            using (DocX document = DocX.Create(file_path))
            {
                Novacode.Paragraph header = document.InsertParagraph(
                    //selected_procedure.ProcedureType.First().ToString().ToUpper() + String.Join("", selected_procedure.ProcedureType.Skip(1)).ToLower(),
                    test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                    false,
                    new Formatting()
                {
                    FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                    Size       = 16D
                }
                    );
                header.Alignment = Alignment.center;
                header.Bold();
                document.InsertParagraph(" ");
                Novacode.Table patient_info = document.AddTable(5, 2);
                patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                    patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                    ", " + patient.City + ", " + patient.Address
                    );
                patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                patient_info.Alignment = Alignment.left;
                patient_info.AutoFit   = AutoFit.Window;
                PropertyInfo[] indicators = test_type.GetProperties().Where(x => x.IsDefined(typeof(TestInfo))).ToArray();
                Novacode.Table test_info  = document.AddTable(indicators.Count(), 2);
                int            k          = 0;
                foreach (var indicator in indicators)
                {
                    test_info.Rows[k].Cells[0].Paragraphs.First().Append(indicator.GetCustomAttribute <TestInfo>().DisplayName);
                    object property_value = indicator.GetValue(test);
                    test_info.Rows[k].Cells[1].Paragraphs.First().Append(property_value != null ? property_value.ToString() : "");
                    k++;
                }
                test_info.Alignment = Alignment.left;
                test_info.AutoFit   = AutoFit.Window;
                document.InsertTable(patient_info);
                document.InsertParagraph(" ");
                document.InsertTable(test_info);
                document.Save();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Получить данные анализов для данного пациента
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="patient_id"></param>
 /// <returns></returns>
 public List <MedicalTest> GetAnalysis(long patient_id, Type test_type)
 {
     try
     {
         List <MedicalTest> tests = new List <MedicalTest>();
         using (SQLiteConnection sql_conn = new SQLiteConnection(sql_conn_str, true))
         {
             sql_conn.Open();
             using (SQLiteCommand sql_command = new SQLiteCommand(sql_conn))
             {
                 sql_command.CommandText = CreateSQLQuery(null, SQLCmd.Select, "WHERE PatientID = " + patient_id.ToString(), test_type);
                 using (SQLiteDataReader sql_reader = sql_command.ExecuteReader())
                 {
                     while (sql_reader.Read())
                     {
                         MedicalTest test = (MedicalTest)test_type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[0], new ParameterModifier[0]).Invoke(new object[0]);
                         foreach (PropertyInfo property in test_type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => !x.IsDefined(typeof(Transient))))
                         {
                             if (DBNull.Value.Equals(sql_reader[property.Name]))
                             {
                                 continue;
                             }
                             if (property.PropertyType == typeof(long))
                             {
                                 property.SetValue(test, (long)sql_reader[property.Name]);
                             }
                             else if (property.PropertyType == typeof(DateTime))
                             {
                                 property.SetValue(test, DateTime.Parse((string)sql_reader[property.Name]));
                             }
                             else if (property.PropertyType == typeof(double))
                             {
                                 property.SetValue(test, (double)sql_reader[property.Name]);
                             }
                         }
                         test.Attachments = GetAttachments(test.ID, test_type.FullName);
                         tests.Add(test);
                     }
                 }
             }
         }
         return(tests);
     }
     catch (IndexOutOfRangeException)
     {
         throw new SQLiteException(SQLiteErrorCode.Corrupt, "Файл базы данных был испорчен и не может быть открыт!");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Добавить данные анализов для данного пациента
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="test"></param>
 public void AddAnalysis(ref MedicalTest test, Type test_type)
 {
     using (SQLiteConnection sql_conn = new SQLiteConnection(sql_conn_str, true))
     {
         sql_conn.Open();
         using (SQLiteCommand sql_command = new SQLiteCommand(sql_conn))
         {
             sql_command.CommandText = CreateSQLQuery(test, SQLCmd.Insert, String.Empty, test_type);
             sql_command.ExecuteNonQuery();
             sql_command.CommandText = "SELECT last_insert_rowid()";
             test.ID = (long)sql_command.ExecuteScalar();
         }
     }
     foreach (var attachment in test.Attachments)
     {
         attachment.TestID = test.ID;
     }
     AddAttachment(test.Attachments);
     if (DBUpdated != null)
     {
         DBUpdated(null, null);
     }
 }