Selaa lähdekoodia

Add Evaluation and History function

+Add Evaluation function
+Add History Function
ZhuYifan 5 vuotta sitten
vanhempi
commit
2990350fff

+ 81 - 28
WpfTest1/MainWindow.xaml

@@ -113,7 +113,7 @@
                             </DataTemplate>
                             </DataTemplate>
                         </Button.ContentTemplate>
                         </Button.ContentTemplate>
                     </Button>
                     </Button>
-                    <Button x:Name="buttonHomePageMeasureFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b">
+                    <Button x:Name="buttonHomePageMeasureFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b" Click="buttonHomePageMeasureFunction_Click">
                         <Button.ContentTemplate>
                         <Button.ContentTemplate>
                             <DataTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                 <StackPanel>
@@ -127,7 +127,7 @@
                             </DataTemplate>
                             </DataTemplate>
                         </Button.ContentTemplate>
                         </Button.ContentTemplate>
                     </Button>
                     </Button>
-                    <Button x:Name="buttonHomePageHistoryRecord" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520">
+                    <Button x:Name="buttonHomePageHistoryRecord" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520" Click="buttonHomePageHistoryRecord_Click">
                         <Button.ContentTemplate>
                         <Button.ContentTemplate>
                             <DataTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                 <StackPanel>
@@ -224,24 +224,96 @@
                     </TabItem>
                     </TabItem>
                     <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
                     <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
                         <Grid Background="White" Margin="0,0,0,0">
                         <Grid Background="White" Margin="0,0,0,0">
-                            
-                            <Button x:Name="buttonAbortFilter" Content="中止筛查" HorizontalAlignment="Left" Margin="1150,35,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortFilter_Click"/>
-                            <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="490,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelFilterNumberofTotalQuestions" Content="XXX" HorizontalAlignment="Left" Margin="530,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="600,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="760,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="830,36,0,0" VerticalAlignment="Top" FontSize="30"/>
+                            <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterNumberofTotalQuestions" Content="XXX" HorizontalAlignment="Left" Margin="110,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="240,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="280,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
                             <TextBlock x:Name="textBlockFilterQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
                             <TextBlock x:Name="textBlockFilterQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
                             <Grid x:Name="gridFilterSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
                             <Grid x:Name="gridFilterSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
                             <Button x:Name="buttonFilterPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterPrevious_Click" />
                             <Button x:Name="buttonFilterPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterPrevious_Click" />
                             <Button x:Name="buttonFilterNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterNext_Click" />
                             <Button x:Name="buttonFilterNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterNext_Click" />
                             <Button x:Name="buttonSubmitFilter" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitFilter_Click"/>
                             <Button x:Name="buttonSubmitFilter" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitFilter_Click"/>
+                            <Button x:Name="buttonAbortFilter" Content="中止筛查" HorizontalAlignment="Left" Margin="1150,550,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortFilter_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="筛查报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDF" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonFilterBackToSelectUser" Content="开始新的筛查" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonFilterBackToSelectUser_Click" />
+                            <Button x:Name="buttonFilterBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonFilterBackToHome_Click" />
+                        </Grid>
+                    </TabItem>
+                </TabControl>
+
+            </TabItem>
+            <!--评估-->
+            <TabItem Header="评估" Style="{StaticResource smallHeader}" >
+                <TabControl x:Name="tabEvaluation" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
+                    <TabItem  Header="选择用户" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <my:selectUser x:Name="selectUserevaluation" Margin="0,0,0,0"/>
+                            <Button x:Name="buttonEvaluationSelectPatient" IsEnabled="True" Content="开始测试" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonEvaluationSelectPatient_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelTiE" Content="当前第" HorizontalAlignment="Left" Margin="94,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelQuestionNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi2E" Content="题" HorizontalAlignment="Left" Margin="190,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
+                            <TextBlock x:Name="textBlockEvaluationQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
+                            <Grid x:Name="gridEvaluationSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
+                            <Button x:Name="buttonEvaluationPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationPrevious_Click" />
+                            <Button x:Name="buttonEvaluationNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationNext_Click" />
+                            <Button x:Name="buttonSubmitEvaluation" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitEvaluation_Click"/>
+                            <Button x:Name="buttonAbortEvaluation" Content="中止评估" HorizontalAlignment="Left" Margin="1150,550,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortEvaluation_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDFE" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonEvaluationBackToSelectUser" Content="开始新的评估" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonEvaluationBackToSelectUser_Click" />
+                            <Button x:Name="buttonEvaluationBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonEvaluationBackToHome_Click" />
                         </Grid>
                         </Grid>
                     </TabItem>
                     </TabItem>
                 </TabControl>
                 </TabControl>
+            </TabItem>
 
 
+            <TabItem Header="历史报告" Style="{StaticResource smallHeader}" >
+                <TabControl x:Name="tabHistoryRecords" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
+                    <TabItem  Header="选择病例" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <my:selectUser x:Name="selectUserHistory" Margin="0,0,0,0"/>
+                            <Button x:Name="buttonHistorySelectPatient" IsEnabled="True" Content="选择该病例" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonHistorySelectPatient_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="选择记录" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <DataGrid x:Name="dataGridRecords" AutoGenerateColumns="False" IsReadOnly="True"  HorizontalAlignment="Left" Margin="299,10,0,0" VerticalAlignment="Top" Height="603" Width="1039" Loaded="LoadDoctorDataGrid" MouseDoubleClick="dataGridRecords_MouseDoubleClick">
+                                <DataGrid.Columns>
+                                    <DataGridTextColumn Header="报告编号" Binding="{Binding r_id}" Width="180"/>
+                                    <DataGridTextColumn Header="报告类型" Binding="{Binding r_type_d}" Width="150"/>
+                                    <DataGridTextColumn Header="生成时间" Binding="{Binding r_time}" Width="180"/>
+                                    <DataGridTextColumn Header="已生成次数" Binding="{Binding r_count}" Width="120"/>
+                                </DataGrid.Columns>
+                            </DataGrid>
+                            <Button x:Name="buttonRegenerateReport" FontSize="18" Content="生成该报告" HorizontalAlignment="Left" Margin="26,40,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonRegenerateReport_Click"/>
+                            <Button x:Name="buttonHistoryBack" FontSize="18" Content="返回上一级" HorizontalAlignment="Left" Margin="26,98,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonHistoryBackToSelectUser_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDFH" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonHistoryBackToSelectUser" Content="重新选择病例" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectUser_Click" />
+                            <Button x:Name="buttonHistoryBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToHome_Click" />
+                        </Grid>
+                    </TabItem>
+                </TabControl>
             </TabItem>
             </TabItem>
 
 
+
             <TabItem Header="系统设置" x:Name="tabitemDoctorSetting" Style="{StaticResource smallHeader}">
             <TabItem Header="系统设置" x:Name="tabitemDoctorSetting" Style="{StaticResource smallHeader}">
                 <TabControl x:Name="tabControlSystemSetting" HorizontalAlignment="Left" Height="645" Margin="10,-5,0,0" VerticalAlignment="Top" Width="1338" SelectionChanged="tabControlSystemSetting_SelectionChanged">
                 <TabControl x:Name="tabControlSystemSetting" HorizontalAlignment="Left" Height="645" Margin="10,-5,0,0" VerticalAlignment="Top" Width="1338" SelectionChanged="tabControlSystemSetting_SelectionChanged">
                     <TabItem Header="医师账户管理" Style="{StaticResource smallerHeader}" >
                     <TabItem Header="医师账户管理" Style="{StaticResource smallerHeader}" >
