diff --git a/iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java b/iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java index 597a64dcbe2b2e856551705c083a34510d2b6546..569f823542961fbe82459366f3d4faca2cb0e3f5 100644 --- a/iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java +++ b/iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java @@ -98,6 +98,64 @@ public class PatientDAO { } } + /** + * Sets that a patient is registered + * + * @param mid The MID of the patient in question. + * @return A boolean representing if the transaction completed successfully + * @throws ITrustException + * @throws DBException + */ + public boolean activatePreregisteredPatient(long mid) { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = factory.getConnection(); + ps = conn.prepareStatement("UPDATE PATIENTS SET registered = ? WHERE mid = ?"); + ps.setByte(1, 1); + ps.setLong(2, mid); + ps.executeUpdate(); + ps.close(); + return true; + + } catch (SQLException e) { + + throw new DBException(e); + } finally { + DBUtil.closeConnection(conn, ps); + } + } + + /** + * Sets that a patient is not registered + * + * @param mid The MID of the patient in question. + * @return A boolean representing if the transaction completed successfully + * @throws ITrustException + * @throws DBException + */ + public boolean deactivatePreregisteredPatient(long mid) { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = factory.getConnection(); + ps = conn.prepareStatement("UPDATE PATIENTS SET DateofDeactivation = ?, registered = ? WHERE mid = ?"); + Date date = new Date(Calendar.getInstance().getTime().getTime()); + ps.setDate(1, date); + ps.setByte(2, 0); + ps.setLong(3, mid); + ps.executeUpdate(); + ps.close(); + return true; + + } catch (SQLException e) { + + throw new DBException(e); + } finally { + DBUtil.closeConnection(conn, ps); + } + } + /** * Returns the name for the given MID *