瀏覽代碼

Finish Patient Management

+Add add patient
+Add modify patient
+Add detete patient
+Add esay add patient
+Add patient search
ZhuYifan 5 年之前
父節點
當前提交
5fb186ea63

二進制
Junde.db3


+ 12 - 193
WpfTest1/MainWindow.xaml.cs

@@ -44,102 +44,11 @@ namespace WpfTest1
         //double highBp;                                        //BP界面高压
         //double lowBp;                                         //BP界面低压
         DateTime lastSettingLogin;                              //上一次在系统设置界面登陆的时间
-        public Dictionary<string, double> expressions = new Dictionary<string, double>();//全部的表达式暂存器
-        public Dictionary<string, string> expressions_position = new Dictionary<string, string>();//全部的表达式所属类别暂存器
-        public List<Dictionary<string, double>> expressionList = new List<Dictionary<string, double>>();//全表达式对应所有波的特征值计算(相当耗时请勿乱用)
-        public List<double> generalExpressionResults = new List<double>(); //总表达式的计算结果
-        public double generalExpressionTemp;//总表达式的计算结果临时存储变量
-        //public Toolkits.EigenValueCalculator evc;  //计算特征值的类
         public Toolkits.Config cfg;                //从数据库取配置的类
-        RPCalculate rpReport;         //RP单元计算模块,开始不要初始化,用的时候再初始化
-        System.Timers.Timer timerUpdateWave = new System.Timers.Timer(5);   //一个每个2ms更新一个数据波形点的计时器
-                                                                            //List<double> dataSource = Toolkits.WaveSimulator.getSimulatedWave();  //20180224数据模拟生成
-        int measure_time_limit = 0; //PPG模块自动计时停止的阈值
-        ConcurrentQueue<string> measureMessage = new ConcurrentQueue<string>();       //采集时控制自动停止的消息队列
-        ConcurrentQueue<string> measureTimeLeft = new ConcurrentQueue<string>();       //采集时倒计时的消息队列
-        SerialPort serialPortUSBPPG;
-        SerialPort serialPortUSBPPGBackup;
-        SerialPort serialPortUSBPPGTest;
-        ConcurrentQueue<double> dataSourceLeftRed = new ConcurrentQueue<double>();
-        ConcurrentQueue<double> dataSourceLeftInfrared = new ConcurrentQueue<double>();
-        ConcurrentQueue<double> dataSourceRightRed = new ConcurrentQueue<double>();
-        ConcurrentQueue<double> dataSourceRightInfrared = new ConcurrentQueue<double>();
-        int measureStartIndex = 0;
-        //BackgroundWorker aWorkerPlusOne = new BackgroundWorker();
-        BackgroundWorker aWorkerInUSBMeasure = new BackgroundWorker();
-        BackgroundWorker bg_calculate_eigen_value = new BackgroundWorker();
-        BackgroundWorker bg_final_report_calculate = new BackgroundWorker();
-        ///SmallDialogs.EigenValueList evl;
-        //SmallDialogs.WaitNotify wn;
-        ConcurrentQueue<string> canditate_searial_port = new ConcurrentQueue<string>(); //判断一个串口是否为本软件使用的端口
         #endregion
 
         #region 优化系统效率参数
-        //首先是PPG部分的历史记录部分
-        //左手红光
-        List<double> historyLeftRed0Q = new List<double>();
-        List<double> historyLeftRed1D = new List<double>();
-        List<double> historyLeftRed2D = new List<double>();
-        List<double> historyLeftRed3D = new List<double>();
-        List<double> historyLeftRed4D = new List<double>();
-        //左手红外光
-        List<double> historyLeftInfrared0Q = new List<double>();
-        List<double> historyLeftInfrared1D = new List<double>();
-        List<double> historyLeftInfrared2D = new List<double>();
-        List<double> historyLeftInfrared3D = new List<double>();
-        List<double> historyLeftInfrared4D = new List<double>();
-        //右手红光
-        List<double> historyRightRed0Q = new List<double>();
-        List<double> historyRightRed1D = new List<double>();
-        List<double> historyRightRed2D = new List<double>();
-        List<double> historyRightRed3D = new List<double>();
-        List<double> historyRightRed4D = new List<double>();
-        //右手红外光
-        List<double> historyRightInfrared0Q = new List<double>();
-        List<double> historyRightInfrared1D = new List<double>();
-        List<double> historyRightInfrared2D = new List<double>();
-        List<double> historyRightInfrared3D = new List<double>();
-        List<double> historyRightInfrared4D = new List<double>();
-        //RP波形部分
-        List<int> historyRP = new List<int>();
-        //然后是PPG部分的测量时部分
-        //滤波器的参数,分别是一阶低通一阶高通,二阶低通和二阶高通
-        List<double>[] filter = new List<double>[4];
-        //左手红光,注意:0Q中0是原始波形,每+1层就用一个过滤器过一下,最终那个用于显示
-        List<double>[] measureLeftRed0Q = new List<double>[4 + 1];
-        List<double> measureLeftRed1D = new List<double>();
-        List<double> measureLeftRed2D = new List<double>();
-        List<double> measureLeftRed3D = new List<double>();
-        List<double> measureLeftRed4D = new List<double>();
-        //左手红外光
-        List<double>[] measureLeftInfrared0Q = new List<double>[4 + 1];
-        List<double> measureLeftInfrared1D = new List<double>();
-        List<double> measureLeftInfrared2D = new List<double>();
-        List<double> measureLeftInfrared3D = new List<double>();
-        List<double> measureLeftInfrared4D = new List<double>();
-        //右手红光
-        List<double>[] measureRightRed0Q = new List<double>[4 + 1];
-        List<double> measureRightRed1D = new List<double>();
-        List<double> measureRightRed2D = new List<double>();
-        List<double> measureRightRed3D = new List<double>();
-        List<double> measureRightRed4D = new List<double>();
-        //右手红外光
-        List<double>[] measureRightInfrared0Q = new List<double>[4 + 1];
-        List<double> measureRightInfrared1D = new List<double>();
-        List<double> measureRightInfrared2D = new List<double>();
-        List<double> measureRightInfrared3D = new List<double>();
-        List<double> measureRightInfrared4D = new List<double>();
-
-        //RP波形部分
-        List<int> measure = new List<int>();
-        //画线的颜色设定
-        System.Drawing.Color lineColorRed = System.Drawing.Color.Wheat;
-        System.Drawing.Color lineColorInfrared = System.Drawing.Color.White;
-        System.Drawing.Color lineColorBlack = System.Drawing.Color.Black;
-
-        //临时补丁
-        //1.针对历史记录大类双击两个dataGrid会导致TabItem回弹一页的问题,加一个标签
-        public bool bugFixHostory = false;
+        
         #endregion
 
         public MainWindow()
@@ -156,14 +65,6 @@ namespace WpfTest1
 
         #region 初始化与系统调用部分
 
-        //加载表达式到内存
-        public void LoadExpressionToMemory()
-        {
-            expressions.Clear();
-            expressions_position.Clear();
-            SQLite.SQLiteModel.GetAllExpressionContent(expressions, expressions_position, loginDoctor.privilege_flag);
-        }
-
         //初始化全部组件后需要先输入医生密码才能进入
         //async 
         private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
@@ -184,76 +85,6 @@ namespace WpfTest1
             {
                 this.Close();
             }
