基于JSP实现医院病历管理系统

 项目编号:BS-YL-006

本系统基于JSP+SERVLET实现医院病历管理系统,前端基于CSS+JS实现开发,数据库采用MYSQL,开发工具为IDEA或ECLIPSE均可。

本系统共分为四个角色:

管理员角色:主要管理工作人员信息,管理员信息,系统日志等。

医生角色:主要进行患者就诊,病历管理,处方管理,个人信息管理等功能。

窗口工作人员角色:主要进行划价收费工作。

库存工作人员角色:主要管理药品相关的库存工作。

系统部分功能展示:

http://localhost:8080/tjsqyygl/login.jsp

管理员登陆:

工作人员管理

管理人员管理

日志管理

医生登陆系统:

患者就诊

填写病历

病历查看

处方管理

个人信息管理

窗口工作人员:

患者挂号

处方划价

处方缴费

药品取药

库管人员登陆

药品管理

药品入库管理

药品盘点

本系统功能完整,运行无误,界面简洁大方,适合做毕业设计使用。

 部分代码实现:

package cn.bukaa.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.bukaa.dao.CommDAO;
import cn.bukaa.util.Info;

public class UserController extends MainCtrl {

	private CommDAO dao;
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		dao = new CommDAO();
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		String ac = request.getParameter("ac");
		String date = Info.getDateStr();
		String today = date.substring(0, 10);
		String tomonth = date.substring(0, 7);
		if ("login".equals(ac)) {
			login(request, response);
		}else if("logout".equals(ac)){
			logout(request,response);
		}
		else if("uppass".equals(ac)){
			updatePass(request, response);
		}
		
	}
	private void logout(HttpServletRequest request,HttpServletResponse response) {
		request.getSession().invalidate();
		gor("login.jsp", request, response);
		
	}
	private void login(HttpServletRequest request, HttpServletResponse response){
		String pagerandom = request.getParameter("pagerandom") == null ? ""
				: request.getParameter("pagerandom");
		String random = (String) request.getSession()
				.getAttribute("random");
		if (!pagerandom.equals(random) && request.getParameter("a") != null) {
			request.setAttribute("random", "");
			go("/login.jsp", request, response);
		} else {
			dao = new CommDAO();
			String username = request.getParameter("uname");
			String password = request.getParameter("upass");
			String utype = request.getParameter("utype");
			request.getSession().setAttribute("utype", utype);
			List<HashMap> list = dao
					.select("select * from sysuser where uname='"
							+ username + "'");
			if (list.size() == 1) {
				HashMap map = list.get(0);
				List<HashMap> ulist = dao
						.select("select * from sysuser where uname='"
								+ username + "' and upass='" + password
								+ "'");

				if (ulist.size() == 1
						&& password.equals(map.get("upass").toString())) {

					request.getSession().setAttribute("admin", map);
					dao = new CommDAO();
					HashMap<String,Object> ext = new HashMap<String,Object>();
					ext.put("userid", map.get("id"));
					ext.put("tname", map.get("tname"));
					ext.put("oper", "登录");
					request.setAttribute("f", "f");
					dao.insert(request, response, "log", ext, false, true);
					gor("admin/index.jsp", request, response);

				} else {
					request.setAttribute("error", "");
					go("/login.jsp", request, response);
				}
			} else {
				request.setAttribute("error", "");
				go("/login.jsp", request, response);
			}
		}

	}
	
	private void  updatePass(HttpServletRequest request, HttpServletResponse response){
		dao = new CommDAO();
		String olduserpass = request.getParameter("oldpass");
		String userpass = request.getParameter("upass");
		String copyuserpass = request.getParameter("repass");
		HashMap user = dao.getmap(Info.getUser(request).get("id")
				.toString(), "sysuser");
		if (!(((String) user.get("upass")).equals(olduserpass))) {
			request.setAttribute("error", "");
			go("/admin/uppass.jsp", request, response);
		} else {
			String id = (String) user.get("id");
			String sql = "update sysuser set upass='" + userpass
					+ "' where id=" + id;
			dao.commOper(sql);
			request.setAttribute("suc", "");
			go("/admin/uppass.jsp", request, response);
		}
	}

}

