Example #1
0
 /**
  * Adds a prescription bean to the database.
  *
  * @param pres The prescription bean to be added.
  * @return The unique ID of the newly added bean.
  * @throws DBException
  */
 public long addPrescription(PrescriptionBean pres) throws DBException {
   Connection conn = null;
   PreparedStatement ps = null;
   try {
     conn = factory.getConnection();
     ps =
         conn.prepareStatement(
             "INSERT INTO OVMedication (VisitID,NDCode,StartDate,EndDate,Dosage,Instructions) VALUES (?,?,?,?,?,?)");
     prescriptionLoader.loadParameters(ps, pres);
     ps.executeUpdate();
     return DBUtil.getLastInsert(conn);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DBException(e);
   } finally {
     DBUtil.closeConnection(conn, ps);
   }
 }
Example #2
0
 /**
  * Returns all of the prescriptions associated with the given office visit
  *
  * @param visitID The ID of the office visit.
  * @return A java.util.List of prescriptions.
  * @throws DBException
  */
 public List<PrescriptionBean> getPrescriptions(long visitID) throws DBException {
   Connection conn = null;
   PreparedStatement ps = null;
   try {
     conn = factory.getConnection();
     ps =
         conn.prepareStatement(
             "Select * From OVMedication,NDCodes Where OVMedication.VisitID = ? "
                 + "AND NDCodes.Code=OVMedication.NDCode");
     ps.setLong(1, visitID);
     ResultSet rs = ps.executeQuery();
     return prescriptionLoader.loadList(rs);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DBException(e);
   } finally {
     DBUtil.closeConnection(conn, ps);
   }
 }
Example #3
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);
   }
 }