-            /*
-            //之后填充程序高级设置的信息
-            //平滑点设置
-            labelOrganizationName.Content = cfg.organization_name;
-            textBoxOriginalSmoothPoints.Text = cfg.original_smooth_points.ToString();
-            textBoxOriginalSmoothTimes.Text = cfg.original_smooth_times.ToString();
-            textBoxDeriveSmoothPoints.Text = cfg.drive_smooth_points.ToString();
-            textBoxDeriveSmoothTimes.Text = cfg.drive_smooth_times.ToString();
-            buttonModifySmoothPoints.IsEnabled = false;
-            if(cfg.filter_when_saving == 1)
-            {
-                checkBoxFilterWhenSaving.IsChecked = true;
-            }
-            //填充医师界面的设置信息
-            if(cfg.bp_unit_hhmg == 1)
-            {
-                radioButtonBP_mmhg.IsChecked = true;
-            }
-            else
-            {
-                radioButtonBP_kpa.IsChecked = true;
-            }
-            //自动诊断公式
-            textBoxgeneralExpression.Text = cfg.general_expression;
-            textBoxgeneralExpressionSegementName0.Text = cfg.segement_name.Split('$').ElementAt(0);
-            textBoxgeneralExpressionSegementName1.Text = cfg.segement_name.Split('$').ElementAt(1);
-            textBoxgeneralExpressionSegementName2.Text = cfg.segement_name.Split('$').ElementAt(2);
-            textBoxgeneralExpressionSegementName3.Text = cfg.segement_name.Split('$').ElementAt(3);
-            textBoxgeneralExpressionSegementName4.Text = cfg.segement_name.Split('$').ElementAt(4);
-            textBoxgeneralExpressionSegementThrehold0.Text = cfg.segement_threhold.Split('$').ElementAt(0);
-            textBoxgeneralExpressionSegementThrehold1.Text = cfg.segement_threhold.Split('$').ElementAt(1);
-            textBoxgeneralExpressionSegementThrehold2.Text = cfg.segement_threhold.Split('$').ElementAt(2);
-            textBoxgeneralExpressionSegementThrehold3.Text = cfg.segement_threhold.Split('$').ElementAt(3);
-            //诊断报告参数设置
-            textboxReportFigureName.Text = cfg.report_figure_name;
-
-            //为PPG波形采集进行注册
-            timerUpdateWave.Elapsed += new System.Timers.ElapsedEventHandler(updateWavePoints);
-            aWorkerInUSBMeasure.WorkerSupportsCancellation = true;
-            aWorkerInUSBMeasure.DoWork += new DoWorkEventHandler(this.startMeasure_RunWorkerDowork);
-            //为后台计算波形结果及公式进行注册
-            bg_calculate_eigen_value.WorkerReportsProgress = false;
-            bg_calculate_eigen_value.RunWorkerCompleted += new RunWorkerCompletedEventHandler(eigenvalue_calculation_process);
-            bg_final_report_calculate.WorkerReportsProgress = false;
-            bg_final_report_calculate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(do_work_bg_final_report_calculate);
-            //aWorkerPlusOne.WorkerSupportsCancellation = true;
-            //aWorkerPlusOne.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bwPlusOne_RunWorkerCompleted);
-            for (int i = 0; i < measureLeftRed0Q.Length; ++i)
-            {
-                measureLeftRed0Q[i] = new List<double>();
-            }
-            for (int i = 0; i < measureLeftInfrared0Q.Length; ++i)
-            {
-                measureLeftInfrared0Q[i] = new List<double>();
-            }
-            for (int i = 0; i < measureRightRed0Q.Length; ++i)
-            {
-                measureRightRed0Q[i] = new List<double>();
-            }
-            for (int i = 0; i < measureRightInfrared0Q.Length; ++i)
-            {
-                measureRightInfrared0Q[i] = new List<double>();
-            }
-
-            //为测量界面的滚动条设置波形图
-            //measureWaveLeftOriginal.SetScrollBar(scrollBarMeasureLeftRed);
-            //measureWaveRightOriginal.SetScrollBar(scrollBarMeasureRightRed);
-            //measureWaveLeftInfraredOriginal.SetScrollBar(scrollBarMeasureLeftInfrared);
-            //measureWaveRightInfraredOriginal.SetScrollBar(scrollBarMeasureRightInfrared);
-            //*/
             //显示医生姓名
             if (loginDoctor != null)
             {
@@ -279,22 +110,10 @@ namespace WpfTest1
 
         //首页--用户管理
         private void buttonHomePagePatientManagent_Click(object sender, RoutedEventArgs e)
-        {
-            tabControlGeneral.SelectedIndex = 2;
-        }
-
-        //首页--检测操作
-        private void buttonHomePageMeasureFunction_Click(object sender, RoutedEventArgs e)
         {
             tabControlGeneral.SelectedIndex = 1;
         }
 
-        //首页--历史记录
-        private void buttonHomePageHistoryRecord_Click(object sender, RoutedEventArgs e)
-        {
-            tabControlGeneral.SelectedIndex = 3;
-        }
-
         //首页--检测报告
         private void buttonHomePageReport_Click(object sender, RoutedEventArgs e)
         {
@@ -304,7 +123,7 @@ namespace WpfTest1
         //首页--系统设置
         private void buttonHomePageSystemSettings_Click(object sender, RoutedEventArgs e)
         {
-            tabControlGeneral.SelectedIndex = 4;
+            tabControlGeneral.SelectedIndex = 2;
         }
        
         //首页--操作帮助
@@ -338,7 +157,7 @@ namespace WpfTest1
             {
                 var target = (DataRowView)this.selectUserPatientManagent.dataGrid.SelectedItem;
                 //MessageBox.Show(target["id"].ToString());
-                ModifyUser modify_one = new ModifyUser(this, target["id"].ToString());
+                ModifyUser modify_one = new ModifyUser(this, target["p_id"].ToString());
                 modify_one.Show();
             }
             catch(Exception err)
@@ -352,37 +171,37 @@ namespace WpfTest1
 
         #region 病例管理--删除病例
         //删除病例
-        private async void buttonDeletePatient_Click(object sender, RoutedEventArgs e)
+        private void buttonDeletePatient_Click(object sender, RoutedEventArgs e)
         {
             try
             {
                 var target = (DataRowView)this.selectUserPatientManagent.dataGrid.SelectedItem;
                 if(target == null)
                 {
-                    await this.ShowMessageAsync("提示", "请选择一个病例进行删除");
+                    MessageBox.Show("请选择一个病例进行删除", "提示");
                     return;
                 }
-                MessageDialogResult clickresult = await this.ShowMessageAsync("提示", "确认删除该病例?", MessageDialogStyle.AffirmativeAndNegative);
-                if (clickresult == MessageDialogResult.Affirmative)//确认
+                MessageBoxResult clickresult = MessageBox.Show("确认删除该病例?", "提示", MessageBoxButton.OKCancel);
+                if (clickresult == MessageBoxResult.OK)
                 {
-                    int status = SQLite.SQLiteModel.DeletePatientItem(target["id"].ToString());
+                    int status = SQLite.SQLiteModel.DeletePatientItem(target["p_id"].ToString());
                     if (status > 0)
                     {
-                        await this.ShowMessageAsync("提示", "删除成功");
+                        MessageBox.Show("删除成功","提示");
                     }
                     else
                     {
-                        await this.ShowMessageAsync("警告", "目标已被删除");
+                        MessageBox.Show("已删除", "提示");
                     }
                 }
-                else//取消
+                else if (clickresult == MessageBoxResult.Cancel)
                 {
                     return;
                 }
             }
             catch (Exception err)
             {
-                await this.ShowMessageAsync("错误", "数据库故障\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace);
+                MessageBox.Show("数据库故障\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
             }
             
 

+ 2 - 2
WpfTest1/PatientInfo.xaml.cs

@@ -79,7 +79,7 @@ namespace WpfTest1
         }
 
         private void fillBlanks(Patient onePerson)
-        {
+        {/*
             textBoxIDNum.Text = onePerson.idNum;
             textBoxPaID.Text = onePerson.record_id;
             textBoxName.Text = onePerson.name;
@@ -104,7 +104,7 @@ namespace WpfTest1
             else
             {
                 textBoxAge.Text = "--";
-            }
+            }*/
         }
 
         private void textBoxHighBP_TextChanged(object sender, TextChangedEventArgs e)

+ 2 - 2
WpfTest1/PatientInfoShort.xaml.cs

@@ -26,13 +26,13 @@ namespace WpfTest1
         }
 
         public void fillBlanks(SQLite.Patient pa)
-        {
+        {/*
             labelName.Content = pa.name;
             labelPaId.Content = pa.record_id;
             labelHeight.Content = pa.height;
             labelWeight.Content = pa.weight;
             labelPregTime.Content = pa.pregnancy_times;
-            labelProdTime.Content = pa.birth_times;
+            labelProdTime.Content = pa.birth_times;*/
         }
     }
 }

+ 17 - 19
WpfTest1/SQLite/Patient.cs

@@ -7,24 +7,22 @@ namespace WpfTest1.SQLite
 {
     public class Patient
     {
-        public int id { get; set; }
-        public string record_id { get; set; } //注意这里的record指的是病例号不是记录的record
-        public string idNum { get; set; }
-        public string name { get; set; }
-        public double height { get; set; }
-        public double weight { get; set; }
-        public int base_heartrate { get; set; }
-        public int pregnancy_times { get; set; }
-        public int birth_times { get; set; }
-        public DateTime pregnancy_date { get; set; }
-        public string mobile { get; set; }
-        public string profession { get; set; }
-        public string address { get; set; }
-        public string category { get; set; }
-        public string group_1 { get; set; }
-        public string firstLetterPY { get; set; }
-        public string description { get; set; }
-        public DateTime lastRecordDate { get; set; }
-        public Boolean delete_flag { get; set; }
+        public int p_id { get; set; }
+        public string p_record_id { get; set; } //注意这里的record指的是病例号不是记录的record
+        public string p_name { get; set; }
+        public string p_gender { get; set; }
+        public double p_height { get; set; }
+        public double p_weight { get; set; }
+        public int p_pregnancy_time { get; set; }
+        public DateTime p_birthdate { get; set; }
+        public string p_phone { get; set; }
+        public string p_address { get; set; }
+        public string p_diagnosis { get; set; }
+        public string p_history { get; set; }
+        public string p_name_py { get; set; }
+        public DateTime p_last_filter_time { get; set; }
+        public DateTime p_last_evaluation_time { get; set; }
+        public Boolean p_delete_flag { get; set; }
+        public int doc_id { get; set; }
     }
 }

+ 75 - 95
WpfTest1/SQLite/SQLiteModel.cs

@@ -155,58 +155,46 @@ namespace WpfTest1.SQLite
 
         #region Patient表各类操作
         //Patient表的插入
-        public static void InsertPatientData(string record_id,string idNum,string name, double height, double weight,int base_heartrate,int pregnancy_times,int birth_times,DateTime pregnancy_date,string mobile,string profession,string address,string category,string group_1, string firstLetterPY,string description,DateTime lastRecordDate,Boolean delete_flag, DateTime birth_date)
+        public static void InsertPatientData(string record_id,string name, string gender, double height, double weight,int pregnancy_times,DateTime birth_date,string phone,string address,string history,string diagnosis, string name_py)
         {
-            string sql = "INSERT INTO Patient(record_id,idNum,name,height,weight,base_heartrate,pregnancy_times,birth_times,pregnancy_date,mobile,profession,address,category,group_1,firstLetterPY,description,lastRecordDate,delete_flag,birth_date)values(@record_id,@idNum,@name,@height,@weight,@base_heartrate,@pregnancy_times,@birth_times,@pregnancy_date,@mobile,@profession,@address,@category,@group_1,@firstLetterPY,@description,@lastRecordDate,@delete_flag,@birth_date)";
+            string sql = "INSERT INTO Patient(p_record_id,p_name,p_gender,p_height,p_weight,p_pregnancy_time,p_birthdate,p_phone,p_address,p_history,p_diagnosis, p_name_py)"+
+                                       "values(@record_id,@name,@gender,@height,@weight,@pregnancy_times,@birthdate,@phone,@address,@history,@diagnosis,@name_py)";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@record_id",record_id),
-                                                               new SQLiteParameter("@idNum",idNum),
                                                                new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@gender",gender),
                                                                new SQLiteParameter("@height",height),
                                                                new SQLiteParameter("@weight",weight),
-                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
                                                                new SQLiteParameter("@pregnancy_times",pregnancy_times),
-                                                               new SQLiteParameter("@birth_times",birth_times),
-                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
-                                                               new SQLiteParameter("@mobile",mobile),
-                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@birthdate",birth_date),
+                                                               new SQLiteParameter("@phone",phone),
                                                                new SQLiteParameter("@address",address),
-                                                               new SQLiteParameter("@category",category),
-                                                               new SQLiteParameter("@group_1",group_1),
-                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
-                                                               new SQLiteParameter("@description",description),
-                                                               new SQLiteParameter("@lastRecordDate",lastRecordDate),
-                                                               new SQLiteParameter("@delete_flag",delete_flag),
-                                                               new SQLiteParameter("@birth_date",birth_date)
+                                                               new SQLiteParameter("@history",history),
+                                                               new SQLiteParameter("@diagnosis",diagnosis),
+                                                               new SQLiteParameter("@name_py",name_py),
                                                                };
             db.ExecuteNonQuery(sql, parameters);
         }
         //Patient表的插入 返回自增主键
-        public static int InsertPatientAndReturnID(string record_id, string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times, DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, DateTime lastRecordDate, Boolean delete_flag, DateTime birth_date)
+        public static int InsertPatientAndReturnID(string record_id, string name, string gender, double height, double weight, int pregnancy_times, DateTime birth_date, string phone, string address, string history, string diagnosis, string name_py)
         {
-            string sql = "INSERT INTO Patient(record_id,idNum,name,height,weight,base_heartrate,pregnancy_times,birth_times,pregnancy_date,mobile,profession,address,category,group_1,firstLetterPY,description,lastRecordDate,delete_flag,birth_date)values(@record_id,@idNum,@name,@height,@weight,@base_heartrate,@pregnancy_times,@birth_times,@pregnancy_date,@mobile,@profession,@address,@category,@group_1,@firstLetterPY,@description,@lastRecordDate,@delete_flag,@birth_date);";
+            string sql = "INSERT INTO Patient(p_record_id,p_name,p_gender,p_height,p_weight,p_pregnancy_time,p_birthdate,p_phone,p_address,p_history,p_diagnosis, p_name_py)" +
+                                       "values(@record_id,@name,@gender,@height,@weight,@pregnancy_times,@birthdate,@phone,@address,@history,@diagnosis,@name_py)";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@record_id",record_id),
-                                                               new SQLiteParameter("@idNum",idNum),
                                                                new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@gender",gender),
                                                                new SQLiteParameter("@height",height),
                                                                new SQLiteParameter("@weight",weight),
-                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
                                                                new SQLiteParameter("@pregnancy_times",pregnancy_times),
-                                                               new SQLiteParameter("@birth_times",birth_times),
-                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
-                                                               new SQLiteParameter("@mobile",mobile),
-                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@birthdate",birth_date),
+                                                               new SQLiteParameter("@phone",phone),
                                                                new SQLiteParameter("@address",address),
-                                                               new SQLiteParameter("@category",category),
-                                                               new SQLiteParameter("@group_1",group_1),
-                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
-                                                               new SQLiteParameter("@description",description),
-                                                               new SQLiteParameter("@lastRecordDate",lastRecordDate),
-                                                               new SQLiteParameter("@delete_flag",delete_flag),
-                                                               new SQLiteParameter("@birth_date",birth_date)
+                                                               new SQLiteParameter("@history",history),
+                                                               new SQLiteParameter("@diagnosis",diagnosis),
+                                                               new SQLiteParameter("@name_py",name_py),
                                                                };
             db.ExecuteNonQuery(sql, parameters);
             //Console.WriteLine(db.ExecuteScalar("select last_insert_rowid() from Patient",null).ToString());
@@ -221,66 +209,59 @@ namespace WpfTest1.SQLite
         }
 
         //Patient表的更新 不更新生日
-        public static void UpdatePatientData2(string id, string record_id, string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times, DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, Boolean delete_flag)
+        public static void UpdatePatientData2_useless(string record_id, string name, string gender, double height, double weight, int pregnancy_times, DateTime birth_date, string phone, string address, string history, string diagnosis, string name_py)
         {
             //Boolean a = false;
-            string sql = "UPDATE Patient SET record_id=@record_id,idNum=@idNum,name=@name,height=@height,weight=@weight,base_heartrate=@base_heartrate,pregnancy_times=@pregnancy_times,birth_times = @birth_times,pregnancy_date= @pregnancy_date, mobile = @mobile,profession=@profession,address=@address,category=@category,group_1=@group_1,firstLetterPY=@firstLetterPY,description=@description,delete_flag=@delete_flag WHERE id=@id";
+            string sql = "UPDATE Patient SET p_record_id=@record_id,p_name=@name,p_gender=@gender,p_height=@height,p_weight=@weight,p_pregnancy_time=@pregnancy_times,p_birthdate= @birth_date, p_phone = @mobile,p_address=@address,p_history=@history,p_diagnosis=@diagnosis,p_name_py=@name_py WHERE id=@id";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@record_id",record_id),
-                                                               new SQLiteParameter("@idNum",idNum),
                                                                new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@gender",gender),
                                                                new SQLiteParameter("@height",height),
                                                                new SQLiteParameter("@weight",weight),
-                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
                                                                new SQLiteParameter("@pregnancy_times",pregnancy_times),
-                                                               new SQLiteParameter("@birth_times",birth_times),
-                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
-                                                               new SQLiteParameter("@mobile",mobile),
-                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@birthdate",birth_date),
+                                                               new SQLiteParameter("@phone",phone),
                                                                new SQLiteParameter("@address",address),
-                                                               new SQLiteParameter("@category",category),
-                                                               new SQLiteParameter("@group_1",group_1),
-                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
-                                                               new SQLiteParameter("@description",description),
-                                                               new SQLiteParameter("@delete_flag",delete_flag),
-                                                               new SQLiteParameter("@id",id)
+                                                               new SQLiteParameter("@history",history),
+                                                               new SQLiteParameter("@diagnosis",diagnosis),
+                                                               new SQLiteParameter("@name_py",name_py),
                                                                };
             db.ExecuteNonQuery(sql, parameters);
         }
         //Patient表的更新
