123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using WpfTest1.SQLite;
- namespace WpfTest1
- {
- /// <summary>
- /// PatientInfo.xaml 的交互逻辑
- /// PatientInfo是显示在各个界面的病例信息组件
- /// </summary>
- public partial class PatientInfo : UserControl
- {
- public PatientInfo()
- {
- InitializeComponent();
- textBoxHighBP.IsEnabled = false;
- textBoxLowBP.IsEnabled = false;
- }
- public void setPatientInfo(Patient onePerson, bool bpReadOnly = false)
- {
-
- fillBlanks(onePerson);
- if (bpReadOnly)
- {
- textBoxHighBP.IsEnabled = false;
- textBoxLowBP.IsEnabled = false;
- }
- else
- {
- textBoxHighBP.IsEnabled = true;
- textBoxLowBP.IsEnabled = true;
- }
- }
- public void setPatientInfo(Patient onePerson, double highBp, double lowBp, Toolkits.Config cfg, bool bpReadOnly = true)
- {
- fillBlanks(onePerson);
- if (cfg.bp_unit_hhmg == 1)
- {
- textBoxHighBP.Text = highBp.ToString();
- textBoxLowBP.Text = lowBp.ToString();
- textBoxMeanBP.Text = ((highBp + lowBp) / 2).ToString();
- bp_unit1.Content = "mmHg";
- bp_unit2.Content = "mmHg";
- bp_unit3.Content = "mmHg";
- }
- else
- {
- textBoxHighBP.Text = (highBp*4/3).ToString();
- textBoxLowBP.Text = (lowBp*4/3).ToString();
- textBoxMeanBP.Text = (((highBp * 4 / 3) + (lowBp * 4 / 3)) / 2).ToString();
- bp_unit1.Content = "kPa";
- bp_unit2.Content = "kPa";
- bp_unit3.Content = "kPa";
- }
-
- if (bpReadOnly)
- {
- textBoxHighBP.IsEnabled = false;
- textBoxLowBP.IsEnabled = false;
- }
- else
- {
- textBoxHighBP.IsEnabled = true;
- textBoxLowBP.IsEnabled = true;
- }
- }
- private void fillBlanks(Patient onePerson)
- {/*
- textBoxIDNum.Text = onePerson.idNum;
- textBoxPaID.Text = onePerson.record_id;
- textBoxName.Text = onePerson.name;
- textBoxPerg_time.Text = onePerson.pregnancy_times.ToString();
- textBoxProd_time.Text = onePerson.birth_times.ToString();
- textBoxHeight.Text = onePerson.height.ToString();
- textBoxDescription.Text = onePerson.description == "" ? "(无)" : onePerson.description;
- textBoxWeight.Text = onePerson.weight.ToString();
- textBoxBMI.Text = (onePerson.weight / ((onePerson.height / 100.0) * (onePerson.height / 100.0))).ToString(); //体重(kg)/身高(m)^2
- textBoxWeek.Text = ((DateTime.Now - onePerson.pregnancy_date).Days / 7 + 1).ToString();
- textBoxDay.Text = ((DateTime.Now - onePerson.pregnancy_date).Days % 7).ToString();
- if (onePerson.idNum.Length >= 13)
- {
- //假设身份证号合法
- string birthday = onePerson.idNum.Substring(6, 8);
- //MessageBox.Show(birthday);
- DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
- int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
- textBoxAge.Text = age.ToString();
- }
- else
- {
- textBoxAge.Text = "--";
- }*/
- }
- private void textBoxHighBP_TextChanged(object sender, TextChangedEventArgs e)
- {
- calculateAverageBP();
- }
- private void textBoxLowBP_TextChanged(object sender, TextChangedEventArgs e)
- {
- calculateAverageBP();
- }
- private void calculateAverageBP()
- {
- try
- {
- textBoxMeanBP.Text = ((Convert.ToDouble(textBoxHighBP.Text) + Convert.ToDouble(textBoxLowBP.Text)) / 2).ToString();
- }
- catch
- {
- ;
- }
- }
- }
- }
|