@@ -263,25 +335,6 @@
                             <Button x:Name="buttonChangeDoctorPWD" FontSize="18" Content="修改医师密码" HorizontalAlignment="Left" Margin="26,154,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonChangeDoctorPWD_Click"/>
                             <Button x:Name="buttonChangeDoctorPWD" FontSize="18" Content="修改医师密码" HorizontalAlignment="Left" Margin="26,154,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonChangeDoctorPWD_Click"/>
                         </Grid>
                         </Grid>
                     </TabItem>
                     </TabItem>
-                    <!--<TabItem Header="常用语编辑" Style="{StaticResource smallerHeader}" >
-                        <Grid x:Name="Seeting_PasswordManagent" Background="White" Margin="0,0,0,0">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition Width="71*"/>
-                                <ColumnDefinition Width="1165*"/>
-                            </Grid.ColumnDefinitions>
-                            <DataGrid x:Name="dataGridCommlang" AutoGenerateColumns="False" IsReadOnly="True" HorizontalAlignment="Left" Margin="228,10,0,0" VerticalAlignment="Top" Height="626" Width="914" Grid.Column="1" Loaded="commlangGrid_Loaded" MouseDoubleClick="dataGridCommlang_MouseDoubleClick">
-                                <DataGrid.Columns>
-                                    <DataGridTextColumn Header="编号" Binding="{Binding id}" Width="90"/>
-                                    <DataGridTextColumn Header="内容" Binding="{Binding content}" Width="500"/>
-                                    <DataGridTextColumn Header="简单描述" Binding="{Binding describe}" Width="200"/>
-                                </DataGrid.Columns>
-                            </DataGrid>
-                            <Button x:Name="buttonAddCommlang" FontSize="18" Content="新增常用语" HorizontalAlignment="Left" Margin="26,40,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonAddCommlang_Click"/>
-                            <Button x:Name="buttonChangeCommlang" FontSize="18" Content="修改常用语" HorizontalAlignment="Left" Margin="26,102,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonChangeCommlang_Click"/>
-                            <Button x:Name="buttonDeleteCommlang" FontSize="18" Content="删除常用语" HorizontalAlignment="Left" Margin="26,162,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonDeleteCommlang_Click"/>
-
-                        </Grid>
-                    </TabItem>-->
                     <TabItem Header="软件激活管理及其他设置" Style="{StaticResource smallerHeader}" >
                     <TabItem Header="软件激活管理及其他设置" Style="{StaticResource smallerHeader}" >
                         <Grid>
                         <Grid>
                             <GroupBox x:Name="groupBoxRegisterInfo" Header="软件激活信息" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="113" Width="1314">
                             <GroupBox x:Name="groupBoxRegisterInfo" Header="软件激活信息" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="113" Width="1314">

+ 528 - 18
WpfTest1/MainWindow.xaml.cs

@@ -10,6 +10,7 @@ using System.Data;
 using WpfTest1.SQLite;
 using WpfTest1.SQLite;
 using WpfTest1.Toolkits;
 using WpfTest1.Toolkits;
 using LitJson;
 using LitJson;
+using System.ComponentModel;
 
 
 namespace WpfTest1
 namespace WpfTest1
 {
 {
@@ -27,16 +28,23 @@ namespace WpfTest1
         //double lowBp;                                         //BP界面低压
         //double lowBp;                                         //BP界面低压
         DateTime lastSettingLogin;                              //上一次在系统设置界面登陆的时间
         DateTime lastSettingLogin;                              //上一次在系统设置界面登陆的时间
         public Toolkits.Config cfg;                //从数据库取配置的类
         public Toolkits.Config cfg;                //从数据库取配置的类
-        #endregion
 
 
-        #region 优化系统效率参数
         Patient filterPatient;
         Patient filterPatient;
+        Patient evaluationPatient;
+        Patient historyPatient;
+        Record filterReportForEvaluation;
+        bool flagEvaluationWithoutFilter = true;
         List<QuestionAnswerPair> filterQuestionaire = new List<QuestionAnswerPair>();
         List<QuestionAnswerPair> filterQuestionaire = new List<QuestionAnswerPair>();
         List<QuestionAnswerPair> evaluationQuestionaire = new List<QuestionAnswerPair>();
         List<QuestionAnswerPair> evaluationQuestionaire = new List<QuestionAnswerPair>();
         List<UserSelection> filterUserSelection = new List<UserSelection>();
         List<UserSelection> filterUserSelection = new List<UserSelection>();
-        List<UserSelection> evaluation = new List<UserSelection>();
+        List<UserSelection> evaluationUserSelection = new List<UserSelection>();
+        string resultsFilter;
+        string resultsEvaluation;
         int currentFilterCount = 0;
         int currentFilterCount = 0;
-        
+        int currentEvaluationCount = 0;
+        List<Record> recordsFromOnePatient;
+        BindingList<Record> bindingRecords;
+
         #endregion
         #endregion
 
 
         public MainWindow()
         public MainWindow()
@@ -47,8 +55,9 @@ namespace WpfTest1
             //绑定三个selectUser的父类
             //绑定三个selectUser的父类
             //selectUserMeasure.setMainWindow(this);
             //selectUserMeasure.setMainWindow(this);
             selectUserPatientManagent.setMainWindow(this);
             selectUserPatientManagent.setMainWindow(this);
-            //selectUserHistory.setMainWindow(this);
-
+            selectUserfilter.setMainWindow(this);
+            selectUserevaluation.setMainWindow(this);
+            selectUserHistory.setMainWindow(this);
         }
         }
 
 
         #region 初始化与系统调用部分
         #region 初始化与系统调用部分
@@ -89,7 +98,7 @@ namespace WpfTest1
             List<Question> questions = SQLite.SQLiteModel.getQuestions(type);
             List<Question> questions = SQLite.SQLiteModel.getQuestions(type);
             foreach (Question oneQuestion in questions)
             foreach (Question oneQuestion in questions)
             {
             {
-                List<Answer> answers = SQLite.SQLiteModel.getAnswersByQid(oneQuestion.q_id.ToString());
+                List<Answer> answers = SQLite.SQLiteModel.getAnswersByQid(oneQuestion.q_id);
                 QuestionAnswerPair temp = new QuestionAnswerPair(oneQuestion, answers);
                 QuestionAnswerPair temp = new QuestionAnswerPair(oneQuestion, answers);
                 oneQuestionaire.Add(temp);
                 oneQuestionaire.Add(temp);
             }
             }
