Database course design (3)

1. Course design topics

hospital management system

2. Course design purpose

The database system course is designed to coordinate with the study of database system principles and application development. It is a teaching link that focuses on the practice of computer science and technology, big data, information security, Internet of Things engineering, software engineering, intelligent manufacturing and other majors. It is a link between the relationship An important link in transforming database theoretical knowledge into the ability to solve practical problems. The database system course is designed to deepen your understanding of the theoretical knowledge of relational databases. By using a specific DBMS, you can master an actual database management system and its operating techniques, and be proficient in using database front-end development tools (such as VB, C++, Java, JSP, Delphi, PowerBuilder, etc.) to further improve students' ability to use database technology to solve practical problems.

3. Overall design

1. Background knowledge

  (1) Java GUI interface design
AWT, Java's earliest interface library, needs to call local system methods to implement functions, and is a heavyweight control. Swing is an extension of AWT. (javax.swing: A set of graphical interface systems based on AWT, which provides more components and is completely implemented in Java. It enhances portability and is a lightweight component.) And JavaFX, JDK1. The new interface library introduced in 8.
In this design, I used swing and awt to design the interface. Java Swing graphical interface development
  (2) Java's JDBC connection database
JDBC: Java DataBase Connectivity (Java database connection technology), which is an application programming interface that combines Java with SQL and is independent of a specific database system. I used ideal and mysql. JDBC from entry to proficiency - detailed explanation of functional classes, CRUD, SQL injection, transactions, connection pooling

2. Module introduction
  1. The main login page and the main registration page
    use different staff to log in. For example, nurses and doctors can handle hospitalization, while senior leaders can enter the employee management module. Only pharmacists can enter the material module. The registration page only requires hospital staff. Only users who are not hospital employees can log in. Other non-hospital employees are not allowed to register and log in.
  2. Menu interface of hospitalization management module.
    Hospitalization management includes patient management and bed management, and doctors and nurses can add, delete, modify and check them.
  3. Employee management module menu interface
    Employee management has menus for employee overview, salary reports and personnel transfers. Only higher-level leaders can enter and add, delete, modify and check.
  4. Material list module menu page
    The material list includes a drug list and an instrument list. Pharmacists can enter the system and add, delete, modify and check them, but other personnel cannot enter.
3. Design steps

(1) First create the database table

(2) Design the interface of each module

(3) Java connects to the database and uses the data (i.e. using jdbc)
(4) Debugging and modification
Insert image description here
(solve some existing errors or flag reminders)

4. Detailed design

1 System requirements analysis

  Through a hospital management system, the hospital management work can be systematized, standardized and automated, thereby achieving the purpose of improving hospital management efficiency.
1.1 System Function Analysis
The main functions that the hospital management system needs to complete include:

  • Input various employee information, including employee basic information, job title, position, etc.
  • Query and modify various employee information, including employee basic information, job title, position, salary, etc.
  • Employee personnel transfer management.
  • Management of patient information.
  • Management of hospital beds.
  • Pharmacy resource management.
  • Instrument resource management.
  • System user management and permission management.

1.2 System functional module design (division)
  According to the system functional requirements, the system can be decomposed into several modules to design the application program interface respectively, as shown in Figure 1. The designer can only implement the relevant functions of the inpatient department and employee management modules, among which the outpatient department, medicine and instrument modules can be selected according to time.
Insert image description here
1.3 Relationship with other systems
1.4 Data flow chart
  The data flow of the hospital management system is shown in Figure 2 (completed by the designer).
Insert image description here

2 Database design

2.1 Database Requirements Analysis
Through analysis of the content and data relationships of hospital management, we designed the data items and data structures as follows:

  • The data items included in the basic status of employees include employee number, employee name, gender, department, ID number, birthday, place of origin, nationality, ethnicity, marital status, health status, working time, employee status, home address, contact number, etc. .
  • The data items included in the basic status of employees include employee number, employee name, gender, department, ID number, birthday, place of origin, nationality, ethnicity, marital status, health status, working time, employee status, home address, contact number, etc. .
  • The data items included in employee salary status include employee number, salary category, salary amount, etc.
  • The hospital job information includes database items such as job code, job name, etc.
  • The hospital department information includes data items such as department code, department name, department head, etc.
  • The data items included in the patient information include patient name, patient gender, admission time, patient department, patient status, patient attending doctor, room question mark, bed number, etc.
  • The data items included in the pharmaceutical resource management information include pharmaceutical code number, pharmaceutical name, pharmaceutical price, pharmaceutical inventory quantity, remarks, etc.
  • Medical instrument management includes data items such as instrument code, instrument name, instrument price, instrument quantity, remarks, etc.
    With the above data structure, data items and data relationships, we can carry out the following database design.
    2.2 Database conceptual structure design
    The entities planned by this system based on the above design include employee entities, department entities, position entities, patient entities, pharmaceutical entities, and instrument entities. The ER diagram model of entities and the relationship between entities is shown in Figure 3.

