/** * 取得指定住院号的记录 * * @param admissionNum 住院号 * @return 住院记录 */ public record GetRecord(String admissionNum) { try { MongoDAO dao = MongoDAO.GetInstance(); BasicDBObject cond = new BasicDBObject(); cond.append("admission_number", new BasicDBObject("$eq", admissionNum)); FindIterable<Document> result = dao.GetCollection("records").find(cond); MongoCursor<Document> it = result.iterator(); if (it.hasNext()) { Document doc = it.next(); record fol = new record(); fol.setAdmission_number(doc.getString("admission_number")); fol.setName(doc.getString("name")); fol.setWeixin_openid(doc.getString("weixin_openid")); fol.setLeaveTime(doc.getDate("leaveTime")); fol.setInTime(doc.getDate("inTime")); fol.setDisease(doc.getString("disease")); return fol; } return null; } catch (Exception e) { e.printStackTrace(); logger.error(e.toString()); return null; } }
/** * 取得正在住院的用户 * * @return */ public List<record> GetInhospitalRecords() { try { List<record> list = new ArrayList<record>(); MongoDAO dao = MongoDAO.GetInstance(); BasicDBObject cond = new BasicDBObject(); cond.append("inHospital", new BasicDBObject("$eq", true)); cond.append("leaveHospital", new BasicDBObject("$eq", false)); FindIterable<Document> result = dao.GetCollection("records").find(cond); MongoCursor<Document> it = result.iterator(); while (it.hasNext()) { Document doc = it.next(); record fol = new record(); fol.setAdmission_number(doc.getString("admission_number")); fol.setName(doc.getString("name")); fol.setWeixin_openid(doc.getString("weixin_openid")); fol.setInTime(doc.getDate("inTime")); System.out.print("\nname = " + fol.getName()); System.out.print("\nadmission_number = " + fol.getAdmission_number()); System.out.print("\nweixin_openid = " + fol.getWeixin_openid()); System.out.print("\nintime = " + fol.getInTime()); list.add(fol); System.out.print("add to list finished"); } System.out.print("list ready"); return list; } catch (Exception e) { e.printStackTrace(); logger.error(e.toString()); return null; } }