-        public static void UpdatePatientData(string id,string record_id ,string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times,DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, Boolean delete_flag, DateTime birth_date)
+        public static void UpdatePatientData(string id, string record_id, string name, string gender, double height, double weight, int pregnancy_times, DateTime birth_date, string phone, string address, string history, string diagnosis, string name_py)
         {
             //Boolean a = false;
-            string sql = "UPDATE Patient SET record_id=@record_id,idNum=@idNum,name=@name,height=@height,weight=@weight,base_heartrate=@base_heartrate,pregnancy_times=@pregnancy_times,birth_times = @birth_times,pregnancy_date= @pregnancy_date, mobile = @mobile,profession=@profession,address=@address,category=@category,group_1=@group_1,firstLetterPY=@firstLetterPY,description=@description,delete_flag=@delete_flag,birth_date=@birth_date WHERE id=@id";
+            string sql = "UPDATE Patient SET p_record_id=@record_id,p_name=@name,p_gender=@gender,p_height=@height,p_weight=@weight,p_pregnancy_time=@pregnancy_times,p_birthdate=@birth_date,p_phone=@phone,p_address=@address,p_history=@history,p_diagnosis=@diagnosis,p_name_py=@name_py WHERE p_id=@id";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@record_id",record_id),
-                                                               new SQLiteParameter("@idNum",idNum),
                                                                new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@gender",gender),
                                                                new SQLiteParameter("@height",height),
                                                                new SQLiteParameter("@weight",weight),
-                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
                                                                new SQLiteParameter("@pregnancy_times",pregnancy_times),
-                                                               new SQLiteParameter("@birth_times",birth_times),
-                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
-                                                               new SQLiteParameter("@mobile",mobile),
-                                                               new SQLiteParameter("@profession",profession),
-                                                               new SQLiteParameter("@address",address),
-                                                               new SQLiteParameter("@category",category),
-                                                               new SQLiteParameter("@group_1",group_1),
-                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
-                                                               new SQLiteParameter("@description",description),
-                                                               new SQLiteParameter("@delete_flag",delete_flag),
                                                                new SQLiteParameter("@birth_date",birth_date),
-                                                               new SQLiteParameter("@id",id)
+                                                               new SQLiteParameter("@phone",phone),
+                                                               new SQLiteParameter("@address",address),
+                                                               new SQLiteParameter("@history",history),
+                                                               new SQLiteParameter("@diagnosis",diagnosis),
+                                                               new SQLiteParameter("@name_py",name_py),
+                                                               new SQLiteParameter("@id",id),
                                                                };
+            //System.Console.WriteLine(sql);
             db.ExecuteNonQuery(sql, parameters);
         }