package cn.bukaa.control;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.servlet.ServletRequestContext;

import cn.bukaa.dao.CommDAO;
import cn.bukaa.util.Info;

public class MainCtrl extends HttpServlet {

	public MainCtrl() {
		super();
	}

	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void go(String url, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			request.getRequestDispatcher(url).forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void gor(String url, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			response.sendRedirect(url);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		String ac = request.getParameter("ac");
		if (ac == null)
			ac = "";
		CommDAO dao = new CommDAO();
		String date = Info.getDateStr();
		String today = date.substring(0, 10);
		String tomonth = date.substring(0, 7);

		if (ac.equals("uploaddoc")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploaddoc.jsp?docname=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploaddoc2")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploaddoc2.jsp?docname=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploaddoc3")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploaddoc3.jsp?docname=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		// 导excel
		if (ac.equals("importexcel")) {
			String page = request.getParameter("page");
			String whzdstr = request.getParameter("whzdstr");
			String tablename = request.getParameter("tablename");
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}

					if (filename.indexOf(".xls") > -1) {
						Workbook workbook;
						try {
							workbook = Workbook.getWorkbook(new File(request
									.getRealPath("/upfile/") + "/" + filename));
							// 通过Workbook的getSheet方法选择第一个工作簿(从0开始)
							Sheet sheet = workbook.getSheet(0);
							// 通过Sheet方法的getCell方法选择位置为C2的单元格(两个参数都从0开始)
							for (int i = 1; i < 1000; i++) {
								Cell cell = null;
								try {
									String isql = "insert into " + tablename
											+ "(";

									for (String str : whzdstr.split("-")) {
										isql += str + ",";
									}
									isql = isql.substring(0, isql.length() - 1);
									isql += ")values(";

									int j = 0;
									int empty = 1;
									for (String str : whzdstr.split("-")) {
										cell = sheet.getCell(j, i);
										isql += "'" + cell.getContents() + "',";
										String content = cell.getContents() == null ? ""
												: cell.getContents();
										if (!"".equals(content.trim())) {
											empty = 0;
										}
										j++;
									}
									if (empty == 1)
										continue;
									isql = isql.substring(0, isql.length() - 1);
									isql += ")";
									dao.commOper(isql);
								} catch (Exception e) {
									continue;
								}

							}
							workbook.close();
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				}
				go("/admin/" + page + "?docname=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploadimg")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploadimg.jsp?filename=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploadimg2")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploadimg2.jsp?filename=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploadimg3")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploadimg3.jsp?filename=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploadimg4")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploadimg4.jsp?filename=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		if (ac.equals("uploadimg5")) {
			try {
				String filename = "";
				request.setCharacterEncoding("utf-8");
				RequestContext requestContext = new ServletRequestContext(
						request);
				if (FileUpload.isMultipartContent(requestContext)) {

					DiskFileItemFactory factory = new DiskFileItemFactory();
					factory.setRepository(new File(request
							.getRealPath("/upfile/") + "/"));
					ServletFileUpload upload = new ServletFileUpload(factory);
					upload.setSizeMax(100 * 1024 * 1024);
					List items = new ArrayList();

					items = upload.parseRequest(request);

					FileItem fileItem = (FileItem) items.get(0);
					if (fileItem.getName() != null && fileItem.getSize() != 0) {
						if (fileItem.getName() != null
								&& fileItem.getSize() != 0) {
							File fullFile = new File(fileItem.getName());
							filename = Info.generalFileName(fullFile.getName());
							File newFile = new File(
									request.getRealPath("/upfile/") + "/"
											+ filename);
							try {
								fileItem.write(newFile);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
						}
					}
				}

				go("/js/uploadimg5.jsp?filename=" + filename, request, response);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}

		dao.close();
		out.flush();
		out.close();
	}

	public void init() throws ServletException {
	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程千纸鹤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值