Skip to content
Snippets Groups Projects
Commit 39a5b82d authored by xuechen5's avatar xuechen5
Browse files

SQL: Added Function for Convert Pre-Registered Patient to Patient

parent 038e14cc
No related branches found
No related tags found
2 merge requests!22Merge UC92 into Master,!15Merge 5-uc-92-activate-pre-registered-patient-2 into UC92v2
......@@ -99,17 +99,19 @@ public class PatientDAO {
* Returns the role of a particular patient - why is this in PatientDAO? It should be in AuthDAO
*
* @param mid The MID of the patient in question.
* @param role A String representing the role of the patient.
* @return A String representing the patient's role.
* @throws ITrustException
* @throws DBException
*/
public String getRole(long mid) throws ITrustException, DBException {
public String getRole(long mid, String role) throws ITrustException, DBException {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = factory.getConnection();
ps = conn.prepareStatement("SELECT role FROM users WHERE MID=?");
ps = conn.prepareStatement("SELECT role FROM users WHERE MID=? AND Role=?");
ps.setLong(1, mid);
ps.setString(2, role);
ResultSet rs;
rs = ps.executeQuery();
if (rs.next()) {
......@@ -190,22 +192,6 @@ public class PatientDAO {
}
}
public void activatePatient(long mid) throws DBException {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = factory.getConnection();
ps = conn.prepareStatement("UPDATE users SET role=? WHERE MID=?");
ps.setString(1, "patient");
ps.setLong(2, mid);
} catch (SQLException e) {
throw new DBException(e);
} finally {
DBUtil.closeConnection(conn, ps);
}
}
/**
* Updates a patient's information for the given MID
*
......@@ -241,6 +227,7 @@ public class PatientDAO {
}
}
/*added for UC91 */
public boolean isEmailInUse(String email) throws DBException {
Connection conn = null;
PreparedStatement ps = null;
......@@ -938,7 +925,7 @@ public class PatientDAO {
}
/**
* Lists every patient in the database.
* Lists every Approved patient in the database.
*
* @return A java.util.List of PatientBeans representing the patients.
* @throws DBException
......@@ -988,6 +975,31 @@ public class PatientDAO {
}
}
/**
* Convert a Pre-Registered patient to a regular patient upon HCP approval.
* by change "role" column in "users" table.
*
* @return void
* @throws DBException
*/
public void ConvertPreRegisteredPatientsToPatient(long mid) throws DBException {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = factory.getConnection();
ps = conn.prepareStatement("UPDATE users SET role=? WHERE MID=?");
ps.setString(1, "patient");
ps.setLong(2, mid);
ps.executeUpdate();
ps.close();
} catch (SQLException e) {
throw new DBException(e);
} finally {
DBUtil.closeConnection(conn, ps);
}
}
/**
* Return a list of patients with a special-diagnosis-history who
......
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