@@ -270,6 +279,9 @@ namespace WpfTest1
         private void buttonAbortFilter_Click(object sender, RoutedEventArgs e)
         private void buttonAbortFilter_Click(object sender, RoutedEventArgs e)
         {
         {
             filterUserSelection.Clear();
             filterUserSelection.Clear();
+            filterPatient = null;
+            resultsFilter = "";
+
             currentFilterCount = 0;
             currentFilterCount = 0;
             buttonFilterPrevious.IsEnabled = false;
             buttonFilterPrevious.IsEnabled = false;
             buttonFilterNext.IsEnabled = false;
             buttonFilterNext.IsEnabled = false;
@@ -341,6 +353,7 @@ namespace WpfTest1
         {
         {
             labelFilterNumberofTotalQuestions.Content = filterQuestionaire.Count.ToString();
             labelFilterNumberofTotalQuestions.Content = filterQuestionaire.Count.ToString();
             labelFilterNumberofCurrentQuestion.Content = currentIndex.ToString();
             labelFilterNumberofCurrentQuestion.Content = currentIndex.ToString();
+            labelFilterQuestionTitle.Content = filterQuestionaire[currentIndex - 1].question.q_title;
             textBlockFilterQuetionContent.Text = filterQuestionaire[currentIndex - 1].question.q_content;
             textBlockFilterQuetionContent.Text = filterQuestionaire[currentIndex - 1].question.q_content;
             int countOptions = filterQuestionaire[currentIndex - 1].answers.Count;
             int countOptions = filterQuestionaire[currentIndex - 1].answers.Count;
             gridFilterSelection.Children.Clear();
             gridFilterSelection.Children.Clear();
@@ -381,27 +394,507 @@ namespace WpfTest1
         /// <param name="e">默认</param>
         /// <param name="e">默认</param>
         private void buttonSubmitFilter_Click(object sender, RoutedEventArgs e)
         private void buttonSubmitFilter_Click(object sender, RoutedEventArgs e)
         {
         {
-            MessageBoxResult dr = MessageBox.Show("确定提交吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            int inserted_r_id;
+            resultsFilter = JsonMapper.ToJson(filterUserSelection);
+            //MessageBox.Show(results);
+            try
+            {
+                inserted_r_id = SQLiteModel.insertRecord(1, filterPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
+                SQLiteModel.UpdatePatientDataWithLastDate(filterPatient.p_id, "p_last_filter_time", DateTime.Now);
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            MessageBoxResult dr = MessageBox.Show("保存筛查结果成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
             if (dr == MessageBoxResult.OK)
             if (dr == MessageBoxResult.OK)
             {
             {
-                string results = JsonMapper.ToJson(filterUserSelection);
-                //MessageBox.Show(results);
-                try
+                Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                ReportGenerater.generateReport(1, filterPatient, loginDoctor, targetRecord, cfg.organization_name);
+                SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                tabFilter.SelectedIndex = 2;
+            }
+            else
+            {
+                buttonAbortFilter_Click(sender, e);
+            }
+            return;
+        }
+
+        /// <summary>
+        /// 返回至选择用户页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonFilterBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortFilter_Click(sender, e);
+        }
+
+        /// <summary>
+        /// 返回至选择首页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonFilterBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortFilter_Click(sender, e);
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        #endregion
+
+        #region 评估功能
+
+        /// <summary>
+        /// 点击开始评估后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        public void buttonEvaluationSelectPatient_Click(object sender, RoutedEventArgs e)
+        {
+            //基本逻辑如下:先找七天内与病例相匹配的筛查记录,如果有,那么要取出结果一题一题比对
+            //如果没有,那么应当把筛查题进行加载处理
+            try
+            {
+                var target = (DataRowView)this.selectUserevaluation.dataGrid.SelectedItem;
+                evaluationPatient = SQLite.SQLiteModel.getPatientById(target["p_id"].ToString());
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "警告");
+                return;
+            }
+            if (evaluationPatient == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+            try
+            {
+                loadQuestionaire(filterQuestionaire, "filter");
+                evaluationQuestionaire.Clear();
+                filterUserSelection.Clear();
+                evaluationUserSelection.Clear();
+                //这里尝试加载用户的筛查记录
+                filterReportForEvaluation = SQLiteModel.getLatestXTypeRecordInYDays(evaluationPatient.p_id, 1, 7);
+                if(filterReportForEvaluation == null)
                 {
                 {
-                    SQLiteModel.insertRecord(1, filterPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, results);
-                    SQLiteModel.UpdatePatientDataWithLastDate(filterPatient.p_id, "p_last_filter_time", DateTime.Now);
+                    flagEvaluationWithoutFilter = true;
+                    foreach (QuestionAnswerPair qa in filterQuestionaire)
+                    {
+                        filterUserSelection.Add(new UserSelection(qa.question.q_id, 0));
+                    }
                 }
                 }
-                catch (Exception err)
+                else
                 {
                 {
-                    MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
-                    return;
+                    var jsonUserSelections = filterReportForEvaluation.r_selection;
+                    filterUserSelection = JsonMapper.ToObject<List<UserSelection>>(jsonUserSelections);
+                    flagEvaluationWithoutFilter = false;
                 }
                 }
-                MessageBox.Show("保存成功", "提示");
-                buttonAbortFilter_Click(sender, e);
+                
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("筛查题目加载失败\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            if (filterQuestionaire.Count == 0)
+            {
+                MessageBox.Show("筛查题目加载失败\r\n数据库中无有效问卷", "错误");
+                return;
+            }
+            if (flagEvaluationWithoutFilter)
+            {
+                MessageBox.Show("发现该病例一周内未进行初筛,评估过程中将自动进行初筛。","提示");
+            }
+            else
+            {
+                MessageBox.Show("发现该病例于"+ filterReportForEvaluation.r_time.ToString("yyyy-MM-dd HH:mm:ss") +"进行过初筛,评估过程中将使用此初筛结果。", "提示");
+            }
+            currentFilterCount = 1;
+            currentEvaluationCount = 1;
+            evaluationQuestionaire.Add(filterQuestionaire[currentFilterCount - 1]);
+            evaluationUserSelection.Add(filterUserSelection[currentFilterCount - 1]);
+            tabEvaluation.SelectedIndex += 1;
+            checkStatusEvaluation();
+        }
+
+        /// <summary>
+        /// 加载currentIndex的评估题目功能
+        /// </summary>
+        /// <param name="currentIndex">需要显示题目的题号</param>
+        private void loadQuestionViewEvaluation(int currentIndex)
+        {
+            labelQuestionNumberofCurrentQuestion.Content = currentIndex.ToString();
+            labelEvaluationQuestionTitle.Content = evaluationQuestionaire[currentIndex - 1].question.q_title;
+            textBlockEvaluationQuetionContent.Text = evaluationQuestionaire[currentIndex - 1].question.q_content;
+            int countOptions = evaluationQuestionaire[currentIndex - 1].answers.Count;
+            gridEvaluationSelection.Children.Clear();
+            for (int i = 0; i < countOptions; ++i)
+            {
+                RadioButton oneOption = new RadioButton();
+                oneOption.Height = 30;
+                oneOption.HorizontalAlignment = HorizontalAlignment.Left;
+                oneOption.VerticalAlignment = VerticalAlignment.Top;
+                oneOption.Margin = new Thickness(i / 5 * 200, i % 5 * 40, 0, 0);
+                if (evaluationUserSelection[currentIndex - 1].a_id == evaluationQuestionaire[currentIndex - 1].answers[i].a_id)
+                    oneOption.IsChecked = true;
+                else
+                    oneOption.IsChecked = false;
+                oneOption.Content = evaluationQuestionaire[currentIndex - 1].answers[i].a_content;
+               oneOption.Checked += radioButtonEvaluation_Checked;
+               oneOption.GroupName = "evaluationOption";
+               oneOption.FontSize = 18;
+               oneOption.Name = "rbe" + evaluationQuestionaire[currentIndex - 1].answers[i].a_id.ToString();
+               gridEvaluationSelection.Children.Add(oneOption);
+            }
+        }
+
+        /// <summary>
+        /// 检查当前答题状态,判断是否需要跳过该题和控制加载题目的功能,能够维护userselection和questionaire
+        /// </summary>
+        private void checkStatusEvaluation()
+        {
+            if(!flagEvaluationWithoutFilter && evaluationQuestionaire[currentEvaluationCount-1].question.q_type == 1)
+            {
+                //有预加载的筛查报告且当前问题是一道筛查题
+                Answer aTemp = SQLiteModel.getAnswerById(filterUserSelection[currentFilterCount - 1].a_id);
+                if (aTemp == null || aTemp.next_q_id == 0)
+                {
+                    if(currentFilterCount == filterQuestionaire.Count)
+                    {
+                        //当前所有题目都已经做完了
+                        buttonEvaluationNext.IsEnabled = false;
+                        bool allQuestionAreSeleceted = true;
+                        foreach (UserSelection us in evaluationUserSelection)
+                        {
+                            if (us.a_id == 0)
+                                allQuestionAreSeleceted = false;
+                        }
+                        //经过检查可以提交
+                        buttonSubmitEvaluation.IsEnabled = allQuestionAreSeleceted;
+                    }
+                    else
+                    {
+                        //还有剩下的筛选题没有过
+                        QuestionAnswerPair qaPairEvaluation = filterQuestionaire[currentFilterCount];
+                        //当前元素后面的题目和选项都清空
+                        for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                        {
+                            evaluationQuestionaire.RemoveAt(i);
+                            evaluationUserSelection.RemoveAt(i);
+                        }
+                        evaluationQuestionaire.Add(qaPairEvaluation);
+                        evaluationUserSelection.Add(filterUserSelection[currentFilterCount]);
+                        //再刷新一次
+                        ++currentFilterCount;
+                        ++currentEvaluationCount;
+                        checkStatusEvaluation();
+                    }
+
+                }
+                else
+                {
+                    //否则还有评估题没做
+                    Question aEvaluationQuestion = SQLiteModel.getQuestionById(aTemp.next_q_id);
+                    List<Answer> answersToTheEvaluation = SQLiteModel.getAnswersByQid(aEvaluationQuestion.q_id);
+                    QuestionAnswerPair qaPairEvaluation = new QuestionAnswerPair(aEvaluationQuestion, answersToTheEvaluation);
+                    //当前元素后面的题目和选项都清空
+                    for(int i= evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                    {
+                        evaluationQuestionaire.RemoveAt(i);
+                        evaluationUserSelection.RemoveAt(i);
+                    }
+                    evaluationQuestionaire.Add(qaPairEvaluation);
+                    evaluationUserSelection.Add(new UserSelection(aEvaluationQuestion.q_id, 0));
+                    //再刷新一次
+                    ++currentEvaluationCount;
+                    checkStatusEvaluation();
+                }
+            }
+            else
+            {
+                //其他情况:没有预加载的筛选题或者有预加载的筛选题但是是一道评估题
+                loadQuestionViewEvaluation(currentEvaluationCount);
+                buttonEvaluationNext.IsEnabled = false;
+                buttonSubmitEvaluation.IsEnabled = false;
+            }
+        }
+
+        /// <summary>
+        /// 评估单选选项被选中的触发事件,主要是修改内存中的选择和判断下一题及提交按钮是否可用
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void radioButtonEvaluation_Checked(object sender, RoutedEventArgs e)
+        {
+            //首先,记录该选择
+            RadioButton oneSelection = (RadioButton)sender;
+            evaluationUserSelection[currentEvaluationCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
+            if (flagEvaluationWithoutFilter)
+            {
+                filterUserSelection[currentFilterCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
+            }
+            //MessageBox.Show(filterUserSelection[currentFilterCount - 1].a_id.ToString());
+            Answer oneAnswer = SQLiteModel.getAnswerById(evaluationUserSelection[currentEvaluationCount - 1].a_id);
+            if(currentFilterCount == filterQuestionaire.Count && oneAnswer.next_q_id == 0)
+            {
+                //后面没有题目了,可以提交
+                buttonEvaluationNext.IsEnabled = false;
+                bool allQuestionAreSeleceted = true;
+                foreach (UserSelection us in evaluationUserSelection)
+                {
+                    if (us.a_id == 0)
+                        allQuestionAreSeleceted = false;
+                }
+                //经过检查可以提交
+                buttonSubmitEvaluation.IsEnabled = allQuestionAreSeleceted;
+            }
+            else
+            {
+                //否则可以做下一题
+                buttonEvaluationNext.IsEnabled = true;
+                buttonSubmitEvaluation.IsEnabled = false;
+            }
+            
+        }
+
+        /// <summary>
+        /// (未实现)评估过程中点击上一题的触发事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationPrevious_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        /// <summary>
+        /// 点击评估页下一题后触发的事件,主要是判断接下来加载哪一题
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationNext_Click(object sender, RoutedEventArgs e)
+        {
+            //先看看后面有没有进退阶题目了
+            Answer oneAnswer = SQLiteModel.getAnswerById(evaluationUserSelection[currentEvaluationCount - 1].a_id);
+            if(oneAnswer.next_q_id!= 0)
+            {
+                //还有后续题目
+                Question aEvaluationQuestion = SQLiteModel.getQuestionById(oneAnswer.next_q_id);
+                List<Answer> answersToTheEvaluation = SQLiteModel.getAnswersByQid(aEvaluationQuestion.q_id);
+                QuestionAnswerPair qaPairEvaluation = new QuestionAnswerPair(aEvaluationQuestion, answersToTheEvaluation);
+                //当前元素后面的题目和选项都清空
+                for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                {
+                    evaluationQuestionaire.RemoveAt(i);
+                    evaluationUserSelection.RemoveAt(i);
+                }
+                evaluationQuestionaire.Add(qaPairEvaluation);
+                evaluationUserSelection.Add(new UserSelection(aEvaluationQuestion.q_id, 0));
+                //再刷新一次
+                ++currentEvaluationCount;
+                checkStatusEvaluation();
+            }
+            else
+            {
+                //否则跳到下一个筛选题上面
+                QuestionAnswerPair qaPairEvaluation = filterQuestionaire[currentFilterCount];
+                //当前元素后面的题目和选项都清空
+                for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                {
+                    evaluationQuestionaire.RemoveAt(i);
+                    evaluationUserSelection.RemoveAt(i);
+                }
+                evaluationQuestionaire.Add(qaPairEvaluation);
+                evaluationUserSelection.Add(filterUserSelection[currentFilterCount]);
+                //再刷新一次
+                ++currentFilterCount;
+                ++currentEvaluationCount;
+                checkStatusEvaluation();
+            }
+        }
+
+        /// <summary>
+        /// 点击评估页提交后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonSubmitEvaluation_Click(object sender, RoutedEventArgs e)
+        {
+            int inserted_r_id;
+            resultsFilter = JsonMapper.ToJson(filterUserSelection);
+            resultsEvaluation = JsonMapper.ToJson(evaluationUserSelection);
+            try
+            {
+                if (flagEvaluationWithoutFilter)
+                {
+                    int tempRId = SQLiteModel.insertRecord(1, evaluationPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
+                    SQLiteModel.UpdatePatientDataWithLastDate(evaluationPatient.p_id, "p_last_filter_time", DateTime.Now);
+                    filterReportForEvaluation.r_id = tempRId;
+                }
+                inserted_r_id = SQLiteModel.insertRecord(2, evaluationPatient.p_id, loginDoctor.id, filterReportForEvaluation.r_id, DateTime.Now, 0, resultsEvaluation);
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            MessageBoxResult dr = MessageBox.Show("保存成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (dr == MessageBoxResult.OK)
+            {
+                Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                ReportGenerater.generateReport(2, evaluationPatient, loginDoctor, targetRecord, cfg.organization_name);
+                tabEvaluation.SelectedIndex = 2;
+            }
+            else
+            {
+                buttonAbortEvaluation_Click(sender, e);
             }
             }
             return;
             return;
         }
         }
 
 
+        /// <summary>
+        /// 点击评估页中止评估后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonAbortEvaluation_Click(object sender, RoutedEventArgs e)
+        {
+            //清理相关变量
+            filterQuestionaire.Clear();
+            filterUserSelection.Clear();
+            evaluationQuestionaire.Clear();
+            evaluationUserSelection.Clear();
+            flagEvaluationWithoutFilter = true;
+            filterReportForEvaluation = null;
+            evaluationPatient = null;
+            resultsFilter = "";
+            resultsEvaluation = "";
+
+            currentFilterCount = 0;
+            currentEvaluationCount = 0;
+            //buttonFilterPrevious.IsEnabled = false;
+            buttonEvaluationNext.IsEnabled = false;
+            buttonSubmitEvaluation.IsEnabled = false;
+
+            tabEvaluation.SelectedIndex = 0;
+        }
+
+        /// <summary>
+        /// 返回至选择用户页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortEvaluation_Click(sender, e);
+        }
+
+        /// <summary>
+        /// 返回至选择首页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortEvaluation_Click(sender, e);
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        #endregion
+
+        #region 历史记录
+
+        /// <summary>
+        /// 点击选择病例查看其历史记录后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        public void buttonHistorySelectPatient_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.selectUserHistory.dataGrid.SelectedItem;
+                historyPatient = SQLiteModel.getPatientById(Convert.ToString(target["p_id"]));
+                recordsFromOnePatient = SQLiteModel.getRecordsByPid(Convert.ToInt32(target["p_id"]));
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "警告");
+                return;
+            }
+            if (recordsFromOnePatient == null || historyPatient == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+
+            try
+            {
+                bindingRecords = new BindingList<Record>(recordsFromOnePatient);
+                dataGridRecords.ItemsSource = bindingRecords;
+            }
+            catch(Exception err)
+            {
+                MessageBox.Show("数据库加载异常\r\n调试信息:\r\n"+err.StackTrace, "错误");
+                return;
+            }
+            tabHistoryRecords.SelectedIndex = 1;
+        }
+
+        private void buttonHistoryBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            recordsFromOnePatient.Clear();
+            tabHistoryRecords.SelectedIndex = 0;
+        }
+
+        private void buttonHistoryBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            recordsFromOnePatient.Clear();
+            tabHistoryRecords.SelectedIndex = 0;
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        private void buttonRegenerateReport_Click(object sender, RoutedEventArgs e)
+        {
+            Record targetRecord;
+            try
+            {
+                var target = this.dataGridRecords.SelectedItem as Record;
+                targetRecord = SQLiteModel.getRecordByID(Convert.ToInt32(target.r_id));
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个记录进行生成\r\n" + err.StackTrace, "提示");
+                return;
+            }
+            if (targetRecord == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+            try
+            {
+                ReportGenerater.generateReport(targetRecord.r_type, historyPatient, loginDoctor, targetRecord, cfg.organization_name);
+                SQLiteModel.plusOneCountOnRecordByRid(targetRecord.r_id);
+            }
+            catch(Exception err)
+            {
+                MessageBox.Show("报告生成异常\r\n调试信息:\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            tabHistoryRecords.SelectedIndex = 2;
+        }
+
+        private void dataGridRecords_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            buttonRegenerateReport_Click(sender, e);
+        }
+
         #endregion
         #endregion
 
 
         #region 系统设置
         #region 系统设置
@@ -803,10 +1296,27 @@ namespace WpfTest1
 
 
 
 
 
 
+
+
+
+
         #endregion
         #endregion
 
 
         #endregion
         #endregion
 
 
+        private void buttonHomePageMeasureFunction_Click(object sender, RoutedEventArgs e)
+        {
+            Patient onePatient = SQLiteModel.getPatientById("1");
+            Record oneRecord = SQLiteModel.getRecordByID(7);
+            ReportGenerater.generateReport(2, onePatient, loginDoctor, oneRecord, cfg.organization_name);
+        }
+
+        private void buttonHomePageHistoryRecord_Click(object sender, RoutedEventArgs e)
+        {
+            string filename = Constants.reportPath + "\\" + "8" + ".pdf";
+            System.Diagnostics.Process.Start(filename);
+        }
+
         
         
     }
     }
 
 

+ 1 - 1
WpfTest1/SQLite/Answer.cs

@@ -10,7 +10,7 @@ namespace WpfTest1.SQLite
         public int a_id { get; set; }
         public int a_id { get; set; }
         public int q_id { get; set; } //1->filter; 2->evaluation
         public int q_id { get; set; } //1->filter; 2->evaluation
         public int a_value { get; set; }
         public int a_value { get; set; }
-        public int evaluation_q_id { get; set; }
+        public int next_q_id { get; set; }
         public string a_content { get; set; }
         public string a_content { get; set; }
         public string a_description_text { get; set; }
         public string a_description_text { get; set; }
         public string a_description_img { get; set; }
         public string a_description_img { get; set; }

+ 2 - 1
WpfTest1/SQLite/Question.cs

@@ -10,7 +10,8 @@ namespace WpfTest1.SQLite
         public int q_id { get; set; }
         public int q_id { get; set; }
         public int q_type { get; set; } //1->filter; 2->evaluation
         public int q_type { get; set; } //1->filter; 2->evaluation
         public int q_number { get; set; }
         public int q_number { get; set; }
+        public string q_title { get; set; }
         public string q_content { get; set; }
         public string q_content { get; set; }
-        public int filter_a_id { get; set; }
+        public int prior_a_id { get; set; }
     }
     }
 }
 }

+ 9 - 14
WpfTest1/SQLite/Record.cs

@@ -8,19 +8,14 @@ namespace WpfTest1.SQLite
 {
 {
     public class Record
     public class Record
     {
     {
-        public int id { get; set; }
-        public int patientId { get; set; }
-        public int doctorId { get; set; }
-        public DateTime recordTime { get; set; }
-        public byte[] dataLeft { get; set; }
-        public byte[] dataRight { get; set; }
-        public byte[] dataWrist { get; set; }
-        public double topBP { get; set; }
-        public double bottomBP { get; set; }
-        public double heartRate { get; set; }
-        public string waveTpye { get; set; }
-        public int eigenValueSaved { get; set; }
-        public string  comments { get; set; }
-        public string hand { get; set; }
+        public int r_id { get; set; }
+        public int r_type { get; set; }
+        public int p_id { get; set; }
+        public int d_id { get; set; }
+        public int filter_id { get; set; }
+        public DateTime r_time { get; set; }
+        public int r_count { get; set; }
+        public string r_selection { get; set; }
+        public string r_type_d { get; set; }
     }
     }
 }
 }

+ 148 - 10
WpfTest1/SQLite/SQLiteModel.cs

@@ -334,15 +334,16 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
-                    temp.q_content = reader.IsDBNull(3) ? "" : reader.GetString(3);
-                    temp.filter_a_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.q_title = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.q_content = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.prior_a_id = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
                     questions.Add(temp);
                     questions.Add(temp);
                 }
                 }
             }
             }
             return questions;
             return questions;
         }
         }
 
 
-        public static Question getQuestionById(string qid)
+        public static Question getQuestionById(int qid)
         { 
         { 
             string sql = "SELECT * FROM Question_template WHERE q_id=@qid LIMIT 1";
             string sql = "SELECT * FROM Question_template WHERE q_id=@qid LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteHelper db = new SQLiteHelper(dbPath);
@@ -357,8 +358,9 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
-                    temp.q_content = reader.IsDBNull(3) ? "" : reader.GetString(3);
-                    temp.filter_a_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.q_title = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.q_content = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.prior_a_id = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
                     return temp;
                     return temp;
                 }
                 }
             }
             }
