Skip to content
Snippets Groups Projects
Commit ae0270e2 authored by mjw11's avatar mjw11
Browse files

Add activate and deactivate patient functions

parent 734f5abb
No related branches found
No related tags found
1 merge request!22Merge UC92 into Master
......@@ -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
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment