@Override @SuppressWarnings("unchecked") protected void process(File csvFile) throws Exception { Transaction t = createTransaction(); Query q = createQuery(t); List<Object[]> list = (List<Object[]>) q.list(); if (list.size() < 1) throw new EmptyResultException(); ArrayList<String> row; Table out = new Table(); for (Object[] o : list) { TestResult tr = (TestResult) o[0]; PatientAttributeValue pc = (PatientAttributeValue) o[1]; PatientAttributeValue bdt = (PatientAttributeValue) o[2]; Date bd = DateUtils.parseDate(bdt.getValue()); Date tDate = tr.getTestDate(); int testCode = TestCode.T4.getCode(); if (bd != null && tDate != null && DateUtils.getDateOffset(bd, Calendar.YEAR, 15).after(tDate)) { // < 15 years old at time of test testCode = TestCode.T4PERCENT.getCode(); if (!tr.getTest() .getTestType() .getDescription() .equals(StandardObjects.getCd4PercentageTestType().getDescription())) continue; } else { if (tr.getTest() .getTestType() .getDescription() .equals(StandardObjects.getCd4PercentageTestType().getDescription())) continue; } String value = tr.getValue(); row = new ArrayList<String>(); row.add(getCentreName()); row.add(OriginCode.ARC.getCode() + ""); row.add(pc.getValue()); row.add(getFormattedDate(tDate)); row.add(TypeOfInformationCode.LAB_RESULT.getCode() + ""); row.add(testCode + ""); row.add(getFormattedDecimal(value, 0, 0)); row.add(""); out.addRow(row); } t.commit(); out.exportAsCsv(new FileOutputStream(csvFile), ';', false); }
public ReportContainer(File summaryCsvFile) { super(); try { Table csv = Table.readTable(summaryCsvFile.getAbsolutePath()); if (csv.numColumns() == 2) { initPieChart(csv); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
public static void main(String[] args) { Table nationalityLIS = Utils.readTable( "/home/plibin0/myWorkspace/regadb-io-db/src/net/sf/regadb/io/db/ghb/mapping/LIS-nationality.csv"); Table nationalityDefault = Utils.readTable( "/home/plibin0/myWorkspace/regadb-analyses/io-assist-files/countrylist.csv"); int CLISCode = Utils.findColumn(nationalityLIS, "codePost"); int CLISName = Utils.findColumn(nationalityLIS, "internationaleOmschrijving"); int CDefaultCode = Utils.findColumn(nationalityDefault, "ISO 3166-1 2 Letter Code"); int CDefaultName = Utils.findColumn(nationalityDefault, "Common Name"); List<Attribute> regadbAttributesList = Utils.prepareRegaDBAttributes(); Attribute countryOfOrigin = Utils.selectAttribute("Country of origin", regadbAttributesList); for (int i = 1; i < nationalityLIS.numRows(); i++) { String LISCode = nationalityLIS.valueAt(CLISCode, i); String LISName = nationalityLIS.valueAt(CLISName, i); String match = ""; for (int j = 1; j < nationalityDefault.numRows(); j++) { String defaultCode = nationalityDefault.valueAt(CDefaultCode, j); String defaultName = nationalityDefault.valueAt(CDefaultName, j); if (LISCode.trim().toLowerCase().equals(defaultCode.trim().toLowerCase())) { match = defaultName; break; } } System.err.println("\"" + LISCode + "\"" + "," + "\"" + match + "\""); } }
public WAbstractItemModel readFromCsv(Table csv) { WAbstractItemModel model = new WStandardItemModel(); for (int r = 0; r < csv.numRows(); r++) { if (r != 0) model.insertRow(r - 1); for (int c = 0; c < csv.numColumns(); c++) { String value = csv.valueAt(c, r); if (r == 0) { model.insertColumn(c); model.setHeaderData(c, Orientation.Horizontal, value); } else { try { Double d = Double.valueOf(value); model.setData(r - 1, c, d); } catch (NumberFormatException e) { model.setData(r - 1, c, value); } } } } return model; }