Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs427fa20team22
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
htmoss2
cs427fa20team22
Commits
4dfe33ac
Commit
4dfe33ac
authored
4 years ago
by
xuechen5
Browse files
Options
Downloads
Patches
Plain Diff
Add function .getAllPreRegisteredPatients() and Modify .getAllPatients()
parent
49e49739
No related branches found
Branches containing commit
No related tags found
1 merge request
!22
Merge UC92 into Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java
+19
-108
19 additions, 108 deletions
iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java
with
19 additions
and
108 deletions
iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java
+
19
−
108
View file @
4dfe33ac
...
...
@@ -60,97 +60,6 @@ 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 DateOfDeactivation FROM patients WHERE MID=?"
);
ps
.
setLong
(
1
,
mid
);
ResultSet
rs
;
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
{
if
(
rs
.
getDate
(
"DateOfDeactivation"
)
==
null
)
{
return
true
;
}
else
{
return
false
;
}
}
else
{
rs
.
close
();
ps
.
close
();
throw
new
ITrustException
(
"User does not exist"
);
}
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
);
}
finally
{
DBUtil
.
closeConnection
(
conn
,
ps
);
}
}
/**
* 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 DateOfDeactivation = NULL WHERE mid = ?"
);
ps
.
setLong
(
1
,
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 = ? WHERE mid = ?"
);
Date
date
=
new
Date
(
Calendar
.
getInstance
().
getTime
().
getTime
());
ps
.
setDate
(
1
,
date
);
ps
.
setLong
(
2
,
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
*
...
...
@@ -202,7 +111,7 @@ public class PatientDAO {
conn
=
factory
.
getConnection
();
ps
=
conn
.
prepareStatement
(
"SELECT role FROM users WHERE MID=? AND Role=?"
);
ps
.
setLong
(
1
,
mid
);
ps
.
setString
(
2
,
role
);
ps
.
setString
(
2
,
"patient"
);
// role); ///////////////////////// ??????????????
ResultSet
rs
;
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
{
...
...
@@ -234,13 +143,14 @@ public class PatientDAO {
PreparedStatement
ps
=
null
;
try
{
conn
=
factory
.
getConnection
();
ps
=
conn
.
prepareStatement
(
"INSERT INTO patients(DateOfDeactivation) VALUES(?)"
);
Date
date
=
new
Date
(
Calendar
.
getInstance
().
getTime
().
getTime
());
ps
.
setDate
(
1
,
date
);
ps
=
conn
.
prepareStatement
(
"INSERT INTO patients(MID) VALUES(NULL)"
);
ps
.
executeUpdate
();
long
a
=
DBUtil
.
getLastInsert
(
conn
);
ps
.
close
();
return
a
;
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
);
...
...
@@ -315,8 +225,9 @@ public class PatientDAO {
}
finally
{
DBUtil
.
closeConnection
(
conn
,
ps
);
}
}
}
/*added for UC91 */
public
boolean
isEmailInUse
(
String
email
)
throws
DBException
{
Connection
conn
=
null
;
PreparedStatement
ps
=
null
;
...
...
@@ -1012,19 +923,19 @@ public class PatientDAO {
DBUtil
.
closeConnection
(
conn
,
ps
);
}
}
/**
* Lists every
preregistered
patient in the database.
* Lists every patient in the database.
*
* @return A java.util.List of PatientBeans representing the
preregistered
patients.
* @return A java.util.List of PatientBeans representing the patients.
* @throws DBException
*/
public
List
<
PatientBean
>
getAllP
reregisteredP
atients
()
throws
DBException
{
public
List
<
PatientBean
>
getAllPatients
()
throws
DBException
{
Connection
conn
=
null
;
PreparedStatement
ps
=
null
;
try
{
conn
=
factory
.
getConnection
();
ps
=
conn
.
prepareStatement
(
"SELECT * FROM patients
WHERE DateOfDeactivation IS NOT NULL
"
);
ps
=
conn
.
prepareStatement
(
"SELECT * FROM patients
, users where patients.MID = users.MID and users.Role='patient'
"
);
ResultSet
rs
=
ps
.
executeQuery
();
List
<
PatientBean
>
loadlist
=
patientLoader
.
loadList
(
rs
);
rs
.
close
();
...
...
@@ -1038,18 +949,19 @@ public class PatientDAO {
}
}
/**
* Lists every patient in the database.
* Lists every
Pre-Registered
patient in the database.
*
* @return A java.util.List of PatientBeans representing the patients.
* @return A java.util.List of PatientBeans representing the
Pre-Registered
patients.
* @throws DBException
*/
public
List
<
PatientBean
>
getAllPatients
()
throws
DBException
{
public
List
<
PatientBean
>
getAllP
reRegisteredP
atients
()
throws
DBException
{
Connection
conn
=
null
;
PreparedStatement
ps
=
null
;
try
{
conn
=
factory
.
getConnection
();
ps
=
conn
.
prepareStatement
(
"SELECT * FROM patients "
);
ps
=
conn
.
prepareStatement
(
"SELECT * FROM patients
, users where patients.MID = users.MID and users.Role='PreRegisteredPatient'
"
);
ResultSet
rs
=
ps
.
executeQuery
();
List
<
PatientBean
>
loadlist
=
patientLoader
.
loadList
(
rs
);
rs
.
close
();
...
...
@@ -1063,6 +975,7 @@ public class PatientDAO {
}
}
/**
* Return a list of patients with a special-diagnosis-history who
* have the logged in HCP as a DHCP and whose medications are going to
...
...
@@ -1342,6 +1255,4 @@ public class PatientDAO {
DBUtil
.
closeConnection
(
conn
,
ps
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment