@Test public void testGetAgeByBirth() throws Exception { }
public int getAgeByBirth(Date birthDay){ int age = 0; Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!"); } int yearNow = cal.get(Calendar.YEAR); int monthNow = cal.get(Calendar.MONTH); int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(birthDay); int yearBirth = cal.get(Calendar.YEAR); int monthBirth = cal.get(Calendar.MONTH); int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { if (dayOfMonthNow < dayOfMonthBirth) age--; } else { age--; } } return age; }
PreliminaryCaseServiceImpl implements PreliminaryCaseService { public int getAgeByBirth(Date birthDay){ int age = 0; Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!"); } int yearNow = cal.get(Calendar.YEAR); int monthNow = cal.get(Calendar.MONTH); int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(birthDay); int yearBirth = cal.get(Calendar.YEAR); int monthBirth = cal.get(Calendar.MONTH); int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { if (dayOfMonthNow < dayOfMonthBirth) age--; } else { age--; } } return age; } }
PreliminaryCaseServiceImpl implements PreliminaryCaseService { public int getAgeByBirth(Date birthDay){ int age = 0; Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!"); } int yearNow = cal.get(Calendar.YEAR); int monthNow = cal.get(Calendar.MONTH); int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(birthDay); int yearBirth = cal.get(Calendar.YEAR); int monthBirth = cal.get(Calendar.MONTH); int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { if (dayOfMonthNow < dayOfMonthBirth) age--; } else { age--; } } return age; }  }
PreliminaryCaseServiceImpl implements PreliminaryCaseService { public int getAgeByBirth(Date birthDay){ int age = 0; Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!"); } int yearNow = cal.get(Calendar.YEAR); int monthNow = cal.get(Calendar.MONTH); int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(birthDay); int yearBirth = cal.get(Calendar.YEAR); int monthBirth = cal.get(Calendar.MONTH); int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { if (dayOfMonthNow < dayOfMonthBirth) age--; } else { age--; } } return age; }  @Override CommonResult listPatients(Integer doctorRoleId); @Override CommonResult getPatientCaseInfo(Integer doctorRoleId, Integer caseId); CommonResult finalDiagnose(PatientCaseParam patientCaseParam); @Override CommonResult savePresentPatientCase(PatientCaseParam patientCaseParam); @Override CommonResult submitPresentPatientCase(PatientCaseParam patientCaseParam); CommonResult savePatientCase(PatientCaseParam patientCaseParam, int status, Boolean isFirstDiagnosed); CommonResult clearPatientCase(Integer caseId); CommonResult listFinalDiagnose(Integer caseId); @Override CommonResult finishDiagnose(Integer caseId); int getAgeByBirth(Date birthDay); }
PreliminaryCaseServiceImpl implements PreliminaryCaseService { public int getAgeByBirth(Date birthDay){ int age = 0; Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!"); } int yearNow = cal.get(Calendar.YEAR); int monthNow = cal.get(Calendar.MONTH); int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(birthDay); int yearBirth = cal.get(Calendar.YEAR); int monthBirth = cal.get(Calendar.MONTH); int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { if (dayOfMonthNow < dayOfMonthBirth) age--; } else { age--; } } return age; }  @Override CommonResult listPatients(Integer doctorRoleId); @Override CommonResult getPatientCaseInfo(Integer doctorRoleId, Integer caseId); CommonResult finalDiagnose(PatientCaseParam patientCaseParam); @Override CommonResult savePresentPatientCase(PatientCaseParam patientCaseParam); @Override CommonResult submitPresentPatientCase(PatientCaseParam patientCaseParam); CommonResult savePatientCase(PatientCaseParam patientCaseParam, int status, Boolean isFirstDiagnosed); CommonResult clearPatientCase(Integer caseId); CommonResult listFinalDiagnose(Integer caseId); @Override CommonResult finishDiagnose(Integer caseId); int getAgeByBirth(Date birthDay);  }