@Override
 protected void setUp() throws Exception {
   pres = new PrescriptionBean();
   pres.setDosage(50);
   pres.setStartDateStr("2007/05/19");
   pres.setEndDateStr("2010/05/19");
   pres.setVisitID(1L);
 }
示例#2
0
 /**
  * Edits an existing prescription bean.
  *
  * @param pres The newly updated prescription bean.
  * @return A long indicating the ID of the newly updated prescription bean.
  * @throws DBException
  */
 public long editPrescription(PrescriptionBean pres) throws DBException {
   Connection conn = null;
   PreparedStatement ps = null;
   try {
     conn = factory.getConnection();
     // ps = conn.prepareStatement("UPDATE OVMedication
     // (VisitID,NDCode,StartDate,EndDate,Dosage,Instructions) VALUES (?,?,?,?,?,?)");
     String statement =
         "UPDATE OVMedication "
             + "SET VisitID=?, NDCode=?, StartDate=?, EndDate=?, Dosage=?, Instructions=? "
             + "WHERE ID=?";
     ps = conn.prepareStatement(statement);
     prescriptionLoader.loadParameters(ps, pres);
     ps.setLong(7, pres.getId());
     ps.executeUpdate();
     return DBUtil.getLastInsert(conn);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DBException(e);
   } finally {
     DBUtil.closeConnection(conn, ps);
   }
 }
 public void testPrescriptionEquals() throws Exception {
   pres.setId(5);
   PrescriptionBean pres2 = new PrescriptionBean();
   pres2.setId(5);
   pres2.setDosage(50);
   pres2.setStartDateStr("2007/05/19");
   pres2.setEndDateStr("2010/05/19");
   pres2.setVisitID(1L);
   pres2.setOverrideReasonOther("Reasoning...");
   OverrideReasonBean override = new OverrideReasonBean();
   override.setORCode("1234");
   List<OverrideReasonBean> reasons = new ArrayList<OverrideReasonBean>();
   reasons.add(override);
   pres2.setReasons(reasons);
   assertEquals(pres2, pres);
   assertEquals("2010/05/19", pres2.getEndDateStr());
   assertEquals("1234", pres2.getReasons().get(0).getORCode());
   assertEquals("Reasoning...", pres2.getOverrideReasonOther());
 }