|
@@ -176,60 +176,7 @@ namespace WpfTest1.SQLite
|
|
|
};
|
|
|
db.ExecuteNonQuery(sql, parameters);
|
|
|
}
|
|
|
- //Patient表的插入 返回自增主键
|
|
|
- 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(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("@name",name),
|
|
|
- new SQLiteParameter("@gender",gender),
|
|
|
- new SQLiteParameter("@height",height),
|
|
|
- new SQLiteParameter("@weight",weight),
|
|
|
- new SQLiteParameter("@pregnancy_times",pregnancy_times),
|
|
|
- new SQLiteParameter("@birthdate",birth_date),
|
|
|
- new SQLiteParameter("@phone",phone),
|
|
|
- new SQLiteParameter("@address",address),
|
|
|
- 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());
|
|
|
- //int new_id = Int32.Parse(db.ExecuteScalar("select id from Patient order by id desc", parameters).ToString());
|
|
|
- int new_id = Convert.ToInt32(db.ExecuteFindNewID("select max(id) from Patient;"));
|
|
|
- //int new_id = Convert.ToInt32(db.ExecuteFindNewID("select last_insert_rowid(id) from Patient;"));
|
|
|
- //Console.WriteLine(new_id);
|
|
|
- //return (Int32)db.ExecuteScalar("select last_insert_rowid();", new SQLiteParameter[] { });
|
|
|
|
|
|
- return new_id;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //Patient表的更新 不更新生日
|
|
|
- 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 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("@name",name),
|
|
|
- new SQLiteParameter("@gender",gender),
|
|
|
- new SQLiteParameter("@height",height),
|
|
|
- new SQLiteParameter("@weight",weight),
|
|
|
- new SQLiteParameter("@pregnancy_times",pregnancy_times),
|
|
|
- new SQLiteParameter("@birthdate",birth_date),
|
|
|
- new SQLiteParameter("@phone",phone),
|
|
|
- new SQLiteParameter("@address",address),
|
|
|
- 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 name, string gender, double height, double weight, int pregnancy_times, DateTime birth_date, string phone, string address, string history, string diagnosis, string name_py)
|
|
|
{
|
|
@@ -256,7 +203,7 @@ namespace WpfTest1.SQLite
|
|
|
}
|
|
|
//Patient表的仅更新最后XX时间的方法
|
|
|
//type 为 filter 或 evaluation
|
|
|
- public static void UpdatePatientDataWithLastFilterDate(string id, string type, DateTime lastRecordDate)
|
|
|
+ public static void UpdatePatientDataWithLastDate(int id, string type, DateTime lastRecordDate)
|
|
|
{
|
|
|
string colum_select = "p_last_filter_time";
|
|
|
if(type == "evaluation")
|
|
@@ -328,44 +275,6 @@ namespace WpfTest1.SQLite
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- //通过身份证号、孕次、产次查找Patient
|
|
|
- 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);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@idNum",idNum),
|
|
|
- new SQLiteParameter("@pregnancy_times",pregnancy_times),
|
|
|
- new SQLiteParameter("@birth_times",birth_times),
|
|
|
-
|
|
|
- };
|
|
|
- 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);
|
|
|
- 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);
|
|
|
- return temp;*/
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
//通过id主键查找Patient
|
|
|
public static Patient getPatientById(string id)
|
|
@@ -402,94 +311,141 @@ namespace WpfTest1.SQLite
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- //根据拼音获取patient记录
|
|
|
- public static void getPatientByPY_useless(string py)
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Question_template表的相关操作
|
|
|
+
|
|
|
+ public static List<Question> getQuestions(string type = "filter")
|
|
|
{
|
|
|
- //查询从20条起的50条记录
|
|
|
- string sql = "SELECT * FROM Patient WHERE firstLetterPY like\'%" + py + "%\' AND delete_flag=0";
|
|
|
+ List<Question> questions = new List<Question>();
|
|
|
+ string condition = "q_type = 1";
|
|
|
+ if(type == "evaluation")
|
|
|
+ {
|
|
|
+ condition = "q_type = 2";
|
|
|
+ }
|
|
|
+ string sql = "SELECT * FROM Question_template WHERE " + condition + " order by q_number asc";
|
|
|
SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]{};
|
|
|
+ using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
- Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
|
|
|
+ Question temp = new Question();
|
|
|
+ temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
+ temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
|
+ 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);
|
|
|
+ questions.Add(temp);
|
|
|
}
|
|
|
}
|
|
|
+ return questions;
|
|
|
}
|
|
|
- //根据姓名获取patient记录
|
|
|
- public static void getPatientByName_useless(string name)
|
|
|
- {
|
|
|
- string sql = "SELECT * FROM Patient WHERE name like\'%" + name+ "%\' AND delete_flag=0";
|
|
|
- Console.WriteLine(sql);
|
|
|
+
|
|
|
+ public static Question getQuestionById(string qid)
|
|
|
+ {
|
|
|
+ string sql = "SELECT * FROM Question_template WHERE q_id=@qid LIMIT 1";
|
|
|
SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
+ new SQLiteParameter("@qid",qid),
|
|
|
+ };
|
|
|
+ using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
- //Console.WriteLine("DDDDDDDDDDDDDDDDDDDD");
|
|
|
- Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
|
|
|
+ Question temp = new Question();
|
|
|
+ temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
+ temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
|
+ 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);
|
|
|
+ return temp;
|
|
|
}
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
- //根据condition获取patient记录
|
|
|
- public static DataView getPatientByCondition_useless(string condition)
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Answer_template表相关操作
|
|
|
+ public static List<Answer> getAnswersByQid(string qid)
|
|
|
{
|
|
|
- /*
|
|
|
- *
|
|
|
-
|
|
|
- string sql = "SELECT * FROM Patient WHERE delete_flag=0 " + condition;
|
|
|
- Console.WriteLine(sql);
|
|
|
+ List<Answer> questions = new List<Answer>();
|
|
|
+ string sql = "SELECT * FROM Answer_template WHERE q_id=@qid order by a_id asc";
|
|
|
SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
+ new SQLiteParameter("@qid",qid),
|
|
|
+ };
|
|
|
+ using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
{
|
|
|
- return reader;
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
- //Console.WriteLine("DDDDDDDDDDDDDDDDDDDD");
|
|
|
- Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
|
|
|
+ Answer temp = new Answer();
|
|
|
+ temp.a_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
+ temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
|
+ temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
|
|
|
+ temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
|
|
|
+ temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
|
|
|
+ temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
|
|
|
+ temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
|
|
|
+ temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
|
|
|
+ temp.a_suggestion_img = reader.IsDBNull(8) ? "" : reader.GetString(8);
|
|
|
+ questions.Add(temp);
|
|
|
}
|
|
|
}
|
|
|
- */
|
|
|
- //var path1 = "d:\\temp\\temp.db";
|
|
|
- string sql = "SELECT * FROM Patient WHERE delete_flag=0 " + condition;
|
|
|
- System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
|
|
|
- connstr.DataSource = dbPath;
|
|
|
- System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();
|
|
|
- conn.ConnectionString = connstr.ToString();
|
|
|
- conn.Open();
|
|
|
- SQLiteDataAdapter adapter = new SQLiteDataAdapter(sql, conn);
|
|
|
- DataSet ds = new DataSet();
|
|
|
- adapter.Fill(ds);
|
|
|
- DataView dv = ds.Tables[0].DefaultView;
|
|
|
-
|
|
|
- conn.Close();
|
|
|
- conn.Dispose();
|
|
|
- return dv;
|
|
|
-
|
|
|
-
|
|
|
+ return questions;
|
|
|
}
|
|
|
|
|
|
- //获取Patient表的用户所有分类和所有用户组
|
|
|
- public static List<string> getCategory_useless(string taskType="category")
|
|
|
+ public static Answer getAnswerById(string aid)
|
|
|
{
|
|
|
- string sql = "SELECT " + taskType + " FROM Patient WHERE delete_flag = 0 group by " + taskType;
|
|
|
- List<string> result = new List<string>();
|
|
|
+ string sql = "SELECT * FROM Answer_template WHERE a_id=@aid LIMIT 1";
|
|
|
SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{ };
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
+ new SQLiteParameter("@aid",aid),
|
|
|
+ };
|
|
|
using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
- if (reader.IsDBNull(0))
|
|
|
- continue;
|
|
|
- result.Add(reader.GetString(0));
|
|
|
+ Answer temp = new Answer();
|
|
|
+ temp.a_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
+ temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
|
+ temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
|
|
|
+ temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
|
|
|
+ temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
|
|
|
+ temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
|
|
|
+ temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
|
|
|
+ temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
|
|
|
+ temp.a_suggestion_img = reader.IsDBNull(8) ? "" : reader.GetString(8);
|
|
|
+ return temp;
|
|
|
}
|
|
|
- reader.Close();
|
|
|
}
|
|
|
- return result;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #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)
|
|
|
+ {
|
|
|
+ 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)";
|
|
|
+ SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
+ new SQLiteParameter("@r_type",r_type),
|
|
|
+ new SQLiteParameter("@p_id",p_id),
|
|
|
+ new SQLiteParameter("@d_id",d_id),
|
|
|
+ new SQLiteParameter("@filter_id",filter_id),
|
|
|
+ new SQLiteParameter("@r_time",r_time),
|
|
|
+ new SQLiteParameter("@r_count",r_count),
|
|
|
+ new SQLiteParameter("@r_selection",r_selection)
|
|
|
+ };
|
|
|
+ db.ExecuteNonQuery(sql, parameters);
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
#region doctor表相关的操作
|
|
|
//医生登录操作
|
|
|
public static doctor doctorLogin(string name,string passwordHash)
|
|
@@ -668,368 +624,6 @@ namespace WpfTest1.SQLite
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region 常用语CommonWords表操作
|
|
|
- //通过id主键查找CommonWords
|
|
|
- public static CommonWords getCommonWordsById(string id)
|
|
|
- {
|
|
|
- string sql = "SELECT * FROM CommonWords WHERE id = @id LIMIT 1";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- };
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
- {
|
|
|
- while (reader.Read())
|
|
|
- {
|
|
|
- CommonWords temp = new CommonWords();
|
|
|
- temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
- temp.content = reader.IsDBNull(1) ? "" : reader.GetString(1);
|
|
|
- temp.describe = reader.IsDBNull(2) ? "" : reader.GetString(2);
|
|
|
- return temp;
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- //CommonWords表的插入
|
|
|
- public static void InsertCommonWordsData(string content, string describe)
|
|
|
- {
|
|
|
- string sql = "INSERT INTO CommonWords(content,describe)values(@content,@describe)";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- new SQLiteParameter("@describe",describe)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- //CommonWords表的更新
|
|
|
- public static void UpdateCommonWordsData(string id, string content, string describe)
|
|
|
- {
|
|
|
- //Boolean a = false;
|
|
|
- string sql = "UPDATE CommonWords SET content=@content,describe=@describe WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- new SQLiteParameter("@describe",describe),
|
|
|
- new SQLiteParameter("@id",id)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- //CommonWords表记录的删除
|
|
|
- public static int DeleteCommonWordsItem(string id)
|
|
|
- {
|
|
|
- string sql = "DELETE FROM CommonWords WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id)
|
|
|
- };
|
|
|
- return db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region Record标的相关操作
|
|
|
- // //通过id主键查找Record
|
|
|
- public static Record getRecordById(string id)
|
|
|
- {
|
|
|
- string sql = "SELECT * FROM Record WHERE id = @id LIMIT 1";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- };
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
- {
|
|
|
- while (reader.Read())
|
|
|
- {
|
|
|
- Record temp = new Record();
|
|
|
-
|
|
|
- //long len = reader.GetBytes(reader.GetOrdinal("Data"), 0, null, 0, 0);
|
|
|
- //Console.WriteLine("len is :" + len.ToString());
|
|
|
- //buffer = new byte[len];
|
|
|
-
|
|
|
- //len = reader.GetBytes(reader.GetOrdinal("Data"), 0, buffer, 0, (int)len);
|
|
|
- temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
- temp.patientId = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
|
- temp.doctorId = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
|
|
|
- temp.recordTime = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
|
|
|
- //左手
|
|
|
- if(!reader.IsDBNull(4))
|
|
|
- {
|
|
|
- long len = reader.GetBytes(reader.GetOrdinal("dataLeft"), 0, null, 0, 0);
|
|
|
- byte[] buffer = new byte[len];
|
|
|
- reader.GetBytes(reader.GetOrdinal("dataLeft"), 0, buffer, 0, (int)len);
|
|
|
- temp.dataLeft = buffer;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temp.dataLeft = new byte[] { };
|
|
|
- }
|
|
|
- //右手
|
|
|
- if (!reader.IsDBNull(5))
|
|
|
- {
|
|
|
- long len = reader.GetBytes(reader.GetOrdinal("dataRight"), 0, null, 0, 0);
|
|
|
- byte[] buffer = new byte[len];
|
|
|
- reader.GetBytes(reader.GetOrdinal("dataRight"), 0, buffer, 0, (int)len);
|
|
|
- temp.dataRight = buffer;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temp.dataRight = new byte[] { };
|
|
|
- }
|
|
|
- //绕关节
|
|
|
- if (!reader.IsDBNull(6))
|
|
|
- {
|
|
|
- long len = reader.GetBytes(reader.GetOrdinal("dataWrist"), 0, null, 0, 0);
|
|
|
- byte[] buffer = new byte[len];
|
|
|
- reader.GetBytes(reader.GetOrdinal("dataWrist"), 0, buffer, 0, (int)len);
|
|
|
- temp.dataWrist = buffer;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temp.dataWrist = new byte[] { };
|
|
|
- }
|
|
|
- temp.topBP = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
|
|
|
- temp.bottomBP = reader.IsDBNull(8) ? 0 : reader.GetDouble(8);
|
|
|
- temp.heartRate = reader.IsDBNull(9) ? 0 : reader.GetDouble(9);
|
|
|
- temp.waveTpye = reader.IsDBNull(10) ? "" : reader.GetString(10);
|
|
|
- temp.eigenValueSaved = reader.IsDBNull(11) ? 0: reader.GetInt32(11);
|
|
|
- temp.comments = reader.IsDBNull(12) ? "" : reader.GetString(12);
|
|
|
- temp.hand = reader.IsDBNull(14) ? "b" : reader.GetString(14);
|
|
|
- return temp;
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- //查找Record中病人id和时间相同的记录个数
|
|
|
- public static int getRecordCountByPatientIdAndTime(int patient_id, DateTime recordTime)
|
|
|
- {
|
|
|
- string sql = "SELECT count(*) FROM Record WHERE patientId = @patient_id AND recordTime=@recordTime";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@patient_id",patient_id),
|
|
|
- new SQLiteParameter("@recordTime",recordTime),
|
|
|
- };
|
|
|
- int count = Convert.ToInt32(db.ExecuteFindCount(sql,parameters));
|
|
|
- return count;
|
|
|
- }
|
|
|
- //Record表的插入
|
|
|
- public static void InsertRecordData(int PatientId, int doctorId, DateTime RecordTime, byte[] DataLeft,byte[] DataRight, byte[] DataWrist, double TopBP, double BottomBP, double HeartRate, int EigenValueSaved, string Comments, string waveType, string hand)
|
|
|
- {
|
|
|
- string sql = "INSERT INTO Record(PatientId,doctorId,RecordTime,DataLeft,DataRight,DataWrist,TopBP,BottomBP,HeartRate,waveType,EigenValueSaved,Comments,hand)values(@PatientId,@doctorId,@RecordTime,@DataLeft,@DataRight,@DataWrist,@TopBP,@BottomBP,@HeartRate,@waveType,@EigenValueSaved,@Comments,@hand)";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@PatientId",PatientId),
|
|
|
- new SQLiteParameter("@doctorId",doctorId),
|
|
|
- new SQLiteParameter("@RecordTime",RecordTime),
|
|
|
- new SQLiteParameter("@DataLeft",DbType.Binary),
|
|
|
- new SQLiteParameter("@DataRight",DbType.Binary),
|
|
|
- new SQLiteParameter("@DataWrist",DbType.Binary),
|
|
|
- new SQLiteParameter("@TopBP",TopBP),
|
|
|
- new SQLiteParameter("@BottomBP",BottomBP),
|
|
|
- new SQLiteParameter("@HeartRate",HeartRate),
|
|
|
- new SQLiteParameter("@waveType",waveType),
|
|
|
- new SQLiteParameter("@EigenValueSaved",EigenValueSaved),
|
|
|
- new SQLiteParameter("@Comments",Comments),
|
|
|
- new SQLiteParameter("@hand",hand)
|
|
|
- };
|
|
|
- parameters[3].Value = DataLeft;
|
|
|
- parameters[4].Value = DataRight;
|
|
|
- parameters[5].Value = DataWrist;
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- ////Record表的更新
|
|
|
- public static void UpdateRecordData(int id,int PatientId, int doctorId, DateTime RecordTime, byte[] DataLeft, byte[] DataRight, byte[] DataWrist, double TopBP, double BottomBP, double HeartRate, int EigenValueSaved, string Comments, string waveType)
|
|
|
- {
|
|
|
- string sql = "UPDATE Record SET PatientId=@PatientId,doctorId=@doctorId,RecordTime=@RecordTime,DataLeft=@DataLeft,DataRight=@DataLeft,DataWrist=@DataWrist,TopBP=@TopBP,BottomBP=@BottomBP,HeartRate=@HeartRate,EigenValueSaved=@EigenValueSaved,comments=@Comments,waveType=@waveType WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@PatientId",PatientId),
|
|
|
- new SQLiteParameter("@doctorId",doctorId),
|
|
|
- new SQLiteParameter("@RecordTime",RecordTime),
|
|
|
- new SQLiteParameter("@DataLeft",DataLeft),
|
|
|
- new SQLiteParameter("@DataRight",DataRight),
|
|
|
- new SQLiteParameter("@DataWrist",DataWrist),
|
|
|
- new SQLiteParameter("@TopBP",TopBP),
|
|
|
- new SQLiteParameter("@BottomBP",BottomBP),
|
|
|
- new SQLiteParameter("@HeartRate",HeartRate),
|
|
|
- new SQLiteParameter("@EigenValueSaved",EigenValueSaved),
|
|
|
- new SQLiteParameter("@Comments",Comments),
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- new SQLiteParameter("@waveType",waveType)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
-
|
|
|
- //Record表更新医生的诊断
|
|
|
- public static void UpdateDiagnosisData(int id, string Comments)
|
|
|
- {
|
|
|
- string sql = "UPDATE Record SET comments=@Comments WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@Comments",Comments),
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
-
|
|
|
- //Record表删除操作
|
|
|
- public static int DeleteRecordItem(string id)
|
|
|
- {
|
|
|
- string sql = "DELETE FROM Record WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id)
|
|
|
- };
|
|
|
- return db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region Expression表的相关操作
|
|
|
- //查找所有的expression的content和position列,privilege_flag为1时才显示所有的公示,否则只显示isCache=1的公式
|
|
|
- public static void GetAllExpressionContent(Dictionary<string, double> target, Dictionary<string, string> positions, int privilege_flag)
|
|
|
- {
|
|
|
- string sql = "SELECT expression_content,position FROM Expression WHERE ";
|
|
|
- if(privilege_flag == 1)
|
|
|
- {
|
|
|
- sql += "1";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql += "isCache = 1";
|
|
|
- }
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- };
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
- {
|
|
|
- while (reader.Read())
|
|
|
- {
|
|
|
- string tempKey = reader.IsDBNull(0) ? "" : reader.GetString(0);
|
|
|
- string tempPosition = reader.IsDBNull(1) ? "" : reader.GetString(1);
|
|
|
- if (tempKey == "")
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- //KeyValuePair<string, double> temp = new KeyValuePair<string, double>(tempKey,0);
|
|
|
- target.Add(tempKey,0);
|
|
|
- positions.Add(tempKey, tempPosition);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //通过id主键查找Expression
|
|
|
- public static Expression getExpressionById(string id)
|
|
|
- {
|
|
|
- string sql = "SELECT * FROM Expression WHERE id = @id LIMIT 1";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- };
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
- {
|
|
|
- while (reader.Read())
|
|
|
- {
|
|
|
- Expression temp = new Expression();
|
|
|
- temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
- temp.expression_content = reader.IsDBNull(1) ? "" : reader.GetString(1);
|
|
|
- temp.expression_description = reader.IsDBNull(2) ? "" : reader.GetString(2);
|
|
|
- temp.range = reader.IsDBNull(3) ? 0.0 : reader.GetDouble(3);
|
|
|
- temp.isRelative = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
|
|
|
- temp.isCache = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
|
|
|
- temp.upBound = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
|
|
|
- temp.downBound = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
|
|
|
- temp.position = reader.IsDBNull(8) ? "o" : reader.GetString(8);
|
|
|
- return temp;
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- //通过公式值查找Expression
|
|
|
- public static Expression getExpressionByContent(string content)
|
|
|
- {
|
|
|
- string sql = "SELECT * FROM Expression WHERE expression_content = @content LIMIT 1";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- };
|
|
|
- using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
|
|
|
- {
|
|
|
- while (reader.Read())
|
|
|
- {
|
|
|
- Expression temp = new Expression();
|
|
|
- temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
|
- temp.expression_content = reader.IsDBNull(1) ? "" : reader.GetString(1);
|
|
|
- temp.expression_description = reader.IsDBNull(2) ? "" : reader.GetString(2);
|
|
|
- temp.range = reader.IsDBNull(3) ? 0.0 : reader.GetDouble(3);
|
|
|
- temp.isRelative = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
|
|
|
- temp.isCache = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
|
|
|
- temp.upBound = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
|
|
|
- temp.downBound = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
|
|
|
- temp.position = reader.IsDBNull(8) ? "o" : reader.GetString(8);
|
|
|
- return temp;
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- //Expression表的插入
|
|
|
- public static void InsertExpressionData(string content, string describe,double range, int relative,double upBound, double downBound, int isCache, string position)
|
|
|
- {
|
|
|
- string sql = "INSERT INTO Expression(expression_content,expression_description,range,isRelative,upBound,downBound,isCache,position)values(@content,@describe,@range,@relative,@upBound,@downBound,@isCache,@position)";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- new SQLiteParameter("@describe",describe),
|
|
|
- new SQLiteParameter("@range",range),
|
|
|
- new SQLiteParameter("@relative",relative),
|
|
|
- new SQLiteParameter("@upBound",upBound),
|
|
|
- new SQLiteParameter("@downBound",downBound),
|
|
|
- new SQLiteParameter("@isCache",isCache),
|
|
|
- new SQLiteParameter("@position",position)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- //Expression表的更新
|
|
|
- public static void UpdateExpressionData(string id, string content, string describe, double range, int relative, double upBound, double downBound, int isCache,string position)
|
|
|
- {
|
|
|
- //Boolean a = false;
|
|
|
- string sql = "UPDATE Expression SET expression_content=@content,expression_description=@describe,range=@range,isRelative=@relative,upBound=@upBound,downBound=@downBound,isCache=@isCache,position=@position WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- new SQLiteParameter("@describe",describe),
|
|
|
- new SQLiteParameter("@id",id),
|
|
|
- new SQLiteParameter("@range",range),
|
|
|
- new SQLiteParameter("@relative",relative),
|
|
|
- new SQLiteParameter("@upBound",upBound),
|
|
|
- new SQLiteParameter("@downBound",downBound),
|
|
|
- new SQLiteParameter("@isCache",isCache),
|
|
|
- new SQLiteParameter("@position",position)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- //Expression表仅更新取值范围的方法
|
|
|
- public static void UpdateExpressionDataOnlyWithRange(string content, double range, int relative)
|
|
|
- {
|
|
|
- //Boolean a = false;
|
|
|
- string sql = "UPDATE Expression SET range=@range,isRelative=@relative WHERE expression_content=@content";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@content",content),
|
|
|
- new SQLiteParameter("@range",range),
|
|
|
- new SQLiteParameter("@relative",relative)
|
|
|
- };
|
|
|
- db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- //Expression表记录的删除
|
|
|
- public static int DeleteExpressionItem(string id)
|
|
|
- {
|
|
|
- string sql = "DELETE FROM Expression WHERE id=@id";
|
|
|
- SQLiteHelper db = new SQLiteHelper(dbPath);
|
|
|
- SQLiteParameter[] parameters = new SQLiteParameter[]{
|
|
|
- new SQLiteParameter("@id",id)
|
|
|
- };
|
|
|
- return db.ExecuteNonQuery(sql, parameters);
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
#region 配置表Config的相关操作
|
|
|
//查找所有的expression的content列
|
|
|
public static void GetAllConfigContent(Dictionary<string, string> target)
|