医院信息管理系统-链式实现

该博客介绍了一个基于链式存储实现的医院信息管理系统。系统中,病人信息存储在链表中,包括id、姓名和病种类型。文章讨论了为何在不同场景下选择顺序存储或链式存储,并提供了C语言实现的输入、删除、搜索、插入和统计心脏病患者数量的函数。
摘要由CSDN通过智能技术生成

/*在关系数据中,病人的信息由若干个基本表存储的,为了简便起见,我们假设所要检索和统计病人的信息存储在线性表p_inof中.每个记录即表元素为上述定义的结构体。
1. 根据病人id来检索病人信息,采用顺序比较好,并简述理由.用c描述。**答:因为顺序存储能方便的通过控制数组序号的方式进行检索,而链式存储需要控制指针指向相应的结点来完成。**
2. 若要经常添加和删除病人信息,则采用链式比较好,并且简述理由.用c描述。**答:因为链式存储能方便的通过指针指向要删除结点的下一个结点完成,而顺序存储需要移动要删除添加结点后面所有结点的位置**
3. 在医院信息系统(his)中统计分析时其中一个重要的模块,现要统计病人中患心脏病(假设病重类型为12),用c描述.
4. 在p_inof struct中为什么定义为病人患病的类型而不定义为患病的名称。**答:这样便于检索,归类和处理。**
*/

 

/*医院信息管理系统-链式实现*/
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define NULL 0
typedef struct
{
 int id;         /*病人的id号*/
 char name[20];  /*病人的姓名*/
 int illtype;    /*病人患病类型。“12”代表心脏病 */
}ill_man;           /*定义链表元素为病人信息的类型*/
typedef struct stack
{
 ill_man man;    /*病人信息的类型*/
 struct stack *next; /*用来指向下一个节点的指针*/
 struct stack *end;  /*用来指向链表最后一个元素的指针*/
}ill_node;              /*链表的节点类型*/         


/*创建一个空表的函数*/
ill_node *initlist()
{
 ill_node *m;
    m=(ill_node *)malloc(sizeof(ill_node));
 m->next=NULL;    /*最后一个结点不指向任何存储单元*/
 m->end=m;        /*使“m->end”指向链表中的最后一个元素*/
 return m;        /*返回一个头指针*/
}
/*输入病人信息到表尾的函数*/
void input(ill_node *m)
{
 ill_node *p;  /*定义一个节点用来暂时存放输入信息,然后连接到主链表中*/
 while(1)      /*用来完成一个无限循环的操作,要退出循环只能通过输入id为0*/
 {
    p=(ill_node *)malloc(sizeof(ill_node));
    printf("/nInput the illman's id:");
    scanf("%d",&p->man.id);
    if(p->man.id==0)break;  /*用来控制循环,如果输入的id为0,则退出该函数*/
       printf("Input the illman's name:");
       scanf("%s",p->man.name);
       printf("Input the illman's illtype:");
       scanf("%d",&p->man.illtype);
    p->next=NULL;   /*使新节点的指针指向空*/
    m->end->next=p; /*将新节点插入链表中*/
    m->end=p;       /*使“m->end”始终指向链表的最后一个节点*/
 }
}
/*根据病人id查找病人信息的函数*/
void search(ill_node *m)
{
 ill_node *p;   /*用来查找和输出所要找的病人的信息*/
 int id_num;   
 printf("Input the patien'id you want to search :");
 scanf("%d",&id_num);  /*输入需要查找病人的id号*/
 for(p=m->next;p!=NULL;p=p->next)
  if(p->man.id==id_num)   /*匹配查找的id*/
  {
   printf("*************************/n");
   printf("The illman's information is:/n");
   printf("The illman's id is: %d/n",p->man.id);
   printf("The illman's name is: %s/n",p->man.name);
   printf("The illman's illtype is: %d/n",p->man.illtype);
   printf("*************************/n");
  }
}
/*删除链表中指定id的病人信息的函数*/
void del(ill_node *m)
{
    ill_node *p;  /*查找和输出要删除病人的信息*/
 int id_num;    /*要删除病人的id号*/
 printf("Input the patien'id you want to delete :");
 scanf("%d",&id_num); /*输入要删除病人的id号*/
 for(p=m;p!=NULL;p=p->next)
  if(p->man.id==id_num)/*匹配删除的id*/
  {
   printf("***********Delete Element**********/n");
   printf("The delete illman's information is:/n");
   printf("The illman's id is: %d/n",p->man.id);
   printf("The illman's name is: %s/n",p->man.name);
   printf("The illman's illtype is: %d/n",p->man.illtype);
   printf("************************************/n");
   p->next=p->next->next;  /*实现删除操作*/
  } 
}
/*插入链表元素在指定病人id号的后面的函数*/
void insert(ill_node *m)
{
    ill_node *p,*n;
 int id_num;
 printf("Input the id:");  
 scanf("%d",&id_num);     /*在id为此输入值的病人后面插入新信息*/
 for(p=m;p!=NULL;p=p->next) 
  if(p->man.id==id_num)   /*匹配输入的id*/
  {
           n=(ill_node *)malloc(sizeof(ill_node));
        printf("Input the illman's id:");
        scanf("%d",&n->man.id);
        printf("Input the illman's name:");
        scanf("%s",n->man.name);
        printf("Input the illman's illtype:");
           scanf("%d",&n->man.illtype);
     n->next=p->next;   /*实现插入操作*/
     p->next=n;         /*实现插入操作*/
  }
}
/*统计表中患某种病的病人个数的函数*/
void cout_ill(ill_node *m)  
{
   ill_node *p;   
   int type;   /*患病的类型*/
   int cout=0;
   printf("Input the illtype :/n");
   scanf("%d",&type);  /*输入所要统计的患病类型*/
   for(p=m;p!=NULL;p=p->next)
   {
    if(p->man.illtype==type)++cout;  /*实现统计功能*/
   }
   printf("The number is: %d/n",cout);/*输出统计数*/
}
/*输出链式表中病人信息的函数*/
void print(ill_node *m)
{
 ill_node *p;
 if(m->next==0){printf("There is no record ./n");return;} /*若为空表则给出提示*/
 for(p=m;p->next!=0;p=p->next)  /*输出链表中的所有元素*/
 {
  printf("*****************/n");
  printf("id: %d/n",p->next->man.id);
  printf("name: %s/n",p->next->man.name);
  printf("illtype: %d/n",p->next->man.illtype);
 }
 printf("*****************/n");
}
/*输出菜单的函数*/
void print_mu()
{
  printf("*******************--menu--*******************/n");
  printf("   Input the patient's information input 1 ./n");
  printf("   Output the patien's information input 2 ./n");
  printf("   Delete the patien's information input 3 ./n");
  printf("   Search the patien with id input 4 ./n");
  printf("   Conut the heart ill number input 5 ./n");
  printf("   Insert the new record behinde the id input 6 ./n");
  printf("*********************menu*********************/n");
  printf("Input your choose :");
}

 