2.3 Database logical structure design
  Based on the above entities and the relationships between entities, we can form the tables in the database and the relationships between each table. The design results of each table in the hospital management system database are shown in Tables 1 to 7.
Insert image description here
Insert image description here
Insert image description hereInsert image description here
2.4 Establishment of database
2.4.1 Establishment of database

2.4.2 Input of initial data

3 Design and implementation of each functional module

3.1 Function description
1. Management of employee information.
2. Management of patient information.
3. Management of hospital beds.
4. Management of pharmaceutical instrument resources.
5. System user management and authority management.
3.2 User interface design
  After completing the database creation and function description, we can proceed to the next step, which is designing the user interface. We divide the form of the hospital management system into 5 main parts, as shown in the figure.
1. System welcome interface and login interface design

Main code:

button1.addActionListener(new ActionListener() {
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
    
    
        new regest();
        f.dispose();
    }
});
    button2.addActionListener(new ActionListener() {
    
    
            @Override
            public void actionPerformed(ActionEvent e) {
    
    
                    String username=id.getText().trim();
                  String  password1= String.valueOf(password.getPassword())/*password.getPassword().toString()*/;
                        System.out.println(password.getPassword());
                String pass=String.valueOf(password.getPassword());
                  if (j.getSelectedItem().equals("住院办理")) {
    
    
                      connection_mysql connection = new connection_mysql();
                      Connection conn = connection.getConnect();
                      PreparedStatement pr = null;
                      ResultSet rs = null;
                      try {
    
    
                          pr = conn.prepareStatement("select * from tms_1 where TMS_user=? and TMS_paswd=?");
                          pr.setString(1, id.getText());
                          pr.setString(2, pass);
                          rs = pr.executeQuery();
                          if(rs.next()) {
    
    
                                  new inpatien_system();
                                  f.dispose();

                          }
                          else {
    
    
                                  JOptionPane.showMessageDialog(null, "密码或用户或用户类型错误", "提示", JOptionPane.WARNING_MESSAGE);
                          }
                          pr.close();
                          rs.close();
                          conn.close();
                      } catch (SQLException e1) {
    
    
                          e1.printStackTrace();
                      }
                  }
                  else if (j.getSelectedItem().equals("员工管理"))
                  {
    
    
                      connection_mysql connection = new connection_mysql();
                      Connection conn = connection.getConnect();
                      PreparedStatement pr = null;
                      ResultSet rs = null;
                      try {
    
    
                          pr = conn.prepareStatement("select * from tms_2 where tms2user=? and tms2paswd=?");
                          pr.setString(1, id.getText());
                          pr.setString(2, pass);
                          rs = pr.executeQuery();
                          if(rs.next())
                          {
    
    
                                  new employee_managemwnt();
                                   f.dispose();
                          } else
                          {
    
    
                              JOptionPane.showMessageDialog(null, "密码或用户或用户类型错误", "提示", JOptionPane.WARNING_MESSAGE);
                          }
                          pr.close();
                          rs.close();
                          conn.close();
                      } catch (SQLException e1) {
    
    
                          e1.printStackTrace();
                      }
                  }else if(j.getSelectedItem().equals("物资清单"))
                  {
    
    
                      connection_mysql connection = new connection_mysql();
                      Connection conn = connection.getConnect();
                      PreparedStatement pr = null;
                      ResultSet rs = null;
                      try {
    
    
                          pr = conn.prepareStatement("select * from tms_3 where tms3user=? and tms3paswd=?");
                          pr.setString(1, id.getText());
                          pr.setString(2, pass);
                          rs = pr.executeQuery();
                          if(rs.next()) {
    
    
                                  new material_list();
                                  f.dispose();
                          }
                          else {
    
    
                              JOptionPane.showMessageDialog(null, "密码或用户或用户类型错误", "提示", JOptionPane.WARNING_MESSAGE);
                          }
                          pr.close();
                          rs.close();
                          conn.close();
                      } catch (SQLException e1) {
    
    
                          e1.printStackTrace();
                      }
                  }

2. Registration module interface

main code:

button1.addActionListener(new ActionListener() {
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
    
    
        String username = id.getText().trim();
        String password1 = String.valueOf(password.getPassword());
        String password3 = String.valueOf(password2.getPassword());
        System.out.print(password1.equals(password3));
        if (password1.equals(password3)) {
    
    
            connection_mysql connection = new connection_mysql();
            Connection conn = connection.getConnect();
            PreparedStatement pr = null;
            PreparedStatement pr1 = null;
            ResultSet rs = null;
            try {
    
    
                pr = conn.prepareStatement("select * from personnel where per_name=?");
                pr1 = conn.prepareStatement("insert into tms_all values(?,?)");
                pr.setString(1, id.getText());
                //pr.setString(2, String.valueOf(password.getPassword()));
                rs = pr.executeQuery();
                if (rs.next()) {
    
    
                    pr1.setString(1, id.getText());
                    pr1.setString(2, String.valueOf(password.getPassword()));
                    pr1.execute();
                    JOptionPane.showMessageDialog(null, "注册成功!", "提示", JOptionPane.WARNING_MESSAGE);
                    new login();
                    f.dispose();
                } else {
    
    
                    JOptionPane.showMessageDialog(null, "你不是该医院的员工,请退出!", "警告", JOptionPane.WARNING_MESSAGE);
                }
                pr.close();
                rs.close();
                conn.close();
            } catch (SQLException e1) {
    
    
                e1.printStackTrace();
            }
        } else {
    
    
            JOptionPane.showMessageDialog(null, "两次密码不一样,请重新输入!", "提示", JOptionPane.WARNING_MESSAGE);
        }
    }
});

2. Main interface

code display of inpatient department management module:

public inpatien_system() {
    
    
    JFrame f = new JFrame("住院办理界面");//相当html的<body></body>启动设置
    //设置窗口大小
    f.setSize(700, 500);//css中的height,width设置
    //使窗口居中
    f.setLocationRelativeTo(null);//css的left,right
    //设置窗口背景图案
    ImageIcon i = new ImageIcon("src/files/4_1.png");//相当url地址格式
    JLabel jLable = new JLabel(i);//JLabel类似<a></a><p></p>等块、行、行块级等标签
    jLable.setBounds(0, -45, 600, 600);
    JPanel panel1 = new JPanel();//JPanel相当网页中div标签
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();
    JPanel panel5 = new JPanel();
    JPanel panel6 = new JPanel();
    /*添加大标题:图书管理系统*/
    JLabel lable = new JLabel("请选择住院办理类型");
    Font font = new Font("宋体", Font.BOLD, 40);//设置字体
    lable.setFont(font);
    panel1.add(lable);
    panel1.setBounds(140, 60, 400, 300);//设置面板大小
    f.add(panel1);//类似body中加div
    //类似设置一个div方便修改位置和大小内容因为有标签修改有限制,然后把<p></p>等放进div中

    JRadioButton rb1=new JRadioButton("病床管理");
    JRadioButton rb2=new JRadioButton("病人管理");
    rb1.setFont(font);
    rb2.setFont(font);
    panel2.add(rb1,BorderLayout.EAST);
    panel3.add(rb2,BorderLayout.EAST);
    panel2.setBounds(140, 120, 400, 300);
    panel3.setBounds(140,200,400,300);
    panel3.add(rb2);
    panel2.add(rb1);
    f.add(panel2);
    f.add(panel3);
    ButtonGroup bg=new ButtonGroup();
    bg.add(rb1);
    bg.add(rb2);
    /*注册登陆按钮*/
    JButton button1 = new JButton("确定");
    JButton button2 = new JButton("取消");
    Font font3 = new Font("宋体", Font.BOLD, 20);
    button1.setFont(font3);
    button2.setFont(font3);
    Dimension dimension2 = new Dimension(100, 50);
    button1.setPreferredSize(dimension2);
    button2.setPreferredSize(dimension2);
    panel5.add(button1);
    panel6.add(button2);
    panel5.setBounds(170, 310, 170, 400);
    panel6.setBounds(350, 310, 170, 400);
    f.add(panel5);
    f.add(panel6);
    //把组件变成透明
    panel1.setOpaque(false);//类似浮动隐藏display:block的作用很重要
    panel2.setOpaque(false);
    panel3.setOpaque(false);
    panel4.setOpaque(false);
    panel5.setOpaque(false);
    panel6.setOpaque(false);
    f.add(jLable);
    button1.addActionListener(new ActionListener() {
    
    
        @Override
        public void actionPerformed(ActionEvent e) {
    
    
            if(rb1.isSelected())
            {
    
    
                new patientroom();
                f.dispose();
            }
            else
            {
    
    
                new patient();
                f.dispose();
            }
        }
    });
    button2.addActionListener(new ActionListener() {
    
    
        @Override
        public void actionPerformed(ActionEvent e) {
    
    
            Object[] option={
    
    "是","否"};
            int n=JOptionPane.showOptionDialog(null,"是否继续","提示",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,option,option[0]);
            if(n==0)
            {
    
    
                JOptionPane.showMessageDialog(null, "亲!请选择办理类型", "提示!", JOptionPane.WARNING_MESSAGE);
            }
            else {
    
    
                new login();
                f.dispose();     }
        }
    });
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

3. Main interface

code display of employee management module:

public employee_managemwnt() {
    JFrame f = new JFrame("员工管理界面");//相当html的<body></body>启动设置
    //设置窗口大小
    f.setSize(700, 500);//css中的height,width设置
    //使窗口居中
    f.setLocationRelativeTo(null);//css的left,right
    //设置窗口背景图案
    ImageIcon i = new ImageIcon("src/files/4_3.png");//相当url地址格式
    JLabel jLable = new JLabel(i);//JLabel类似<a></a><p></p>等块、行、行块级等标签
    jLable.setBounds(0, -45, 600, 600);
    JPanel panel1 = new JPanel();//JPanel相当网页中div标签
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();
    JPanel panel5 = new JPanel();
    JPanel panel6 = new JPanel();
    /*添加大标题:图书管理系统*/
    JLabel lable = new JLabel("请选择查询类型");
    Font font = new Font("宋体", Font.BOLD, 30);//设置字体
    lable.setFont(font);
    panel1.add(lable);
    panel1.setBounds(140, 60, 400, 300);//设置面板大小
    f.add(panel1);//类似body中加div
    //类似设置一个div方便修改位置和大小内容因为有标签修改有限制,然后把<p></p>等放进div中

    JRadioButton rb1=new JRadioButton("员工一览");
    JRadioButton rb2=new JRadioButton("工资报表");
    JRadioButton rb3=new JRadioButton("人事调动");
    rb1.setFont(font);
    rb2.setFont(font);
    rb3.setFont(font);
    panel2.add(rb1,BorderLayout.EAST);
    panel3.add(rb2,BorderLayout.EAST);
    panel4.add(rb3,BorderLayout.EAST);
    panel2.setBounds(140, 120, 400, 200);
    panel3.setBounds(140,200,400,200);
    panel4.setBounds(140,280,400,200);
    panel3.add(rb2);
    panel2.add(rb1);
    panel4.add(rb3);
    f.add(panel2);
    f.add(panel3);
    f.add(panel4);
    ButtonGroup bg=new ButtonGroup();
    bg.add(rb1);
    bg.add(rb2);
    bg.add(rb3);
    /*注册登陆按钮*/
    JButton button1 = new JButton("确定");
    JButton button2 = new JButton("取消");
    Font font3 = new Font("宋体", Font.BOLD, 20);
    button1.setFont(font3);
    button2.setFont(font3);
    Dimension dimension2 = new Dimension(100, 50);
    button1.setPreferredSize(dimension2);
    button2.setPreferredSize(dimension2);
    panel5.add(button1);
    panel6.add(button2);
    panel5.setBounds(170, 350, 170, 400);
    panel6.setBounds(350, 350, 170, 400);
    f.add(panel5);
    f.add(panel6);
    //把组件变成透明
    panel1.setOpaque(false);//类似浮动隐藏display:block的作用很重要
    panel2.setOpaque(false);
    panel3.setOpaque(false);
    panel4.setOpaque(false);
    panel5.setOpaque(false);
    panel6.setOpaque(false);
    f.add(jLable);
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if(rb1.isSelected())
            {
                new employee_information();
                f.dispose();
            }
            if (rb2.isSelected())
            {
                new pay_sheet();
                f.dispose();
            }
            if(rb3.isSelected())
            {
                new personnel_transfer();
                f.dispose();
            }
        }
    });
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object[] option={"是","否"};
            int n=JOptionPane.showOptionDialog(null,"是否继续","提示",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,option,option[0]);
            if(n==0)
            {
                JOptionPane.showMessageDialog(null, "亲!请选择查询类型", "提示!", JOptionPane.WARNING_MESSAGE);
            }
            else {
                new login();
                f.dispose();
            }
        }
    });
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

