├── photo_path.txt ├── COIMS ├── hospital.db ├── get_row_and_column.c ├── help_about.c ├── hospital.sql ├── README ├── search_hsp.c ├── panss.c ├── Makefile ├── into_choose.c ├── happened_choose.c ├── coims.h ├── update_hsp.c ├── insert_hsp.c ├── photo_choose.c ├── birthday_choose.c ├── cancel.c ├── new_person.c ├── out_choose.c ├── check_sure.c └── main_window.c /photo_path.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /COIMS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/COIMS/master/COIMS -------------------------------------------------------------------------------- /hospital.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/COIMS/master/hospital.db -------------------------------------------------------------------------------- /get_row_and_column.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void get_row_and_column(GtkCList *clist, gint row, gint column, GdkEvent *event, Item *parents) 4 | { 5 | (*parents).get_row = row; 6 | (*parents).get_column = column; 7 | 8 | printf("row = %d, column = %d.\n", (*parents).get_row, (*parents).get_column); 9 | } 10 | -------------------------------------------------------------------------------- /help_about.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void help_about(GtkWidget *widget, gpointer parents) 4 | { 5 | GtkWidget *about; 6 | 7 | about = gtk_about_dialog_new(); 8 | gtk_about_dialog_set_name( 9 | GTK_ABOUT_DIALOG(about), 10 | "公共卫生管理系统" 11 | ); 12 | gtk_about_dialog_set_version( 13 | GTK_ABOUT_DIALOG(about), 14 | "1.0" 15 | ); 16 | gtk_about_dialog_set_copyright( 17 | GTK_ABOUT_DIALOG(about), 18 | "(c)2013-2014 西电开源社区" 19 | ); 20 | gtk_about_dialog_set_website( 21 | GTK_ABOUT_DIALOG(about), 22 | "https://github.com/newmlee/COIMS" 23 | ); 24 | 25 | gtk_dialog_run(GTK_DIALOG(about)); 26 | gtk_widget_destroy(about); 27 | } 28 | -------------------------------------------------------------------------------- /hospital.sql: -------------------------------------------------------------------------------- 1 | /* 新建“在院病人”数据表; 2 | * 全部规定为TEXT数据类型,方便操作; 3 | * 暂时不做指纹识别和人脸识别了,做不了, 4 | * 所以不为指纹识别预留接口了 5 | */ 6 | CREATE TABLE IF NOT EXISTS 7 | tb_hospital( 8 | /* 基本资料部分 */ 9 | id TEXT PRIMARY KEY DEFAULT '\0', 10 | photo_path TEXT DEFAULT '\0', 11 | name TEXT DEFAULT '\0', 12 | sex TEXT DEFAULT '\0', 13 | birthday TEXT DEFAULT '\0', 14 | age TEXT DEFAULT '\0', 15 | marriage TEXT DEFAULT '\0', 16 | edu TEXT DEFAULT '\0', 17 | census TEXT DEFAULT '\0', 18 | happened TEXT DEFAULT '\0', 19 | place TEXT DEFAULT '\0', 20 | bill TEXT DEFAULT '\0', 21 | num TEXT DEFAULT '\0', 22 | into_hospital TEXT DEFAULT '\0', 23 | inps TEXT DEFAULT '\0', 24 | out_hospital TEXT DEFAULT '\0', 25 | outps TEXT DEFAULT '\0', 26 | days TEXT DEFAULT '\0', 27 | panss TEXT DEFAULT '\0', 28 | cost TEXT DEFAULT '\0', 29 | goto TEXT DEFAULT '\0', 30 | 31 | /* 诊断治疗部分 */ 32 | do_level TEXT DEFAULT '\0', 33 | symptom TEXT DEFAULT '\0', 34 | status TEXT DEFAULT '\0', 35 | psy TEXT DEFAULT '\0', 36 | dep TEXT DEFAULT '\0', 37 | anxiety TEXT DEFAULT '\0', 38 | heart TEXT DEFAULT '\0', 39 | 40 | /* 补充信息部分 */ 41 | addicted TEXT DEFAULT '\0', 42 | drug TEXT DEFAULT '\0', 43 | body TEXT DEFAULT '\0', 44 | infect TEXT DEFAULT '\0' 45 | ); 46 | 47 | /* 新建“在院病人”视图,方便搜索和显示 */ 48 | CREATE VIEW ve_hospital AS 49 | SELECT 50 | id, 51 | num, 52 | name 53 | FROM tb_hospital; 54 | 55 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 程序说明: 2 | COIMS是应西安某救助站需求,义务为其开发的简易流浪者病例软件,基于GTK+2.24版本、SQLite3并采用C语言进行开发。不以成败论英雄。 3 | 目前软件仍在开发。 4 | 5 | 合作人员: 6 | 李明亮 https://github.com/newmlee 7 | 周金宇 https://github.com/zhou-jered 8 | 9 | 源代码说明: 10 | coims.h 头文件 11 | birthday_choose.c 选择生日 12 | cancel.c 取消保存 13 | check_sure.c 确定按钮对应的各种事件处理 14 | COIMS Linux Gnome桌面环境下编译的可执行文件, 15 | 若要运行在Windows环境下, 16 | 需要配置相应环境和重新编译 17 | get_row_and_column.c 获取在院病人列表中被选中的选项 18 | happened_choose.c 选择事发时间 19 | help_about.c 显示关于菜单 20 | hospital.sql 创建“在院病人”数据库 21 | hospital.db SQLite3创建的”在院病人“数据库 22 | hsp_list.c ”在院病人“列表的刷新 23 | insert_hsp.c 插入“在院病人”数据表 24 | into_choose.c 选择入院时间 25 | main_window.c 主界面文件 26 | Makefile Makefile 27 | new_person.c 新建入院病人 28 | out_choose.c 选择出院时间 29 | panss.c 计算PANSS减分率 30 | photo_choose.c 选择照片 31 | photo_path.txt 储存被选中照片的临时路径 32 | README README 33 | search_hsp.c 在“在院病人”数据视图中进行搜索 34 | update_hsp.c 对”在院病人“数据库进行更新 35 | 36 | 运行环境需要: 37 | GTK+ 2.24 Runtime 38 | SQLite3 39 | 40 | 补充说明: 41 | 1. 没办法制作指纹识别模块和人脸识别模块,所以这部分(暂时/永久)不做,并且数据库中也没有为这部分预留接口,所以可能需要重构代码。 42 | 2. 最终目标是建立联网,但目前还是暂时制作本地软件先,需要学习Socket编程。 43 | -------------------------------------------------------------------------------- /search_hsp.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | int callback_id(void *parents, int argc, char **argv, char **headers) 4 | { 5 | Pchar *p; 6 | int i = 0; 7 | 8 | /* 注意类型转换 */ 9 | p = (Pchar *)parents; 10 | /* 开始进行身份证和住院号的检测 */ 11 | for (i = 0; i < argc; i++) { 12 | /* 是否需要NOT NULL? */ 13 | if (strcmp((*p).id, argv[i]) == 0) { 14 | /* 采用自加方式统计重复次数, 15 | * 不过这样好像没什么必要, 16 | * 但是还是这样做吧,说不定以后有用 17 | */ 18 | (*p).find_id++; 19 | } 20 | } 21 | 22 | return 0; 23 | } 24 | 25 | int callback_num(void *parents, int argc, char **argv, char **headers) 26 | { 27 | Pchar *p; 28 | int i = 0; 29 | 30 | /* 注意类型转换 */ 31 | p = (Pchar *)parents; 32 | /* 开始进行身份证和住院号的检测 */ 33 | for (i = 0; i < argc; i++) { 34 | /* 是否需要NOT NULL? */ 35 | if (strcmp((*p).num, argv[i]) == 0) { 36 | /* 采用自加方式统计重复次数, 37 | * 不过这样好像没什么必要, 38 | * 但是还是这样做吧,说不定以后有用 39 | */ 40 | (*p).find_num++; 41 | } 42 | } 43 | 44 | return 0; 45 | } 46 | 47 | int search_hsp(Pchar *p) 48 | { 49 | sqlite3 *db; 50 | char query_id[100] = {0}; 51 | char query_num[100] = {0}; 52 | /* 这里rc有多种用途, 53 | * 但是写出来的语句不一定被用到, 54 | * 所以有些调用sqlite3_*语句的地方就不提取返回值了 55 | */ 56 | int rc = 0; 57 | 58 | /* 注意及时关闭数据库 */ 59 | sqlite3_open("hospital.db", &db); 60 | 61 | /* 开始组装SELECT语句 */ 62 | strcat(query_id, "SELECT id FROM ve_hospital;"); 63 | strcat(query_num, "SELECT num FROM ve_hospital;"); 64 | 65 | (*p).find_id = 0; 66 | (*p).find_num = 0; 67 | /* 回调函数的应用 */ 68 | sqlite3_exec(db, query_id, callback_id, p, NULL); 69 | sqlite3_exec(db, query_num, callback_num, p, NULL); 70 | /* 确定返回值 */ 71 | if ((*p).find_id == 0 && (*p).find_num == 0) { 72 | rc = 0; 73 | } else if ((*p).find_id == 0 && (*p).find_num != 0) { 74 | rc = 1; 75 | } else if ((*p).find_id != 0 && (*p).find_num == 0) { 76 | rc = 2; 77 | } else { 78 | rc = 3; 79 | } 80 | 81 | sqlite3_close(db); 82 | 83 | return rc; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /panss.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void panss(GtkWidget *widght, Item *parents) 4 | { 5 | GtkWidget *message; 6 | const gchar *get_inps; 7 | const gchar *get_outps; 8 | char str_inps[10] = {0}, 9 | str_outps[10] = {0}; 10 | int judge = 0; 11 | double dou_inps = 0, 12 | dou_outps = 0, 13 | persent = 0; 14 | char str_per[20] = {0}; 15 | int i = 0, 16 | j = 0; 17 | 18 | /* 获取字符串 */ 19 | get_inps = gtk_entry_get_text(GTK_ENTRY((*parents).inps_entry)); 20 | get_outps = gtk_entry_get_text(GTK_ENTRY((*parents).outps_entry)); 21 | 22 | /* 对字符串进行处理 */ 23 | strcpy(str_inps, get_inps); 24 | strcpy(str_outps, get_outps); 25 | /* 检测输入是否正确 */ 26 | judge = 0; 27 | for (i = 0; i < strlen(str_inps); i++) { 28 | if (!('0' <= str_inps[i] && str_inps[i] <= '9')) { 29 | judge = 1; 30 | break; 31 | } 32 | } 33 | for (i = 0; i < strlen(str_outps); i++) { 34 | if (!('0' <= str_outps[i] && str_outps[i] <= '9')) { 35 | judge = 1; 36 | break; 37 | } 38 | } 39 | /* 如果格式错误则出现提示框, 40 | * 显然目前还不完善,应该在键入的时候判断输入是否有效, 41 | * 不过这个问题暂时搁置一边 42 | */ 43 | if (judge == 1) { 44 | message = gtk_message_dialog_new( 45 | NULL, 46 | GTK_DIALOG_MODAL, 47 | GTK_MESSAGE_ERROR, 48 | GTK_BUTTONS_CLOSE, 49 | "入院评分或出院评分输入错误" 50 | ); 51 | gtk_dialog_run(GTK_DIALOG(message)); 52 | gtk_widget_destroy(message); 53 | } else { 54 | sscanf(str_inps, "%lf", &dou_inps); 55 | sscanf(str_outps, "%lf", &dou_outps); 56 | /* 0不能当分母 */ 57 | if (dou_inps == 0) { 58 | message = gtk_message_dialog_new( 59 | NULL, 60 | GTK_DIALOG_MODAL, 61 | GTK_MESSAGE_ERROR, 62 | GTK_BUTTONS_CLOSE, 63 | "入院评分或出院评分输入错误" 64 | ); 65 | gtk_dialog_run(GTK_DIALOG(message)); 66 | gtk_widget_destroy(message); 67 | } else { 68 | persent = (dou_inps - dou_outps) / dou_inps * 100; 69 | sprintf(str_per, "%.2lf", persent); 70 | strcat(str_per, "%"); 71 | gtk_button_set_label( 72 | GTK_BUTTON((*parents).persent_button), 73 | str_per 74 | ); 75 | gtk_widget_show((*parents).persent_button); 76 | } 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | COIMS: main_window.o \ 2 | help_about.o \ 3 | new_person.o \ 4 | cancel.o \ 5 | photo_choose.o \ 6 | birthday_choose.o \ 7 | happened_choose.o \ 8 | into_choose.o \ 9 | out_choose.o \ 10 | panss.o \ 11 | check_sure.o \ 12 | get_row_and_column.o \ 13 | search_hsp.o \ 14 | insert_hsp.o \ 15 | update_hsp.o \ 16 | hsp_list.o 17 | gcc -o COIMS \ 18 | main_window.o \ 19 | help_about.o \ 20 | new_person.o \ 21 | cancel.o \ 22 | photo_choose.o \ 23 | birthday_choose.o \ 24 | happened_choose.o \ 25 | into_choose.o \ 26 | out_choose.o \ 27 | panss.o \ 28 | check_sure.o \ 29 | get_row_and_column.o \ 30 | search_hsp.o \ 31 | insert_hsp.o \ 32 | update_hsp.o \ 33 | hsp_list.o \ 34 | `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 35 | 36 | main_window.o: main_window.c coims.h 37 | gcc -c main_window.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 38 | 39 | help_about.o: help_about.c coims.h 40 | gcc -c help_about.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 41 | 42 | new_person.o: new_person.c coims.h 43 | gcc -c new_person.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 44 | 45 | cancel.o: cancel.c coims.h 46 | gcc -c cancel.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 47 | 48 | photo_choose.o: photo_choose.c coims.h 49 | gcc -c photo_choose.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 50 | 51 | birthday_choose.o: birthday_choose.c coims.h 52 | gcc -c birthday_choose.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 53 | 54 | happened_choose.o: happened_choose.c coims.h 55 | gcc -c happened_choose.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 56 | 57 | into_choose.o: into_choose.c coims.h 58 | gcc -c into_choose.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 59 | 60 | out_choose.o: out_choose.c coims.h 61 | gcc -c out_choose.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 62 | 63 | panss.o: panss.c coims.h 64 | gcc -c panss.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 65 | 66 | check_sure.o: check_sure.c coims.h 67 | gcc -c check_sure.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 68 | 69 | get_row_and_column.o: get_row_and_column.c coims.h 70 | gcc -c get_row_and_column.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 71 | 72 | search_hsp.o: search_hsp.c coims.h 73 | gcc -c search_hsp.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 74 | 75 | insert_hsp.o: insert_hsp.c coims.h 76 | gcc -c insert_hsp.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 77 | 78 | update_hsp.o: update_hsp.c coims.h 79 | gcc -c update_hsp.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 80 | 81 | hsp_list.o: hsp_list.c coims.h 82 | gcc -c hsp_list.c `pkg-config --cflags --libs gtk+-2.0` -l sqlite3 83 | 84 | clean: 85 | rm main_window.o \ 86 | help_about.o \ 87 | new_person.o \ 88 | cancel.o \ 89 | photo_choose.o \ 90 | birthday_choose.o \ 91 | happened_choose.o \ 92 | into_choose.o \ 93 | out_choose.o \ 94 | panss.o \ 95 | check_sure.o \ 96 | get_row_and_column.o \ 97 | search_hsp.o \ 98 | insert_hsp.o \ 99 | update_hsp.o \ 100 | hsp_list.o 101 | -------------------------------------------------------------------------------- /into_choose.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void into_choose(GtkWidget *widget, Item *parents) 4 | { 5 | /* dialog对话框 */ 6 | GtkWidget *dialog; 7 | GtkWidget *message; 8 | /* 日期 */ 9 | GtkWidget *into_cal; 10 | int int_year = 0, 11 | int_month = 0, 12 | int_day = 0; 13 | char str[50] = {0}, 14 | str_year[10] = {0}, 15 | str_month[10] = {0}, 16 | str_day[10] = {0}; 17 | time_t timep; 18 | struct tm *p; 19 | int now_year = 0, 20 | now_month = 0, 21 | now_day = 0; 22 | 23 | /* 创建对话框 */ 24 | dialog = gtk_dialog_new_with_buttons( 25 | "选择入院时间", 26 | NULL, GTK_DIALOG_MODAL, 27 | "确定", GTK_RESPONSE_ACCEPT, 28 | "取消", GTK_RESPONSE_REJECT, 29 | NULL 30 | ); 31 | gtk_window_set_position( 32 | GTK_WINDOW(dialog), 33 | GTK_WIN_POS_CENTER 34 | ); 35 | gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 36 | 37 | /* 创建日历选择框 */ 38 | into_cal = gtk_calendar_new(); 39 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog) -> vbox), 40 | into_cal, 41 | TRUE, 42 | TRUE, 43 | 0); 44 | gtk_widget_show(into_cal); 45 | 46 | /* 处理事件 */ 47 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 48 | gtk_calendar_get_date( 49 | GTK_CALENDAR(into_cal), 50 | &int_year, 51 | &int_month, 52 | &int_day 53 | ); 54 | int_month = int_month + 1; /* 因为获取的月份比实际月份小1 */ 55 | /* 获取当前时间 */ 56 | time(&timep); 57 | p = gmtime(&timep); 58 | now_year = 1900 + p -> tm_year; 59 | now_month = 1 + p -> tm_mon; 60 | now_day = p -> tm_mday; 61 | /* 错误消息提示框 */ 62 | message = gtk_message_dialog_new( 63 | NULL, 64 | GTK_DIALOG_MODAL, 65 | GTK_MESSAGE_ERROR, 66 | GTK_BUTTONS_CLOSE, 67 | "入院时间不可能超过今天" 68 | ); 69 | /* 开始进行判断 */ 70 | if ( 71 | (int_year > now_year) || 72 | (int_year == now_year && int_month > now_month) || 73 | (int_year == now_year && int_month == now_month && int_day > now_day) 74 | ) { 75 | gtk_widget_destroy(dialog); 76 | gtk_dialog_run(GTK_DIALOG(message)); 77 | gtk_widget_destroy(message); 78 | } else { 79 | sprintf(str_year, "%d", int_year); 80 | sprintf(str_month, "%d", int_month); 81 | sprintf(str_day, "%d", int_day); 82 | strcat(str, str_year); 83 | strcat(str, "年"); 84 | strcat(str, str_month); 85 | strcat(str, "月"); 86 | strcat(str, str_day); 87 | strcat(str, "日"); 88 | gtk_button_set_label( 89 | GTK_BUTTON((*parents).into_button), 90 | str 91 | ); 92 | gtk_widget_show_now((*parents).into_button); 93 | gtk_widget_destroy(dialog); 94 | } 95 | } else { 96 | gtk_widget_destroy(dialog); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /happened_choose.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void happened_choose(GtkWidget *widget, Item *parents) 4 | { 5 | /* dialog控件 */ 6 | GtkWidget *dialog; 7 | GtkWidget *message; 8 | /* 日期 */ 9 | GtkWidget *happened_cal; 10 | int int_year = 0, 11 | int_month = 0, 12 | int_day = 0; 13 | char str[50] = {0}, 14 | str_year[10] = {0}, 15 | str_month[10] = {0}, 16 | str_day[10] = {0}; 17 | time_t timep; 18 | struct tm *p; 19 | int now_year = 0, 20 | now_month = 0, 21 | now_day = 0; 22 | 23 | /* 创建对话框 */ 24 | dialog = gtk_dialog_new_with_buttons( 25 | "选择事发时间", 26 | NULL, GTK_DIALOG_MODAL, 27 | "确定", GTK_RESPONSE_ACCEPT, 28 | "取消", GTK_RESPONSE_REJECT, 29 | NULL 30 | ); 31 | gtk_window_set_position( 32 | GTK_WINDOW(dialog), 33 | GTK_WIN_POS_CENTER 34 | ); 35 | gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 36 | 37 | /* 创建日历选择框 */ 38 | happened_cal = gtk_calendar_new(); 39 | gtk_box_pack_start( 40 | GTK_BOX(GTK_DIALOG(dialog) -> vbox), 41 | happened_cal, 42 | TRUE, 43 | TRUE, 44 | 0 45 | ); 46 | /* 记住及时显示 */ 47 | gtk_widget_show(happened_cal); 48 | 49 | /* 处理事件 */ 50 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 51 | gtk_calendar_get_date( 52 | GTK_CALENDAR(happened_cal), 53 | &int_year, 54 | &int_month, 55 | &int_day 56 | ); 57 | 58 | int_month = int_month + 1; /* 因为获取的月份比实际月份小1 */ 59 | /* 获取当前时间 */ 60 | time(&timep); 61 | p = gmtime(&timep); 62 | now_year = 1900 + p -> tm_year; 63 | now_month = 1 + p -> tm_mon; 64 | now_day = p -> tm_mday; 65 | /* 错误消息提示框 */ 66 | message = gtk_message_dialog_new( 67 | NULL, 68 | GTK_DIALOG_MODAL, 69 | GTK_MESSAGE_ERROR, 70 | GTK_BUTTONS_CLOSE, 71 | "事发时间不可能超过今天" 72 | ); 73 | /* 开始进行判断 */ 74 | if ( 75 | (int_year > now_year) || 76 | (int_year == now_year && int_month > now_month) || 77 | (int_year == now_year && int_month == now_month && int_day > now_day) 78 | ) { 79 | gtk_widget_destroy(dialog); 80 | gtk_dialog_run(GTK_DIALOG(message)); 81 | gtk_widget_destroy(message); 82 | } else { 83 | sprintf(str_year, "%d", int_year); 84 | sprintf(str_month, "%d", int_month); 85 | sprintf(str_day, "%d", int_day); 86 | strcat(str, str_year); 87 | strcat(str, "年"); 88 | strcat(str, str_month); 89 | strcat(str, "月"); 90 | strcat(str, str_day); 91 | strcat(str, "日"); 92 | gtk_button_set_label( 93 | GTK_BUTTON((*parents).happened_button), 94 | str 95 | ); 96 | gtk_widget_show((*parents).happened_button); 97 | gtk_widget_destroy(dialog); 98 | } 99 | } else { 100 | gtk_widget_destroy(dialog); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /coims.h: -------------------------------------------------------------------------------- 1 | #ifndef __COIMS__ 2 | #define __COIMS__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* 只有以下几种控件需要加入结构体: 14 | * 1. 不可替代的button; 15 | * 2. 不可替代的combo; 16 | * 3. 不可替代的entry; 17 | * 4. 不可替代的text_view; 18 | * 5. 不可替代的tree_view; 19 | * 6. 其他不可替代的控件。 20 | */ 21 | typedef struct _Item { 22 | /* “在院病人列表”树形图 */ 23 | GtkWidget *hospital_list; 24 | gint get_row; 25 | gint get_column; 26 | 27 | /* “住院信息”标签页内容 */ 28 | GtkWidget *photo_button; /* “照片”按钮 */ 29 | GtkWidget *name_entry; /* “姓名”输入框 */ 30 | GtkWidget *sex_combo; /* “性别”下拉菜单 */ 31 | GtkWidget *age_entry; /* “年龄”输入框 */ 32 | GtkWidget *birthday_button; /* “生日”选择按钮 */ 33 | GtkWidget *marriage_combo; /* “婚姻”下拉菜单 */ 34 | GtkWidget *edu_combo; /* “教育”下拉菜单 */ 35 | GtkWidget *id_entry; /* “身份证”输入框 */ 36 | GtkWidget *census_entry; /* “户籍”输入框 */ 37 | GtkWidget *happened_button; /* “发生时间”按钮*/ 38 | GtkWidget *place_combo; /* “发生地点”下拉菜单 */ 39 | GtkWidget *bill_entry; /* “三联单”输入框 */ 40 | GtkWidget *num_entry; /* “住院号”输入框 */ 41 | GtkWidget *into_button; /* “入院时间”选择按钮 */ 42 | GtkWidget *inps_entry; /* “入院评分”输入框 */ 43 | GtkWidget *out_button; /* “出院时间”选择按钮 */ 44 | GtkWidget *outps_entry; /* “出院评分”输入框 */ 45 | GtkWidget *days_entry; /* “住院天数”输入框 */ 46 | GtkWidget *persent_button; /* 计算“减分率”按钮 */ 47 | GtkWidget *cost_entry; /* “花费”输入框 */ 48 | GtkWidget *goto_combo; /* “患者去向”选择框 */ 49 | GtkWidget *level_combo; /* “行为分级”下拉菜单 */ 50 | GtkWidget *symptom_combo; /* “患者症状”下拉菜单 */ 51 | GtkWidget *status_combo; /* “患者状态”下拉菜单 */ 52 | GtkWidget *psy_combo; /* “抗精神病药物”下拉菜单 */ 53 | GtkWidget *dep_combo; /* “抗抑郁药物”下拉菜单 */ 54 | GtkWidget *anxiety_combo; /* “抗焦虑药物”下拉菜单 */ 55 | GtkWidget *heart_combo; /* “心境稳定剂”下拉菜单 */ 56 | GtkWidget *addicted_combo; /* “物质依赖”下拉菜单 */ 57 | GtkWidget *drug_combo; /* “吸毒”输入框 */ 58 | GtkWidget *body_entry; /* “躯体疾病”输入框 */ 59 | GtkWidget *infect_entry; /* “传染病”输入框 */ 60 | 61 | /* “历史记录”标签页内容 */ 62 | GtkWidget *histroy_list; /* “历史记录”树形图 */ 63 | 64 | /* “确认出院”按钮 */ 65 | GtkWidget *out_check; 66 | } Item; 67 | 68 | /* 从界面抓取到的字符串集合, 69 | * 可用于数据库的操作 70 | */ 71 | typedef struct _Pchar { 72 | char photo_path[100]; 73 | char name[100]; 74 | char sex[100]; 75 | char birthday[100]; 76 | char age[100]; 77 | char marriage[100]; 78 | char edu[100]; 79 | char id[100]; 80 | char census[100]; 81 | char happened[100]; 82 | char place[100]; 83 | char bill[100]; 84 | char num[100]; 85 | char into_hospital[100]; 86 | char inps[100]; 87 | char out_hospital[100]; 88 | char outps[100]; 89 | char days[100]; 90 | char panss[100]; 91 | char cost[100]; 92 | char go_to[100]; 93 | char level[100]; 94 | char symptom[100]; 95 | char status[100]; 96 | char psy[100]; 97 | char dep[100]; 98 | char anxiety[100]; 99 | char heart[100]; 100 | char addicted[100]; 101 | char drug[100]; 102 | /* 注意字符串长度 */ 103 | char body[1000]; 104 | char infect[1000]; 105 | /* 搜索检测 */ 106 | int find_id; 107 | int find_num; 108 | } Pchar; 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /update_hsp.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | int update_hsp(Pchar *p) 4 | { 5 | sqlite3 *db; 6 | char query[10000] = {0}; 7 | int rc = 0; 8 | 9 | sqlite3_open("hospital.db", &db); 10 | 11 | /* 显然只能用strcat()更好, 12 | * 因为sprintf()的空格问题; 13 | * 另外更新的时候也要注意检索id和num是否重复 14 | */ 15 | strcat(query, "REPLACE INTO tb_hospital VALUES("); 16 | /* 身份证 */ 17 | strcat(query, "'"); 18 | strcat(query, (*p).id); 19 | strcat(query, "',"); 20 | /* 余下都按照这种格式 */ 21 | strcat(query, "'"); 22 | strcat(query, (*p).photo_path); 23 | strcat(query, "',"); 24 | strcat(query, "'"); 25 | strcat(query, (*p).name); 26 | strcat(query, "',"); 27 | strcat(query, "'"); 28 | strcat(query, (*p).sex); 29 | strcat(query, "',"); 30 | strcat(query, "'"); 31 | strcat(query, (*p).birthday); 32 | strcat(query, "',"); 33 | strcat(query, "'"); 34 | strcat(query, (*p).age); 35 | strcat(query, "',"); 36 | strcat(query, "'"); 37 | strcat(query, (*p).marriage); 38 | strcat(query, "',"); 39 | strcat(query, "'"); 40 | strcat(query, (*p).edu); 41 | strcat(query, "',"); 42 | strcat(query, "'"); 43 | strcat(query, (*p).census); 44 | strcat(query, "',"); 45 | strcat(query, "'"); 46 | strcat(query, (*p).happened); 47 | strcat(query, "',"); 48 | strcat(query, "'"); 49 | strcat(query, (*p).place); 50 | strcat(query, "',"); 51 | strcat(query, "'"); 52 | strcat(query, (*p).bill); 53 | strcat(query, "',"); 54 | strcat(query, "'"); 55 | strcat(query, (*p).num); 56 | strcat(query, "',"); 57 | strcat(query, "'"); 58 | strcat(query, (*p).into_hospital); 59 | strcat(query, "',"); 60 | strcat(query, "'"); 61 | strcat(query, (*p).inps); 62 | strcat(query, "',"); 63 | strcat(query, "'"); 64 | strcat(query, (*p).out_hospital); 65 | strcat(query, "',"); 66 | strcat(query, "'"); 67 | strcat(query, (*p).outps); 68 | strcat(query, "',"); 69 | strcat(query, "'"); 70 | strcat(query, (*p).days); 71 | strcat(query, "',"); 72 | strcat(query, "'"); 73 | strcat(query, (*p).panss); 74 | strcat(query, "',"); 75 | strcat(query, "'"); 76 | strcat(query, (*p).cost); 77 | strcat(query, "',"); 78 | strcat(query, "'"); 79 | strcat(query, (*p).go_to); 80 | strcat(query, "',"); 81 | strcat(query, "'"); 82 | strcat(query, (*p).level); 83 | strcat(query, "',"); 84 | strcat(query, "'"); 85 | strcat(query, (*p).symptom); 86 | strcat(query, "',"); 87 | strcat(query, "'"); 88 | strcat(query, (*p).status); 89 | strcat(query, "',"); 90 | strcat(query, "'"); 91 | strcat(query, (*p).psy); 92 | strcat(query, "',"); 93 | strcat(query, "'"); 94 | strcat(query, (*p).dep); 95 | strcat(query, "',"); 96 | strcat(query, "'"); 97 | strcat(query, (*p).anxiety); 98 | strcat(query, "',"); 99 | strcat(query, "'"); 100 | strcat(query, (*p).heart); 101 | strcat(query, "',"); 102 | strcat(query, "'"); 103 | strcat(query, (*p).addicted); 104 | strcat(query, "',"); 105 | strcat(query, "'"); 106 | strcat(query, (*p).drug); 107 | strcat(query, "',"); 108 | strcat(query, "'"); 109 | strcat(query, (*p).body); 110 | strcat(query, "',"); 111 | strcat(query, "'"); 112 | strcat(query, (*p).infect); 113 | strcat(query, "');"); 114 | 115 | /* 开始执行语句 */ 116 | rc = sqlite3_exec(db, query, NULL, NULL, NULL); 117 | 118 | /* 关闭数据库 */ 119 | sqlite3_close(db); 120 | 121 | return rc; 122 | } 123 | -------------------------------------------------------------------------------- /insert_hsp.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | int insert_hsp(Pchar *p) 4 | { 5 | sqlite3 *db; 6 | char query[10000] = {0}; 7 | int rc = 0; 8 | 9 | /* 注意及时关闭数据库 */ 10 | sqlite3_open("hospital.db", &db); 11 | 12 | /* 开始组装插入语句, 13 | * 显然用sprintf()面临字符串中的空格问题, 14 | * 所以用strcat() 15 | */ 16 | strcat(query, "INSERT INTO tb_hospital VALUES("); 17 | /* 身份证 */ 18 | strcat(query, "'"); 19 | strcat(query, (*p).id); 20 | strcat(query, "',"); 21 | /* 余下都按照这种格式 */ 22 | strcat(query, "'"); 23 | strcat(query, (*p).photo_path); 24 | strcat(query, "',"); 25 | strcat(query, "'"); 26 | strcat(query, (*p).name); 27 | strcat(query, "',"); 28 | strcat(query, "'"); 29 | strcat(query, (*p).sex); 30 | strcat(query, "',"); 31 | strcat(query, "'"); 32 | strcat(query, (*p).birthday); 33 | strcat(query, "',"); 34 | strcat(query, "'"); 35 | strcat(query, (*p).age); 36 | strcat(query, "',"); 37 | strcat(query, "'"); 38 | strcat(query, (*p).marriage); 39 | strcat(query, "',"); 40 | strcat(query, "'"); 41 | strcat(query, (*p).edu); 42 | strcat(query, "',"); 43 | strcat(query, "'"); 44 | strcat(query, (*p).census); 45 | strcat(query, "',"); 46 | strcat(query, "'"); 47 | strcat(query, (*p).happened); 48 | strcat(query, "',"); 49 | strcat(query, "'"); 50 | strcat(query, (*p).place); 51 | strcat(query, "',"); 52 | strcat(query, "'"); 53 | strcat(query, (*p).bill); 54 | strcat(query, "',"); 55 | strcat(query, "'"); 56 | strcat(query, (*p).num); 57 | strcat(query, "',"); 58 | strcat(query, "'"); 59 | strcat(query, (*p).into_hospital); 60 | strcat(query, "',"); 61 | strcat(query, "'"); 62 | strcat(query, (*p).inps); 63 | strcat(query, "',"); 64 | strcat(query, "'"); 65 | strcat(query, (*p).out_hospital); 66 | strcat(query, "',"); 67 | strcat(query, "'"); 68 | strcat(query, (*p).outps); 69 | strcat(query, "',"); 70 | strcat(query, "'"); 71 | strcat(query, (*p).days); 72 | strcat(query, "',"); 73 | strcat(query, "'"); 74 | strcat(query, (*p).panss); 75 | strcat(query, "',"); 76 | strcat(query, "'"); 77 | strcat(query, (*p).cost); 78 | strcat(query, "',"); 79 | strcat(query, "'"); 80 | strcat(query, (*p).go_to); 81 | strcat(query, "',"); 82 | strcat(query, "'"); 83 | strcat(query, (*p).level); 84 | strcat(query, "',"); 85 | strcat(query, "'"); 86 | strcat(query, (*p).symptom); 87 | strcat(query, "',"); 88 | strcat(query, "'"); 89 | strcat(query, (*p).status); 90 | strcat(query, "',"); 91 | strcat(query, "'"); 92 | strcat(query, (*p).psy); 93 | strcat(query, "',"); 94 | strcat(query, "'"); 95 | strcat(query, (*p).dep); 96 | strcat(query, "',"); 97 | strcat(query, "'"); 98 | strcat(query, (*p).anxiety); 99 | strcat(query, "',"); 100 | strcat(query, "'"); 101 | strcat(query, (*p).heart); 102 | strcat(query, "',"); 103 | strcat(query, "'"); 104 | strcat(query, (*p).addicted); 105 | strcat(query, "',"); 106 | strcat(query, "'"); 107 | strcat(query, (*p).drug); 108 | strcat(query, "',"); 109 | strcat(query, "'"); 110 | strcat(query, (*p).body); 111 | strcat(query, "',"); 112 | strcat(query, "'"); 113 | strcat(query, (*p).infect); 114 | strcat(query, "');"); 115 | 116 | /* 开始执行语句 */ 117 | rc = sqlite3_exec(db, query, NULL, NULL, NULL); 118 | 119 | /* 关闭数据库 */ 120 | sqlite3_close(db); 121 | 122 | return rc; 123 | }; 124 | -------------------------------------------------------------------------------- /photo_choose.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | /* 获取文件路径后对文件后缀名进行解析, 4 | * 如果不是图片的格式,则错误提醒; 5 | * 如果是图片,则直接通过。 6 | */ 7 | 8 | void photo_choose(GtkWidget *widget, Item *parents) 9 | { 10 | /* 对话框 */ 11 | GtkWidget *dialog; 12 | GtkWidget *message; 13 | /* 照片相关 */ 14 | GtkWidget *new_photo; 15 | GdkPixbuf *photo_pixbuf; 16 | int choose_photo_width = 0, 17 | choose_photo_height = 0, 18 | new_photo_width = 0, 19 | new_photo_height = 0; 20 | /* 字符串相关 */ 21 | gchar *choose_photo_path; 22 | char str_path[256] = {0}; 23 | char *is_bmp, 24 | *is_jpeg, 25 | *is_jpg, 26 | *is_png; 27 | /* 文件相关 */ 28 | FILE *fp; 29 | 30 | /* 创建文件选择框 */ 31 | dialog = gtk_file_chooser_dialog_new( 32 | "选择照片", 33 | NULL, 34 | GTK_FILE_CHOOSER_ACTION_OPEN, 35 | "确定", GTK_RESPONSE_ACCEPT, 36 | "取消", GTK_RESPONSE_CANCEL, 37 | NULL 38 | ); 39 | /* 错误消息对话框 */ 40 | message = gtk_message_dialog_new( 41 | NULL, 42 | GTK_DIALOG_MODAL, 43 | GTK_MESSAGE_ERROR, 44 | GTK_BUTTONS_CLOSE, 45 | "文件格式错误" 46 | ); 47 | 48 | /* 处理事件 */ 49 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 50 | choose_photo_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 51 | /* 通过后缀名检测被选中的文件是否为图片, 52 | * 支持bmp,jpeg,jpg和png; 53 | * 注意: 54 | * 通过后缀名判断文件格式显然有缺陷,在windows调用api更为合理,不过暂时这样做先; 55 | * 显然用strsrt()的方法并不完美,不过先暂时这样做先。 56 | */ 57 | strcpy(str_path, choose_photo_path); 58 | is_bmp = strstr(str_path, ".bmp"); 59 | is_jpeg = strstr(str_path, ".jpeg"); 60 | is_jpg = strstr(str_path, ".jpg"); 61 | is_png = strstr(str_path, ".png"); 62 | if(is_bmp == NULL && is_jpeg == NULL && is_jpg == NULL && is_png == NULL) { 63 | gtk_widget_destroy(dialog); 64 | gtk_dialog_run(GTK_DIALOG(message)); 65 | gtk_widget_destroy(message); 66 | } else { 67 | new_photo = gtk_image_new_from_file(choose_photo_path); 68 | /* 获取被选择的照片的 pixbuf,用于缩放 */ 69 | photo_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(new_photo)); 70 | /* 获取被选中的照片的信息 */ 71 | choose_photo_width = gdk_pixbuf_get_width(photo_pixbuf); 72 | choose_photo_height = gdk_pixbuf_get_height(photo_pixbuf); 73 | /* 设置缩放系数 */ 74 | new_photo_width = 80; 75 | new_photo_height = ((double)new_photo_width / choose_photo_width) * choose_photo_height; 76 | /* 开始进行缩放 */ 77 | photo_pixbuf = gdk_pixbuf_scale_simple( 78 | photo_pixbuf, 79 | new_photo_width, 80 | new_photo_height, 81 | GDK_INTERP_BILINEAR 82 | ); 83 | gtk_image_set_from_pixbuf( 84 | GTK_IMAGE(new_photo), 85 | photo_pixbuf 86 | ); 87 | /* 将缩放得到的照片加入到界面之中 */ 88 | gtk_button_set_image( 89 | GTK_BUTTON((*parents).photo_button), 90 | new_photo 91 | ); 92 | /* 将原始照片复制到相对目录的文件夹下,这部分暂时不做 */ 93 | /* 将原始照片的绝对路径写入文本,以后有用 */ 94 | fp = fopen("photo_path.txt", "w+"); 95 | fputs(choose_photo_path, fp); 96 | fclose(fp); 97 | /* gchar *需要释放 */ 98 | g_free(choose_photo_path); 99 | choose_photo_path = NULL; 100 | gtk_widget_destroy(dialog); 101 | } 102 | } else { 103 | gtk_widget_destroy(dialog); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /birthday_choose.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void birthday_choose(GtkWidget *widget, Item *parents) 4 | { 5 | /* dialog控件 */ 6 | GtkWidget *dialog; 7 | GtkWidget *message; 8 | /* 日期 */ 9 | GtkWidget *birthday_cal; 10 | int int_year = 0, 11 | int_month = 0, 12 | int_day = 0; 13 | char str[50] = {0}, 14 | str_year[10] = {0}, 15 | str_month[10] = {0}, 16 | str_day[10] = {0}; 17 | /* 时间相关 */ 18 | time_t timep; 19 | struct tm *p; 20 | int now_year = 0, 21 | now_month = 0, 22 | now_day = 0; 23 | /* 年龄 */ 24 | int int_age = 0; 25 | char str_age[10] = {0}; 26 | /* 临时变量 */ 27 | int i = 0, 28 | j = 0; 29 | 30 | /* 创建对话框 */ 31 | dialog = gtk_dialog_new_with_buttons( 32 | "选择生日", 33 | NULL, GTK_DIALOG_MODAL, 34 | "确定", GTK_RESPONSE_ACCEPT, 35 | "取消", GTK_RESPONSE_REJECT, 36 | NULL 37 | ); 38 | gtk_window_set_position( 39 | GTK_WINDOW(dialog), 40 | GTK_WIN_POS_CENTER 41 | ); 42 | gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 43 | 44 | /* 创建日历选择框 */ 45 | birthday_cal = gtk_calendar_new(); 46 | gtk_box_pack_start( 47 | GTK_BOX(GTK_DIALOG(dialog) -> vbox), 48 | birthday_cal, 49 | TRUE, 50 | TRUE, 51 | 0 52 | ); 53 | /* 记住及时显示 */ 54 | gtk_widget_show(birthday_cal); 55 | 56 | /* 处理事件 */ 57 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 58 | gtk_calendar_get_date( 59 | GTK_CALENDAR(birthday_cal), 60 | &int_year, 61 | &int_month, 62 | &int_day 63 | ); 64 | int_month = int_month + 1; /* 因为获取的月份比实际月份小1 */ 65 | /* 获取当前时间 */ 66 | time(&timep); 67 | p = gmtime(&timep); 68 | now_year = 1900 + p -> tm_year; 69 | now_month = 1 + p -> tm_mon; 70 | now_day = p -> tm_mday; 71 | /* 错误消息提示框 */ 72 | message = gtk_message_dialog_new( 73 | NULL, 74 | GTK_DIALOG_MODAL, 75 | GTK_MESSAGE_ERROR, 76 | GTK_BUTTONS_CLOSE, 77 | "生日不可能超过今天" 78 | ); 79 | if ( 80 | (int_year > now_year) || 81 | (int_year == now_year && int_month > now_month) || 82 | (int_year == now_year && int_month == now_month && int_day > now_day) 83 | ) { 84 | gtk_widget_destroy(dialog); 85 | gtk_dialog_run(GTK_DIALOG(message)); 86 | gtk_widget_destroy(message); 87 | } else { 88 | sprintf(str_year, "%d", int_year); 89 | sprintf(str_month, "%d", int_month); 90 | sprintf(str_day, "%d", int_day); 91 | /* 决定采用“年月日”的显示方式,所以对字符串的处理要求高些 */ 92 | strcat(str, str_year); 93 | strcat(str, "年"); 94 | strcat(str, str_month); 95 | strcat(str, "月"); 96 | strcat(str, str_day); 97 | strcat(str, "日"); 98 | gtk_button_set_label( 99 | GTK_BUTTON((*parents).birthday_button), 100 | str 101 | ); 102 | int_age = now_year - int_year; 103 | /* 如果生日的月份小于当前月份,则没过生日 */ 104 | if (int_month > now_month) { 105 | int_age -= 1; 106 | } 107 | /* 如果月份相同,但日期未到,则也没过生日 */ 108 | if (int_month == now_month && int_day > now_day) { 109 | int_age -= 1; 110 | } 111 | sprintf(str_age, "%d", int_age); 112 | gtk_entry_set_text( 113 | GTK_ENTRY((*parents).age_entry), 114 | str_age 115 | ); 116 | gtk_widget_show((*parents).birthday_button); 117 | gtk_widget_show((*parents).age_entry); 118 | gtk_widget_destroy(dialog); 119 | } 120 | } else { 121 | gtk_widget_destroy(dialog); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /cancel.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void cancel(GtkWidget *widget, Item *parents) 4 | { 5 | /* “取消”按钮与“新建”按钮的逻辑不同,只是暂时这样做罢了: 6 | * 1. 如果是“新建”且未保存,则“取消”按钮与新建按钮功能相同,都是清空当前界面内容 7 | * 2. 如果是查看在院/历史病人的信息,那么“取消”按钮相当于把修改过但未保存的内容重置 8 | */ 9 | 10 | FILE *fp; 11 | /* 移除照片 */ 12 | gtk_button_set_image( 13 | GTK_BUTTON((*parents).photo_button), 14 | NULL 15 | ); 16 | remove("photo_path.txt"); 17 | fp = fopen("photo_path.txt", "w+"); 18 | fclose(fp); 19 | gtk_widget_show((*parents).photo_button); 20 | /* 移除姓名 */ 21 | gtk_entry_set_text( 22 | GTK_ENTRY((*parents).name_entry), 23 | "" 24 | ); 25 | gtk_widget_show((*parents).name_entry); 26 | /* 设置“性别”下拉菜单为空 */ 27 | gtk_combo_box_set_active( 28 | GTK_COMBO_BOX((*parents).sex_combo), 29 | -1 30 | ); 31 | gtk_widget_show((*parents).sex_combo); 32 | /* “生日”按钮 */ 33 | gtk_button_set_label( 34 | GTK_BUTTON((*parents).birthday_button), 35 | "选择日期" 36 | ); 37 | gtk_widget_show((*parents).birthday_button); 38 | /* “年龄”输入框 */ 39 | gtk_entry_set_text( 40 | GTK_ENTRY((*parents).age_entry), 41 | "" 42 | ); 43 | gtk_widget_show((*parents).age_entry); 44 | /* “婚姻” */ 45 | gtk_combo_box_set_active( 46 | GTK_COMBO_BOX((*parents).marriage_combo), 47 | -1 48 | ); 49 | gtk_widget_show((*parents).marriage_combo); 50 | /* “教育” */ 51 | gtk_combo_box_set_active( 52 | GTK_COMBO_BOX((*parents).edu_combo), 53 | -1 54 | ); 55 | gtk_widget_show((*parents).edu_combo); 56 | /* “身份证” */ 57 | gtk_entry_set_text( 58 | GTK_ENTRY((*parents).id_entry), 59 | "" 60 | ); 61 | gtk_widget_show((*parents).id_entry); 62 | /* “户籍” */ 63 | gtk_entry_set_text( 64 | GTK_ENTRY((*parents).census_entry), 65 | "" 66 | ); 67 | gtk_widget_show((*parents).census_entry); 68 | /* “发生时间” */ 69 | gtk_button_set_label( 70 | GTK_BUTTON((*parents).happened_button), 71 | "选择日期" 72 | ); 73 | gtk_widget_show((*parents).happened_button); 74 | /* “发生地点” */ 75 | gtk_combo_box_set_active( 76 | GTK_COMBO_BOX((*parents).place_combo), 77 | -1 78 | ); 79 | gtk_widget_show((*parents).place_combo); 80 | /* “三联单” */ 81 | gtk_entry_set_text( 82 | GTK_ENTRY((*parents).bill_entry), 83 | "" 84 | ); 85 | gtk_widget_show((*parents).bill_entry); 86 | /* “住院号” */ 87 | gtk_entry_set_text( 88 | GTK_ENTRY((*parents).num_entry), 89 | "" 90 | ); 91 | gtk_widget_show((*parents).num_entry); 92 | /* “入院时间” */ 93 | gtk_button_set_label( 94 | GTK_BUTTON((*parents).into_button), 95 | "选择日期" 96 | ); 97 | gtk_widget_show((*parents).into_button); 98 | /* “入院评分” */ 99 | gtk_entry_set_text( 100 | GTK_ENTRY((*parents).inps_entry), 101 | "" 102 | ); 103 | gtk_widget_show((*parents).inps_entry); 104 | /* “出院时间” */ 105 | gtk_button_set_label( 106 | GTK_BUTTON((*parents).out_button), 107 | "选择日期" 108 | ); 109 | gtk_widget_show((*parents).out_button); 110 | /* “出院评分” */ 111 | gtk_entry_set_text( 112 | GTK_ENTRY((*parents).outps_entry), 113 | "" 114 | ); 115 | gtk_widget_show((*parents).outps_entry); 116 | /* “住院天数” */ 117 | gtk_entry_set_text( 118 | GTK_ENTRY((*parents).days_entry), 119 | "" 120 | ); 121 | gtk_widget_show((*parents).days_entry); 122 | /* “减分率” */ 123 | gtk_button_set_label( 124 | GTK_BUTTON((*parents).persent_button), 125 | "计算" 126 | ); 127 | gtk_widget_show((*parents).persent_button); 128 | /* “花费” */ 129 | gtk_entry_set_text( 130 | GTK_ENTRY((*parents).cost_entry), 131 | "" 132 | ); 133 | gtk_widget_show((*parents).cost_entry); 134 | /* “患者去向” */ 135 | gtk_combo_box_set_active( 136 | GTK_COMBO_BOX((*parents).goto_combo), 137 | -1 138 | ); 139 | gtk_widget_show((*parents).goto_combo); 140 | /* “行为分级” */ 141 | gtk_combo_box_set_active( 142 | GTK_COMBO_BOX((*parents).level_combo), 143 | -1 144 | ); 145 | gtk_widget_show((*parents).level_combo); 146 | /* “患者症状” */ 147 | gtk_combo_box_set_active( 148 | GTK_COMBO_BOX((*parents).symptom_combo), 149 | -1 150 | ); 151 | gtk_widget_show((*parents).symptom_combo); 152 | /* “患者状态” */ 153 | gtk_combo_box_set_active( 154 | GTK_COMBO_BOX((*parents).status_combo), 155 | -1 156 | ); 157 | gtk_widget_show((*parents).status_combo); 158 | /* “抗精神病药物” */ 159 | gtk_combo_box_set_active( 160 | GTK_COMBO_BOX((*parents).psy_combo), 161 | -1 162 | ); 163 | gtk_widget_show((*parents).psy_combo); 164 | /* “抗抑郁药物” */ 165 | gtk_combo_box_set_active( 166 | GTK_COMBO_BOX((*parents).dep_combo), 167 | -1 168 | ); 169 | gtk_widget_show((*parents).dep_combo); 170 | /* “抗焦虑药物” */ 171 | gtk_combo_box_set_active( 172 | GTK_COMBO_BOX((*parents).anxiety_combo), 173 | -1 174 | ); 175 | gtk_widget_show((*parents).anxiety_combo); 176 | /* “心境稳定剂” */ 177 | gtk_combo_box_set_active( 178 | GTK_COMBO_BOX((*parents).heart_combo), 179 | -1 180 | ); 181 | gtk_widget_show((*parents).heart_combo); 182 | /* “物质依赖” */ 183 | gtk_combo_box_set_active( 184 | GTK_COMBO_BOX((*parents).addicted_combo), 185 | -1 186 | ); 187 | gtk_widget_show((*parents).addicted_combo); 188 | /* “是否吸毒” */ 189 | gtk_combo_box_set_active( 190 | GTK_COMBO_BOX((*parents).drug_combo), 191 | -1 192 | ); 193 | gtk_widget_show((*parents).drug_combo); 194 | /* “躯体疾病” */ 195 | gtk_entry_set_text( 196 | GTK_ENTRY((*parents).body_entry), 197 | "" 198 | ); 199 | gtk_widget_show((*parents).body_entry); 200 | /* “传染病” */ 201 | gtk_entry_set_text( 202 | GTK_ENTRY((*parents).infect_entry), 203 | "" 204 | ); 205 | gtk_widget_show((*parents).infect_entry); 206 | /* “确认出院” */ 207 | gtk_toggle_button_set_active( 208 | GTK_TOGGLE_BUTTON((*parents).out_check), 209 | FALSE 210 | ); 211 | 212 | /* 对于clist的处理,暂时不做 */ 213 | } 214 | -------------------------------------------------------------------------------- /new_person.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | void new_person(GtkWidget *widget, Item *parents) 4 | { 5 | /* 仅仅是把当前person_notebook界面的内容清空, 6 | * 并且把“在院病人列表”设置为没有选项被选择即可, 7 | * 不需要对数据库进行更改。 8 | */ 9 | 10 | FILE *fp; 11 | /* 移除照片 */ 12 | gtk_button_set_image( 13 | GTK_BUTTON((*parents).photo_button), 14 | NULL 15 | ); 16 | remove("photo_path.txt"); 17 | fp = fopen("photo_path.txt", "w+"); 18 | fclose(fp); 19 | gtk_widget_show((*parents).photo_button); 20 | /* 移除姓名 */ 21 | gtk_entry_set_text( 22 | GTK_ENTRY((*parents).name_entry), 23 | "" 24 | ); 25 | gtk_widget_show((*parents).name_entry); 26 | /* 设置“性别”下拉菜单为空 */ 27 | gtk_combo_box_set_active( 28 | GTK_COMBO_BOX((*parents).sex_combo), 29 | -1 30 | ); 31 | gtk_widget_show((*parents).sex_combo); 32 | /* “生日”按钮 */ 33 | gtk_button_set_label( 34 | GTK_BUTTON((*parents).birthday_button), 35 | "选择日期" 36 | ); 37 | gtk_widget_show((*parents).birthday_button); 38 | /* “年龄”输入框 */ 39 | gtk_entry_set_text( 40 | GTK_ENTRY((*parents).age_entry), 41 | "" 42 | ); 43 | gtk_widget_show((*parents).age_entry); 44 | /* “婚姻” */ 45 | gtk_combo_box_set_active( 46 | GTK_COMBO_BOX((*parents).marriage_combo), 47 | -1 48 | ); 49 | gtk_widget_show((*parents).marriage_combo); 50 | /* “教育” */ 51 | gtk_combo_box_set_active( 52 | GTK_COMBO_BOX((*parents).edu_combo), 53 | -1 54 | ); 55 | gtk_widget_show((*parents).edu_combo); 56 | /* “身份证” */ 57 | gtk_entry_set_text( 58 | GTK_ENTRY((*parents).id_entry), 59 | "" 60 | ); 61 | gtk_widget_show((*parents).id_entry); 62 | /* “户籍” */ 63 | gtk_entry_set_text( 64 | GTK_ENTRY((*parents).census_entry), 65 | "" 66 | ); 67 | gtk_widget_show((*parents).census_entry); 68 | /* “发生时间” */ 69 | gtk_button_set_label( 70 | GTK_BUTTON((*parents).happened_button), 71 | "选择日期" 72 | ); 73 | gtk_widget_show((*parents).happened_button); 74 | /* “发生地点” */ 75 | gtk_combo_box_set_active( 76 | GTK_COMBO_BOX((*parents).place_combo), 77 | -1 78 | ); 79 | gtk_widget_show((*parents).place_combo); 80 | /* “三联单” */ 81 | gtk_entry_set_text( 82 | GTK_ENTRY((*parents).bill_entry), 83 | "" 84 | ); 85 | gtk_widget_show((*parents).bill_entry); 86 | /* “住院号” */ 87 | gtk_entry_set_text( 88 | GTK_ENTRY((*parents).num_entry), 89 | "" 90 | ); 91 | gtk_widget_show((*parents).num_entry); 92 | /* “入院时间” */ 93 | gtk_button_set_label( 94 | GTK_BUTTON((*parents).into_button), 95 | "选择日期" 96 | ); 97 | gtk_widget_show((*parents).into_button); 98 | /* “入院评分” */ 99 | gtk_entry_set_text( 100 | GTK_ENTRY((*parents).inps_entry), 101 | "" 102 | ); 103 | gtk_widget_show((*parents).inps_entry); 104 | /* “出院时间” */ 105 | gtk_button_set_label( 106 | GTK_BUTTON((*parents).out_button), 107 | "选择日期" 108 | ); 109 | gtk_widget_show((*parents).out_button); 110 | /* “出院评分” */ 111 | gtk_entry_set_text( 112 | GTK_ENTRY((*parents).outps_entry), 113 | "" 114 | ); 115 | gtk_widget_show((*parents).outps_entry); 116 | /* “住院天数” */ 117 | gtk_entry_set_text( 118 | GTK_ENTRY((*parents).days_entry), 119 | "" 120 | ); 121 | gtk_widget_show((*parents).days_entry); 122 | /* “减分率” */ 123 | gtk_button_set_label( 124 | GTK_BUTTON((*parents).persent_button), 125 | "计算" 126 | ); 127 | gtk_widget_show((*parents).persent_button); 128 | /* “花费” */ 129 | gtk_entry_set_text( 130 | GTK_ENTRY((*parents).cost_entry), 131 | "" 132 | ); 133 | gtk_widget_show((*parents).cost_entry); 134 | /* “患者去向” */ 135 | gtk_combo_box_set_active( 136 | GTK_COMBO_BOX((*parents).goto_combo), 137 | -1 138 | ); 139 | gtk_widget_show((*parents).goto_combo); 140 | /* “行为分级” */ 141 | gtk_combo_box_set_active( 142 | GTK_COMBO_BOX((*parents).level_combo), 143 | -1 144 | ); 145 | gtk_widget_show((*parents).level_combo); 146 | /* “患者症状” */ 147 | gtk_combo_box_set_active( 148 | GTK_COMBO_BOX((*parents).symptom_combo), 149 | -1 150 | ); 151 | gtk_widget_show((*parents).symptom_combo); 152 | /* “患者状态” */ 153 | gtk_combo_box_set_active( 154 | GTK_COMBO_BOX((*parents).status_combo), 155 | -1 156 | ); 157 | gtk_widget_show((*parents).status_combo); 158 | /* “抗精神病药物” */ 159 | gtk_combo_box_set_active( 160 | GTK_COMBO_BOX((*parents).psy_combo), 161 | -1 162 | ); 163 | gtk_widget_show((*parents).psy_combo); 164 | /* “抗抑郁药物” */ 165 | gtk_combo_box_set_active( 166 | GTK_COMBO_BOX((*parents).dep_combo), 167 | -1 168 | ); 169 | gtk_widget_show((*parents).dep_combo); 170 | /* “抗焦虑药物” */ 171 | gtk_combo_box_set_active( 172 | GTK_COMBO_BOX((*parents).anxiety_combo), 173 | -1 174 | ); 175 | gtk_widget_show((*parents).anxiety_combo); 176 | /* “心境稳定剂” */ 177 | gtk_combo_box_set_active( 178 | GTK_COMBO_BOX((*parents).heart_combo), 179 | -1 180 | ); 181 | gtk_widget_show((*parents).heart_combo); 182 | /* “物质依赖” */ 183 | gtk_combo_box_set_active( 184 | GTK_COMBO_BOX((*parents).addicted_combo), 185 | -1 186 | ); 187 | gtk_widget_show((*parents).addicted_combo); 188 | /* “是否吸毒” */ 189 | gtk_combo_box_set_active( 190 | GTK_COMBO_BOX((*parents).drug_combo), 191 | -1 192 | ); 193 | gtk_widget_show((*parents).drug_combo); 194 | /* “躯体疾病” */ 195 | gtk_entry_set_text( 196 | GTK_ENTRY((*parents).body_entry), 197 | "" 198 | ); 199 | gtk_widget_show((*parents).body_entry); 200 | /* “传染病” */ 201 | gtk_entry_set_text( 202 | GTK_ENTRY((*parents).infect_entry), 203 | "" 204 | ); 205 | gtk_widget_show((*parents).infect_entry); 206 | /* “确认出院” */ 207 | gtk_toggle_button_set_active( 208 | GTK_TOGGLE_BUTTON((*parents).out_check), 209 | FALSE 210 | ); 211 | 212 | /* 对于clist的处理 */ 213 | (*parents).get_row = -1; 214 | (*parents).get_column = -1; 215 | gtk_clist_unselect_all(GTK_CLIST((*parents).hospital_list)); 216 | } 217 | -------------------------------------------------------------------------------- /out_choose.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | /* 思考一个问题: 4 | * 是否需要在对话框中添加更多按钮, 5 | * 比如“重置”按钮。 6 | * 暂时不考虑这个问题,搁置一边。 7 | */ 8 | 9 | typedef struct _Date { 10 | int year; 11 | int month; 12 | int day; 13 | } Date; 14 | 15 | /* 计算距离当年1月1号有多少天的函数 */ 16 | int get(Date x) 17 | { 18 | int month[12] = { 19 | 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 20 | }; 21 | int year = 0; 22 | int day = 0; 23 | int i = 0; 24 | 25 | year = x.year - 1; 26 | day = year * 365 + year / 4 - year / 100 + year / 400; 27 | /* 求出之前闰年的个数,并在2月的天数上相加 */ 28 | if ((x.year % 4 == 0 && x.year % 100 != 0) || (x.year % 400 == 0)) { 29 | month[1]++; 30 | } 31 | /* 计算出总天数 */ 32 | for (i = 0; i < x.month - 1; i++) { 33 | day += month[i]; 34 | } 35 | /* 当天应该不算在内 */ 36 | day += x.day - 1; 37 | 38 | return day; 39 | } 40 | 41 | /* 计算两个日期之间的差值的函数 */ 42 | int diff(Date a, Date b) 43 | { 44 | int n = 0; 45 | 46 | n = get(b) - get(a); 47 | 48 | return n; 49 | } 50 | 51 | int calculate_days(into_year, into_month, into_day, out_year, out_month, out_day) 52 | { 53 | Date a; 54 | Date b; 55 | int n = 0; 56 | 57 | a.year = into_year; 58 | a.month = into_month; 59 | a.day = into_day; 60 | b.year = out_year; 61 | b.month = out_month; 62 | b.day = out_day; 63 | 64 | n = diff(a, b); 65 | 66 | return n; 67 | } 68 | 69 | void out_choose(GtkWidget *widget, Item *parents) 70 | { 71 | /* 对话框 */ 72 | GtkWidget *dialog; 73 | GtkWidget *message_0; 74 | GtkWidget *message_1; 75 | GtkWidget *message_2; 76 | /* 日期 */ 77 | GtkWidget *out_cal; 78 | int out_year = 0, 79 | out_month = 0, 80 | out_day = 0; 81 | char str[50] = {0}, 82 | str_year[10] = {0}, 83 | str_month[10] = {0}, 84 | str_day[10] = {0}; 85 | time_t timep; 86 | struct tm *p; 87 | int now_year = 0, 88 | now_month = 0, 89 | now_day = 0; 90 | /* 日期字符串处理相关 */ 91 | const gchar *into_str; 92 | char temp_str[50] = {0}, 93 | temp_year[10] = {0}, 94 | temp_month[10] = {0}, 95 | temp_day[10] = {0}; 96 | int into_year = 0, 97 | into_month = 0, 98 | into_day = 0; 99 | char cal_days[10] = {0}; 100 | /* 临时变量 */ 101 | int i = 0, 102 | j = 0, 103 | n = 0; 104 | 105 | /* 创建对话框 */ 106 | dialog = gtk_dialog_new_with_buttons( 107 | "选择出院时间", 108 | NULL, GTK_DIALOG_MODAL, 109 | "确定", GTK_RESPONSE_ACCEPT, 110 | "取消", GTK_RESPONSE_REJECT, 111 | NULL 112 | ); 113 | gtk_window_set_position( 114 | GTK_WINDOW(dialog), 115 | GTK_WIN_POS_CENTER 116 | ); 117 | gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 118 | 119 | /* 创建日历选择框 */ 120 | out_cal = gtk_calendar_new(); 121 | gtk_box_pack_start( 122 | GTK_BOX(GTK_DIALOG(dialog) -> vbox), 123 | out_cal, 124 | TRUE, 125 | TRUE, 126 | 0 127 | ); 128 | gtk_widget_show(out_cal); 129 | 130 | /* 处理事件,注意这里对字符串的处理要求高些 */ 131 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 132 | /* 获取into_button中的字符串 */ 133 | into_str = gtk_button_get_label(GTK_BUTTON((*parents).into_button)); 134 | if (strcmp(into_str, "选择日期") == 0) { 135 | message_0 = gtk_message_dialog_new( 136 | NULL, 137 | GTK_DIALOG_MODAL, 138 | GTK_MESSAGE_ERROR, 139 | GTK_BUTTONS_CLOSE, 140 | "请先选择入院时间" 141 | ); 142 | gtk_widget_destroy(dialog); 143 | gtk_dialog_run(GTK_DIALOG(message_0)); 144 | gtk_widget_destroy(message_0); 145 | } else { 146 | gtk_calendar_get_date( 147 | GTK_CALENDAR(out_cal), 148 | &out_year, 149 | &out_month, 150 | &out_day 151 | ); 152 | out_month = out_month + 1; /* 因为获取的月份比实际月份小1 */ 153 | /* 获取当前时间 */ 154 | time(&timep); 155 | p = gmtime(&timep); 156 | now_year = 1900 + p -> tm_year; 157 | now_month = 1 + p -> tm_mon; 158 | now_day = p -> tm_mday; 159 | /* 错误消息对话框 */ 160 | message_1 = gtk_message_dialog_new( 161 | NULL, 162 | GTK_DIALOG_MODAL, 163 | GTK_MESSAGE_ERROR, 164 | GTK_BUTTONS_CLOSE, 165 | "出院时间不可能小于入院时间" 166 | ); 167 | message_2 = gtk_message_dialog_new( 168 | NULL, 169 | GTK_DIALOG_MODAL, 170 | GTK_MESSAGE_ERROR, 171 | GTK_BUTTONS_CLOSE, 172 | "出院时间不可能小于今天" 173 | ); 174 | /* 开始解析出相应日期;有时间可以研究一下sscanf()函数,可能更简便些 */ 175 | strcpy(temp_str, into_str); 176 | /* 提取出年份 */ 177 | for (i = 0, j = 0; i < 4; i++, j++) { 178 | temp_year[j] = temp_str[i]; 179 | } 180 | /* 提取出月份 */ 181 | while (!('0' <= temp_str[i] && temp_str[i] <= '9')) { 182 | i++; 183 | } 184 | for (j = 0; '0' <= temp_str[i] && temp_str[i] <= '9'; i++, j++) { 185 | temp_month[j] = temp_str[i]; 186 | } 187 | /* 提取出日期 */ 188 | while (!('0' <= temp_str[i] && temp_str[i] <= '9')) { 189 | i++; 190 | } 191 | for (j = 0; '0' <= temp_str[i] && temp_str[i] <= '9'; i++, j++) { 192 | temp_day[j] = temp_str[i]; 193 | } 194 | /* 把提取出来的字符串转换成数字 */ 195 | sscanf(temp_year, "%d", &into_year); 196 | sscanf(temp_month, "%d", &into_month); 197 | sscanf(temp_day, "%d", &into_day); 198 | 199 | /* 判断日期是否合理 */ 200 | if ( 201 | (into_year > out_year) || 202 | ((into_year == out_year) && (into_month > out_month)) || 203 | ((into_year == out_year) && (into_month == out_month) && (into_day > out_day)) 204 | ) { 205 | gtk_widget_destroy(dialog); 206 | gtk_dialog_run(GTK_DIALOG(message_1)); 207 | gtk_widget_destroy(message_1); 208 | } else if ( 209 | (out_year > now_year) || 210 | ((out_year == now_year) && (out_month > now_month)) || 211 | ((out_year == now_year) && (out_month == now_month) && (out_day > now_day)) 212 | ) { 213 | gtk_widget_destroy(dialog); 214 | gtk_dialog_run(GTK_DIALOG(message_2)); 215 | gtk_widget_destroy(message_2); 216 | } else { 217 | sprintf(str_year, "%d", out_year); 218 | sprintf(str_month, "%d", out_month); 219 | sprintf(str_day, "%d", out_day); 220 | strcat(str, str_year); 221 | strcat(str, "年 "); 222 | strcat(str, str_month); 223 | strcat(str, "月 "); 224 | strcat(str, str_day); 225 | strcat(str, "日"); 226 | gtk_button_set_label(GTK_BUTTON((*parents).out_button), str); 227 | /* 开始计算住院天数 */ 228 | n = calculate_days(into_year, into_month, into_day, out_year, out_month, out_day); 229 | sprintf(cal_days, "%d", n); 230 | gtk_entry_set_text(GTK_ENTRY((*parents).days_entry), cal_days); 231 | gtk_widget_show((*parents).out_button); 232 | gtk_widget_show((*parents).days_entry); 233 | gtk_widget_destroy(dialog); 234 | } 235 | } 236 | } else { 237 | gtk_widget_destroy(dialog); 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /check_sure.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | int search_hsp(Pchar *p); 4 | int insert_hsp(Pchar *p); 5 | int update_hsp(Pchar *p); 6 | void hsp_list(Item *parents); 7 | 8 | void check_sure(GtkWidget *widget, Item *parents) 9 | { 10 | GtkWidget *message; 11 | const gchar *cnt; 12 | gchar *gtx; 13 | gboolean is_active; 14 | /* 注意一些数组的大小, 15 | * 全部把长度设置为100好了 16 | */ 17 | FILE *fp; 18 | Pchar *p; 19 | int judge_id = 0; 20 | int judge_num = 0; 21 | int judge_temp = 0; 22 | int rc_search = 0; 23 | int rc_update = 0; 24 | int rc_sqlite = 0; 25 | int i = 0; 26 | 27 | p = (Pchar *)malloc(sizeof(Pchar)); 28 | 29 | /* 照片路径 */ 30 | fp = fopen("photo_path.txt", "r+"); 31 | fgets((*p).photo_path, 101, fp); 32 | /* 姓名 */ 33 | cnt = gtk_entry_get_text( 34 | GTK_ENTRY((*parents).name_entry) 35 | ); 36 | strcpy((*p).name, cnt); 37 | /* 性别 */ 38 | gtx = gtk_combo_box_text_get_active_text( 39 | GTK_COMBO_BOX_TEXT((*parents).sex_combo) 40 | ); 41 | /* 这样的做法实在缺考虑,可能把Pchar结构体里面换成指针更好一些, 42 | * 不过用数组对数据库语句的操作比较方便吧 43 | */ 44 | if (gtx == NULL) { 45 | strcpy((*p).sex, "\0"); 46 | } else { 47 | strcpy((*p).sex, gtx); 48 | } 49 | /* 生日 */ 50 | cnt = gtk_button_get_label( 51 | GTK_BUTTON((*parents).birthday_button) 52 | ); 53 | strcpy((*p).birthday, cnt); 54 | /* 年龄 */ 55 | cnt = gtk_entry_get_text( 56 | GTK_ENTRY((*parents).age_entry) 57 | ); 58 | strcpy((*p).age, cnt); 59 | /* 婚姻状况 */ 60 | gtx = gtk_combo_box_text_get_active_text( 61 | GTK_COMBO_BOX_TEXT((*parents).marriage_combo) 62 | ); 63 | if (gtx == NULL) { 64 | strcpy((*p).marriage, "\0"); 65 | } else { 66 | strcpy((*p).marriage, gtx); 67 | } 68 | /* 文化程度 */ 69 | gtx = gtk_combo_box_text_get_active_text( 70 | GTK_COMBO_BOX_TEXT((*parents).edu_combo) 71 | ); 72 | if (gtx == NULL) { 73 | strcpy((*p).edu, "\0"); 74 | } else { 75 | strcpy((*p).edu, gtx); 76 | } 77 | /* 身份证,需要进行数据检测 */ 78 | cnt = gtk_entry_get_text( 79 | GTK_ENTRY((*parents).id_entry) 80 | ); 81 | strcpy((*p).id, cnt); 82 | /* 户籍证明 */ 83 | cnt = gtk_entry_get_text( 84 | GTK_ENTRY((*parents).census_entry) 85 | ); 86 | strcpy((*p).census, cnt); 87 | /* 事发时间 */ 88 | cnt = gtk_button_get_label( 89 | GTK_BUTTON((*parents).happened_button) 90 | ); 91 | strcpy((*p).happened, cnt); 92 | /* 事发地点 */ 93 | gtx = gtk_combo_box_text_get_active_text( 94 | GTK_COMBO_BOX_TEXT((*parents).place_combo) 95 | ); 96 | if (gtx == NULL) { 97 | strcpy((*p).place, "\0"); 98 | } else { 99 | strcpy((*p).place, gtx); 100 | } 101 | /* 三联单 */ 102 | cnt = gtk_entry_get_text( 103 | GTK_ENTRY((*parents).bill_entry) 104 | ); 105 | strcpy((*p).bill, cnt); 106 | /* 住院号,需要进行数据检测吗 */ 107 | cnt = gtk_entry_get_text( 108 | GTK_ENTRY((*parents).num_entry) 109 | ); 110 | strcpy((*p).num, cnt); 111 | /* 入院时间 */ 112 | cnt = gtk_button_get_label( 113 | GTK_BUTTON((*parents).into_button) 114 | ); 115 | strcpy((*p).into_hospital, cnt); 116 | /* 入院评分 */ 117 | cnt = gtk_entry_get_text( 118 | GTK_ENTRY((*parents).inps_entry) 119 | ); 120 | strcpy((*p).inps, cnt); 121 | /* 出院时间 */ 122 | cnt = gtk_button_get_label( 123 | GTK_BUTTON((*parents).out_button) 124 | ); 125 | strcpy((*p).out_hospital, cnt); 126 | /* 出院评分 */ 127 | cnt = gtk_entry_get_text( 128 | GTK_ENTRY((*parents).outps_entry) 129 | ); 130 | strcpy((*p).outps, cnt); 131 | /* 住院天数 */ 132 | cnt = gtk_entry_get_text( 133 | GTK_ENTRY((*parents).days_entry) 134 | ); 135 | strcpy((*p).days, cnt); 136 | /* 减分率 */ 137 | cnt = gtk_button_get_label( 138 | GTK_BUTTON((*parents).persent_button) 139 | ); 140 | strcpy((*p).panss, cnt); 141 | /* 住院花费 */ 142 | cnt = gtk_entry_get_text( 143 | GTK_ENTRY((*parents).cost_entry) 144 | ); 145 | strcpy((*p).cost, cnt); 146 | /* 患者去向 */ 147 | gtx = gtk_combo_box_text_get_active_text( 148 | GTK_COMBO_BOX_TEXT((*parents).goto_combo) 149 | ); 150 | if (gtx == NULL) { 151 | strcpy((*p).go_to, "\0"); 152 | } else { 153 | strcpy((*p).go_to, gtx); 154 | } 155 | /* 行为分级 */ 156 | gtx = gtk_combo_box_text_get_active_text( 157 | GTK_COMBO_BOX_TEXT((*parents).level_combo) 158 | ); 159 | if (gtx == NULL) { 160 | strcpy((*p).level, "\0"); 161 | } else { 162 | strcpy((*p).level, gtx); 163 | } 164 | /* 患者症状 */ 165 | gtx = gtk_combo_box_text_get_active_text( 166 | GTK_COMBO_BOX_TEXT((*parents).symptom_combo) 167 | ); 168 | if (gtx == NULL) { 169 | strcpy((*p).symptom, "\0"); 170 | } else { 171 | strcpy((*p).symptom, gtx); 172 | } 173 | /* 患者状态 */ 174 | gtx = gtk_combo_box_text_get_active_text( 175 | GTK_COMBO_BOX_TEXT((*parents).status_combo) 176 | ); 177 | if (gtx == NULL) { 178 | strcpy((*p).status, "\0"); 179 | } else { 180 | strcpy((*p).status, gtx); 181 | } 182 | /* 抗精神病药物 */ 183 | gtx = gtk_combo_box_text_get_active_text( 184 | GTK_COMBO_BOX_TEXT((*parents).psy_combo) 185 | ); 186 | if (gtx == NULL) { 187 | strcpy((*p).psy, "\0"); 188 | } else { 189 | strcpy((*p).psy, gtx); 190 | } 191 | /* 抗抑郁药物 */ 192 | gtx = gtk_combo_box_text_get_active_text( 193 | GTK_COMBO_BOX_TEXT((*parents).dep_combo) 194 | ); 195 | if (gtx == NULL) { 196 | strcpy((*p).dep, "\0"); 197 | } else { 198 | strcpy((*p).dep, gtx); 199 | } 200 | /* 抗焦虑药物 */ 201 | gtx = gtk_combo_box_text_get_active_text( 202 | GTK_COMBO_BOX_TEXT((*parents).anxiety_combo) 203 | ); 204 | if (gtx == NULL) { 205 | strcpy((*p).anxiety, "\0"); 206 | } else { 207 | strcpy((*p).anxiety, gtx); 208 | } 209 | /* 心境稳定剂 */ 210 | gtx = gtk_combo_box_text_get_active_text( 211 | GTK_COMBO_BOX_TEXT((*parents).heart_combo) 212 | ); 213 | if (gtx == NULL) { 214 | strcpy((*p).heart, "\0"); 215 | } else { 216 | strcpy((*p).heart, gtx); 217 | } 218 | /* 物质依赖 */ 219 | gtx = gtk_combo_box_text_get_active_text( 220 | GTK_COMBO_BOX_TEXT((*parents).addicted_combo) 221 | ); 222 | if (gtx == NULL) { 223 | strcpy((*p).addicted, "\0"); 224 | } else { 225 | strcpy((*p).addicted, gtx); 226 | } 227 | /* 是否吸毒 */ 228 | gtx = gtk_combo_box_text_get_active_text( 229 | GTK_COMBO_BOX_TEXT((*parents).drug_combo) 230 | ); 231 | if (gtx == NULL) { 232 | strcpy((*p).drug, "\0"); 233 | } else { 234 | strcpy((*p).drug, gtx); 235 | } 236 | /* 躯体疾病,注意字符串长度 */ 237 | cnt = gtk_entry_get_text( 238 | GTK_ENTRY((*parents).body_entry) 239 | ); 240 | if (gtx == NULL) { 241 | strcpy((*p).body, "\0"); 242 | } else { 243 | strcpy((*p).body, gtx); 244 | } 245 | /* 传染病,注意字符串长度 */ 246 | cnt = gtk_entry_get_text( 247 | GTK_ENTRY((*parents).infect_entry) 248 | ); 249 | if (gtx == NULL) { 250 | strcpy((*p).infect, "\0"); 251 | } else { 252 | strcpy((*p).infect, gtx); 253 | } 254 | /* 释放gchar * */ 255 | g_free(gtx); 256 | 257 | /* 需要对id和num进行基本的检查判断 */ 258 | judge_id = 0; 259 | judge_num = 0; 260 | judge_temp = 0; 261 | /* 首先对id进行基本的判断检测 */ 262 | if (strlen((*p).id) == 0) { 263 | judge_id = 1; 264 | message = gtk_message_dialog_new( 265 | NULL, 266 | GTK_DIALOG_MODAL, 267 | GTK_MESSAGE_ERROR, 268 | GTK_BUTTONS_CLOSE, 269 | "未填写身份证号码" 270 | ); 271 | gtk_dialog_run(GTK_DIALOG(message)); 272 | gtk_widget_destroy(message); 273 | } else if (strlen((*p).id) < 18) { 274 | judge_id = 1; 275 | message = gtk_message_dialog_new( 276 | NULL, 277 | GTK_DIALOG_MODAL, 278 | GTK_MESSAGE_ERROR, 279 | GTK_BUTTONS_CLOSE, 280 | "身份证位数未满18" 281 | ); 282 | gtk_dialog_run(GTK_DIALOG(message)); 283 | gtk_widget_destroy(message); 284 | } else if (strlen((*p).id) > 18) { 285 | judge_id = 1; 286 | message = gtk_message_dialog_new( 287 | NULL, 288 | GTK_DIALOG_MODAL, 289 | GTK_MESSAGE_ERROR, 290 | GTK_BUTTONS_CLOSE, 291 | "身份证位数超过18" 292 | ); 293 | gtk_dialog_run(GTK_DIALOG(message)); 294 | gtk_widget_destroy(message); 295 | } else { 296 | for (i = 0; i < strlen((*p).id); i++) { 297 | /* 其实在这里可以添加身份证号码的校检,不过暂时不做 */ 298 | if (!(('0' <= (*p).id[i] && (*p).id[i] <= '9') || (*p).id[i] == 'X')) { 299 | judge_temp = 1; 300 | break; 301 | } 302 | } 303 | if (judge_temp == 1) { 304 | judge_id = 1; 305 | message = gtk_message_dialog_new( 306 | NULL, 307 | GTK_DIALOG_MODAL, 308 | GTK_MESSAGE_ERROR, 309 | GTK_BUTTONS_CLOSE, 310 | "输入的身份证号码中含有非法字符串" 311 | ); 312 | gtk_dialog_run(GTK_DIALOG(message)); 313 | gtk_widget_destroy(message); 314 | } else { 315 | /* 再对num进行基本的检测 */ 316 | if (strlen((*p).num) == 0) { 317 | judge_num = 1; 318 | message = gtk_message_dialog_new( 319 | NULL, 320 | GTK_DIALOG_MODAL, 321 | GTK_MESSAGE_ERROR, 322 | GTK_BUTTONS_CLOSE, 323 | "未填写住院号" 324 | ); 325 | gtk_dialog_run(GTK_DIALOG(message)); 326 | gtk_widget_destroy(message); 327 | } 328 | } 329 | } 330 | 331 | /* 如果id和num通过了基本的检测, 332 | * 则开始进行数据处理, 333 | * 点击了确定按钮后的逻辑 334 | * 一、如果out_check没有被选中 335 | * 1. 如果clist中没有选项被选中,且数据库中没有重复,则成功插入在院病人列表 336 | * 2. 如果clist中没有选项被选中,但数据库中有重复,则提示(报错/载入历史数据) 337 | * 3. 如果clist中有选项被选中,则直接更新在院病人列表 338 | * 4. 其他选项直接报错 339 | * 二、如果out_check被选中 340 | * 1. 如果clist中没有选项被选中,则提示报错 341 | * 2. 如果clist中有选项,则出院操作,归入历史数据库 342 | * 3. 其他选项直接报错 343 | * 关于out_check是否被选中,需要在new_person.c中进行具体设置一下 344 | */ 345 | if (judge_id == 0 && judge_num == 0) { 346 | /* 获取out_check状态 */ 347 | is_active = gtk_toggle_button_get_active( 348 | GTK_TOGGLE_BUTTON((*parents).out_check) 349 | ); 350 | /*首先进行out_check没有被选中的处理 */ 351 | if (is_active == FALSE) { 352 | /* 首先进行数据库的检索工作,对身份证和住院号进行检索, 353 | * 要对clist的row开始数值进行确定,到底是从0开始,还是1开始 354 | */ 355 | rc_search = search_hsp(p); 356 | if ((*parents).get_row == -1 && rc_search == 0) { 357 | rc_sqlite = insert_hsp(p); 358 | if (rc_sqlite == SQLITE_OK) { 359 | hsp_list(parents); // 360 | message = gtk_message_dialog_new( 361 | NULL, 362 | GTK_DIALOG_MODAL, 363 | GTK_MESSAGE_INFO, 364 | GTK_BUTTONS_OK, 365 | "保存成功" 366 | ); 367 | gtk_dialog_run(GTK_DIALOG(message)); 368 | gtk_widget_destroy(message); 369 | } else { 370 | message = gtk_message_dialog_new( 371 | NULL, 372 | GTK_DIALOG_MODAL, 373 | GTK_MESSAGE_ERROR, 374 | GTK_BUTTONS_CLOSE, 375 | "保存失败" 376 | ); 377 | gtk_dialog_run(GTK_DIALOG(message)); 378 | gtk_widget_destroy(message); 379 | } 380 | } else if ((*parents).get_row == -1 && rc_search != 0) { 381 | if (rc_search == 1) { 382 | message = gtk_message_dialog_new( 383 | NULL, 384 | GTK_DIALOG_MODAL, 385 | GTK_MESSAGE_ERROR, 386 | GTK_BUTTONS_CLOSE, 387 | "住院号重复了,请重新输入" 388 | ); 389 | gtk_dialog_run(GTK_DIALOG(message)); 390 | gtk_widget_destroy(message); 391 | } else if (rc_search == 2) { 392 | message = gtk_message_dialog_new( 393 | NULL, 394 | GTK_DIALOG_MODAL, 395 | GTK_MESSAGE_ERROR, 396 | GTK_BUTTONS_CLOSE, 397 | "身份证号码重复,请重新输入" 398 | ); 399 | gtk_dialog_run(GTK_DIALOG(message)); 400 | gtk_widget_destroy(message); 401 | } else { 402 | message = gtk_message_dialog_new( 403 | NULL, 404 | GTK_DIALOG_MODAL, 405 | GTK_MESSAGE_ERROR, 406 | GTK_BUTTONS_CLOSE, 407 | "住院号和身份证号码均重复,请重新输入" 408 | ); 409 | gtk_dialog_run(GTK_DIALOG(message)); 410 | gtk_widget_destroy(message); 411 | } 412 | } else if ((*parents).get_row != -1 && rc_search == 0) { 413 | /* 开始更新数据 */ 414 | rc_update = update_hsp(p); 415 | if (rc_update == SQLITE_OK) { 416 | hsp_list(parents); // 417 | message = gtk_message_dialog_new( 418 | NULL, 419 | GTK_DIALOG_MODAL, 420 | GTK_MESSAGE_INFO, 421 | GTK_BUTTONS_OK, 422 | "保存成功" 423 | ); 424 | gtk_dialog_run(GTK_DIALOG(message)); 425 | gtk_widget_destroy(message); 426 | } else { 427 | message = gtk_message_dialog_new( 428 | NULL, 429 | GTK_DIALOG_MODAL, 430 | GTK_MESSAGE_ERROR, 431 | GTK_BUTTONS_CLOSE, 432 | "保存失败" 433 | ); 434 | gtk_dialog_run(GTK_DIALOG(message)); 435 | gtk_widget_destroy(message); 436 | } 437 | } else { 438 | message = gtk_message_dialog_new( 439 | NULL, 440 | GTK_DIALOG_MODAL, 441 | GTK_MESSAGE_ERROR, 442 | GTK_BUTTONS_CLOSE, 443 | "未知错误,请仔细填写数据" 444 | ); 445 | gtk_dialog_run(GTK_DIALOG(message)); 446 | gtk_widget_destroy(message); 447 | } 448 | } else { 449 | /* 这里就是出院操作了,暂时不做 */ 450 | } 451 | } 452 | } 453 | -------------------------------------------------------------------------------- /main_window.c: -------------------------------------------------------------------------------- 1 | #include "coims.h" 2 | 3 | /* 各种强制转换还是有必要的,避免错误和警告,所以还是加上的好 */ 4 | 5 | /* 回调函数声明 */ 6 | void help_about(GtkWidget *widget, gpointer parents); 7 | void get_row_and_column(GtkCList *clist, gint row, gint column, GdkEvent *event, Item *parents); 8 | void new_person(GtkWidget *widget, Item *parents); 9 | void cancel(GtkWidget *widget, Item *parents); 10 | void photo_choose(GtkWidget *widget, Item *parents); 11 | void birthday_choose(GtkWidget *widget, Item *parents); 12 | void happened_choose(GtkWidget *widget, Item *parents); 13 | void into_choose(GtkWidget *widget, Item *parents); 14 | void out_choose(GtkWidget *widget, Item *parents); 15 | void panss(GtkWidget *widght, Item *parents); 16 | void check_sure(GtkWidget *widget, Item *parents); 17 | void hsp_list(Item *parents); 18 | 19 | int main(int argc, char **argv) 20 | { 21 | /* 主框架部分 */ 22 | GtkWidget *main_window; 23 | GtkWidget *main_vbox; 24 | GtkWidget *main_hbox; 25 | /* 菜单栏部分 */ 26 | GtkWidget *menubar; 27 | GtkWidget *menubar_item; 28 | GtkWidget *menu; 29 | GtkWidget *menu_item; 30 | /* notebook部分 */ 31 | GtkWidget *person_notebook; 32 | /* 临时框架 */ 33 | GtkWidget *temp_vbox; 34 | GtkWidget *temp_hbox; 35 | GtkWidget *temp_table; 36 | GtkWidget *temp_scrolled; 37 | GtkWidget *temp_separator; 38 | GtkWidget *temp_label; 39 | GtkWidget *temp_entry; 40 | GtkWidget *temp_button; 41 | 42 | /* 开辟notebook内部控件所需的内存空间, 43 | * 注意及时free() 44 | */ 45 | Item *item; 46 | item = (Item *)malloc(sizeof(Item)); 47 | 48 | /* 所有Gtk+程序都必须有的开头 */ 49 | gtk_init(&argc, &argv); 50 | 51 | /* main_window部分: 52 | * 暂时不考虑窗口大小和缩放问题。 53 | */ 54 | main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 55 | gtk_window_set_title( 56 | GTK_WINDOW(main_window), 57 | "公共卫生管理系统" 58 | ); 59 | gtk_window_set_position( 60 | GTK_WINDOW(main_window), 61 | GTK_WIN_POS_CENTER 62 | ); 63 | g_signal_connect( 64 | G_OBJECT(main_window), 65 | "destroy", 66 | G_CALLBACK(gtk_main_quit), 67 | NULL 68 | ); 69 | gtk_window_set_resizable(GTK_WINDOW(main_window), FALSE); 70 | 71 | /* 菜单栏部分 */ 72 | menubar = gtk_menu_bar_new(); 73 | /* “病例”菜单 */ 74 | menubar_item = gtk_menu_item_new_with_label("病例"); 75 | menu = gtk_menu_new(); 76 | menu_item = gtk_menu_item_new_with_label("新建"); 77 | g_signal_connect( 78 | G_OBJECT(menu_item), 79 | "activate", 80 | G_CALLBACK(new_person), 81 | item 82 | ); 83 | gtk_menu_shell_append( 84 | GTK_MENU_SHELL(menu), 85 | menu_item 86 | ); 87 | menu_item = gtk_menu_item_new_with_label("保存"); 88 | gtk_menu_shell_append( 89 | GTK_MENU_SHELL(menu), 90 | menu_item 91 | ); /* 回调函数 */ 92 | menu_item = gtk_menu_item_new_with_label("取消"); 93 | g_signal_connect( 94 | G_OBJECT(menu_item), 95 | "activate", 96 | G_CALLBACK(cancel), 97 | item 98 | ); 99 | gtk_menu_shell_append( 100 | GTK_MENU_SHELL(menu), 101 | menu_item 102 | ); 103 | menu_item = gtk_separator_menu_item_new(); 104 | gtk_menu_shell_append( 105 | GTK_MENU_SHELL(menu), 106 | menu_item 107 | ); 108 | menu_item = gtk_menu_item_new_with_label("退出"); 109 | g_signal_connect(G_OBJECT(menu_item), 110 | "activate", 111 | G_CALLBACK(gtk_main_quit), 112 | NULL); 113 | gtk_menu_shell_append( 114 | GTK_MENU_SHELL(menu), 115 | menu_item 116 | ); 117 | gtk_menu_item_set_submenu( 118 | GTK_MENU_ITEM(menubar_item), 119 | menu 120 | ); 121 | gtk_menu_shell_append( 122 | GTK_MENU_SHELL(menubar), 123 | menubar_item 124 | ); 125 | /* “报表”菜单 */ 126 | menubar_item = gtk_menu_item_new_with_label("报表"); 127 | menu = gtk_menu_new(); 128 | menu_item = gtk_menu_item_new_with_label("生成《危重病人救治情况月报表》"); 129 | gtk_menu_shell_append( 130 | GTK_MENU_SHELL(menu), 131 | menu_item 132 | ); /* 回调函数 */ 133 | menu_item = gtk_separator_menu_item_new(); 134 | gtk_menu_shell_append( 135 | GTK_MENU_SHELL(menu), 136 | menu_item 137 | ); 138 | menu_item = gtk_menu_item_new_with_label("生成《危害病人救治费用明细表》"); 139 | gtk_menu_shell_append( 140 | GTK_MENU_SHELL(menu), 141 | menu_item 142 | ); /* 回调函数 */ 143 | gtk_menu_item_set_submenu( 144 | GTK_MENU_ITEM(menubar_item), 145 | menu 146 | ); 147 | gtk_menu_shell_append( 148 | GTK_MENU_SHELL(menubar), 149 | menubar_item 150 | ); 151 | /* “数据库”菜单 */ 152 | menubar_item = gtk_menu_item_new_with_label("数据"); 153 | menu = gtk_menu_new(); 154 | menu_item = gtk_menu_item_new_with_label("备份"); 155 | gtk_menu_shell_append( 156 | GTK_MENU_SHELL(menu), 157 | menu_item 158 | ); /* 回调函数 */ 159 | gtk_menu_item_set_submenu( 160 | GTK_MENU_ITEM(menubar_item), 161 | menu 162 | ); 163 | gtk_menu_shell_append( 164 | GTK_MENU_SHELL(menubar), 165 | menubar_item 166 | ); 167 | /* “帮助”菜单 */ 168 | menubar_item = gtk_menu_item_new_with_label("帮助"); 169 | menu = gtk_menu_new(); 170 | menu_item = gtk_menu_item_new_with_label("使用说明"); 171 | gtk_menu_shell_append( 172 | GTK_MENU_SHELL(menu), 173 | menu_item 174 | ); /* 回调函数 */ 175 | menu_item = gtk_separator_menu_item_new(); 176 | gtk_menu_shell_append( 177 | GTK_MENU_SHELL(menu), 178 | menu_item 179 | ); 180 | menu_item = gtk_menu_item_new_with_label("关于"); 181 | g_signal_connect( 182 | G_OBJECT(menu_item), 183 | "activate", 184 | G_CALLBACK(help_about), 185 | NULL 186 | ); 187 | gtk_menu_shell_append( 188 | GTK_MENU_SHELL(menu), 189 | menu_item 190 | ); 191 | gtk_menu_item_set_submenu( 192 | GTK_MENU_ITEM(menubar_item), 193 | menu 194 | ); 195 | gtk_menu_shell_append( 196 | GTK_MENU_SHELL(menubar), 197 | menubar_item 198 | ); 199 | main_vbox = gtk_vbox_new(FALSE, 0); 200 | gtk_box_pack_start( 201 | GTK_BOX(main_vbox), 202 | menubar, 203 | FALSE, 204 | FALSE, 205 | 0 206 | ); 207 | 208 | /* 侧边栏部分: 209 | * 注意一下控件的尺寸大小和参数选项; 210 | * 另外按照demo里面的例子仔细做一下搜索框,提供三个选项: 211 | * 1. 按照身份证搜索(必须有) 212 | * 2. 按照住院号搜索(必须有) 213 | * 3. 按照三联单号搜索(可选,所以暂时不做) 214 | */ 215 | temp_vbox = gtk_vbox_new(FALSE, 0); 216 | temp_hbox = gtk_hbox_new(FALSE, 0); 217 | /* 指纹识别模块和人脸识别模块暂时不做了,做不了 218 | * 219 | temp_button = gtk_button_new_with_label("人脸识别"); 220 | gtk_widget_set_size_request(temp_button, 100, 25); 221 | gtk_box_pack_start( 222 | GTK_BOX(temp_hbox), 223 | temp_button, 224 | TRUE, 225 | TRUE, 226 | 0 227 | ); 228 | temp_button = gtk_button_new_with_label("指纹识别"); 229 | gtk_widget_set_size_request(temp_button, 100, 25); 230 | gtk_box_pack_start( 231 | GTK_BOX(temp_hbox), 232 | temp_button, 233 | TRUE, 234 | TRUE, 235 | 0 236 | ); 237 | gtk_box_pack_start( 238 | GTK_BOX(temp_vbox), 239 | temp_hbox, 240 | FALSE, 241 | FALSE, 242 | 0 243 | ); 244 | temp_separator = gtk_hseparator_new(); 245 | gtk_widget_set_size_request(temp_separator, 200, 25); 246 | gtk_box_pack_start( 247 | GTK_BOX(temp_vbox), 248 | temp_separator, 249 | FALSE, 250 | FALSE, 251 | 0 252 | ); 253 | */ 254 | temp_hbox = gtk_hbox_new(FALSE, 0); 255 | temp_entry = gtk_entry_new(); 256 | gtk_widget_set_size_request(temp_entry, 150, 25); 257 | gtk_box_pack_start( 258 | GTK_BOX(temp_hbox), 259 | temp_entry, 260 | TRUE, 261 | TRUE, 262 | 0 263 | ); 264 | temp_button = gtk_button_new_with_label("搜索"); 265 | gtk_widget_set_size_request(temp_button, 50, 25); /* 回调函数 */ 266 | gtk_box_pack_start( 267 | GTK_BOX(temp_hbox), 268 | temp_button, 269 | TRUE, 270 | TRUE, 271 | 0 272 | ); 273 | gtk_box_pack_start( 274 | GTK_BOX(temp_vbox), 275 | temp_hbox, 276 | FALSE, 277 | FALSE, 278 | 0 279 | ); 280 | temp_separator = gtk_hseparator_new(); 281 | gtk_widget_set_size_request(temp_separator, 200, 25); 282 | gtk_box_pack_start( 283 | GTK_BOX(temp_vbox), 284 | temp_separator, 285 | FALSE, 286 | FALSE, 287 | 0 288 | ); 289 | temp_label = gtk_label_new("在院病人列表:"); 290 | gtk_widget_set_size_request(temp_label, 200, 25); 291 | gtk_box_pack_start( 292 | GTK_BOX(temp_vbox), 293 | temp_label, 294 | FALSE, 295 | FALSE, 296 | 0 297 | ); 298 | temp_scrolled = gtk_scrolled_window_new(NULL, NULL); 299 | gtk_scrolled_window_set_policy( 300 | GTK_SCROLLED_WINDOW(temp_scrolled), 301 | GTK_POLICY_AUTOMATIC, 302 | GTK_POLICY_AUTOMATIC 303 | ); 304 | /* 在滚动窗口temp_scrolled中放置列表, 305 | * 注意一下文本的长短和对齐问题 306 | */ 307 | (*item).hospital_list = gtk_clist_new(2); 308 | hsp_list(item); 309 | /* 这个回调函数不知道可不可以用 */ 310 | (*item).get_row = -1; 311 | (*item).get_column = -1; 312 | g_signal_connect( 313 | G_OBJECT((*item).hospital_list), 314 | "select-row", 315 | G_CALLBACK(get_row_and_column), 316 | item 317 | ); 318 | gtk_clist_set_row_height( 319 | GTK_CLIST((*item).hospital_list), 320 | 25 321 | ); 322 | gtk_clist_set_shadow_type( 323 | GTK_CLIST((*item).hospital_list), 324 | GTK_SHADOW_IN 325 | ); 326 | gtk_clist_set_column_title( 327 | GTK_CLIST((*item).hospital_list), 328 | 0, 329 | "住院号" 330 | ); 331 | /* gtk_clist_set_column_width( 332 | GTK_CLIST((*item).hospital_list), 333 | 0, 334 | 100 335 | ); */ 336 | gtk_clist_set_column_justification( 337 | GTK_CLIST((*item).hospital_list), 338 | 0, 339 | GTK_JUSTIFY_CENTER 340 | ); 341 | gtk_clist_set_column_auto_resize( 342 | GTK_CLIST((*item).hospital_list), 343 | 0, 344 | TRUE 345 | ); 346 | gtk_clist_set_column_title( 347 | GTK_CLIST((*item).hospital_list), 348 | 1, 349 | "姓名" 350 | ); 351 | /* gtk_clist_set_column_width( 352 | GTK_CLIST((*item).hospital_list), 353 | 1, 354 | 100 355 | ); */ 356 | gtk_clist_set_column_justification( 357 | GTK_CLIST((*item).hospital_list), 358 | 1, 359 | GTK_JUSTIFY_CENTER 360 | ); 361 | gtk_clist_set_column_auto_resize( 362 | GTK_CLIST((*item).hospital_list), 363 | 1, 364 | TRUE 365 | ); 366 | gtk_clist_column_titles_show(GTK_CLIST((*item).hospital_list)); 367 | gtk_scrolled_window_add_with_viewport( 368 | GTK_SCROLLED_WINDOW(temp_scrolled), 369 | (*item).hospital_list 370 | ); 371 | gtk_box_pack_start( 372 | GTK_BOX(temp_vbox), 373 | temp_scrolled, 374 | TRUE, 375 | TRUE, 376 | 0 377 | ); 378 | temp_button = gtk_button_new_with_label("新建"); 379 | g_signal_connect( 380 | G_OBJECT(temp_button), 381 | "clicked", 382 | G_CALLBACK(new_person), 383 | item 384 | ); 385 | gtk_widget_set_size_request(temp_button, 200, 25); 386 | gtk_box_pack_start( 387 | GTK_BOX(temp_vbox), 388 | temp_button, 389 | FALSE, 390 | FALSE, 391 | 0 392 | ); 393 | main_hbox = gtk_hbox_new(FALSE, 0); 394 | gtk_box_pack_start( 395 | GTK_BOX(main_hbox), 396 | temp_vbox, 397 | TRUE, 398 | TRUE, 399 | 0 400 | ); 401 | 402 | /* person_notebook部分 */ 403 | person_notebook = gtk_notebook_new(); 404 | gtk_notebook_set_tab_pos( 405 | GTK_NOTEBOOK(person_notebook), 406 | GTK_POS_TOP 407 | ); 408 | /* 首先制作“住院信息”标签页 */ 409 | temp_table = gtk_table_new(20, 5, FALSE); 410 | (*item).photo_button = gtk_button_new(); 411 | g_signal_connect( 412 | G_OBJECT((*item).photo_button), 413 | "clicked", 414 | G_CALLBACK(photo_choose), 415 | item 416 | ); 417 | gtk_table_attach( 418 | GTK_TABLE(temp_table), 419 | (*item).photo_button, 420 | 0, 1, 421 | 0, 6, 422 | GTK_FILL, 423 | GTK_FILL, 424 | 0, 0 425 | ); 426 | temp_button = gtk_button_new_with_label("拍照"); /* 回调函数 */ 427 | gtk_widget_set_size_request(temp_button, 100, 25); 428 | gtk_table_attach( 429 | GTK_TABLE(temp_table), 430 | temp_button, 431 | 0, 1, 432 | 6, 7, 433 | GTK_FILL, 434 | GTK_FILL, 435 | 0, 0 436 | ); 437 | temp_label = gtk_label_new("姓名:"); 438 | gtk_widget_set_size_request(temp_label, 100, 25); 439 | gtk_table_attach( 440 | GTK_TABLE(temp_table), 441 | temp_label, 442 | 1, 2, 443 | 0, 1, 444 | GTK_FILL, 445 | GTK_FILL, 446 | 0, 0 447 | ); 448 | (*item).name_entry = gtk_entry_new(); 449 | gtk_widget_set_size_request((*item).name_entry, 150, 25); 450 | gtk_table_attach( 451 | GTK_TABLE(temp_table), 452 | (*item).name_entry, 453 | 2, 3, 454 | 0, 1, 455 | GTK_FILL, 456 | GTK_FILL, 457 | 0, 0 458 | ); 459 | temp_label = gtk_label_new("性别:"); 460 | gtk_widget_set_size_request(temp_label, 100, 25); 461 | gtk_table_attach( 462 | GTK_TABLE(temp_table), 463 | temp_label, 464 | 3, 4, 465 | 0, 1, 466 | GTK_FILL, 467 | GTK_FILL, 468 | 0, 0 469 | ); 470 | (*item).sex_combo = gtk_combo_box_text_new(); 471 | gtk_combo_box_text_append_text( 472 | GTK_COMBO_BOX_TEXT((*item).sex_combo), 473 | "" 474 | ); 475 | gtk_combo_box_text_append_text( 476 | GTK_COMBO_BOX_TEXT((*item).sex_combo), 477 | "男" 478 | ); 479 | gtk_combo_box_text_append_text( 480 | GTK_COMBO_BOX_TEXT((*item).sex_combo), 481 | "女" 482 | ); 483 | gtk_combo_box_text_append_text( 484 | GTK_COMBO_BOX_TEXT((*item).sex_combo), 485 | "其他" 486 | ); 487 | gtk_widget_set_size_request((*item).sex_combo, 150, 25); 488 | gtk_table_attach( 489 | GTK_TABLE(temp_table), 490 | (*item).sex_combo, 491 | 4, 5, 492 | 0, 1, 493 | GTK_FILL, 494 | GTK_FILL, 495 | 0, 0 496 | ); 497 | temp_label = gtk_label_new("生日:"); 498 | gtk_widget_set_size_request(temp_label, 100, 25); 499 | gtk_table_attach( 500 | GTK_TABLE(temp_table), temp_label, 501 | 1, 2, 502 | 1, 2, 503 | GTK_FILL, 504 | GTK_FILL, 505 | 0, 0 506 | ); 507 | (*item).birthday_button = gtk_button_new_with_label("选择日期"); 508 | g_signal_connect( 509 | G_OBJECT((*item).birthday_button), 510 | "clicked", 511 | G_CALLBACK(birthday_choose), 512 | item 513 | ); 514 | gtk_widget_set_size_request((*item).birthday_button, 150, 25); 515 | gtk_table_attach( 516 | GTK_TABLE(temp_table), 517 | (*item).birthday_button, 518 | 2, 3, 519 | 1, 2, 520 | GTK_FILL, 521 | GTK_FILL, 522 | 0, 0 523 | ); 524 | temp_label = gtk_label_new("年龄:"); 525 | gtk_widget_set_size_request(temp_label, 100, 25); 526 | gtk_table_attach( 527 | GTK_TABLE(temp_table), 528 | temp_label, 529 | 3, 4, 530 | 1, 2, 531 | GTK_FILL, 532 | GTK_FILL, 533 | 0, 0 534 | ); 535 | (*item).age_entry = gtk_entry_new(); /* 可以由生日计算得到,这里帮忙做了 */ 536 | gtk_widget_set_size_request((*item).age_entry, 150, 25); 537 | gtk_table_attach( 538 | GTK_TABLE(temp_table), 539 | (*item).age_entry, 540 | 4, 5, 541 | 1, 2, 542 | GTK_FILL, 543 | GTK_FILL, 544 | 0, 0 545 | ); 546 | temp_label = gtk_label_new("婚姻状况:"); 547 | gtk_widget_set_size_request(temp_label, 100, 25); 548 | gtk_table_attach( 549 | GTK_TABLE(temp_table), temp_label, 550 | 1, 2, 551 | 2, 3, 552 | GTK_FILL, 553 | GTK_FILL, 554 | 0, 0 555 | ); 556 | (*item).marriage_combo = gtk_combo_box_text_new(); 557 | gtk_combo_box_text_append_text( 558 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 559 | "" 560 | ); 561 | gtk_combo_box_text_append_text( 562 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 563 | "未婚" 564 | ); 565 | gtk_combo_box_text_append_text( 566 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 567 | "已婚" 568 | ); 569 | gtk_combo_box_text_append_text( 570 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 571 | "再婚" 572 | ); 573 | gtk_combo_box_text_append_text( 574 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 575 | "离异" 576 | ); 577 | gtk_combo_box_text_append_text( 578 | GTK_COMBO_BOX_TEXT((*item).marriage_combo), 579 | "未知" 580 | ); 581 | gtk_widget_set_size_request((*item).marriage_combo, 150, 25); 582 | gtk_table_attach( 583 | GTK_TABLE(temp_table), 584 | (*item).marriage_combo, 585 | 2, 3, 586 | 2, 3, 587 | GTK_FILL, 588 | GTK_FILL, 589 | 0, 0 590 | ); 591 | temp_label = gtk_label_new("文化程度:"); 592 | gtk_widget_set_size_request(temp_label, 100, 25); 593 | gtk_table_attach( 594 | GTK_TABLE(temp_table), 595 | temp_label, 596 | 3, 4, 597 | 2, 3, 598 | GTK_FILL, 599 | GTK_FILL, 600 | 0, 0 601 | ); 602 | (*item).edu_combo = gtk_combo_box_text_new(); 603 | gtk_combo_box_text_append_text( 604 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 605 | "" 606 | ); 607 | gtk_combo_box_text_append_text( 608 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 609 | "文盲" 610 | ); 611 | gtk_combo_box_text_append_text( 612 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 613 | "小学" 614 | ); 615 | gtk_combo_box_text_append_text( 616 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 617 | "初中" 618 | ); 619 | gtk_combo_box_text_append_text( 620 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 621 | "高中" 622 | ); 623 | gtk_combo_box_text_append_text( 624 | GTK_COMBO_BOX_TEXT((*item).edu_combo), 625 | "本科及本科以上" 626 | ); 627 | gtk_widget_set_size_request((*item).edu_combo, 150, 25); 628 | gtk_table_attach( 629 | GTK_TABLE(temp_table), (*item).edu_combo, 630 | 4, 5, 631 | 2, 3, 632 | GTK_FILL, 633 | GTK_FILL, 634 | 0, 0 635 | ); 636 | temp_label = gtk_label_new("身份证:"); 637 | gtk_widget_set_size_request(temp_label, 100, 25); 638 | gtk_table_attach( 639 | GTK_TABLE(temp_table), temp_label, 640 | 1, 2, 641 | 3, 4, 642 | GTK_FILL, 643 | GTK_FILL, 644 | 0, 0 645 | ); 646 | (*item).id_entry = gtk_entry_new(); 647 | gtk_widget_set_size_request((*item).id_entry, 150, 25); 648 | gtk_table_attach( 649 | GTK_TABLE(temp_table), (*item).id_entry, 650 | 2, 3, 651 | 3, 4, 652 | GTK_FILL, 653 | GTK_FILL, 654 | 0, 0 655 | ); 656 | temp_label = gtk_label_new("户籍证明:"); 657 | gtk_widget_set_size_request(temp_label, 100, 25); 658 | gtk_table_attach( 659 | GTK_TABLE(temp_table), temp_label, 660 | 3, 4, 661 | 3, 4, 662 | GTK_FILL, 663 | GTK_FILL, 664 | 0, 0 665 | ); 666 | (*item).census_entry = gtk_entry_new(); 667 | gtk_widget_set_size_request((*item).census_entry, 150, 25); 668 | gtk_table_attach( 669 | GTK_TABLE(temp_table), (*item).census_entry, 670 | 4, 5, 671 | 3, 4, 672 | GTK_FILL, 673 | GTK_FILL, 674 | 0, 0 675 | ); 676 | temp_label = gtk_label_new("事发时间:"); 677 | gtk_widget_set_size_request(temp_label, 100, 25); 678 | gtk_table_attach( 679 | GTK_TABLE(temp_table), 680 | temp_label, 681 | 1, 2, 682 | 4, 5, 683 | GTK_FILL, 684 | GTK_FILL, 685 | 0, 0 686 | ); 687 | (*item).happened_button = gtk_button_new_with_label("选择日期"); 688 | g_signal_connect( 689 | G_OBJECT((*item).happened_button), 690 | "clicked", 691 | G_CALLBACK(happened_choose), 692 | item 693 | ); 694 | gtk_widget_set_size_request((*item).happened_button, 150, 25); 695 | gtk_table_attach( 696 | GTK_TABLE(temp_table), 697 | (*item).happened_button, 698 | 2, 3, 699 | 4, 5, 700 | GTK_FILL, 701 | GTK_FILL, 702 | 0, 0 703 | ); 704 | temp_label = gtk_label_new("事发地点:"); 705 | gtk_widget_set_size_request(temp_label, 100, 25); 706 | gtk_table_attach( 707 | GTK_TABLE(temp_table), 708 | temp_label, 709 | 3, 4, 710 | 4, 5, 711 | GTK_FILL, 712 | GTK_FILL, 713 | 0, 0 714 | ); 715 | (*item).place_combo = gtk_combo_box_text_new(); 716 | gtk_combo_box_text_append_text( 717 | GTK_COMBO_BOX_TEXT((*item).place_combo), 718 | "" 719 | ); 720 | gtk_combo_box_text_append_text( 721 | GTK_COMBO_BOX_TEXT((*item).place_combo), 722 | "莲湖区" 723 | ); 724 | gtk_combo_box_text_append_text( 725 | GTK_COMBO_BOX_TEXT((*item).place_combo), 726 | "碑林区" 727 | ); 728 | gtk_combo_box_text_append_text( 729 | GTK_COMBO_BOX_TEXT((*item).place_combo), 730 | "雁塔区" 731 | ); 732 | gtk_combo_box_text_append_text( 733 | GTK_COMBO_BOX_TEXT((*item).place_combo), 734 | "新城区" 735 | ); 736 | gtk_combo_box_text_append_text( 737 | GTK_COMBO_BOX_TEXT((*item).place_combo), 738 | "未央区" 739 | ); 740 | gtk_combo_box_text_append_text( 741 | GTK_COMBO_BOX_TEXT((*item).place_combo), 742 | "长安区" 743 | ); 744 | gtk_widget_set_size_request((*item).place_combo, 150, 25); 745 | gtk_table_attach( 746 | GTK_TABLE(temp_table), 747 | (*item).place_combo, 748 | 4, 5, 749 | 4, 5, 750 | GTK_FILL, 751 | GTK_FILL, 752 | 0, 0 753 | ); 754 | temp_label = gtk_label_new("三联单:"); 755 | gtk_widget_set_size_request(temp_label, 100, 25); 756 | gtk_table_attach( 757 | GTK_TABLE(temp_table), 758 | temp_label, 759 | 1, 2, 5, 6, 760 | GTK_FILL, 761 | GTK_FILL, 762 | 0, 0 763 | ); 764 | (*item).bill_entry = gtk_entry_new(); 765 | gtk_widget_set_size_request((*item).bill_entry, 150, 25); 766 | gtk_table_attach( 767 | GTK_TABLE(temp_table), 768 | (*item).bill_entry, 769 | 2, 3, 770 | 5, 6, 771 | GTK_FILL, 772 | GTK_FILL, 773 | 0, 0 774 | ); 775 | temp_label = gtk_label_new("住院号:"); 776 | gtk_widget_set_size_request(temp_label, 100, 25); 777 | gtk_table_attach( 778 | GTK_TABLE(temp_table), 779 | temp_label, 780 | 3, 4, 781 | 5, 6, 782 | GTK_FILL, 783 | GTK_FILL, 784 | 0, 0 785 | ); 786 | (*item).num_entry = gtk_entry_new(); 787 | gtk_widget_set_size_request((*item).num_entry, 150, 25); 788 | gtk_table_attach( 789 | GTK_TABLE(temp_table), 790 | (*item).num_entry, 791 | 4, 5, 792 | 5, 6, 793 | GTK_FILL, 794 | GTK_FILL, 795 | 0, 0 796 | ); 797 | temp_label = gtk_label_new("入院时间:"); 798 | gtk_widget_set_size_request(temp_label, 100, 25); 799 | gtk_table_attach( 800 | GTK_TABLE(temp_table), temp_label, 801 | 1, 2, 802 | 6, 7, 803 | GTK_FILL, 804 | GTK_FILL, 805 | 0, 0 806 | ); 807 | (*item).into_button = gtk_button_new_with_label("选择日期"); 808 | g_signal_connect( 809 | G_OBJECT((*item).into_button), 810 | "clicked", 811 | G_CALLBACK(into_choose), 812 | item 813 | ); 814 | gtk_widget_set_size_request((*item).into_button, 150, 25); 815 | gtk_table_attach( 816 | GTK_TABLE(temp_table), 817 | (*item).into_button, 818 | 2, 3, 819 | 6, 7, 820 | GTK_FILL, 821 | GTK_FILL, 822 | 0, 0 823 | ); 824 | temp_label = gtk_label_new("入院评分:"); 825 | gtk_widget_set_size_request(temp_label, 100, 25); 826 | gtk_table_attach( 827 | GTK_TABLE(temp_table), 828 | temp_label, 829 | 3, 4, 830 | 6, 7, 831 | GTK_FILL, 832 | GTK_FILL, 833 | 0, 0 834 | ); 835 | (*item).inps_entry = gtk_entry_new(); 836 | gtk_widget_set_size_request((*item).inps_entry, 150, 25); 837 | gtk_table_attach( 838 | GTK_TABLE(temp_table), 839 | (*item).inps_entry, 840 | 4, 5, 841 | 6, 7, 842 | GTK_FILL, 843 | GTK_FILL, 844 | 0, 0 845 | ); 846 | temp_label = gtk_label_new("出院时间:"); 847 | gtk_widget_set_size_request(temp_label, 100, 25); 848 | gtk_table_attach( 849 | GTK_TABLE(temp_table), 850 | temp_label, 851 | 1, 2, 852 | 7, 8, 853 | GTK_FILL, 854 | GTK_FILL, 855 | 0, 0 856 | ); 857 | (*item).out_button = gtk_button_new_with_label("选择日期"); 858 | g_signal_connect( 859 | G_OBJECT((*item).out_button), 860 | "clicked", 861 | G_CALLBACK(out_choose), 862 | item 863 | ); 864 | gtk_widget_set_size_request((*item).out_button, 150, 25); 865 | gtk_table_attach( 866 | GTK_TABLE(temp_table), 867 | (*item).out_button, 868 | 2, 3, 869 | 7, 8, 870 | GTK_FILL, 871 | GTK_FILL, 872 | 0, 0 873 | ); 874 | temp_label = gtk_label_new("出院评分:"); 875 | gtk_widget_set_size_request(temp_label, 100, 25); 876 | gtk_table_attach( 877 | GTK_TABLE(temp_table), 878 | temp_label, 879 | 3, 4, 880 | 7, 8, 881 | GTK_FILL, 882 | GTK_FILL, 883 | 0, 0 884 | ); 885 | (*item).outps_entry = gtk_entry_new(); 886 | gtk_widget_set_size_request((*item).outps_entry, 150, 25); 887 | gtk_table_attach( 888 | GTK_TABLE(temp_table), 889 | (*item).outps_entry, 890 | 4, 5, 891 | 7, 8, 892 | GTK_FILL, 893 | GTK_FILL, 894 | 0, 0 895 | ); 896 | temp_label = gtk_label_new("住院天数:"); 897 | gtk_widget_set_size_request(temp_label, 100, 25); 898 | gtk_table_attach( 899 | GTK_TABLE(temp_table), 900 | temp_label, 901 | 1, 2, 902 | 8, 9, 903 | GTK_FILL, 904 | GTK_FILL, 905 | 0, 0 906 | ); 907 | (*item).days_entry = gtk_entry_new(); 908 | gtk_widget_set_size_request((*item).days_entry, 150, 25); 909 | gtk_table_attach( 910 | GTK_TABLE(temp_table), 911 | (*item).days_entry, 912 | 2, 3, 913 | 8, 9, 914 | GTK_FILL, 915 | GTK_FILL, 916 | 0, 0 917 | ); 918 | temp_label = gtk_label_new("减分率:"); 919 | gtk_widget_set_size_request(temp_label, 100, 25); 920 | gtk_table_attach( 921 | GTK_TABLE(temp_table), 922 | temp_label, 923 | 3, 4, 924 | 8, 9, 925 | GTK_FILL, 926 | GTK_FILL, 927 | 0, 0 928 | ); 929 | (*item).persent_button = gtk_button_new_with_label("计算"); 930 | g_signal_connect( 931 | G_OBJECT((*item).persent_button), 932 | "clicked", 933 | G_CALLBACK(panss), 934 | item 935 | ); 936 | gtk_widget_set_size_request((*item).persent_button, 150, 25); 937 | gtk_table_attach( 938 | GTK_TABLE(temp_table), 939 | (*item).persent_button, 940 | 4, 5, 941 | 8, 9, 942 | GTK_FILL, 943 | GTK_FILL, 944 | 0, 0 945 | ); 946 | temp_label = gtk_label_new("住院花费:"); 947 | gtk_widget_set_size_request(temp_label, 100, 25); 948 | gtk_table_attach( 949 | GTK_TABLE(temp_table), 950 | temp_label, 951 | 1, 2, 952 | 9, 10, 953 | GTK_FILL, 954 | GTK_FILL, 955 | 0, 0 956 | ); 957 | (*item).cost_entry = gtk_entry_new(); 958 | gtk_widget_set_size_request((*item).cost_entry, 150, 25); 959 | gtk_table_attach( 960 | GTK_TABLE(temp_table), 961 | (*item).cost_entry, 962 | 2, 3, 963 | 9, 10, 964 | GTK_FILL, 965 | GTK_FILL, 966 | 0, 0 967 | ); 968 | temp_label = gtk_label_new("患者去向:"); 969 | gtk_widget_set_size_request(temp_label, 100, 25); 970 | gtk_table_attach( 971 | GTK_TABLE(temp_table), 972 | temp_label, 973 | 3, 4, 9, 10, 974 | GTK_FILL, 975 | GTK_FILL, 976 | 0, 0 977 | ); 978 | (*item).goto_combo = gtk_combo_box_text_new(); 979 | gtk_combo_box_text_append_text( 980 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 981 | "" 982 | ); 983 | gtk_combo_box_text_append_text( 984 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 985 | "救助站接走" 986 | ); 987 | gtk_combo_box_text_append_text( 988 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 989 | "转到市二院" 990 | ); 991 | gtk_combo_box_text_append_text( 992 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 993 | "转到市按摩院" 994 | ); 995 | gtk_combo_box_text_append_text( 996 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 997 | "转到西安医学院附属医院市结核医院" 998 | ); 999 | gtk_combo_box_text_append_text( 1000 | GTK_COMBO_BOX_TEXT((*item).goto_combo), 1001 | "家属接走" 1002 | ); 1003 | gtk_widget_set_size_request((*item).goto_combo, 150, 25); 1004 | gtk_table_attach( 1005 | GTK_TABLE(temp_table), 1006 | (*item).goto_combo, 1007 | 4, 5, 1008 | 9, 10, 1009 | GTK_FILL, 1010 | GTK_FILL, 1011 | 0, 0 1012 | ); 1013 | temp_separator = gtk_hseparator_new(); 1014 | gtk_widget_set_size_request(temp_separator, 500, 25); 1015 | gtk_table_attach( 1016 | GTK_TABLE(temp_table), 1017 | temp_separator, 1018 | 1, 5, 1019 | 10, 11, 1020 | GTK_FILL, 1021 | GTK_FILL, 1022 | 0, 0 1023 | ); 1024 | temp_label = gtk_label_new("行为分级:"); 1025 | gtk_widget_set_size_request(temp_label, 100, 25); 1026 | gtk_table_attach( 1027 | GTK_TABLE(temp_table), 1028 | temp_label, 1029 | 1, 2, 1030 | 11, 12, 1031 | GTK_FILL, 1032 | GTK_FILL, 1033 | 0, 0 1034 | ); 1035 | (*item).level_combo = gtk_combo_box_text_new(); 1036 | gtk_combo_box_text_append_text( 1037 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1038 | "" 1039 | ); 1040 | gtk_combo_box_text_append_text( 1041 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1042 | "0级:无符合以下1——5级中的任何行为" 1043 | ); 1044 | gtk_combo_box_text_append_text( 1045 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1046 | "1级:口头威胁、喊叫、但没有打砸行为" 1047 | ); 1048 | gtk_combo_box_text_append_text( 1049 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1050 | "2级:打砸行为,局限在家里,针对财物;不能接受劝说而停止" 1051 | ); 1052 | gtk_combo_box_text_append_text( 1053 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1054 | "3级:明显打砸行为,不分场合,针对财物或人,不能接受劝说而停止" 1055 | ); 1056 | gtk_combo_box_text_append_text( 1057 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1058 | "4级:连续的打砸行为,不分场合,针对财物或人,不能接受劝说而停止;包括自伤、自杀" 1059 | ); 1060 | gtk_combo_box_text_append_text( 1061 | GTK_COMBO_BOX_TEXT((*item).level_combo), 1062 | "5级:持械针对的任何暴力行为,或者纵火、爆炸等行为;无论在家里还是公共场合" 1063 | ); 1064 | gtk_table_attach( 1065 | GTK_TABLE(temp_table), 1066 | (*item).level_combo, 1067 | 2, 5, 1068 | 11, 12, 1069 | GTK_FILL, 1070 | GTK_FILL, 1071 | 0, 0 1072 | ); 1073 | temp_label = gtk_label_new("患者症状:"); 1074 | gtk_widget_set_size_request(temp_label, 100, 25); 1075 | gtk_table_attach( 1076 | GTK_TABLE(temp_table), 1077 | temp_label, 1078 | 1, 2, 1079 | 12, 13, 1080 | GTK_FILL, 1081 | GTK_FILL, 1082 | 0, 0 1083 | ); 1084 | (*item).symptom_combo = gtk_combo_box_text_new(); 1085 | gtk_combo_box_text_append_text( 1086 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1087 | "" 1088 | ); 1089 | gtk_combo_box_text_append_text( 1090 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1091 | "精神分裂症" 1092 | ); 1093 | gtk_combo_box_text_append_text( 1094 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1095 | "分裂情感性障碍" 1096 | ); 1097 | gtk_combo_box_text_append_text( 1098 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1099 | "偏执性障碍" 1100 | ); 1101 | gtk_combo_box_text_append_text( 1102 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1103 | "双相情感障碍" 1104 | ); 1105 | gtk_combo_box_text_append_text( 1106 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1107 | "癫痫所致精神障碍" 1108 | ); 1109 | gtk_combo_box_text_append_text( 1110 | GTK_COMBO_BOX_TEXT((*item).symptom_combo), 1111 | "精神发育迟滞" 1112 | ); 1113 | gtk_widget_set_size_request((*item).symptom_combo, 150, 25); 1114 | gtk_table_attach( 1115 | GTK_TABLE(temp_table), 1116 | (*item).symptom_combo, 1117 | 2, 3, 1118 | 12, 13, 1119 | GTK_FILL, 1120 | GTK_FILL, 1121 | 0, 0 1122 | ); 1123 | temp_label = gtk_label_new("患者状态:"); 1124 | gtk_widget_set_size_request(temp_label, 100, 25); 1125 | gtk_table_attach( 1126 | GTK_TABLE(temp_table), 1127 | temp_label, 1128 | 3, 4, 1129 | 12, 13, 1130 | GTK_FILL, 1131 | GTK_FILL, 1132 | 0, 0 1133 | ); 1134 | (*item).status_combo = gtk_combo_box_text_new(); 1135 | gtk_combo_box_text_append_text( 1136 | GTK_COMBO_BOX_TEXT((*item).status_combo), 1137 | "" 1138 | ); 1139 | gtk_combo_box_text_append_text( 1140 | GTK_COMBO_BOX_TEXT((*item).status_combo), 1141 | "兴奋状态" 1142 | ); 1143 | gtk_combo_box_text_append_text( 1144 | GTK_COMBO_BOX_TEXT((*item).status_combo), 1145 | "偏执状态" 1146 | ); 1147 | gtk_combo_box_text_append_text( 1148 | GTK_COMBO_BOX_TEXT((*item).status_combo), 1149 | "缄默状态" 1150 | ); 1151 | gtk_combo_box_text_append_text( 1152 | GTK_COMBO_BOX_TEXT((*item).status_combo), 1153 | "焦虑状态" 1154 | ); 1155 | gtk_widget_set_size_request((*item).status_combo, 150, 25); 1156 | gtk_table_attach( 1157 | GTK_TABLE(temp_table), 1158 | (*item).status_combo, 1159 | 4, 5, 1160 | 12, 13, 1161 | GTK_FILL, 1162 | GTK_FILL, 1163 | 0, 0 1164 | ); 1165 | temp_label = gtk_label_new("抗精神病药物:"); 1166 | gtk_widget_set_size_request(temp_label, 100, 25); 1167 | gtk_table_attach( 1168 | GTK_TABLE(temp_table), 1169 | temp_label, 1170 | 1, 2, 1171 | 13, 14, 1172 | GTK_FILL, 1173 | GTK_FILL, 1174 | 0, 0 1175 | ); 1176 | (*item).psy_combo = gtk_combo_box_text_new(); 1177 | gtk_combo_box_text_append_text( 1178 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1179 | "" 1180 | ); 1181 | gtk_combo_box_text_append_text( 1182 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1183 | "氯丙嗪片" 1184 | ); 1185 | gtk_combo_box_text_append_text( 1186 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1187 | "氯丙嗪注射液" 1188 | ); 1189 | gtk_combo_box_text_append_text( 1190 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1191 | "奋乃静片" 1192 | ); 1193 | gtk_combo_box_text_append_text( 1194 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1195 | "氟哌啶醇片" 1196 | ); 1197 | gtk_combo_box_text_append_text( 1198 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1199 | "氟哌啶醇注射液" 1200 | ); 1201 | gtk_combo_box_text_append_text( 1202 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1203 | "奥氮平片" 1204 | ); 1205 | gtk_combo_box_text_append_text( 1206 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1207 | "喹硫平片" 1208 | ); 1209 | gtk_combo_box_text_append_text( 1210 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1211 | "阿立哌唑口腔崩解片" 1212 | ); 1213 | gtk_combo_box_text_append_text( 1214 | GTK_COMBO_BOX_TEXT((*item).psy_combo), 1215 | "利培酮片" 1216 | ); 1217 | gtk_table_attach( 1218 | GTK_TABLE(temp_table), 1219 | (*item).psy_combo, 1220 | 2, 3, 1221 | 13, 14, 1222 | GTK_FILL, 1223 | GTK_FILL, 1224 | 0, 0 1225 | ); 1226 | temp_label = gtk_label_new("抗抑郁药物:"); 1227 | gtk_widget_set_size_request(temp_label, 100, 25); 1228 | gtk_table_attach( 1229 | GTK_TABLE(temp_table), 1230 | temp_label, 1231 | 3, 4, 1232 | 13, 14, 1233 | GTK_FILL, 1234 | GTK_FILL, 1235 | 0, 0 1236 | ); 1237 | (*item).dep_combo = gtk_combo_box_text_new(); 1238 | gtk_combo_box_text_append_text( 1239 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1240 | "" 1241 | ); 1242 | gtk_combo_box_text_append_text( 1243 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1244 | "多虑平片" 1245 | ); 1246 | gtk_combo_box_text_append_text( 1247 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1248 | "氯丙咪嗪片" 1249 | ); 1250 | gtk_combo_box_text_append_text( 1251 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1252 | "氟西丁片" 1253 | ); 1254 | gtk_combo_box_text_append_text( 1255 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1256 | "氟伏沙明片" 1257 | ); 1258 | gtk_combo_box_text_append_text( 1259 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1260 | "帕罗西丁片" 1261 | ); 1262 | gtk_combo_box_text_append_text( 1263 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1264 | "舍曲林片" 1265 | ); 1266 | gtk_combo_box_text_append_text( 1267 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1268 | "曲唑酮片" 1269 | ); 1270 | gtk_combo_box_text_append_text( 1271 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1272 | "米氯平" 1273 | ); 1274 | gtk_combo_box_text_append_text( 1275 | GTK_COMBO_BOX_TEXT((*item).dep_combo), 1276 | "文拉法星片" 1277 | ); 1278 | gtk_widget_set_size_request((*item).dep_combo, 150, 25); 1279 | gtk_table_attach( 1280 | GTK_TABLE(temp_table), 1281 | (*item).dep_combo, 1282 | 4, 5, 1283 | 13, 14, 1284 | GTK_FILL, 1285 | GTK_FILL, 1286 | 0, 0 1287 | ); 1288 | temp_label = gtk_label_new("抗焦虑药物:"); 1289 | gtk_widget_set_size_request(temp_label, 100, 25); 1290 | gtk_table_attach( 1291 | GTK_TABLE(temp_table), 1292 | temp_label, 1293 | 1, 2, 1294 | 14, 15, 1295 | GTK_FILL, 1296 | GTK_FILL, 1297 | 0, 0 1298 | ); 1299 | (*item).anxiety_combo = gtk_combo_box_text_new(); 1300 | gtk_combo_box_text_append_text( 1301 | GTK_COMBO_BOX_TEXT((*item).anxiety_combo), 1302 | "" 1303 | ); 1304 | gtk_combo_box_text_append_text( 1305 | GTK_COMBO_BOX_TEXT((*item).anxiety_combo), 1306 | "阿普唑仑片" 1307 | ); 1308 | gtk_combo_box_text_append_text( 1309 | GTK_COMBO_BOX_TEXT((*item).anxiety_combo), 1310 | "劳拉西泮片" 1311 | ); 1312 | gtk_combo_box_text_append_text( 1313 | GTK_COMBO_BOX_TEXT((*item).anxiety_combo), 1314 | "艾司唑仑片" 1315 | ); 1316 | gtk_combo_box_text_append_text( 1317 | GTK_COMBO_BOX_TEXT((*item).anxiety_combo), 1318 | "佐匹克隆片" 1319 | ); 1320 | gtk_widget_set_size_request((*item).anxiety_combo, 150, 25); 1321 | gtk_table_attach( 1322 | GTK_TABLE(temp_table), 1323 | (*item).anxiety_combo, 1324 | 2, 3, 1325 | 14, 15, 1326 | GTK_FILL, 1327 | GTK_FILL, 1328 | 0, 0 1329 | ); 1330 | temp_label = gtk_label_new("心境稳定剂:"); 1331 | gtk_widget_set_size_request(temp_label, 100, 25); 1332 | gtk_table_attach( 1333 | GTK_TABLE(temp_table), 1334 | temp_label, 1335 | 3, 4, 1336 | 14, 15, 1337 | GTK_FILL, 1338 | GTK_FILL, 1339 | 0, 0); 1340 | (*item).heart_combo = gtk_combo_box_text_new(); 1341 | gtk_combo_box_text_append_text( 1342 | GTK_COMBO_BOX_TEXT((*item).heart_combo), 1343 | "" 1344 | ); 1345 | gtk_combo_box_text_append_text( 1346 | GTK_COMBO_BOX_TEXT((*item).heart_combo), 1347 | "丙戊酸盐片" 1348 | ); 1349 | gtk_combo_box_text_append_text( 1350 | GTK_COMBO_BOX_TEXT((*item).heart_combo), 1351 | "丙戊酸盐注射液" 1352 | ); 1353 | gtk_combo_box_text_append_text( 1354 | GTK_COMBO_BOX_TEXT((*item).heart_combo), 1355 | "卡马西平片" 1356 | ); 1357 | gtk_combo_box_text_append_text( 1358 | GTK_COMBO_BOX_TEXT((*item).heart_combo), 1359 | "碳酸锂片" 1360 | ); 1361 | gtk_widget_set_size_request((*item).heart_combo, 150, 25); 1362 | gtk_table_attach( 1363 | GTK_TABLE(temp_table), 1364 | (*item).heart_combo, 1365 | 4, 5, 1366 | 14, 15, 1367 | GTK_FILL, 1368 | GTK_FILL, 1369 | 0, 0 1370 | ); 1371 | temp_separator = gtk_hseparator_new(); 1372 | gtk_widget_set_size_request(temp_separator, 500, 25); 1373 | gtk_table_attach( 1374 | GTK_TABLE(temp_table), 1375 | temp_separator, 1376 | 1, 5, 1377 | 15, 16, 1378 | GTK_FILL, 1379 | GTK_FILL, 1380 | 0, 0 1381 | ); 1382 | temp_label = gtk_label_new("物质依赖:"); 1383 | gtk_widget_set_size_request(temp_label, 100, 25); 1384 | gtk_table_attach( 1385 | GTK_TABLE(temp_table), 1386 | temp_label, 1387 | 1, 2, 1388 | 16, 17, 1389 | GTK_FILL, 1390 | GTK_FILL, 1391 | 0, 0 1392 | ); 1393 | (*item).addicted_combo = gtk_combo_box_text_new(); 1394 | gtk_combo_box_text_append_text( 1395 | GTK_COMBO_BOX_TEXT((*item).addicted_combo), 1396 | "" 1397 | ); 1398 | gtk_combo_box_text_append_text( 1399 | GTK_COMBO_BOX_TEXT((*item).addicted_combo), 1400 | "吸烟" 1401 | ); 1402 | gtk_combo_box_text_append_text( 1403 | GTK_COMBO_BOX_TEXT((*item).addicted_combo), 1404 | "饮酒" 1405 | ); 1406 | gtk_combo_box_text_append_text( 1407 | GTK_COMBO_BOX_TEXT((*item).addicted_combo), 1408 | "吸烟和饮酒" 1409 | ); 1410 | gtk_widget_set_size_request((*item).addicted_combo, 150, 25); 1411 | gtk_table_attach( 1412 | GTK_TABLE(temp_table), 1413 | (*item).addicted_combo, 1414 | 2, 3, 1415 | 16, 17, 1416 | GTK_FILL, 1417 | GTK_FILL, 1418 | 0, 0 1419 | ); 1420 | temp_label = gtk_label_new("是否吸毒:"); 1421 | gtk_widget_set_size_request(temp_label, 100, 25); 1422 | gtk_table_attach( 1423 | GTK_TABLE(temp_table), 1424 | temp_label, 1425 | 3, 4, 1426 | 16, 17, 1427 | GTK_FILL, 1428 | GTK_FILL, 1429 | 0, 0 1430 | ); 1431 | (*item).drug_combo = gtk_combo_box_text_new(); 1432 | gtk_combo_box_text_append_text( 1433 | GTK_COMBO_BOX_TEXT((*item).drug_combo), 1434 | "" 1435 | ); 1436 | gtk_combo_box_text_append_text( 1437 | GTK_COMBO_BOX_TEXT((*item).drug_combo), 1438 | "是" 1439 | ); 1440 | gtk_combo_box_text_append_text( 1441 | GTK_COMBO_BOX_TEXT((*item).drug_combo), 1442 | "否" 1443 | ); 1444 | gtk_widget_set_size_request((*item).drug_combo, 150, 25); 1445 | gtk_table_attach( 1446 | GTK_TABLE(temp_table), 1447 | (*item).drug_combo, 1448 | 4, 5, 1449 | 16, 17, 1450 | GTK_FILL, 1451 | GTK_FILL, 1452 | 0, 0 1453 | ); 1454 | temp_label = gtk_label_new("躯体疾病:"); 1455 | gtk_widget_set_size_request(temp_label, 100, 25); 1456 | gtk_table_attach( 1457 | GTK_TABLE(temp_table), 1458 | temp_label, 1459 | 1, 2, 1460 | 17, 18, 1461 | GTK_FILL, 1462 | GTK_FILL, 1463 | 0, 0 1464 | ); 1465 | (*item).body_entry = gtk_entry_new(); 1466 | gtk_widget_set_size_request((*item).body_entry, 150, 25); 1467 | gtk_table_attach( 1468 | GTK_TABLE(temp_table), 1469 | (*item).body_entry, 1470 | 2, 3, 1471 | 17, 18, 1472 | GTK_FILL, 1473 | GTK_FILL, 1474 | 0, 0 1475 | ); 1476 | temp_label = gtk_label_new("传染病:"); 1477 | gtk_widget_set_size_request(temp_label, 100, 25); 1478 | gtk_table_attach( 1479 | GTK_TABLE(temp_table), 1480 | temp_label, 1481 | 3, 4, 1482 | 17, 18, 1483 | GTK_FILL, 1484 | GTK_FILL, 1485 | 0, 0 1486 | ); 1487 | (*item).infect_entry = gtk_entry_new(); 1488 | gtk_widget_set_size_request((*item).infect_entry, 150, 25); 1489 | gtk_table_attach( 1490 | GTK_TABLE(temp_table), 1491 | (*item).infect_entry, 1492 | 4, 5, 1493 | 17, 18, 1494 | GTK_FILL, 1495 | GTK_FILL, 1496 | 0, 0 1497 | ); 1498 | temp_label = gtk_label_new(" "); 1499 | gtk_widget_set_size_request(temp_label, 100, 25); 1500 | gtk_table_attach( 1501 | GTK_TABLE(temp_table), 1502 | temp_label, 1503 | 1, 2, 1504 | 18, 19, 1505 | GTK_FILL, 1506 | GTK_FILL, 1507 | 0, 0 1508 | ); 1509 | temp_label = gtk_label_new("住院信息"); 1510 | gtk_notebook_append_page( 1511 | GTK_NOTEBOOK(person_notebook), 1512 | temp_table, 1513 | temp_label 1514 | ); 1515 | /* 接下来创建“历史记录”标签页 */ 1516 | temp_scrolled = gtk_scrolled_window_new(NULL, NULL); 1517 | gtk_scrolled_window_set_policy( 1518 | GTK_SCROLLED_WINDOW(temp_scrolled), 1519 | GTK_POLICY_AUTOMATIC, 1520 | GTK_POLICY_AUTOMATIC 1521 | ); 1522 | /* 开始创建“历史记录”列表 */ 1523 | (*item).histroy_list = gtk_clist_new(16); 1524 | gtk_clist_set_row_height( 1525 | GTK_CLIST((*item).histroy_list), 1526 | 25 1527 | ); 1528 | gtk_clist_set_shadow_type( 1529 | GTK_CLIST((*item).histroy_list), 1530 | GTK_SHADOW_IN 1531 | ); 1532 | gtk_clist_set_column_title( 1533 | GTK_CLIST((*item).histroy_list), 1534 | 0, 1535 | "入院时间" 1536 | ); 1537 | gtk_clist_set_column_justification( 1538 | GTK_CLIST((*item).histroy_list), 1539 | 0, 1540 | GTK_JUSTIFY_CENTER 1541 | ); 1542 | gtk_clist_set_column_auto_resize( 1543 | GTK_CLIST((*item).histroy_list), 1544 | 0, 1545 | TRUE 1546 | ); 1547 | gtk_clist_set_column_title( 1548 | GTK_CLIST((*item).histroy_list), 1549 | 1, 1550 | "出院时间" 1551 | ); 1552 | gtk_clist_set_column_justification( 1553 | GTK_CLIST((*item).histroy_list), 1554 | 1, 1555 | GTK_JUSTIFY_CENTER 1556 | ); 1557 | gtk_clist_set_column_auto_resize( 1558 | GTK_CLIST((*item).histroy_list), 1559 | 1, 1560 | TRUE 1561 | ); 1562 | gtk_clist_set_column_title( 1563 | GTK_CLIST((*item).histroy_list), 1564 | 2, 1565 | "入院评分" 1566 | ); 1567 | gtk_clist_set_column_justification( 1568 | GTK_CLIST((*item).histroy_list), 1569 | 2, 1570 | GTK_JUSTIFY_CENTER 1571 | ); 1572 | gtk_clist_set_column_auto_resize( 1573 | GTK_CLIST((*item).histroy_list), 1574 | 2, 1575 | TRUE 1576 | ); 1577 | gtk_clist_set_column_title( 1578 | GTK_CLIST((*item).histroy_list), 1579 | 3, 1580 | "出院评分" 1581 | ); 1582 | gtk_clist_set_column_justification( 1583 | GTK_CLIST((*item).histroy_list), 1584 | 3, 1585 | GTK_JUSTIFY_CENTER 1586 | ); 1587 | gtk_clist_set_column_auto_resize( 1588 | GTK_CLIST((*item).histroy_list), 1589 | 3, 1590 | TRUE 1591 | ); 1592 | gtk_clist_set_column_title( 1593 | GTK_CLIST((*item).histroy_list), 1594 | 4, 1595 | "减分率" 1596 | ); 1597 | gtk_clist_set_column_justification( 1598 | GTK_CLIST((*item).histroy_list), 1599 | 4, 1600 | GTK_JUSTIFY_CENTER 1601 | ); 1602 | gtk_clist_set_column_auto_resize( 1603 | GTK_CLIST((*item).histroy_list), 1604 | 4, 1605 | TRUE 1606 | ); 1607 | gtk_clist_set_column_title( 1608 | GTK_CLIST((*item).histroy_list), 1609 | 5, 1610 | "行为分级" 1611 | ); 1612 | gtk_clist_set_column_justification( 1613 | GTK_CLIST((*item).histroy_list), 1614 | 5, 1615 | GTK_JUSTIFY_CENTER 1616 | ); 1617 | gtk_clist_set_column_auto_resize( 1618 | GTK_CLIST((*item).histroy_list), 1619 | 5, 1620 | TRUE 1621 | ); 1622 | gtk_clist_set_column_title( 1623 | GTK_CLIST((*item).histroy_list), 1624 | 6, 1625 | "患者症状" 1626 | ); 1627 | gtk_clist_set_column_justification( 1628 | GTK_CLIST((*item).histroy_list), 1629 | 6, 1630 | GTK_JUSTIFY_CENTER 1631 | ); 1632 | gtk_clist_set_column_auto_resize( 1633 | GTK_CLIST((*item).histroy_list), 1634 | 6, 1635 | TRUE 1636 | ); 1637 | gtk_clist_set_column_title( 1638 | GTK_CLIST((*item).histroy_list), 1639 | 7, 1640 | "患者状态" 1641 | ); 1642 | gtk_clist_set_column_justification( 1643 | GTK_CLIST((*item).histroy_list), 1644 | 7, 1645 | GTK_JUSTIFY_CENTER 1646 | ); 1647 | gtk_clist_set_column_auto_resize( 1648 | GTK_CLIST((*item).histroy_list), 1649 | 7, 1650 | TRUE 1651 | ); 1652 | gtk_clist_set_column_title( 1653 | GTK_CLIST((*item).histroy_list), 1654 | 8, 1655 | "抗精神病药物" 1656 | ); 1657 | gtk_clist_set_column_justification( 1658 | GTK_CLIST((*item).histroy_list), 1659 | 8, 1660 | GTK_JUSTIFY_CENTER 1661 | ); 1662 | gtk_clist_set_column_auto_resize( 1663 | GTK_CLIST((*item).histroy_list), 1664 | 8, 1665 | TRUE 1666 | ); 1667 | gtk_clist_set_column_title( 1668 | GTK_CLIST((*item).histroy_list), 1669 | 9, 1670 | "抗抑郁药物" 1671 | ); 1672 | gtk_clist_set_column_justification( 1673 | GTK_CLIST((*item).histroy_list), 1674 | 9, 1675 | GTK_JUSTIFY_CENTER 1676 | ); 1677 | gtk_clist_set_column_auto_resize( 1678 | GTK_CLIST((*item).histroy_list), 1679 | 9, 1680 | TRUE 1681 | ); 1682 | gtk_clist_set_column_title( 1683 | GTK_CLIST((*item).histroy_list), 1684 | 10, 1685 | "抗焦虑药物" 1686 | ); 1687 | gtk_clist_set_column_justification( 1688 | GTK_CLIST((*item).histroy_list), 1689 | 10, 1690 | GTK_JUSTIFY_CENTER 1691 | ); 1692 | gtk_clist_set_column_auto_resize( 1693 | GTK_CLIST((*item).histroy_list), 1694 | 10, 1695 | TRUE 1696 | ); 1697 | gtk_clist_set_column_title( 1698 | GTK_CLIST((*item).histroy_list), 1699 | 11, 1700 | "心境稳定剂" 1701 | ); 1702 | gtk_clist_set_column_justification( 1703 | GTK_CLIST((*item).histroy_list), 1704 | 11, 1705 | GTK_JUSTIFY_CENTER 1706 | ); 1707 | gtk_clist_set_column_auto_resize( 1708 | GTK_CLIST((*item).histroy_list), 1709 | 11, 1710 | TRUE 1711 | ); 1712 | gtk_clist_set_column_title( 1713 | GTK_CLIST((*item).histroy_list), 1714 | 12, 1715 | "物质依赖" 1716 | ); 1717 | gtk_clist_set_column_justification( 1718 | GTK_CLIST((*item).histroy_list), 1719 | 12, 1720 | GTK_JUSTIFY_CENTER 1721 | ); 1722 | gtk_clist_set_column_auto_resize( 1723 | GTK_CLIST((*item).histroy_list), 1724 | 12, 1725 | TRUE 1726 | ); 1727 | gtk_clist_set_column_title( 1728 | GTK_CLIST((*item).histroy_list), 1729 | 13, 1730 | "是否吸毒" 1731 | ); 1732 | gtk_clist_set_column_justification( 1733 | GTK_CLIST((*item).histroy_list), 1734 | 13, 1735 | GTK_JUSTIFY_CENTER 1736 | ); 1737 | gtk_clist_set_column_auto_resize( 1738 | GTK_CLIST((*item).histroy_list), 1739 | 13, 1740 | TRUE 1741 | ); 1742 | gtk_clist_set_column_title( 1743 | GTK_CLIST((*item).histroy_list), 1744 | 14, 1745 | "躯体疾病" 1746 | ); 1747 | gtk_clist_set_column_justification( 1748 | GTK_CLIST((*item).histroy_list), 1749 | 14, 1750 | GTK_JUSTIFY_CENTER 1751 | ); 1752 | gtk_clist_set_column_auto_resize( 1753 | GTK_CLIST((*item).histroy_list), 1754 | 14, 1755 | TRUE 1756 | ); 1757 | gtk_clist_set_column_title( 1758 | GTK_CLIST((*item).histroy_list), 1759 | 15, 1760 | "传染病" 1761 | ); 1762 | gtk_clist_set_column_justification( 1763 | GTK_CLIST((*item).histroy_list), 1764 | 15, 1765 | GTK_JUSTIFY_CENTER 1766 | ); 1767 | gtk_clist_set_column_auto_resize( 1768 | GTK_CLIST((*item).histroy_list), 1769 | 15, 1770 | TRUE 1771 | ); 1772 | gtk_clist_column_titles_show(GTK_CLIST((*item).histroy_list)); 1773 | gtk_scrolled_window_add_with_viewport( 1774 | GTK_SCROLLED_WINDOW(temp_scrolled), 1775 | (*item).histroy_list 1776 | ); 1777 | temp_label = gtk_label_new("历史记录"); 1778 | gtk_notebook_append_page( 1779 | GTK_NOTEBOOK(person_notebook), 1780 | temp_scrolled, 1781 | temp_label 1782 | ); 1783 | 1784 | /* 底部按钮设置 */ 1785 | temp_vbox = gtk_vbox_new(FALSE, 0); 1786 | gtk_box_pack_start( 1787 | GTK_BOX(temp_vbox), 1788 | person_notebook, 1789 | TRUE, 1790 | TRUE, 1791 | 0 1792 | ); 1793 | temp_hbox = gtk_hbox_new(FALSE, 0); 1794 | (*item).out_check = gtk_check_button_new_with_label("确认出院"); 1795 | gtk_widget_set_size_request((*item).out_check, 100, 25); 1796 | gtk_box_pack_start( 1797 | GTK_BOX(temp_hbox), 1798 | (*item).out_check, 1799 | FALSE, 1800 | FALSE, 1801 | 0 1802 | ); 1803 | temp_button = gtk_button_new_with_label("确定"); 1804 | g_signal_connect( 1805 | G_OBJECT(temp_button), 1806 | "clicked", 1807 | G_CALLBACK(check_sure), 1808 | item 1809 | ); 1810 | gtk_box_pack_start(GTK_BOX(temp_hbox), 1811 | temp_button, 1812 | TRUE, 1813 | TRUE, 1814 | 0 1815 | ); 1816 | temp_button = gtk_button_new_with_label("取消"); 1817 | g_signal_connect( 1818 | G_OBJECT(temp_button), 1819 | "clicked", 1820 | G_CALLBACK(cancel), 1821 | item 1822 | ); 1823 | gtk_box_pack_start( 1824 | GTK_BOX(temp_hbox), 1825 | temp_button, 1826 | TRUE, 1827 | TRUE, 1828 | 0 1829 | ); 1830 | gtk_box_pack_start( 1831 | GTK_BOX(temp_vbox), 1832 | temp_hbox, 1833 | TRUE, 1834 | TRUE, 1835 | 0 1836 | ); 1837 | gtk_box_pack_start( 1838 | GTK_BOX(main_hbox), 1839 | temp_vbox, 1840 | TRUE, 1841 | TRUE, 1842 | 0 1843 | ); 1844 | gtk_box_pack_start( 1845 | GTK_BOX(main_vbox), 1846 | main_hbox, 1847 | TRUE, 1848 | TRUE, 1849 | 10 1850 | ); 1851 | 1852 | /* 把主框架放入主窗口 */ 1853 | gtk_container_add( 1854 | GTK_CONTAINER(main_window), 1855 | main_vbox 1856 | ); 1857 | 1858 | /* 显示所有控件 */ 1859 | gtk_widget_show_all(main_window); 1860 | /* 进入事件循环 */ 1861 | gtk_main(); 1862 | 1863 | return 0; 1864 | } 1865 | --------------------------------------------------------------------------------