-        //Patient表的仅更新最后测量时间的方法
-        public static void UpdatePatientDataWithLastMeasureDate(string id, DateTime lastRecordDate)
+        //Patient表的仅更新最后XX时间的方法
+        //type 为 filter 或 evaluation
+        public static void UpdatePatientDataWithLastFilterDate(string id, string type, DateTime lastRecordDate)
         {
-            string sql = "UPDATE Patient SET lastRecordDate=@lastRecordDate WHERE id=@id";
+            string colum_select = "p_last_filter_time";
+            if(type == "evaluation")
+                colum_select = "p_last_evaluation_time";
+            string sql = "UPDATE Patient SET " + colum_select + "=@lastRecordDate WHERE p_id=@id";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@lastRecordDate",lastRecordDate),
@@ -292,7 +273,7 @@ namespace WpfTest1.SQLite
         //Patient表记录的删除
         public static int DeletePatientItem(string id)
         {
-            string sql = "UPDATE Patient SET delete_flag=1 WHERE id=@id";
+            string sql = "UPDATE Patient SET p_delete_flag=1 WHERE p_id=@id";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@id",id)
@@ -304,7 +285,7 @@ namespace WpfTest1.SQLite
         /// </summary>
         public static List<string> getDeletedPatients()
         {
-            string sql = "SELECT id FROM Patient WHERE delete_flag = 1";
+            string sql = "SELECT p_id FROM Patient WHERE p_delete_flag = 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[] { };
             List<string> result = new List<string>();
@@ -323,20 +304,19 @@ namespace WpfTest1.SQLite
         /// </summary>
         public static int realDeleteRecords()
         {
-            string sql = "DELETE from Patient WHERE delete_flag=1";
+            string sql = "DELETE from Patient WHERE p_delete_flag=1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{ };
             return db.ExecuteNonQuery(sql, parameters);
         }
 
-        //检查Patient表是否重复,条件提供身份号和病例号(至少一个)重复返回true,否则返回false
-        public static bool checkRepeatPatient(string idnum,string record_id)
+        //检查Patient表是否重复,条件提病例号.重复返回true,否则返回false
+        public static bool checkRepeatPatient(string record_id)
         {
-            string sql = "SELECT * FROM Patient WHERE (record_id = @record_id OR idNum = @idnum) AND delete_flag = 0";
+            string sql = "SELECT * FROM Patient WHERE p_record_id = @record_id AND p_delete_flag = 0";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@record_id",record_id),
-                                                               new SQLiteParameter("@idnum",idnum)
+                                                               new SQLiteParameter("@record_id",record_id)
                                                                };
             using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
             {
@@ -349,7 +329,7 @@ namespace WpfTest1.SQLite
             return false;
         }
         //通过身份证号、孕次、产次查找Patient
-        public static Patient getPatientByIdNum_pregnancy_brith(string idNum,int pregnancy_times, int birth_times)
+        public static Patient getPatientByIdNum_pregnancy_brith_useless(string idNum,int pregnancy_times, int birth_times)
         {
             string sql = "SELECT * FROM Patient WHERE idNUm = @idNum AND pregnancy_times = @pregnancy_times AND birth_times = @birth_times AND delete_flag = 0 LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
@@ -362,7 +342,7 @@ namespace WpfTest1.SQLite
             using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
             {
                 while (reader.Read())
-                {
+                {/*
                     Patient temp = new Patient();
                     temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.record_id = reader.IsDBNull(1) ? "" : reader.GetString(1);
@@ -381,7 +361,7 @@ namespace WpfTest1.SQLite
                     temp.group_1 = reader.IsDBNull(14) ? "" : reader.GetString(14);
                     temp.firstLetterPY = reader.IsDBNull(15) ? "" : reader.GetString(15);
                     temp.description = reader.IsDBNull(16) ? "" : reader.GetString(16);
-                    return temp;
+                    return temp;*/
                 }
             }
             return null;
@@ -390,7 +370,7 @@ namespace WpfTest1.SQLite
         //通过id主键查找Patient
         public static Patient getPatientById(string id)
         {
-            string sql = "SELECT * FROM Patient WHERE id = @id AND delete_flag = 0 LIMIT 1";
+            string sql = "SELECT * FROM Patient WHERE p_id = @id AND p_delete_flag = 0 LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[]{
                                                                new SQLiteParameter("@id",id),
@@ -400,30 +380,30 @@ namespace WpfTest1.SQLite
                 while (reader.Read())
                 {
                     Patient temp = new Patient();
-                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
-                    temp.record_id = reader.IsDBNull(1) ? "" : reader.GetString(1);
-                    temp.idNum = reader.IsDBNull(2) ? "" : reader.GetString(2);
-                    temp.name = reader.IsDBNull(3) ? "" : reader.GetString(3);
-                    temp.height = reader.IsDBNull(4) ? 0 : reader.GetDouble(4);
-                    temp.weight = reader.IsDBNull(5) ? 0 : reader.GetDouble(5);
-                    temp.base_heartrate = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
-                    temp.pregnancy_times = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
-                    temp.birth_times = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
-                    temp.pregnancy_date = reader.IsDBNull(9) ? DateTime.MinValue : reader.GetDateTime(9);
-                    temp.mobile = reader.IsDBNull(10) ? "" : reader.GetString(10);
-                    temp.profession = reader.IsDBNull(11) ? "" : reader.GetString(11);
-                    temp.address = reader.IsDBNull(12) ? "" : reader.GetString(12);
-                    temp.category = reader.IsDBNull(13) ? "" : reader.GetString(13);
-                    temp.group_1 = reader.IsDBNull(14) ? "" : reader.GetString(14);
-                    temp.firstLetterPY = reader.IsDBNull(15) ? "" : reader.GetString(15);
-                    temp.description = reader.IsDBNull(16) ? "" : reader.GetString(16);
+                    temp.p_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.p_name = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.p_name_py = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.p_record_id = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.p_gender = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.p_birthdate = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.p_height = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
+                    temp.p_weight = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
+                    temp.p_pregnancy_time = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
+                    temp.p_phone = reader.IsDBNull(9) ? "" : reader.GetString(9);
+                    temp.p_address = reader.IsDBNull(10) ? "" : reader.GetString(10);
+                    temp.p_history = reader.IsDBNull(11) ? "" : reader.GetString(11);
+                    temp.p_diagnosis = reader.IsDBNull(12) ? "" : reader.GetString(12);
+                    temp.doc_id = reader.IsDBNull(13) ? 0 : reader.GetInt32(13);
+                    temp.p_last_filter_time = reader.IsDBNull(14) ? DateTime.MinValue : reader.GetDateTime(14);
+                    temp.p_last_evaluation_time = reader.IsDBNull(15) ? DateTime.MinValue : reader.GetDateTime(15);
+                    temp.p_delete_flag = reader.IsDBNull(16) ? false : reader.GetBoolean(16); ;
                     return temp;
                 }
             }
             return null;
         }
         //根据拼音获取patient记录
-        public static void getPatientByPY(string py)
+        public static void getPatientByPY_useless(string py)
         {
             //查询从20条起的50条记录 
             string sql = "SELECT * FROM Patient WHERE firstLetterPY like\'%" + py + "%\' AND delete_flag=0";
@@ -437,7 +417,7 @@ namespace WpfTest1.SQLite
             }
         }
         //根据姓名获取patient记录
-        public static void getPatientByName(string name)
+        public static void getPatientByName_useless(string name)
         {
             string sql = "SELECT * FROM Patient WHERE name like\'%" + name+ "%\' AND delete_flag=0";
             Console.WriteLine(sql);
@@ -452,7 +432,7 @@ namespace WpfTest1.SQLite
             }
         }
         //根据condition获取patient记录
-        public static DataView getPatientByCondition(string condition)
+        public static DataView getPatientByCondition_useless(string condition)
         {
             /*
              * 
@@ -490,7 +470,7 @@ namespace WpfTest1.SQLite
         }
 
         //获取Patient表的用户所有分类和所有用户组
-        public static List<string> getCategory(string taskType="category")
+        public static List<string> getCategory_useless(string taskType="category")
         {
             string sql = "SELECT " + taskType + " FROM Patient WHERE delete_flag = 0 group by " + taskType;
             List<string> result = new List<string>();

+ 30 - 40
WpfTest1/SmallDialogs/AddPatient.xaml

@@ -11,51 +11,41 @@
         <Button x:Name="buttonAddPatinetcReset" Content="重置" HorizontalAlignment="Left" Margin="334,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcReset_Click"/>
         <Button x:Name="buttonAddPatinetcCancel" Content="取消" HorizontalAlignment="Left" Margin="511,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcCancel_Click"/>
         <Label x:Name="label" Content="病例编号:" HorizontalAlignment="Left" Margin="112,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="112,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy4" Content="静息心率:" HorizontalAlignment="Left" Margin="112,265,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy6" Content="产次:" HorizontalAlignment="Left" Margin="148,341,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy7" Content="受孕日期:" HorizontalAlignment="Left" Margin="112,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,163,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,203,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="性别:" HorizontalAlignment="Left" Margin="148,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,283,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy7" Content="出生日期:" HorizontalAlignment="Left" Margin="112,323,0,0" VerticalAlignment="Top" FontSize="18"/>
         <Label x:Name="label_Copy8" Content="联系方式:" HorizontalAlignment="Left" Margin="450,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy9" Content="职业:" HorizontalAlignment="Left" Margin="486,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy11" Content="分类:" HorizontalAlignment="Left" Margin="486,151,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy12" Content="用户组:" HorizontalAlignment="Left" Margin="468,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy13" Content="备注:" HorizontalAlignment="Left" Margin="486,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,151,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
+        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy11" Content="病史:" HorizontalAlignment="Left" Margin="486,123,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy12" Content="诊断:" HorizontalAlignment="Left" Margin="486,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,123,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
         <TextBox x:Name="textBoxCaseId" HorizontalAlignment="Left" Height="33" Margin="219,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxIdNum" HorizontalAlignment="Left" Height="33" Margin="219,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
-        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxBaseHartrate" HorizontalAlignment="Left" Height="33" Margin="219,265,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,303,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxBirthTimes" HorizontalAlignment="Left" Height="33" Margin="219,341,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <DatePicker x:Name="textBoxPregnancyDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,379,382,157">
+        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,83,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
+        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,123,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,163,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,203,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxGender" HorizontalAlignment="Left" Height="33" Margin="219,243,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,283,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <DatePicker x:Name="textBoxBirthDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,323,382,213">
         </DatePicker>
         <TextBox x:Name="textBoxMobile" HorizontalAlignment="Left" Height="33" Margin="555,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxProfession" HorizontalAlignment="Left" Height="33" Margin="555,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxCategory" HorizontalAlignment="Left" Height="33" Margin="555,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxGroup" HorizontalAlignment="Left" Height="33" Margin="555,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxDescription" HorizontalAlignment="Left" Height="33" Margin="555,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,83,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHistory" HorizontalAlignment="Left" Height="113" Margin="555,123,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxDiagnosis" HorizontalAlignment="Left" Height="113" Margin="555,243,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
         <Label x:Name="label_Copy15" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy16" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,151,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,265,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy23" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,341,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,374,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,123,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,163,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,203,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,283,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,323,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,380,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,380,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,380,0,0" VerticalAlignment="Top" FontSize="18"/>
 
     </Grid>
 </Window>

+ 31 - 71
WpfTest1/SmallDialogs/AddPatient.xaml.cs

@@ -65,21 +65,21 @@ namespace WpfTest1
         private void doResetInfo()
         {
             textBoxCaseId.Text = "";
-            textBoxIdNum.Text = "";
+            textBoxGender.Text = "";
             textBoxName.Text = "";
             textBoxPY.Text = "";
             textBoxHeight.Text = "";
             textBoxWeight.Text = "";
-            textBoxBaseHartrate.Text = "";
             textBoxPregnancyTimes.Text = "";
-            textBoxBirthTimes.Text = "";
-            textBoxPregnancyDate.Text = "";
+            //textBoxBirthTimes.Text = "";
+            //textBoxPregnancyDate.Text = "";
             textBoxMobile.Text = "";
-            textBoxProfession.Text = "";
+            //textBoxProfession.Text = "";
             textBoxAddress.Text = "";
-            textBoxCategory.Text = "";
-            textBoxGroup.Text = "";
-            textBoxDescription.Text = "";
+            textBoxHistory.Text = "";
+            textBoxDiagnosis.Text = "";
+            textBoxBirthDate.Text = "";
+            //textBoxDescription.Text = "";
         }
 
         //提交按钮
@@ -91,18 +91,7 @@ namespace WpfTest1
                 textBoxCaseId.Focus();
                 return;
             }
-            if (textBoxIdNum.Text == "")
-            {
-                MessageBox.Show("必要信息未填写");
-                textBoxIdNum.Focus();
-                return;
-            }
-            if (textBoxIdNum.Text.Length != 18 || !(textBoxIdNum.Text.Substring(6, 2) == "19" || textBoxIdNum.Text.Substring(6, 2) == "20"))
-            {
-                MessageBox.Show("身份证信息异常");
-                textBoxIdNum.Focus();
-                return;
-            }
+            
             if (textBoxName.Text == "")
             {
                 MessageBox.Show("必要信息未填写");
@@ -127,10 +116,10 @@ namespace WpfTest1
                 textBoxWeight.Focus();
                 return;
             }
-            if (textBoxBaseHartrate.Text == "")
+            if (textBoxGender.Text == "")
             {
                 MessageBox.Show("必要信息未填写");
-                textBoxBaseHartrate.Focus();
+                textBoxGender.Focus();
                 return;
             }
             if (textBoxPregnancyTimes.Text == "")
@@ -139,82 +128,53 @@ namespace WpfTest1
                 textBoxPregnancyTimes.Focus();
                 return;
             }
-            if (textBoxBirthTimes.Text == "")
+            if (textBoxBirthDate.Text == "")
             {
                 MessageBox.Show("必要信息未填写");
-                textBoxBirthTimes.Focus();
-                return;
-            }
-            if (textBoxPregnancyDate.Text == "")
-            {
-                MessageBox.Show("必要信息未填写");
-                textBoxPregnancyDate.Focus();
+                textBoxBirthDate.Focus();
                 return;
             }
 
             //筛选通过后调用数据库进行存储
             string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
-            string idnum = FilterDangerousCharacter.filter(textBoxIdNum.Text);
             string name = FilterDangerousCharacter.filter(textBoxName.Text);
             string py = FilterDangerousCharacter.filter(textBoxPY.Text);
             string height = FilterDangerousCharacter.filter(textBoxHeight.Text);
             string weight = FilterDangerousCharacter.filter(textBoxWeight.Text);
-            string baseheartrate = FilterDangerousCharacter.filter(textBoxBaseHartrate.Text);
+            string gender = FilterDangerousCharacter.filter(textBoxGender.Text);
             string pregnancytimes = FilterDangerousCharacter.filter(textBoxPregnancyTimes.Text);
-            string birthtimes = FilterDangerousCharacter.filter(textBoxBirthTimes.Text);
-            string pregnancydate = FilterDangerousCharacter.filter(textBoxPregnancyDate.Text);
+            string birthdate = FilterDangerousCharacter.filter(textBoxBirthDate.Text);
             DateTime dt;
             System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
             //MessageBox.Show(pregnancydate);
             dtFormat.ShortDatePattern = "yyyy/M/d";
-            dt = Convert.ToDateTime(pregnancydate, dtFormat);
+            dt = Convert.ToDateTime(birthdate, dtFormat);
             string mobile = FilterDangerousCharacter.filter(textBoxMobile.Text);
-            string profession = FilterDangerousCharacter.filter(textBoxProfession.Text);
             string address = FilterDangerousCharacter.filter(textBoxAddress.Text);
-            string category = FilterDangerousCharacter.filter(textBoxCategory.Text);
-            string group = FilterDangerousCharacter.filter(textBoxGroup.Text);
-            string description = FilterDangerousCharacter.filter(textBoxDescription.Text);
-            //通过身份证号计算出生日期
-            string birthday = textBoxIdNum.Text.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)));
-
-            //string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
-
+            string history = FilterDangerousCharacter.filter(textBoxHistory.Text);
+            string diagnosis = FilterDangerousCharacter.filter(textBoxDiagnosis.Text);
+            
             bool success_flag = true;
             try
             {
-                if(SQLite.SQLiteModel.checkRepeatPatient(idnum, record_id))
+                if(SQLite.SQLiteModel.checkRepeatPatient(record_id))
                 {
-                    MessageBoxResult dr = MessageBox.Show("发现数据库中存在身份证号或者病例号重复,是否继续储存?", "警告", MessageBoxButton.OKCancel);
-                    if (dr == MessageBoxResult.OK)
-                    {
-                        
-                    }
-                    else if (dr == MessageBoxResult.Cancel)
-                    {
-                        return;
-                    }
+                    MessageBox.Show("病历号重复","错误");
+                    textBoxCaseId.Focus();
+                    return;
                 }
                 SQLite.SQLiteModel.InsertPatientData(record_id, 
-                                                     idnum, 
                                                      name, 
+                                                     gender,
                                                      Convert.ToDouble(height), 
-                                                     Convert.ToDouble(weight), 
-                                                     Convert.ToInt32(baseheartrate), 
-                                                     Convert.ToInt32(pregnancytimes), 
-                                                     Convert.ToInt32(birthtimes),
-                                                     dt, 
+                                                     Convert.ToDouble(weight),
+                                                     Convert.ToInt32(pregnancytimes),
+                                                     dt,
                                                      mobile, 
-                                                     profession, 
                                                      address, 
-                                                     category, 
-                                                     group, 
-                                                     py, 
-                                                     description, 
-                                                     DateTime.MinValue, 
-                                                     false,
-                                                     birthdayDate);
+                                                     history, 
+                                                     diagnosis,
+                                                     py);
 
             }catch(Exception err)
             {
@@ -224,7 +184,7 @@ namespace WpfTest1
             if(success_flag)
             {
                 //MessageBox.Show("插入成功", "提示");
-                //father.selectUserPatientManagent.LoadDataGrid();
+                father.selectUserPatientManagent.LoadDataGrid();
                 //father.selectUserMeasure.LoadDataGrid();
                 //father.selectUserHistory.LoadDataGrid();
                 MessageBoxResult dr = MessageBox.Show("插入成功,是否继续添加?", "提示", MessageBoxButton.OKCancel);

+ 1 - 1
WpfTest1/SmallDialogs/LoginWindow.xaml.cs

@@ -41,7 +41,7 @@ namespace WpfTest1.SmallDialogs
             else
             {
                 mw.loginDoctor = loginDoctor;
-                mw.LoadExpressionToMemory();
+                //mw.LoadExpressionToMemory();
                 if (loginDoctor.privilege_flag != 1)
                 {
                     //mw.tabitemOEMSetting.Visibility = Visibility.Hidden;

+ 30 - 44
WpfTest1/SmallDialogs/ModifyUser.xaml

@@ -11,55 +11,41 @@
         <Button x:Name="buttonAddPatinetcReset" Content="重置" HorizontalAlignment="Left" Margin="334,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcReset_Click"/>
         <Button x:Name="buttonAddPatinetcCancel" Content="取消" HorizontalAlignment="Left" Margin="511,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcCancel_Click"/>
         <Label x:Name="label" Content="病例编号:" HorizontalAlignment="Left" Margin="112,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="112,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy4" Content="静息心率:" HorizontalAlignment="Left" Margin="112,265,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy6" Content="产次:" HorizontalAlignment="Left" Margin="148,341,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy7" Content="受孕日期:" HorizontalAlignment="Left" Margin="112,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,163,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,203,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="性别:" HorizontalAlignment="Left" Margin="148,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,283,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy7" Content="出生日期:" HorizontalAlignment="Left" Margin="112,323,0,0" VerticalAlignment="Top" FontSize="18"/>
         <Label x:Name="label_Copy8" Content="联系方式:" HorizontalAlignment="Left" Margin="450,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy9" Content="职业:" HorizontalAlignment="Left" Margin="486,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy11" Content="分类:" HorizontalAlignment="Left" Margin="486,151,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy12" Content="用户组:" HorizontalAlignment="Left" Margin="468,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy13" Content="备注:" HorizontalAlignment="Left" Margin="486,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,151,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
+        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy11" Content="病史:" HorizontalAlignment="Left" Margin="486,123,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy12" Content="诊断:" HorizontalAlignment="Left" Margin="486,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,123,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
         <TextBox x:Name="textBoxCaseId" HorizontalAlignment="Left" Height="33" Margin="219,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxIdNum" HorizontalAlignment="Left" Height="33" Margin="219,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
-        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxBaseHartrate" HorizontalAlignment="Left" Height="33" Margin="219,265,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,303,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxBirthTimes" HorizontalAlignment="Left" Height="33" Margin="219,341,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <DatePicker x:Name="textBoxPregnancyDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,379,382,157">
+        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,83,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
+        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,123,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,163,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,203,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxGender" HorizontalAlignment="Left" Height="33" Margin="219,243,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,283,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <DatePicker x:Name="textBoxBirthDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,323,382,213">
         </DatePicker>
         <TextBox x:Name="textBoxMobile" HorizontalAlignment="Left" Height="33" Margin="555,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxProfession" HorizontalAlignment="Left" Height="33" Margin="555,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxCategory" HorizontalAlignment="Left" Height="33" Margin="555,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxGroup" HorizontalAlignment="Left" Height="33" Margin="555,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
-        <TextBox x:Name="textBoxDescription" HorizontalAlignment="Left" Height="33" Margin="555,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,83,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHistory" HorizontalAlignment="Left" Height="113" Margin="555,123,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxDiagnosis" HorizontalAlignment="Left" Height="113" Margin="555,243,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
         <Label x:Name="label_Copy15" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,37,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy16" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,75,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,113,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,151,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,189,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,227,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,265,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy23" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,341,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,374,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,303,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <RadioButton x:Name="radioButtonModify" Content="勘误(这样会修改原来病例的信息)" GroupName="updateOption" IsChecked="True" HorizontalAlignment="Left" Margin="234,439,0,0" VerticalAlignment="Top"/>
-        <RadioButton x:Name="radioButtonAdd" Content="病例因流产等原因需要重建(这样会新增一个有着相同身份信息的新病例)" GroupName="updateOption" HorizontalAlignment="Left" Margin="234,462,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy28" Content="修改原因:" HorizontalAlignment="Left" Margin="112,439,0,0" VerticalAlignment="Top" FontSize="18"/>
-        <Label x:Name="label_Copy29" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,439,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,83,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,123,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,163,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,203,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,243,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,283,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,323,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,380,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,380,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,380,0,0" VerticalAlignment="Top" FontSize="18"/>
 
     </Grid>
 </Window>

+ 27 - 105
WpfTest1/SmallDialogs/ModifyUser.xaml.cs

@@ -56,22 +56,18 @@ namespace WpfTest1
         //用系统中的Patient target 填充所有空格
         private void fillBlanks()
         {
-            textBoxCaseId.Text = target.record_id;
-            textBoxIdNum.Text = target.idNum;
-            textBoxName.Text = target.name;
-            textBoxPY.Text = target.firstLetterPY;
-            textBoxHeight.Text = target.height.ToString();
-            textBoxWeight.Text = target.weight.ToString();
-            textBoxBaseHartrate.Text = target.base_heartrate.ToString();
-            textBoxPregnancyTimes.Text = target.pregnancy_times.ToString();
-            textBoxBirthTimes.Text = target.birth_times.ToString();
-            textBoxPregnancyDate.Text = target.pregnancy_date.ToString("yyyy/M/d");
-            textBoxMobile.Text = target.mobile;
-            textBoxProfession.Text = target.profession;
-            textBoxAddress.Text = target.address;
-            textBoxCategory.Text = target.category;
-            textBoxGroup.Text = target.group_1;
-            textBoxDescription.Text = target.description;
+            textBoxCaseId.Text = target.p_record_id;
+            textBoxGender.Text = target.p_gender;
+            textBoxName.Text = target.p_name;
+            textBoxPY.Text = target.p_name_py;
+            textBoxHeight.Text = target.p_height.ToString();
+            textBoxWeight.Text = target.p_weight.ToString();
+            textBoxPregnancyTimes.Text = target.p_pregnancy_time.ToString();
+            textBoxBirthDate.Text = target.p_birthdate.ToString("yyyy/M/d");
+            textBoxMobile.Text = target.p_phone;
+            textBoxAddress.Text = target.p_address;
+            textBoxHistory.Text = target.p_history;
+            textBoxDiagnosis.Text = target.p_diagnosis;
         }
 
         //每输一个姓名摘取其拼音缩写
@@ -94,16 +90,10 @@ namespace WpfTest1
                 textBoxCaseId.Focus();
                 return;
             }
-            if (textBoxIdNum.Text == "")
+            if (textBoxGender.Text == "")
             {
                 MessageBox.Show("必要信息未填写");
-                textBoxIdNum.Focus();
-                return;
-            }
-            if (textBoxIdNum.Text.Length != 18 || !(textBoxIdNum.Text.Substring(6, 2) == "19" || textBoxIdNum.Text.Substring(6, 2) == "20"))
-            {
-                MessageBox.Show("身份证信息异常");
-                textBoxIdNum.Focus();
+                textBoxGender.Focus();
                 return;
             }
             if (textBoxName.Text == "")
@@ -130,122 +120,54 @@ namespace WpfTest1
                 textBoxWeight.Focus();
                 return;
             }
-            if (textBoxBaseHartrate.Text == "")
-            {
-                MessageBox.Show("必要信息未填写");
-                textBoxBaseHartrate.Focus();
-                return;
-            }
             if (textBoxPregnancyTimes.Text == "")
             {
                 MessageBox.Show("必要信息未填写");
                 textBoxPregnancyTimes.Focus();
                 return;
             }
-            if (textBoxBirthTimes.Text == "")
+            if (textBoxBirthDate.Text == "")
             {
-                MessageBox.Show("必要信息未填写");
-                textBoxBirthTimes.Focus();
-                return;
-            }
-            if (textBoxPregnancyDate.Text == "")
-            {
-                MessageBox.Show("必要信息未填写");
-                textBoxPregnancyDate.Focus();
+                MessageBox.Show("出生日期未选择");
+                textBoxBirthDate.Focus();
                 return;
             }
 
             //筛选通过后调用数据库进行存储
             string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
-            string idnum = FilterDangerousCharacter.filter(textBoxIdNum.Text);
             string name = FilterDangerousCharacter.filter(textBoxName.Text);
             string py = FilterDangerousCharacter.filter(textBoxPY.Text);
             string height = FilterDangerousCharacter.filter(textBoxHeight.Text);
             string weight = FilterDangerousCharacter.filter(textBoxWeight.Text);
-            string baseheartrate = FilterDangerousCharacter.filter(textBoxBaseHartrate.Text);
+            string gender = FilterDangerousCharacter.filter(textBoxGender.Text);
             string pregnancytimes = FilterDangerousCharacter.filter(textBoxPregnancyTimes.Text);
-            string birthtimes = FilterDangerousCharacter.filter(textBoxBirthTimes.Text);
-            string pregnancydate = FilterDangerousCharacter.filter(textBoxPregnancyDate.Text);
+            string birthdate = FilterDangerousCharacter.filter(textBoxBirthDate.Text);
             DateTime dt;
             System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
             //MessageBox.Show(pregnancydate);
             dtFormat.ShortDatePattern = "yyyy/M/d";
-            dt = Convert.ToDateTime(pregnancydate, dtFormat);
+            dt = Convert.ToDateTime(birthdate, dtFormat);
             string mobile = FilterDangerousCharacter.filter(textBoxMobile.Text);
-            string profession = FilterDangerousCharacter.filter(textBoxProfession.Text);
             string address = FilterDangerousCharacter.filter(textBoxAddress.Text);
-            string category = FilterDangerousCharacter.filter(textBoxCategory.Text);
-            string group = FilterDangerousCharacter.filter(textBoxGroup.Text);
-            string description = FilterDangerousCharacter.filter(textBoxDescription.Text);
-            //string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
-            //通过身份证号计算出生日期
-            string birthday = textBoxIdNum.Text.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)));
+            string history = FilterDangerousCharacter.filter(textBoxHistory.Text);
+            string diagnosis = FilterDangerousCharacter.filter(textBoxDiagnosis.Text);
 
             bool success_flag = true;
             try
             {
-                //首先检查修改原因再决定执行更新还是插入
-                if(radioButtonModify.IsChecked == true)
-                {
-                    SQLite.SQLiteModel.UpdatePatientData(id,
+                SQLite.SQLiteModel.UpdatePatientData(id,
                                                      record_id,
-                                                     idnum,
                                                      name,
+                                                     gender,
                                                      Convert.ToDouble(height),
                                                      Convert.ToDouble(weight),
-                                                     Convert.ToInt32(baseheartrate),
                                                      Convert.ToInt32(pregnancytimes),
-                                                     Convert.ToInt32(birthtimes),
                                                      dt,
                                                      mobile,
-                                                     profession,
                                                      address,
-                                                     category,
-                                                     group,
-                                                     py,
-                                                     description,
-                                                     false, 
-                                                     birthdayDate);
-
-                }
-                else if(radioButtonAdd.IsChecked == true)
-                {
-                    if (SQLite.SQLiteModel.checkRepeatPatient(idnum, record_id))
-                    {
-                        MessageBoxResult dr = MessageBox.Show("发现数据库中存在身份证号或者病例号重复,是否继续储存?", "警告", MessageBoxButton.OKCancel);
-                        if (dr == MessageBoxResult.OK)
-                        {
-
-                        }
-                        else if (dr == MessageBoxResult.Cancel)
-                        {
-                            return;
-                        }
-                    }
-                    SQLite.SQLiteModel.InsertPatientData(record_id,
-                                                         idnum,
-                                                         name,
-                                                         Convert.ToDouble(height),
-                                                         Convert.ToDouble(weight),
-                                                         Convert.ToInt32(baseheartrate),
-                                                         Convert.ToInt32(pregnancytimes),
-                                                         Convert.ToInt32(birthtimes),
-                                                         dt,
-                                                         mobile,
-                                                         profession,
-                                                         address,
-                                                         category,
-                                                         group,
-                                                         py,
-                                                         description,
-                                                         DateTime.MinValue,
-                                                         false,
-                                                         birthdayDate
-                                                         );
-
-                }
+                                                     history,
+                                                     diagnosis,
+                                                     py);
             }
             catch (Exception err)
             {

+ 1 - 1
WpfTest1/Toolkits/CSVWriter.cs

@@ -11,7 +11,7 @@ namespace WpfTest1.Toolkits
     {
         public static void generateWaveToCSV(List<double> leftRed, List<double> leftInfrared, List<double> rightRed, List<double> rightInfrared, SQLite.Patient pa, SQLite.Record re)
         {
-            FileStream fs = new FileStream(Constants.exportWavePath + "\\" + re.recordTime.ToString("yyyyMMddHHmmss") + "_" + pa.idNum + "_" + pa.name +  ".csv", FileMode.Create);
+            FileStream fs = new FileStream(Constants.exportWavePath + "\\" + re.recordTime.ToString("yyyyMMddHHmmss") + "_" + pa.p_name +  ".csv", FileMode.Create);
             StreamWriter sw = new StreamWriter(fs);
             //开始写入
             sw.Write("leftRed,leftInfrared,rightRed,rightInfrared\n");

+ 11 - 11
WpfTest1/Toolkits/ReportGenerator.cs

@@ -34,8 +34,8 @@ namespace WpfTest1.Toolkits
              String picName3 = path + "\\" + "3.jpg";
              String picName4 = path + "\\" + "4.jpg";
              */
-            String fileName = path + "\\" + patient.idNum + "_" + patient.name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".doc";
-            String pdfFileName = path + "\\" + patient.idNum + "_" + patient.name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".pdf";
+            String fileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".doc";
+            String pdfFileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".pdf";
             if (File.Exists(fileName))
             {
                 try
@@ -175,18 +175,18 @@ namespace WpfTest1.Toolkits
                 }
 
                 table.Cell(1, 1).Range.Text = "身份证号:";
-                table.Cell(1, 2).Range.Text = patient.idNum;
+                table.Cell(1, 2).Range.Text = patient.p_record_id;
                 table.Cell(1, 3).Range.Text = "性别:";
                 table.Cell(1, 4).Range.Text = "女";
                 table.Cell(1, 5).Range.Text = "病例号:";
-                table.Cell(1, 6).Range.Text = patient.id.ToString();
+                table.Cell(1, 6).Range.Text = patient.p_record_id.ToString();
                 table.Cell(2, 1).Range.Text = "姓名:";
-                table.Cell(2, 2).Range.Text = patient.name;
+                table.Cell(2, 2).Range.Text = patient.p_name;
                 table.Cell(2, 3).Range.Text = "年龄:";
-                if (patient.idNum.Length == 18)
+                if (patient.p_record_id.Length == 18)
                 {
                     //假设身份证号合法
-                    string birthday = patient.idNum.Substring(6, 8);
+                    string birthday = patient.p_record_id.Substring(6, 8);
                     //MessageBox.Show(birthday);
                     if (birthday.Substring(0, 2) == "19" || birthday.Substring(0, 2) == "20")
                     {
@@ -206,7 +206,7 @@ namespace WpfTest1.Toolkits
                 table.Cell(2, 5).Range.Text = "床号:";
                 table.Cell(2, 6).Range.Text = "--";
                 table.Cell(3, 1).Range.Text = "身高:";
-                table.Cell(3, 2).Range.Text = patient.height.ToString();
+                table.Cell(3, 2).Range.Text = patient.p_height.ToString();
                 table.Cell(3, 3).Range.Text = "科别:";
                 table.Cell(3, 4).Range.Text = "产科";
                 table.Cell(3, 5).Range.Text = "检查部位:";
@@ -226,11 +226,11 @@ namespace WpfTest1.Toolkits
                         break;
                 }
                 table.Cell(4, 1).Range.Text = "体重:";
-                table.Cell(4, 2).Range.Text = patient.weight.ToString();
+                table.Cell(4, 2).Range.Text = patient.p_weight.ToString();
                 table.Cell(4, 3).Range.Text = "孕周:";
-                table.Cell(4, 4).Range.Text = ((DateTime.Now - patient.pregnancy_date).Days / 7 + 1).ToString(); ;
+                //table.Cell(4, 4).Range.Text = ((DateTime.Now - patient.pregnancy_date).Days / 7 + 1).ToString(); ;
                 table.Cell(4, 5).Range.Text = "孕次:";
-                table.Cell(4, 6).Range.Text = patient.pregnancy_times.ToString();
+                //table.Cell(4, 6).Range.Text = patient.pregnancy_times.ToString();
                 table.Cell(5, 1).Range.Text = "科室:";
                 table.Cell(5, 2).Range.Text = "--";
                 table.Cell(5, 3).Range.Text = "病床号:";

+ 38 - 39
WpfTest1/selectUser.xaml

@@ -10,64 +10,63 @@
         <DataGrid x:Name="dataGrid"  Loaded="dataGrid_Loaded" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="314,10,0,0" VerticalAlignment="Top" Height="580" Width="976" IsReadOnly="True" MouseDoubleClick="dataGrid_MouseDoubleClick">
             <DataGrid.Columns>
                 <!---->
-                <DataGridTextColumn Header="病例编号" Binding="{Binding Path=record_id}" Width="90"/>
-                <DataGridTextColumn Header="病例姓名" Binding="{Binding Path=name}" Width="90"/>
-                <DataGridTextColumn Header="病例身份证号" Binding="{Binding Path=idNum}" Width="120"/>
-                <DataGridTextColumn Header="身高" Binding="{Binding Path=height}" Width="50"/>
-                <DataGridTextColumn Header="体重" Binding="{Binding Path=weight}" Width="50"/>
-                <DataGridTextColumn Header="心率" Binding="{Binding Path=base_heartrate}" Width="50"/>
-                <DataGridTextColumn Header="受孕日期" Binding="{Binding Path=pregnancy_date}" Width="80"/>
-                <DataGridTextColumn Header="孕次" Binding="{Binding Path=birth_times}" Width="50"/>
-                <DataGridTextColumn Header="产次" Binding="{Binding Path=pregnancy_times}" Width="50"/>
-                <DataGridTextColumn Header="描述信息" Binding="{Binding Path=description}" Width="70"/>
-                <DataGridTextColumn Header="最近测量时间" Binding="{Binding Path=lastRecordDate}" Width="110"/>
-                <DataGridTextColumn Header="分类" Binding="{Binding Path=category}" Width="75"/>
-                <DataGridTextColumn Header="用户组" Binding="{Binding Path=group_1}" Width="75"/>
+                <DataGridTextColumn Header="病例编号" Binding="{Binding Path=p_record_id}" Width="120"/>
+                <DataGridTextColumn Header="病例姓名" Binding="{Binding Path=p_name}" Width="90"/>
+                <DataGridTextColumn Header="拼音首字母" Binding="{Binding Path=p_name_py}" Width="90"/>
+                <DataGridTextColumn Header="性别" Binding="{Binding Path=p_gender}" Width="50"/>
+                <DataGridTextColumn Header="身高" Binding="{Binding Path=p_height}" Width="50"/>
+                <DataGridTextColumn Header="体重" Binding="{Binding Path=p_weight}" Width="50"/>
+                <DataGridTextColumn Header="出生日期" Binding="{Binding Path=p_birthdate}" Width="80"/>
+                <DataGridTextColumn Header="孕次" Binding="{Binding Path=p_pregnancy_time}" Width="50"/>
+                <DataGridTextColumn Header="最近筛查时间" Binding="{Binding Path=p_last_filter_time}" Width="110"/>
+                <DataGridTextColumn Header="最近评估时间" Binding="{Binding Path=p_last_evaluation_time}" Width="110"/>
+                <DataGridTextColumn Header="病史" Binding="{Binding Path=p_history}" Width="75"/>
+                <DataGridTextColumn Header="诊断" Binding="{Binding Path=p_diagnosis}" Width="75"/>
                 <!-- -->
             </DataGrid.Columns>
         </DataGrid>
         <Label x:Name="label" Content="姓名:" HorizontalAlignment="Left" Margin="23,18,0,0" VerticalAlignment="Top"/>
         <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="23" Margin="89,18,0,0" TextWrapping="Wrap"  Text="姓名或者拼音首字母" VerticalAlignment="Top" Width="127" GotFocus="textBoxName_GotFocus" PreviewMouseDown="textBoxName_PreviewMouseDown" LostFocus="textBoxName_LostFocus"/>
-        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="23,50,0,0" VerticalAlignment="Top"/>
-        <TextBox x:Name="textBoxIDNumber" HorizontalAlignment="Left" Height="23" Margin="89,49,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
+        <!--<Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="23,50,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="textBoxIDNumber" HorizontalAlignment="Left" Height="23" Margin="89,49,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/> -->
         <Label x:Name="label_Copy1" Content="病例编号:" HorizontalAlignment="Left" Margin="23,81,0,0" VerticalAlignment="Top"/>
         <TextBox x:Name="textBoxCaseID" HorizontalAlignment="Left" Height="23" Margin="89,80,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
         <Label x:Name="label_Copy2" Content="孕次:" HorizontalAlignment="Left" Margin="23,112,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy3" Content="产次:" HorizontalAlignment="Left" Margin="23,142,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy4" Content="受孕时间:" HorizontalAlignment="Left" Margin="23,180,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy5" Content="身高:" HorizontalAlignment="Left" Margin="23,312,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy6" Content="体重:" HorizontalAlignment="Left" Margin="23,342,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.471,1.027"/>
-        <Label x:Name="label_Copy7" Content="静息心率:" HorizontalAlignment="Left" Margin="23,372,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy8" Content="至" HorizontalAlignment="Left" Margin="166,371,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
-        <Label x:Name="label_Copy9" Content="至" HorizontalAlignment="Left" Margin="166,341,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.409,0.48"/>
-        <Label x:Name="label_Copy10" Content="至" HorizontalAlignment="Left" Margin="166,312,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.545,0.44"/>
+        <!--<Label x:Name="label_Copy3" Content="产次:" HorizontalAlignment="Left" Margin="23,142,0,0" VerticalAlignment="Top"/> -->
+        <!--<Label x:Name="label_Copy4" Content="受孕时间:" HorizontalAlignment="Left" Margin="23,180,0,0" VerticalAlignment="Top"/>-->
+        <Label x:Name="label_Copy5" Content="身高:" HorizontalAlignment="Left" Margin="23,230,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy6" Content="体重:" HorizontalAlignment="Left" Margin="23,270,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.471,1.027"/>
+        <!--<Label x:Name="label_Copy7" Content="静息心率:" HorizontalAlignment="Left" Margin="23,372,0,0" VerticalAlignment="Top"/>-->
+        <!--<Label x:Name="label_Copy8" Content="至" HorizontalAlignment="Left" Margin="166,371,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>-->
+        <Label x:Name="label_Copy9" Content="至" HorizontalAlignment="Left" Margin="166,270,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.409,0.48"/>
+        <Label x:Name="label_Copy10" Content="至" HorizontalAlignment="Left" Margin="166,230,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.545,0.44"/>
         <TextBox x:Name="textBoxPregnancyTime" HorizontalAlignment="Left" Height="23" Margin="89,111,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
-        <TextBox x:Name="textBoxProductionTime" HorizontalAlignment="Left" Height="23" Margin="89,142,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
-        <Label x:Name="label_Copy11" Content="至" HorizontalAlignment="Left" Margin="66,213,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
-        <TextBox x:Name="textBoxHeightStart" HorizontalAlignment="Left" Height="25" Margin="94,309,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
-        <TextBox x:Name="textBoxHeightEnd" HorizontalAlignment="Left" Height="25" Margin="202,309,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
-        <TextBox x:Name="textBoxWeightStart" HorizontalAlignment="Left" Height="25" Margin="93,340,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
-        <TextBox x:Name="textBoxWeightEnd" HorizontalAlignment="Left" Height="24" Margin="202,340,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
-        <TextBox x:Name="textBoxHeartRateStart" HorizontalAlignment="Left" Height="25" Margin="93,371,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
-        <TextBox x:Name="textBoxHeartRateEnd" HorizontalAlignment="Left" Height="23" Margin="202,370,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <!--<TextBox x:Name="textBoxProductionTime" HorizontalAlignment="Left" Height="23" Margin="89,142,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>-->
+        <!--<Label x:Name="label_Copy11" Content="至" HorizontalAlignment="Left" Margin="66,213,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>-->
+        <TextBox x:Name="textBoxHeightStart" HorizontalAlignment="Left" Height="25" Margin="95,230,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
+        <TextBox x:Name="textBoxHeightEnd" HorizontalAlignment="Left" Height="25" Margin="200,230,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <TextBox x:Name="textBoxWeightStart" HorizontalAlignment="Left" Height="25" Margin="95,270,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <TextBox x:Name="textBoxWeightEnd" HorizontalAlignment="Left" Height="24" Margin="200,270,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <!--<TextBox x:Name="textBoxHeartRateStart" HorizontalAlignment="Left" Height="25" Margin="93,371,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
+        <TextBox x:Name="textBoxHeartRateEnd" HorizontalAlignment="Left" Height="23" Margin="202,370,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>-->
         <Button x:Name="buttonQuery" Content="筛选" HorizontalAlignment="Left" Margin="148,469,0,0" VerticalAlignment="Top" Width="114" Height="37" FontSize="18" Background="#FF54BD4A" Click="buttonQuery_Click" RenderTransformOrigin="0.5,0.514"/>
         <Button x:Name="buttonQueryCopy2" Content="筛选" HorizontalAlignment="Left" Margin="216,17,0,0" VerticalAlignment="Top" Width="46" Height="26" FontSize="10" Click="buttonQuery_Click" RenderTransformOrigin="0.5,0.541"/>
 
         <Button x:Name="buttonReset" Content="重置" HorizontalAlignment="Left" Margin="23,469,0,0" VerticalAlignment="Top" Width="107" Height="37" FontSize="18" Click="buttonReset_Click"/>
-        <DatePicker x:Name="datePickerTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,179,1038,395">
+       <!-- <DatePicker x:Name="datePickerTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,179,1038,395">
         </DatePicker>
         <DatePicker x:Name="datePickerTimeEnd" SelectedDateFormat="Short" FirstDayOfWeek="Monday"  IsTodayHighlighted="True" Margin="93,213,1038,361">
+        </DatePicker>-->
+        <DatePicker x:Name="datePickerBirthTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,144,1038,423">
         </DatePicker>
-        <DatePicker x:Name="datePickerBirthTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,244,1038,330">
+        <DatePicker x:Name="datePickerBirthTimeEnd" SelectedDateFormat="Short" FirstDayOfWeek="Monday"  IsTodayHighlighted="True" Margin="93,180,1038,386">
         </DatePicker>
-        <DatePicker x:Name="datePickerBirthTimeEnd" SelectedDateFormat="Short" FirstDayOfWeek="Monday"  IsTodayHighlighted="True" Margin="93,275,1038,299">
-        </DatePicker>
-        <Label x:Name="label_Copy12" Content="出生日期:" HorizontalAlignment="Left" Margin="23,245,0,0" VerticalAlignment="Top"/>
-        <Label x:Name="label_Copy13" Content="至" HorizontalAlignment="Left" Margin="66,276,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
-        <Label x:Name="label_Copy14" Content="分类:" HorizontalAlignment="Left" Margin="23,404,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy12" Content="出生日期:" HorizontalAlignment="Left" Margin="23,150,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy13" Content="至" HorizontalAlignment="Left" Margin="66,185,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
+        <!--<Label x:Name="label_Copy14" Content="分类:" HorizontalAlignment="Left" Margin="23,404,0,0" VerticalAlignment="Top"/>
         <Label x:Name="label_Copy15" Content="用户组:" HorizontalAlignment="Left" Margin="23,438,0,0" VerticalAlignment="Top"/>
         <ComboBox x:Name="comboBoxCategory" HorizontalAlignment="Left" Margin="93,403,0,0" VerticalAlignment="Top" Width="169" Height="17"/>
-        <ComboBox x:Name="comboBoxGroup_1" HorizontalAlignment="Left" Margin="93,438,0,0" VerticalAlignment="Top" Width="169" Height="17"/>
+        <ComboBox x:Name="comboBoxGroup_1" HorizontalAlignment="Left" Margin="93,438,0,0" VerticalAlignment="Top" Width="169" Height="17"/>-->
 
     </Grid>
 

+ 14 - 117
WpfTest1/selectUser.xaml.cs

@@ -65,35 +65,17 @@ namespace WpfTest1
             //连接对象
             SQLiteConnection con = new SQLiteConnection(Connstr);
             //Sql语句
-            string orderCondition = "lastRecordDate desc";
-            if (this.Name == "selectUserMeasure")
-            {
-                orderCondition = "id desc";
-            }
+            string orderCondition = "p_last_filter_time desc";
             if (this.Name == "selectUserPatientManagent")
             {
-                orderCondition = "id asc";
+                orderCondition = "p_id asc";
             }
-            string selectCmd = "SELECT * FROM Patient WHERE delete_flag = 0 ORDER BY " + orderCondition + " LIMIT 100";
+            string selectCmd = "SELECT * FROM Patient WHERE p_delete_flag = 0 ORDER BY " + orderCondition + " LIMIT 100";
             con.Open();
             da = new SQLiteDataAdapter(selectCmd, con);
             ds = new DataSet();
             da.Fill(ds);
             dataGrid.ItemsSource = ds.Tables[0].DefaultView;
-
-            //之后为筛选用户组和分类进行枚举
-            comboBoxCategory.Items.Clear();
-            comboBoxGroup_1.Items.Clear();
-            List<string> category = SQLiteModel.getCategory("category");
-            foreach(string one_item in category)
-            {
-                comboBoxCategory.Items.Add(one_item);
-            }
-            List<string> group_1 = SQLiteModel.getCategory("group_1");
-            foreach (string one_item in group_1)
-            {
-                comboBoxGroup_1.Items.Add(one_item);
-            }
             con.Close();
         }
 
@@ -101,22 +83,14 @@ namespace WpfTest1
         private void buttonReset_Click(object sender, RoutedEventArgs e)
         {
             textBoxName.Text = "姓名或者拼音首字母";
-            textBoxIDNumber.Text = "";
             textBoxCaseID.Text = "";
             textBoxPregnancyTime.Text = "";
-            textBoxProductionTime.Text = "";
-            datePickerTimeStart.Text = "";
-            datePickerTimeEnd.Text = "";
-            //textBoxTimeStart.Text = "";
-            //textBoxTimeEnd.Text = "";
             textBoxHeightStart.Text = "";
             textBoxHeightEnd.Text = "";
             textBoxWeightStart.Text = "";
             textBoxWeightEnd.Text = "";
-            textBoxHeartRateStart.Text = "";
-            textBoxHeartRateEnd.Text = "";
-            comboBoxCategory.SelectedIndex = -1;
-            comboBoxGroup_1.SelectedIndex = -1;
+            datePickerBirthTimeStart.Text = "";
+            datePickerBirthTimeEnd.Text = "";
             LoadDataGrid();
         }
 
@@ -159,19 +133,13 @@ namespace WpfTest1
             string name_or_py = textBoxName.Text;
             if (name_or_py != "姓名或者拼音首字母" && name_or_py != "")
             {
-                condition_list.Add(" and (name LIKE \'%"+ name_or_py +"%\' or firstLetterPY LIKE \'%"+ name_or_py +"%\') ");
-            }
-
-            //身份证号
-            if (textBoxIDNumber.Text != "")
-            {
-                condition_list.Add("  and idNum = '" + textBoxIDNumber.Text + "' ");
+                condition_list.Add(" and (p_name LIKE \'%"+ name_or_py +"%\' or p_name_py LIKE \'%"+ name_or_py +"%\') ");
             }
 
             //病例编号
             if(textBoxCaseID.Text != "")
             {
-                condition_list.Add("  and record_id = '" + textBoxCaseID.Text + "' ");
+                condition_list.Add("  and p_record_id = '" + textBoxCaseID.Text + "' ");
             }
 
             //孕次
@@ -187,50 +155,7 @@ namespace WpfTest1
                     MessageBox.Show("孕次信息格式不正确,请填写一个整数数字。\r\n调试信息:"+err.Message,"警告");
                     return;
                 }
-                condition_list.Add("  and pregnancy_times = " + pt_temp + " ");
-            }
-
-            //产次
-            if (textBoxProductionTime.Text != "")
-            {
-                string bt_temp = "";
-                try
-                {
-                    bt_temp = Convert.ToString(Convert.ToInt32(textBoxProductionTime.Text));
-                }
-                catch (Exception err)
-                {
-                    MessageBox.Show("产次信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
-                    return;
-                }
-                condition_list.Add("  and birth_times = " + bt_temp + " ");
-            }
-
-            //怀孕日期
-            if(datePickerTimeStart.Text != "" && datePickerTimeEnd.Text != "")
-            {
-
-
-                DateTime dt;
-                System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
-                //MessageBox.Show(pregnancydate);
-                dtFormat.ShortDatePattern = "yyyy/M/d";
-                string dateStart = datePickerTimeStart.Text;
-                string dateEnd = datePickerTimeEnd.Text;
-                try
-                {
-                    dt = Convert.ToDateTime(dateStart, dtFormat);
-                    dateStart = dt.ToString("yyyy-MM-dd");
-                    dt = Convert.ToDateTime(dateEnd, dtFormat);
-                    dateEnd = dt.ToString("yyyy-MM-dd");
-                }
-                catch (Exception err)
-                {
-                    MessageBox.Show("推测怀孕日期格式不正确,请通过栏中日历的按钮选择日期。\r\n调试信息:" + err.Message, "警告");
-                    return;
-                }
-                condition_list.Add("  and (pregnancy_date between '" + dateStart + "' and '" + dateEnd + "') ");
-
+                condition_list.Add("  and p_pregnancy_time = " + pt_temp + " ");
             }
 
             //出生日期
@@ -255,7 +180,7 @@ namespace WpfTest1
                     MessageBox.Show("孕妇出生日期格式不正确,请通过栏中日历的按钮选择日期。\r\n调试信息:" + err.Message, "警告");
                     return;
                 }
-                condition_list.Add("  and (birth_date between '" + dateStart + "' and '" + dateEnd + "') ");
+                condition_list.Add("  and (p_birthdate between '" + dateStart + "' and '" + dateEnd + "') ");
 
             }
 