4. Main interface

code display of material list module:

public material_list() {
    JFrame f = new JFrame("物资清单界面");//相当html的<body></body>启动设置
    //设置窗口大小
    f.setSize(700, 500);//css中的height,width设置
    //使窗口居中
    f.setLocationRelativeTo(null);//css的left,right
    //设置窗口背景图案
    ImageIcon i = new ImageIcon("src/files/4_2.png");//相当url地址格式
    JLabel jLable = new JLabel(i);//JLabel类似<a></a><p></p>等块、行、行块级等标签
    jLable.setBounds(0, -45, 600, 600);
    JPanel panel1 = new JPanel();//JPanel相当网页中div标签
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();
    JPanel panel5 = new JPanel();
    JPanel panel6 = new JPanel();
    /*添加大标题:图书管理系统*/
    JLabel lable = new JLabel("请选择清单类型");
    Font font = new Font("宋体", Font.BOLD, 40);//设置字体
    lable.setFont(font);
    panel1.add(lable);
    panel1.setBounds(140, 60, 400, 300);//设置面板大小
    f.add(panel1);//类似body中加div
    JRadioButton rb1=new JRadioButton("药品清单");
    JRadioButton rb2=new JRadioButton("仪器清单");
    rb1.setFont(font);
    rb2.setFont(font);
    panel2.add(rb1,BorderLayout.EAST);
    panel3.add(rb2,BorderLayout.EAST);
    panel2.setBounds(140, 120, 400, 300);
    panel3.setBounds(140,200,400,300);
    panel3.add(rb2);
    panel2.add(rb1);
    f.add(panel2);
    f.add(panel3);
    ButtonGroup bg=new ButtonGroup();
    bg.add(rb1);
    bg.add(rb2);
    /*注册登陆按钮*/
    JButton button1 = new JButton("确定");
    JButton button2 = new JButton("取消");
    Font font3 = new Font("宋体", Font.BOLD, 20);
    button1.setFont(font3);
    button2.setFont(font3);
    Dimension dimension2 = new Dimension(100, 50);
    button1.setPreferredSize(dimension2);
    button2.setPreferredSize(dimension2);
    panel5.add(button1);
    panel6.add(button2);
    panel5.setBounds(170, 310, 170, 400);
    panel6.setBounds(350, 310, 170, 400);
    f.add(panel5);
    f.add(panel6);
    //把组件变成透明
    panel1.setOpaque(false);//类似浮动隐藏display:block的作用很重要
    panel2.setOpaque(false);
    panel3.setOpaque(false);
    panel4.setOpaque(false);
    panel5.setOpaque(false);
    panel6.setOpaque(false);
    f.add(jLable);
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if(rb1.isSelected())  {
                new drug_list();
                f.dispose();
            }
            else
            {
                new instrument_list();
                f.dispose();
            }
        }
    });
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object[] option={"是","否"};
            int n=JOptionPane.showOptionDialog(null,"是否继续","提示",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,option,option[0]);
            if(n==0)
            {
                JOptionPane.showMessageDialog(null, "亲!请选择清单类型", "提示!", JOptionPane.WARNING_MESSAGE);
            }
            else {
                new login();
                f.dispose();
            }
        }
    });
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

3.3 Implementation of each functional module of each main interface
1. Main interface design of inpatient department management module
(1) Interface design of hospital bed management module

(2) Patient management module interface design 2. Employee management module main interface design (1) Employee overview module interface design (2) Salary report module interface design (3) Personnel transfer module interface design 3. Material list module main interface design (1 ) Interface design of drug list module (2) Interface design of instrument list module 4 System implementation 1. Implementation of inpatient department management module 2. Implementation of employee management module 3. Implementation of material list module

5. Results and analysis

  Each module basically has functions such as adding, deleting, modifying, and checking. As a result, it has been basically designed and implemented except for printing reports.

6. Summary and experience

I was really confused when I started to do it. Not only did the downloaded software have bugs, but there were also various software mismatches and other debugging before entering into the establishment of the database, then the page design, and finally the database. data are connected. But the most difficult thing is the bug. I keep looking for problems and solving them. It is also a sense of accomplishment to be able to succeed on my own in the end.

Guess you like

Origin blog.csdn.net/m0_63084496/article/details/129290336