void main()
{
    ill_node L;
 ill_node *L1=&L;
    int a;
    print_mu(); 
 L1=initlist();
 while(1)
 {
     scanf("%d",&a);
     switch(a)
       {
         case 1:input(L1);print_mu();break;
         case 2:print(L1);print_mu();break;
         case 3:del(L1);print_mu();break;
         case 4:search(L1);print_mu();break;
      case 5:cout_ill(L1);print_mu();break;
   case 6:insert(L1);print_mu();break;
       }
 }
}

随着信息技术的飞速发展,我国医疗卫生行业的信息化建设取得了显著成效。但与发达国家相比,无论是从信息技术应用的广度和深度上,还是从开发的规模和水平上,还存在着一定的差距。目前,国内的医疗信息化建设仍存在着资金投入少,技术力量薄弱,从业人员知识结构欠佳,管理标准不规范等问题。绝大部分医院没有全面实现计算机管理,部分医院的计算机应用仍停留在简单的财务管理模式上,因此,从严格意义上讲,我国医院的信息处理基本上还停留在手工方式,劳动强度大且工作效率低,医师护士和管理人员的大量时间都消耗在事务性工作上,致使"人不能尽其才";病人排队等候时间长,辗转过程多,影响医院的秩序;病案、临床检验、病理检查等许多宝贵的数据资料的检索十分费事甚至难以实现;对这些资料深入的统计分析手工方式无法进行,不能充分为医学科研利用;在经济管理上也因而存在漏、跑、错费现象;医院物资管理由于信息不准确,家底不明,积压浪费,以致"物不能尽其用"。开发HIS是解决上述问题的有效途径。HIS系统的有效运行,将提高医院各项工作的效率和质量,促进医学科研、教学;减轻各类事务性工作的劳动强度,使他们腾出更多的精力和时间来服务于病人;改善经营管理,堵塞漏洞,保证病人和医院的经济利益;为医院创造经济效益。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值