Screenshots
Download Installer
User Manual
Support
Bug Tracking
Mailing List
Add-Ons
Address Update
FAQ
/** * Converts the measuring date of the second column into the Age * of the patient at the measuring day, using the birthday calculated * in the function setBirthday. * * NEEDED FUNCTIONS: * - getBirthdayOfCurrentPatient() * - calculateAge() * * @param datatable: * The table, that shall be manipulated * * @param columnToConvert: * the index of the column, that shall be converted * from a date to the age at that date (index 0 = first column) */ function convertColumnDateToAge (datatable, columnToConvert) { /* ======================================== */ // IMPORTS importPackage(java.util); importPackage(java.lang); importPackage(java.text); var tableModel = datatable.getModel(); // get the patients birthday var calendar_birthday = getBirthdayOfCurrentPatient(); var calendar_creationDate = new GregorianCalendar(); /* a date formater to format a date into a String * and parse a formated String into a date */ var formater = DateFormat.getDateInstance( DateFormat.SHORT); // replace the creation date with the patient's age in every row for (var int_row = 0; int_row < tableModel.getRowCount(); int_row++) { /* ---------------------------------------- */ try { // make a Date resp. Calendar out of the formated String calendar_creationDate.setTime( formater.parse(tableModel.getValueAt(int_row, columnToConvert))); } catch (err) { // the String couldn't be parsed // println("manipulateTable(): " + err); continue; } // calculate the patient's age out of the creation date and birthdate var int_age = new Integer(calculateAge(calendar_birthday, calendar_creationDate)); // replace the date in the column age with the calculated age tableModel.setValueAt(int_age, int_row, columnToConvert); /* ---------------------------------------- */ } /* ======================================== */ }