@@ -274,7 +199,7 @@ namespace WpfTest1
                     MessageBox.Show("身高信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
                     return;
                 }
-                condition_list.Add("  and (height between " + hs_temp + " and "+ he_temp + ") ");
+                condition_list.Add("  and (p_height between " + hs_temp + " and "+ he_temp + ") ");
             }
 
             //体重条件
@@ -292,35 +217,7 @@ namespace WpfTest1
                     MessageBox.Show("体重信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
                     return;
                 }
-                condition_list.Add("  and (weight between " + ws_temp + " and " + we_temp + ") ");
-            }
-
-            //基础心率条件
-            if (textBoxHeartRateStart.Text != "" && textBoxHeartRateEnd.Text != "")
-            {
-                string bhs_temp = "";
-                string bhe_temp = "";
-                try
-                {
-                    bhs_temp = Convert.ToString(Convert.ToInt32(textBoxHeartRateStart.Text));
-                    bhe_temp = Convert.ToString(Convert.ToInt32(textBoxHeartRateEnd.Text));
-                }
-                catch (Exception err)
-                {
-                    MessageBox.Show("基础心率信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
-                    return;
-                }
-                condition_list.Add("  and (base_heartrate between " + bhs_temp + " and " + bhe_temp + ") ");
-            }
-            //用户分类条件
-            if (comboBoxCategory.SelectedIndex > -1)
-            {
-                condition_list.Add("  and category = '" + comboBoxCategory.SelectedValue + "' ");
-            }
-            //用户组条件
-            if (comboBoxGroup_1.SelectedIndex != -1)
-            {
-                condition_list.Add("  and group_1 = '" + comboBoxGroup_1.SelectedValue + "' ");
+                condition_list.Add("  and (p_weight between " + ws_temp + " and " + we_temp + ") ");
             }
 
             //连接字符串
@@ -328,12 +225,12 @@ namespace WpfTest1
             //连接对象
             SQLiteConnection con = new SQLiteConnection(Connstr);
             //Sql语句
-            string selectCmd = "SELECT * FROM Patient WHERE delete_flag = 0";
+            string selectCmd = "SELECT * FROM Patient WHERE p_delete_flag = 0";
             foreach(string one_more_condition in condition_list)
             {
                 selectCmd += one_more_condition;
             }
-            selectCmd += " ORDER BY lastRecordDate desc LIMIT 1000;";
+            selectCmd += " ORDER BY p_last_filter_time desc LIMIT 1000;";
             con.Open();
             da = new SQLiteDataAdapter(selectCmd, con);
             ds = new DataSet();
@@ -358,7 +255,7 @@ namespace WpfTest1
                 if (this.Name == "selectUserHistory")
                 {
                     //father.buttonSelectPaitentHistory_Click(this.father, e);
-                    father.bugFixHostory = true;
+                    //father.bugFixHostory = true;
                     //father.selectUserHistory.LoadDataGrid();
                     //MessageBox.Show(this.father.tabControlHistory.SelectedIndex.ToString());
                 }