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

Add getter for if a patient is registered

parent e9e3b17f
No related branches found
No related tags found
1 merge request!22Merge UC92 into Master
......@@ -60,6 +60,44 @@ public class PatientDAO {
this.procedureLoader = new ProcedureBeanLoader(true);
}
/**
* Returns if the patient is registered
*
* @param mid The MID of the patient in question.
* @return A boolean representing if the patient is registered
* @throws ITrustException
* @throws DBException
*/
public boolean getRegistered(long mid) throws ITrustException, DBException {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = factory.getConnection();
ps = conn.prepareStatement("SELECT registered FROM patients WHERE MID=?");
ps.setLong(1, mid);
ResultSet rs;
rs = ps.executeQuery();
if (rs.next()) {
Integer b = rs.getObject("registered") != null ? rs.getInt("registered") : null;
if (b == 1) {
return true;
} else if (b == 0) {
return false;
} else {
throw new ITrustException("Number is not a boolean");
}
} else {
rs.close();
ps.close();
throw new ITrustException("User does not exist");
}
} 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