@@ -368,7 +370,7 @@ namespace WpfTest1.SQLite
         #endregion
         #endregion
 
 
         #region Answer_template表相关操作
         #region Answer_template表相关操作
-        public static List<Answer> getAnswersByQid(string qid)
+        public static List<Answer> getAnswersByQid(int qid)
         {
         {
             List<Answer> questions = new List<Answer>();
             List<Answer> questions = new List<Answer>();
             string sql = "SELECT * FROM Answer_template WHERE q_id=@qid order by a_id asc";
             string sql = "SELECT * FROM Answer_template WHERE q_id=@qid order by a_id asc";
@@ -385,7 +387,7 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
-                    temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.next_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
@@ -396,7 +398,7 @@ namespace WpfTest1.SQLite
             return questions;
             return questions;
         }
         }
 
 
-        public static Answer getAnswerById(string aid)
+        public static Answer getAnswerById(int aid)
         {
         {
             string sql = "SELECT * FROM Answer_template WHERE a_id=@aid LIMIT 1";
             string sql = "SELECT * FROM Answer_template WHERE a_id=@aid LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteHelper db = new SQLiteHelper(dbPath);
@@ -412,7 +414,7 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
-                    temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.next_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
@@ -426,7 +428,17 @@ namespace WpfTest1.SQLite
 
 
         #region Record表相关操作
         #region Record表相关操作
 
 
-        public static void insertRecord(int r_type, int p_id, int d_id, int filter_id, DateTime r_time, int r_count, string r_selection)
+        /// <summary>
+        /// 插入报告一份,并返回报告的ID
+        /// </summary>
+        /// <param name="r_type">1-筛查,2-评估</param>
+        /// <param name="p_id">病例ID</param>
+        /// <param name="d_id">医生ID</param>
+        /// <param name="filter_id">如是评估报告,那么其遵顼的筛查记录ID</param>
+        /// <param name="r_time">报告时间</param>
+        /// <param name="r_count">报告计数</param>
+        /// <param name="r_selection">报告内容</param>
+        public static int insertRecord(int r_type, int p_id, int d_id, int filter_id, DateTime r_time, int r_count, string r_selection)
         {
         {
             string sql = "INSERT INTO Record(r_type,p_id,d_id,filter_id,r_time,r_count,r_selection)" +
             string sql = "INSERT INTO Record(r_type,p_id,d_id,filter_id,r_time,r_count,r_selection)" +
                             "values(@r_type,@p_id,@d_id,@filter_id,@r_time,@r_count,@r_selection)";
                             "values(@r_type,@p_id,@d_id,@filter_id,@r_time,@r_count,@r_selection)";
@@ -441,6 +453,132 @@ namespace WpfTest1.SQLite
                                                                new SQLiteParameter("@r_selection",r_selection)
                                                                new SQLiteParameter("@r_selection",r_selection)
                                                                };
                                                                };
             db.ExecuteNonQuery(sql, parameters);
             db.ExecuteNonQuery(sql, parameters);
+
+            //返回所插入的r_id
+            sql = "SELECT MAX(r_id) FROM Record;";
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    int max_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    return max_id;
+                }
+            }
+            return 0;
+        }
+
+        /// <summary>
+        /// 根据ID返回一份报告记录
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static Record getRecordByID(int r_id)
+        {
+            string sql = "SELECT * FROM Record WHERE r_id=@r_id LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@r_id",r_id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    return temp;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 根据ID返回一份报告记录
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static List<Record> getRecordsByPid(int p_id)
+        {
+            string sql = "SELECT * FROM Record WHERE p_id=@p_id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@p_id",p_id),
+                                                               };
+            List<Record> results = new List<Record>();
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    if (temp.r_type == 2)
+                        temp.r_type_d = "评估报告";
+                    else
+                        temp.r_type_d = "筛查报告";
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    results.Add(temp);
+                }
+            }
+            return results;
+        }
+
+        /// <summary>
+        /// 选取近days里某一病例的type类报告一份
+        /// </summary>
+        /// <param name="p_id">病例ID</param>
+        /// <param name="r_type">1-筛查,2-评估</param>
+        /// <param name="days">前多少天内有效</param>
+        public static Record getLatestXTypeRecordInYDays(int p_id, int r_type, int days)
+        {
+            DateTime dt = DateTime.Now;
+            string sql = "SELECT * FROM Record WHERE p_id=@p_id and r_time >=@r_time and r_type=@r_type LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@p_id",p_id),
+                                                               new SQLiteParameter("@r_type",r_type),
+                                                               new SQLiteParameter("@r_time",dt.AddDays(-days)),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time =reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    return temp;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 将r_id对应的记录生成计数+1
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static int plusOneCountOnRecordByRid(int r_id)
+        {
+            string sql = "UPDATE Record SET r_count=r_count+1 WHERE r_id=@r_id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@r_id",r_id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
         }
         }
 
 
         #endregion
         #endregion

