Ejemplo n.º 1
0
 /**
  * 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);
   }
 }
Ejemplo n.º 2
0
 /**
  * Updates an existing lab procedure.
  *
  * @param b The LabProcedureBean representing the procedure to be updated.
  * @throws DBException
  */
 public void updateLabProcedure(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 Status = ?, Commentary = ?, Results = ?, UpdatedDate = ? WHERE LaboratoryProcedureID=?");
     ps.setString(1, b.getStatus());
     ps.setString(2, b.getCommentary());
     ps.setString(3, b.getResults());
     ps.setTimestamp(4, new java.sql.Timestamp(System.currentTimeMillis()));
     ps.setLong(5, b.getProcedureID());
     ps.executeUpdate();
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DBException(e);
   } finally {
     DBUtil.closeConnection(conn, ps);
   }
 }
Ejemplo n.º 3
0
  /**
   * 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());
  }