Skip to content
Snippets Groups Projects
Commit 9475e137 authored by ahmadaldhalaan's avatar ahmadaldhalaan
Browse files

returning PatientBean.java to original form with no code smells and pushing...

returning PatientBean.java to original form with no code smells and pushing code refactoring to a seperate branch
parent 0aa9ed68
No related branches found
No related tags found
2 merge requests!7Uc20,!2UC20 Data Access Object Completed
...@@ -46,8 +46,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -46,8 +46,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
private String creditCardType = ""; private String creditCardType = "";
private String creditCardNumber = ""; private String creditCardNumber = "";
// Topical Health Information // Topical Health Information
private String dateFormat = "MM/dd/yyyy"; private String dateOfBirthStr = new SimpleDateFormat("MM/dd/yyyy").format(new Date());
private String dateOfBirthStr = new SimpleDateFormat(dateFormat).format(new Date());
private String dateOfDeathStr = ""; private String dateOfDeathStr = "";
private String causeOfDeath = ""; private String causeOfDeath = "";
private String motherMID = "0"; private String motherMID = "0";
...@@ -62,12 +61,6 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -62,12 +61,6 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
private String spiritualPractices = ""; private String spiritualPractices = "";
private String alternateName = ""; private String alternateName = "";
private String dateOfDeactivationStr = ""; private String dateOfDeactivationStr = "";
// Age calculations
private long milliseconds = 1000;
private long seconds = 60;
private long minutes = 60;
private long hours = 24;
private long days = 365;
public BloodType getBloodType() { public BloodType getBloodType() {
...@@ -104,7 +97,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -104,7 +97,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
public Date getDateOfBirth() { public Date getDateOfBirth() {
try { try {
return new SimpleDateFormat(dateFormat).parse(dateOfBirthStr); return new SimpleDateFormat("MM/dd/yyyy").parse(dateOfBirthStr);
} catch (ParseException e) { } catch (ParseException e) {
return null; return null;
...@@ -113,7 +106,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -113,7 +106,7 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
public Date getDateOfDeath() { public Date getDateOfDeath() {
try { try {
return new SimpleDateFormat(dateFormat).parse(dateOfDeathStr); return new SimpleDateFormat("MM/dd/yyyy").parse(dateOfDeathStr);
} catch (ParseException e) { } catch (ParseException e) {
return null; return null;
...@@ -126,10 +119,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -126,10 +119,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
public int getAge() { public int getAge() {
try { try {
long currentTime = System.currentTimeMillis(); long ageInMs = System.currentTimeMillis()
long birthTime = new SimpleDateFormat(dateFormat).parse(dateOfBirthStr).getTime(); - new SimpleDateFormat("MM/dd/yyyy").parse(dateOfBirthStr).getTime();
long ageInMs = currentTime - birthTime; long age = ageInMs / (1000L * 60L * 60L * 24L * 365L);
long age = ageInMs / (milliseconds * seconds * minutes * hours * days);
return (int) age; return (int) age;
} catch (ParseException e) { } catch (ParseException e) {
...@@ -143,10 +135,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -143,10 +135,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
long ageInMs; long ageInMs;
try { try {
long currentTime = System.currentTimeMillis(); ageInMs = System.currentTimeMillis()
long birthTime = new SimpleDateFormat(dateFormat).parse(dateOfBirthStr).getTime(); - new SimpleDateFormat("MM/dd/yyyy").parse(dateOfBirthStr).getTime();
ageInMs = currentTime - birthTime; age = ageInMs / (1000L * 60L * 60L * 24L);
age = ageInMs / (milliseconds * seconds * minutes * hours * days);
} }
catch (ParseException e) { catch (ParseException e) {
...@@ -163,10 +154,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -163,10 +154,9 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
long ageInMs; long ageInMs;
try { try {
long currentTime = System.currentTimeMillis(); ageInMs = System.currentTimeMillis()
long birthTime = new SimpleDateFormat(dateFormat).parse(dateOfBirthStr).getTime(); - new SimpleDateFormat("MM/dd/yyyy").parse(dateOfBirthStr).getTime();
ageInMs = currentTime - birthTime; age = ageInMs / (1000L * 60L * 60L * 24L * 7L);
age = ageInMs / (milliseconds * seconds * minutes * hours * days);
} }
catch (ParseException e) { catch (ParseException e) {
...@@ -509,4 +499,4 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -509,4 +499,4 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
return 42; // any arbitrary constant will do return 42; // any arbitrary constant will do
} }
} }
\ No newline at end of file
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