+ 4 - 0
WpfTest1/SQLite/UserSelection.cs

@@ -19,5 +19,9 @@ namespace WpfTest1.SQLite
             q_id = q;
             q_id = q;
             a_id = a;
             a_id = a;
         }
         }
+        public UserSelection()
+        {
+
+        }
     }
     }
 }
 }

+ 0 - 54
WpfTest1/Toolkits/CSVWriter.cs

@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    public class CSVWriter
-    {
-        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.p_name +  ".csv", FileMode.Create);
-            StreamWriter sw = new StreamWriter(fs);
-            //开始写入
-            sw.Write("leftRed,leftInfrared,rightRed,rightInfrared\n");
-
-            int counter = new int[] { leftRed.Count, rightRed.Count, leftInfrared.Count, rightInfrared.Count }.Max();
-            for(int i = 0; i < counter; ++i)
-            {
-                string[] thisLine = new string[] { "","","",""};
-                if((re.hand == "b" || re.hand=="l"))
-                {
-                    if(i < leftRed.Count)
-                    {
-                        thisLine[0] = leftRed[i].ToString();
-                    }
-                    if(i < leftInfrared.Count)
-                    {
-                        thisLine[1] = leftInfrared[i].ToString();
-                    }
-                }
-                if ((re.hand == "b" || re.hand == "r" ))
-                {
-                    if (i < rightRed.Count)
-                    {
-                        thisLine[2] = rightRed[i].ToString();
-                    }
-                    if (i < rightInfrared.Count)
-                    {
-                        thisLine[3] = rightInfrared[i].ToString();
-                    }
-                }
-                sw.Write(thisLine[0]+","+ thisLine[1] + "," + thisLine[2] + "," + thisLine[3] + "\n");
-            }
-            //清空缓冲区
-            sw.Flush();
-            //关闭流
-            sw.Close();
-            fs.Close();
-        }
-    }
-}

