/** * Updates a lab procedure * * @param b the procedure to update * @throws DBException * @throws FormValidationException */ public void updateProcedure(LabProcedureBean b) throws DBException, FormValidationException { validator.validate(b); // need to check if status is what's being changed - if new status!=old status send email if (!b.getStatus().equals(lpDAO.getLabProcedure(b.getProcedureID()).getStatus())) { new EmailUtil(factory).sendEmail(makeEmail(b)); } lpDAO.updateLabProcedure(b); transDAO.logTransaction( TransactionType.ENTER_EDIT_LAB_PROCEDURE, loggedInMID, b.getPid(), "UAP updated procedure id: " + b.getProcedureID()); }
/** * Sends an e-mail informing the patient that their procedure has been updated * * @param b the procedure that was updated * @return an e-mail to the patient with the notice * @throws DBException */ private Email makeEmail(LabProcedureBean b) throws DBException { PatientBean p = new PatientDAO(factory).getPatient(b.getPid()); Email email = new Email(); email.setFrom("*****@*****.**"); email.setToList(Arrays.asList(p.getEmail())); email.setSubject("A Lab Procedure Was Updated"); email.setBody( String.format( "Dear %s, \n Your Lab Procedure (%s) has a new updated status of %s. Log on to iTrust to view.", p.getFullName(), b.getLoinc(), b.getStatus())); return email; }
/** * Inserts a lab procedure into the database. * * @param b The LabProcedureBean to be inserted. * @return A long containing the ID of the newly inserted lab procedure bean. * @throws DBException */ public long addLabProcedure(LabProcedureBean b) throws DBException { Connection conn = null; PreparedStatement ps = null; try { if (b.getPid() == 0L) throw new SQLException("PatientMID cannot be null"); conn = factory.getConnection(); ps = conn.prepareStatement( "INSERT INTO LabProcedure (PatientMID, LaboratoryProcedureCode, Status, Commentary, Results, OfficeVisitID, Rights) VALUES (?,?,?,?,?,?,?)"); ps.setLong(1, b.getPid()); ps.setString(2, b.getLoinc()); ps.setString(3, b.getStatus()); ps.setString(4, b.getCommentary()); ps.setString(5, b.getResults()); ps.setLong(6, b.getOvID()); ps.setString(7, b.getRights()); ps.executeUpdate(); return DBUtil.getLastInsert(conn); } catch (SQLException e) { e.printStackTrace(); throw new DBException(e); } finally { DBUtil.closeConnection(conn, ps); } }
/** * testSubmitResultsEvilFactory * * @throws Exception */ public void testSubmitResultsEvilFactory() throws Exception { action = new LabProcLTAction(new EvilDAOFactory()); LabProcedureBean lp = new LabProcedureBean(); lp.setLoinc("10763-1"); lp.setCommentary(""); lp.setOvID(902L); lp.setPid(2L); lp.setResults(""); lp.allow(); lp.statusReceived(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); assertFalse(action.submitResults("" + id, "12", "grams", "13", "14")); }
public void testGetHCPName() throws Exception { LabProcedureBean lp = new LabProcedureBean(); lp.setLoinc("10763-1"); lp.setCommentary(""); lp.setOvID(902L); lp.setPid(2L); lp.setResults(""); lp.allow(); lp.statusTesting(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); lpDAO.getLabProcedure(id); assertEquals("Kelly Doctor", action.getHCPName(902L)); }
/** * Updates the rights of a user on a given lab procedure. * * @param b The LabProcedureBean in question. * @throws DBException */ public void updateRights(LabProcedureBean b) throws DBException { Connection conn = null; PreparedStatement ps = null; try { if (b.getPid() == 0L) throw new SQLException("PatientMID cannot be null"); conn = factory.getConnection(); ps = conn.prepareStatement( "UPDATE LabProcedure SET Rights = ?, UpdatedDate = ? WHERE LaboratoryProcedureID=?"); ps.setString(1, b.getRights()); ps.setTimestamp(2, new java.sql.Timestamp(System.currentTimeMillis())); ps.setLong(3, b.getProcedureID()); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); throw new DBException(e); } finally { DBUtil.closeConnection(conn, ps); } }
@Override protected void setUp() throws Exception { gen = new TestDataGenerator(); gen.labProcedures(); l = new LabProcedureBean(); l.setPid(1L); l.setOvID(905L); l.setLoinc("10763-8"); l.statusPending(); l.setCommentary("Awaiting results"); l.setResults(""); l.restrict(); }
public void testUpdateRights() throws Exception { long id = lpDAO.addLabProcedure(l); LabProcedureBean procedures = lpDAO.getLabProcedure(id); assertEquals(1L, procedures.getPid()); l.allow(); l.setProcedureID(id); lpDAO.updateRights(l); LabProcedureBean updprocedures = lpDAO.getLabProcedure(id); assertEquals(LabProcedureBean.Allow, updprocedures.getRights()); }
public void testViewTestingProcedures() throws Exception { LabProcedureBean lp = new LabProcedureBean(); lp.setLoinc("10763-1"); lp.setCommentary(""); lp.setOvID(902L); lp.setPid(2L); lp.setResults(""); lp.allow(); lp.statusTesting(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); LabProcedureBean procedures = lpDAO.getLabProcedure(id); List<LabProcedureBean> beans = action.viewTestingProcedures(5000000005L); assertEquals(1, beans.size()); LabProcedureBean lpBean = beans.get(0); assertEquals(procedures.getLoinc(), lpBean.getLoinc()); assertEquals(procedures.getOvID(), lpBean.getOvID()); assertEquals(procedures.getLoinc(), lpBean.getLoinc()); assertEquals("Testing", lpBean.getStatus()); assertEquals(procedures.getProcedureID(), lpBean.getProcedureID()); }
/** * testGetLabProc * * @throws Exception */ public void testGetLabProc() throws Exception { LabProcedureBean lp = new LabProcedureBean(); lp.setPid(2L); lp.setLoinc("10763-1"); lp.setCommentary("This is a test"); lp.setOvID(902L); lp.setResults("Test Result"); lp.allow(); lp.statusReceived(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); assertEquals(lp.getCommentary(), action.getLabProcedure(id).getCommentary()); assertEquals(lp.getPid(), action.getLabProcedure(id).getPid()); assertEquals(lp.getLoinc(), action.getLabProcedure(id).getLoinc()); assertEquals(lp.getOvID(), action.getLabProcedure(id).getOvID()); assertEquals(lp.getResults(), action.getLabProcedure(id).getResults()); assertEquals(lp.getLTID(), action.getLabProcedure(id).getLTID()); assertEquals(lp.getStatus(), action.getLabProcedure(id).getStatus()); assertEquals(lp.getRights(), action.getLabProcedure(id).getRights()); }
/** * testSetToTesting * * @throws Exception */ public void testSetToTesting() throws Exception { LabProcedureBean lp = new LabProcedureBean(); lp.setLoinc("10763-1"); lp.setCommentary(""); lp.setOvID(902L); lp.setPid(2L); lp.setResults(""); lp.allow(); lp.statusReceived(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); assertTrue(action.setToTesting(id)); LabProcedureBean procedures = lpDAO.getLabProcedure(id); assertEquals("Testing", procedures.getStatus()); }
/** * testSubmiteResults * * @throws Exception */ public void testSubmitResults() throws Exception { LabProcedureBean lp = new LabProcedureBean(); lp.setLoinc("10763-1"); lp.setCommentary(""); lp.setOvID(902L); lp.setPid(2L); lp.setResults(""); lp.allow(); lp.statusReceived(); lp.setLTID(5000000005L); long id = lpDAO.addLabProcedure(lp); lp.setProcedureID(id); assertTrue(action.submitResults("" + id, "12", "grams", "13", "14")); LabProcedureBean procedures = lpDAO.getLabProcedure(id); assertEquals("Pending", procedures.getStatus()); assertEquals("12", procedures.getNumericalResult()); assertEquals("grams", procedures.getNumericalResultUnit()); assertEquals("13", procedures.getUpperBound()); assertEquals("14", procedures.getLowerBound()); }