PatientInfo.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using WpfTest1.SQLite;
  16. namespace WpfTest1
  17. {
  18. /// <summary>
  19. /// PatientInfo.xaml 的交互逻辑
  20. /// PatientInfo是显示在各个界面的病例信息组件
  21. /// </summary>
  22. public partial class PatientInfo : UserControl
  23. {
  24. public PatientInfo()
  25. {
  26. InitializeComponent();
  27. textBoxHighBP.IsEnabled = false;
  28. textBoxLowBP.IsEnabled = false;
  29. }
  30. public void setPatientInfo(Patient onePerson, bool bpReadOnly = false)
  31. {
  32. fillBlanks(onePerson);
  33. if (bpReadOnly)
  34. {
  35. textBoxHighBP.IsEnabled = false;
  36. textBoxLowBP.IsEnabled = false;
  37. }
  38. else
  39. {
  40. textBoxHighBP.IsEnabled = true;
  41. textBoxLowBP.IsEnabled = true;
  42. }
  43. }
  44. public void setPatientInfo(Patient onePerson, double highBp, double lowBp, Toolkits.Config cfg, bool bpReadOnly = true)
  45. {
  46. fillBlanks(onePerson);
  47. if (cfg.bp_unit_hhmg == 1)
  48. {
  49. textBoxHighBP.Text = highBp.ToString();
  50. textBoxLowBP.Text = lowBp.ToString();
  51. textBoxMeanBP.Text = ((highBp + lowBp) / 2).ToString();
  52. bp_unit1.Content = "mmHg";
  53. bp_unit2.Content = "mmHg";
  54. bp_unit3.Content = "mmHg";
  55. }
  56. else
  57. {
  58. textBoxHighBP.Text = (highBp*4/3).ToString();
  59. textBoxLowBP.Text = (lowBp*4/3).ToString();
  60. textBoxMeanBP.Text = (((highBp * 4 / 3) + (lowBp * 4 / 3)) / 2).ToString();
  61. bp_unit1.Content = "kPa";
  62. bp_unit2.Content = "kPa";
  63. bp_unit3.Content = "kPa";
  64. }
  65. if (bpReadOnly)
  66. {
  67. textBoxHighBP.IsEnabled = false;
  68. textBoxLowBP.IsEnabled = false;
  69. }
  70. else
  71. {
  72. textBoxHighBP.IsEnabled = true;
  73. textBoxLowBP.IsEnabled = true;
  74. }
  75. }
  76. private void fillBlanks(Patient onePerson)
  77. {/*
  78. textBoxIDNum.Text = onePerson.idNum;
  79. textBoxPaID.Text = onePerson.record_id;
  80. textBoxName.Text = onePerson.name;
  81. textBoxPerg_time.Text = onePerson.pregnancy_times.ToString();
  82. textBoxProd_time.Text = onePerson.birth_times.ToString();
  83. textBoxHeight.Text = onePerson.height.ToString();
  84. textBoxDescription.Text = onePerson.description == "" ? "(无)" : onePerson.description;
  85. textBoxWeight.Text = onePerson.weight.ToString();
  86. textBoxBMI.Text = (onePerson.weight / ((onePerson.height / 100.0) * (onePerson.height / 100.0))).ToString(); //体重(kg)/身高(m)^2
  87. textBoxWeek.Text = ((DateTime.Now - onePerson.pregnancy_date).Days / 7 + 1).ToString();
  88. textBoxDay.Text = ((DateTime.Now - onePerson.pregnancy_date).Days % 7).ToString();
  89. if (onePerson.idNum.Length >= 13)
  90. {
  91. //假设身份证号合法
  92. string birthday = onePerson.idNum.Substring(6, 8);
  93. //MessageBox.Show(birthday);
  94. DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
  95. int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
  96. textBoxAge.Text = age.ToString();
  97. }
  98. else
  99. {
  100. textBoxAge.Text = "--";
  101. }*/
  102. }
  103. private void textBoxHighBP_TextChanged(object sender, TextChangedEventArgs e)
  104. {
  105. calculateAverageBP();
  106. }
  107. private void textBoxLowBP_TextChanged(object sender, TextChangedEventArgs e)
  108. {
  109. calculateAverageBP();
  110. }
  111. private void calculateAverageBP()
  112. {
  113. try
  114. {
  115. textBoxMeanBP.Text = ((Convert.ToDouble(textBoxHighBP.Text) + Convert.ToDouble(textBoxLowBP.Text)) / 2).ToString();
  116. }
  117. catch
  118. {
  119. ;
  120. }
  121. }
  122. }
  123. }