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
689c9fee
Commit
689c9fee
authored
4 years ago
by
adityab3
Browse files
Options
Downloads
Patches
Plain Diff
[backend] added health info logic to preregister action
parent
eb974966
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Uc91v2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
+35
-9
35 additions, 9 deletions
...ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
with
35 additions
and
9 deletions
iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
+
35
−
9
View file @
689c9fee
package
edu.ncsu.csc.itrust.action
;
import
edu.ncsu.csc.itrust.RandomPassword
;
import
edu.ncsu.csc.itrust.beans.PatientBean
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
edu.ncsu.csc.itrust.beans.HealthRecord
;
import
edu.ncsu.csc.itrust.beans.forms.HealthRecordForm
;
import
edu.ncsu.csc.itrust.dao.DAOFactory
;
import
edu.ncsu.csc.itrust.dao.mysql.PatientDAO
;
import
edu.ncsu.csc.itrust.dao.mysql.AuthDAO
;
import
edu.ncsu.csc.itrust.dao.mysql.HealthRecordsDAO
;
import
edu.ncsu.csc.itrust.enums.Role
;
import
edu.ncsu.csc.itrust.exception.DBException
;
import
edu.ncsu.csc.itrust.exception.FormValidationException
;
import
edu.ncsu.csc.itrust.exception.ITrustException
;
import
edu.ncsu.csc.itrust.validate.AddPatientValidator
;
import
edu.ncsu.csc.itrust.validate.HealthRecordFormValidator
;
/**
* Used for Add Pre-registered Patient page (PreRegisterPatient.jsp). This just adds an empty patient, creates an entered password for
...
...
@@ -22,7 +29,8 @@ import edu.ncsu.csc.itrust.validate.AddPatientValidator;
public
class
AddPreRegisteredPatientAction
{
private
PatientDAO
patientDAO
;
private
AuthDAO
authDAO
;
private
long
loggedInMID
;
private
long
loggedInMID
;
private
HealthRecordsDAO
healthDAO
;
/**
* Just the factory and logged in MID
...
...
@@ -33,7 +41,8 @@ public class AddPreRegisteredPatientAction {
public
AddPreRegisteredPatientAction
(
DAOFactory
factory
,
long
loggedInMID
)
{
this
.
patientDAO
=
factory
.
getPatientDAO
();
this
.
loggedInMID
=
loggedInMID
;
this
.
authDAO
=
factory
.
getAuthDAO
();
this
.
authDAO
=
factory
.
getAuthDAO
();
this
.
healthDAO
=
factory
.
getHealthRecordsDAO
();
}
/**
...
...
@@ -47,9 +56,9 @@ public class AddPreRegisteredPatientAction {
*/
public
long
addPatient
(
PatientBean
p
)
throws
FormValidationException
,
ITrustException
{
public
long
addPatient
(
PatientBean
p
,
HealthRecordForm
h
)
throws
FormValidationException
,
ITrustException
{
new
AddPatientValidator
().
validate
(
p
);
new
HealthRecordFormValidator
().
validatePreregistration
(
h
);
// Make sure the email is unique
if
(
patientDAO
.
isEmailInUse
(
p
.
getEmail
()))
{
...
...
@@ -62,7 +71,24 @@ public class AddPreRegisteredPatientAction {
String
pwd
=
authDAO
.
addUser
(
newMID
,
Role
.
PREREGISTEREDPATIENT
,
p
.
getPassword
());
p
.
setPassword
(
pwd
);
patientDAO
.
editPatient
(
p
,
loggedInMID
);
return
newMID
;
}
patientDAO
.
editPatient
(
p
,
loggedInMID
);
// Convert the HealthRecordForm into a HeathRecord
HealthRecord
r
=
formToRecord
(
h
,
newMID
);
healthDAO
.
add
(
r
);
return
newMID
;
}
// TODO: this is taken directly from EditHealthAction.java (DRY)
private
HealthRecord
formToRecord
(
HealthRecordForm
form
,
long
pid
)
{
HealthRecord
record
=
new
HealthRecord
();
record
.
setPatientID
(
pid
);
if
(!
""
.
equals
(
form
.
getHeight
()))
record
.
setHeight
(
Double
.
parseDouble
(
form
.
getHeight
()));
if
(!
""
.
equals
(
form
.
getWeight
()))
record
.
setWeight
(
Double
.
parseDouble
(
form
.
getWeight
()));
record
.
setSmoker
(
Integer
.
parseInt
(
form
.
getIsSmoker
()));
return
record
;
}
}
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