+ 137 - 0
WpfTest1/Toolkits/ReportGenerater.cs

@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using iTextSharp.text;
+using iTextSharp.text.pdf;
+using System.IO;
+using LitJson;
+
+namespace WpfTest1.Toolkits
+{
+    class ReportGenerater
+    {
+        public static void generateReport(int type, SQLite.Patient onePatient, SQLite.doctor oneDoctor, SQLite.Record oneRecord, string organization_name)
+        {
+            string fileName = Constants.reportPath + "\\" + oneRecord.r_id.ToString() + ".pdf";
+            Document document = new Document(PageSize.A4);
+            //中文字体
+            string chinese = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "STSONG.TTF");
+            //System.Console.WriteLine(chinese);
+            BaseFont baseFont = BaseFont.CreateFont(chinese, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+            //文字大小12,文字样式
+            Font cn = new Font(baseFont, 12, Font.NORMAL);
+            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
+            document.Open();
+
+            //首先是标题
+            var title = new Paragraph(String.Format("\n {0}检测报告", organization_name), new Font(baseFont, 16, Font.BOLD, BaseColor.BLACK));
+            //居中
+            title.Alignment = Element.ALIGN_CENTER;
+            document.Add(title);
+            //加一个空段预防遮挡
+            document.Add(new iTextSharp.text.Paragraph(" "));
+            var border = new Paragraph("------------------------------------------------------------------------------------------------------", new Font(baseFont, 16, Font.BOLD, BaseColor.BLACK));
+            border.Alignment = Element.ALIGN_CENTER;
+            document.Add(border);
+
+            //然后是病例信息表格
+            //添加表格
+            PdfPTable table = new PdfPTable(6);
+            
+
+            DateTime now = DateTime.Today;
+            int age = now.Year - onePatient.p_birthdate.Year;
+            if (onePatient.p_birthdate > now.AddYears(-age))
+                age--;
+
+            string[] dataToBeFilled = new string[] 
+            {
+                "病案号:",
+                onePatient.p_record_id,
+                "姓名:",
+                onePatient.p_name,
+                "性别:",
+                onePatient.p_gender,
+                "年龄:",
+                age.ToString(),
+                "身高:",
+                onePatient.p_height.ToString() + "cm",
+                "体重:",
+                onePatient.p_weight.ToString() + "kg",
+                "操作医师:",
+                oneDoctor.name,
+                "操作时间:",
+                oneRecord.r_time.ToString("g"),
+                " ",
+                " "
+            };
+            foreach(string oneSentance in dataToBeFilled)
+            {
+                Paragraph p = new Paragraph(oneSentance, new Font(baseFont));
+                PdfPCell cell = new PdfPCell(p);
+                
+                cell.Border = Rectangle.NO_BORDER;
+                table.AddCell(cell);
+            }
+            table.HorizontalAlignment = Element.ALIGN_CENTER;
+            //table.
+            table.TotalWidth = 500;
+            table.LockedWidth = true;
+            float[] widths = new float[] { 100, 100, 100, 100, 50, 50 };//三列列宽不同若果是浮点数需要加f
+            table.SetWidths(widths);
+            document.Add(table);
+
+            document.Add(border);
+            
+            //最后是文档
+
+            
+            var jsonUserSelections = oneRecord.r_selection;
+            List<SQLite.UserSelection> uss = JsonMapper.ToObject<List<SQLite.UserSelection>>(jsonUserSelections);
+            foreach(SQLite.UserSelection us in uss)
+            {
+                SQLite.Question qTemp = SQLite.SQLiteModel.getQuestionById(us.q_id);
+                SQLite.Answer aTemp = SQLite.SQLiteModel.getAnswerById(us.a_id);
+                //System.Console.WriteLine(String.Format("a_id:{0},next_qid:{1}", aTemp.a_id, aTemp.next_q_id));
+                if(type == 2 && aTemp.next_q_id != 0)
+                {
+                    //evaluation
+                    continue;
+                }
+                else
+                {
+                    var questionTitle = new Paragraph(String.Format("{0}:{1}", qTemp.q_title, aTemp.a_content), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                    document.Add(questionTitle);
+                    if (aTemp.a_description_img != "")
+                    {
+                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_description_img);
+                        image.ScaleAbsoluteWidth(500);
+                        document.Add(image);
+                    }
+                    if (aTemp.a_description_text != "")
+                    {
+                        var description = new Paragraph(String.Format("问题说明:\n    {0}", aTemp.a_description_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                        document.Add(description);
+                    }
+                    if (aTemp.a_suggestion_img != "")
+                    {
+                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_suggestion_img);
+                        image.ScaleAbsoluteWidth(500);
+                        document.Add(image);
+                    }
+                    if (aTemp.a_suggestion_text != "")
+                    {
+                        var suggestion = new Paragraph(String.Format("建议:\n    {0}", aTemp.a_suggestion_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                        document.Add(suggestion);
+                    }
+                }
+            }
+            document.Close();
+
+            //打开文件
+            System.Diagnostics.Process.Start(fileName);
+        }
+    }
+}

+ 6 - 6
WpfTest1/Toolkits/ReportGenerator.cs → WpfTest1/Toolkits/ReportGenerator_old.cs

@@ -9,7 +9,7 @@ using System.Reflection;
 
 
 namespace WpfTest1.Toolkits
 namespace WpfTest1.Toolkits
 {
 {
-    class ReportGenerator
+    class ReportGenerator_old
     {
     {
         /*
         /*
          * generateReport:生成报告的方法
          * generateReport:生成报告的方法
@@ -34,8 +34,8 @@ namespace WpfTest1.Toolkits
              String picName3 = path + "\\" + "3.jpg";
              String picName3 = path + "\\" + "3.jpg";
              String picName4 = path + "\\" + "4.jpg";
              String picName4 = path + "\\" + "4.jpg";
              */
              */
-            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";
+            String fileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".doc";
+            String pdfFileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".pdf";
             if (File.Exists(fileName))
             if (File.Exists(fileName))
             {
             {
                 try
                 try
@@ -117,7 +117,7 @@ namespace WpfTest1.Toolkits
                 WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
                 WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
                 WordApp.Selection.Font.Size = 10;
                 WordApp.Selection.Font.Size = 10;
                 string currentData = DateTime.Now.ToString("yy/MM/dd");
                 string currentData = DateTime.Now.ToString("yy/MM/dd");
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("病案编号:" + rcd.id + "      " + "检查日期:" + currentData);
+                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("病案编号:" + rcd.r_id + "      " + "检查日期:" + currentData);
 
 
                 //去掉页眉的横线
                 //去掉页眉的横线
                 //WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                 //WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
@@ -574,7 +574,7 @@ namespace WpfTest1.Toolkits
                 table2.Cell(16, 4).Range.Text = "1.2-2ml/mmHg";
                 table2.Cell(16, 4).Range.Text = "1.2-2ml/mmHg";
 
 
                 table2.Cell(17, 1).Range.Text = "心率HR:";
                 table2.Cell(17, 1).Range.Text = "心率HR:";
-                table2.Cell(17, 2).Range.Text = rcd.heartRate.ToString();
+                table2.Cell(17, 2).Range.Text = "";
                 table2.Cell(17, 4).Range.Text = "bpm";
                 table2.Cell(17, 4).Range.Text = "bpm";
 
 
                 table2.Cell(18, 1).Range.Text = "中心血流量CBF:";
                 table2.Cell(18, 1).Range.Text = "中心血流量CBF:";
@@ -680,7 +680,7 @@ namespace WpfTest1.Toolkits
                     + rpRecord.cankaojieguo + "\n"
                     + rpRecord.cankaojieguo + "\n"
                     + "二、参考指数\n"
                     + "二、参考指数\n"
                     + "排量:" + rpRecord.xpl.ToString() + "(" + pailiangRemark + ")\n阻力:" + rpRecord.wzzl.ToString() + "(" + zuliRemark + ")\n"
                     + "排量:" + rpRecord.xpl.ToString() + "(" + pailiangRemark + ")\n阻力:" + rpRecord.wzzl.ToString() + "(" + zuliRemark + ")\n"
-                    + "三、脉搏波形\n" + rcd.waveTpye + "\n"
+                    + "三、脉搏波形\n" + rcd.r_type + "\n"
                     + "四、医师建议" + "\n风险等级:" + generalExpressionResult + "\n";// + mw.textBoxDiagnosis.Text;
                     + "四、医师建议" + "\n风险等级:" + generalExpressionResult + "\n";// + mw.textBoxDiagnosis.Text;
                 table2.Cell(2, 5).Range.Font.Size = 15;
                 table2.Cell(2, 5).Range.Font.Size = 15;
 
 

+ 4 - 4
WpfTest1/WpTest.csproj

@@ -46,8 +46,8 @@
       <HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath>
       <HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath>
       <Private>True</Private>
       <Private>True</Private>
     </Reference>
     </Reference>
-    <Reference Include="ExpressionEvaluator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=90d9f15d622e2348, processorArchitecture=MSIL">
-      <HintPath>..\packages\ExpressionEvaluator.2.0.4.0\lib\net40\ExpressionEvaluator.dll</HintPath>
+    <Reference Include="itextsharp, Version=5.5.13.1, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL">
+      <HintPath>..\packages\iTextSharp.5.5.13.1\lib\itextsharp.dll</HintPath>
       <Private>True</Private>
       <Private>True</Private>
     </Reference>
     </Reference>
     <Reference Include="LitJSON, Version=0.16.0.0, Culture=neutral, processorArchitecture=MSIL">
     <Reference Include="LitJSON, Version=0.16.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -202,13 +202,13 @@
     <Compile Include="SQLite\Question.cs" />
     <Compile Include="SQLite\Question.cs" />
     <Compile Include="SQLite\Run.cs" />
     <Compile Include="SQLite\Run.cs" />
     <Compile Include="Toolkits\Config.cs" />
     <Compile Include="Toolkits\Config.cs" />
-    <Compile Include="Toolkits\CSVWriter.cs" />
     <Compile Include="Exceptions\ExpressionCalculateExpression.cs" />
     <Compile Include="Exceptions\ExpressionCalculateExpression.cs" />
     <Compile Include="Exceptions\ExpressionFindFailedException.cs" />
     <Compile Include="Exceptions\ExpressionFindFailedException.cs" />
     <Compile Include="Exceptions\ExpressionUnformattedException.cs" />
     <Compile Include="Exceptions\ExpressionUnformattedException.cs" />
     <Compile Include="Toolkits\FilterFile.cs" />
     <Compile Include="Toolkits\FilterFile.cs" />
     <Compile Include="Toolkits\MeasureHandle.cs" />
     <Compile Include="Toolkits\MeasureHandle.cs" />
-    <Compile Include="Toolkits\ReportGenerator.cs" />
+    <Compile Include="Toolkits\ReportGenerater.cs" />
+    <Compile Include="Toolkits\ReportGenerator_old.cs" />
     <Compile Include="Toolkits\RPCalculate.cs" />
     <Compile Include="Toolkits\RPCalculate.cs" />
     <Compile Include="Toolkits\SocketListener.cs" />
     <Compile Include="Toolkits\SocketListener.cs" />
     <Compile Include="Toolkits\WaveHandle.cs" />
     <Compile Include="Toolkits\WaveHandle.cs" />

+ 1 - 1
WpfTest1/packages.config

@@ -2,7 +2,7 @@
 <packages>
 <packages>
   <package id="Antlr" version="3.5.0.2" targetFramework="net452" />
   <package id="Antlr" version="3.5.0.2" targetFramework="net452" />
   <package id="ControlzEx" version="3.0.2.4" targetFramework="net452" />
   <package id="ControlzEx" version="3.0.2.4" targetFramework="net452" />
-  <package id="ExpressionEvaluator" version="2.0.4.0" targetFramework="net452" />
+  <package id="iTextSharp" version="5.5.13.1" targetFramework="net452" />
   <package id="LitJson" version="0.16.0" targetFramework="net452" />
   <package id="LitJson" version="0.16.0" targetFramework="net452" />
   <package id="MahApps.Metro" version="1.5.0" targetFramework="net452" />
   <package id="MahApps.Metro" version="1.5.0" targetFramework="net452" />
   <package id="MahApps.Metro.IconPacks" version="3.2.0" targetFramework="net452" />
   <package id="MahApps.Metro.IconPacks" version="3.2.0" targetFramework="net452" />

+ 1 - 1
WpfTest1/selectUser.xaml

@@ -22,7 +22,7 @@
                 <DataGridTextColumn Header="最近评估时间" Binding="{Binding Path=p_last_evaluation_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_history}" Width="75"/>
                 <DataGridTextColumn Header="诊断" Binding="{Binding Path=p_diagnosis}" Width="75"/>
                 <DataGridTextColumn Header="诊断" Binding="{Binding Path=p_diagnosis}" Width="75"/>
-                <DataGridTextColumn Header=" " Binding="{Binding Path=p_delete_flag}" Width="75"/>
+                <!--<DataGridTextColumn Header=" " Binding="{Binding Path=p_delete_flag}" Width="75"/>-->
             </DataGrid.Columns>
             </DataGrid.Columns>
         </DataGrid>
         </DataGrid>
         <Label x:Name="label" Content="姓名:" HorizontalAlignment="Left" Margin="23,18,0,0" VerticalAlignment="Top"/>
         <Label x:Name="label" Content="姓名:" HorizontalAlignment="Left" Margin="23,18,0,0" VerticalAlignment="Top"/>

+ 5 - 4
WpfTest1/selectUser.xaml.cs

@@ -257,12 +257,13 @@ namespace WpfTest1
                 {
                 {
                     father.buttonModifyPatient_Click(this.father, e);
                     father.buttonModifyPatient_Click(this.father, e);
                 }
                 }
+                if (this.Name == "selectUserevaluation")
+                {
+                    father.buttonEvaluationSelectPatient_Click(this.father, e);
+                }
                 if (this.Name == "selectUserHistory")
                 if (this.Name == "selectUserHistory")
                 {
                 {
-                    //father.buttonSelectPaitentHistory_Click(this.father, e);
-                    //father.bugFixHostory = true;
-                    //father.selectUserHistory.LoadDataGrid();
-                    //MessageBox.Show(this.father.tabControlHistory.SelectedIndex.ToString());
+                    father.buttonHistorySelectPatient_Click(this.father, e);
                 }
                 }
             }
             }
         }
         }